babylon.module.d.ts 6.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static get LogCache(): string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static set LogLevels(level: number);
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static get Now(): number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  486. /**
  487. * Returns client's state
  488. */
  489. get readyState(): number;
  490. /**
  491. * Returns client's status
  492. */
  493. get status(): number;
  494. /**
  495. * Returns client's status as a text
  496. */
  497. get statusText(): string;
  498. /**
  499. * Returns client's response
  500. */
  501. get response(): any;
  502. /**
  503. * Returns client's response url
  504. */
  505. get responseURL(): string;
  506. /**
  507. * Returns client's response as text
  508. */
  509. get responseText(): string;
  510. /**
  511. * Gets or sets the expected response type
  512. */
  513. get responseType(): XMLHttpRequestResponseType;
  514. set responseType(value: XMLHttpRequestResponseType);
  515. /** @hidden */
  516. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  517. /** @hidden */
  518. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  519. /**
  520. * Cancels any network activity
  521. */
  522. abort(): void;
  523. /**
  524. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  525. * @param body defines an optional request body
  526. */
  527. send(body?: Document | BodyInit | null): void;
  528. /**
  529. * Sets the request method, request URL
  530. * @param method defines the method to use (GET, POST, etc..)
  531. * @param url defines the url to connect with
  532. */
  533. open(method: string, url: string): void;
  534. /**
  535. * Sets the value of a request header.
  536. * @param name The name of the header whose value is to be set
  537. * @param value The value to set as the body of the header
  538. */
  539. setRequestHeader(name: string, value: string): void;
  540. /**
  541. * Get the string containing the text of a particular header's value.
  542. * @param name The name of the header
  543. * @returns The string containing the text of the given header name
  544. */
  545. getResponseHeader(name: string): Nullable<string>;
  546. }
  547. }
  548. declare module "babylonjs/Misc/fileRequest" {
  549. import { Observable } from "babylonjs/Misc/observable";
  550. /**
  551. * File request interface
  552. */
  553. export interface IFileRequest {
  554. /**
  555. * Raised when the request is complete (success or error).
  556. */
  557. onCompleteObservable: Observable<IFileRequest>;
  558. /**
  559. * Aborts the request for a file.
  560. */
  561. abort: () => void;
  562. }
  563. }
  564. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  565. /**
  566. * Define options used to create a render target texture
  567. */
  568. export class RenderTargetCreationOptions {
  569. /**
  570. * Specifies is mipmaps must be generated
  571. */
  572. generateMipMaps?: boolean;
  573. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  574. generateDepthBuffer?: boolean;
  575. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  576. generateStencilBuffer?: boolean;
  577. /** Defines texture type (int by default) */
  578. type?: number;
  579. /** Defines sampling mode (trilinear by default) */
  580. samplingMode?: number;
  581. /** Defines format (RGBA by default) */
  582. format?: number;
  583. }
  584. }
  585. declare module "babylonjs/Engines/constants" {
  586. /** Defines the cross module used constants to avoid circular dependncies */
  587. export class Constants {
  588. /** Defines that alpha blending is disabled */
  589. static readonly ALPHA_DISABLE: number;
  590. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  591. static readonly ALPHA_ADD: number;
  592. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  593. static readonly ALPHA_COMBINE: number;
  594. /** Defines that alpha blending is DEST - SRC * DEST */
  595. static readonly ALPHA_SUBTRACT: number;
  596. /** Defines that alpha blending is SRC * DEST */
  597. static readonly ALPHA_MULTIPLY: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  599. static readonly ALPHA_MAXIMIZED: number;
  600. /** Defines that alpha blending is SRC + DEST */
  601. static readonly ALPHA_ONEONE: number;
  602. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_PREMULTIPLIED: number;
  604. /**
  605. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  606. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  607. */
  608. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  609. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  610. static readonly ALPHA_INTERPOLATE: number;
  611. /**
  612. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  613. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  614. */
  615. static readonly ALPHA_SCREENMODE: number;
  616. /**
  617. * Defines that alpha blending is SRC + DST
  618. * Alpha will be set to SRC ALPHA + DST ALPHA
  619. */
  620. static readonly ALPHA_ONEONE_ONEONE: number;
  621. /**
  622. * Defines that alpha blending is SRC * DST ALPHA + DST
  623. * Alpha will be set to 0
  624. */
  625. static readonly ALPHA_ALPHATOCOLOR: number;
  626. /**
  627. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  628. */
  629. static readonly ALPHA_REVERSEONEMINUS: number;
  630. /**
  631. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  632. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  633. */
  634. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  635. /**
  636. * Defines that alpha blending is SRC + DST
  637. * Alpha will be set to SRC ALPHA
  638. */
  639. static readonly ALPHA_ONEONE_ONEZERO: number;
  640. /**
  641. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  642. * Alpha will be set to DST ALPHA
  643. */
  644. static readonly ALPHA_EXCLUSION: number;
  645. /** Defines that alpha blending equation a SUM */
  646. static readonly ALPHA_EQUATION_ADD: number;
  647. /** Defines that alpha blending equation a SUBSTRACTION */
  648. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  649. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  650. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  651. /** Defines that alpha blending equation a MAX operation */
  652. static readonly ALPHA_EQUATION_MAX: number;
  653. /** Defines that alpha blending equation a MIN operation */
  654. static readonly ALPHA_EQUATION_MIN: number;
  655. /**
  656. * Defines that alpha blending equation a DARKEN operation:
  657. * It takes the min of the src and sums the alpha channels.
  658. */
  659. static readonly ALPHA_EQUATION_DARKEN: number;
  660. /** Defines that the ressource is not delayed*/
  661. static readonly DELAYLOADSTATE_NONE: number;
  662. /** Defines that the ressource was successfully delay loaded */
  663. static readonly DELAYLOADSTATE_LOADED: number;
  664. /** Defines that the ressource is currently delay loading */
  665. static readonly DELAYLOADSTATE_LOADING: number;
  666. /** Defines that the ressource is delayed and has not started loading */
  667. static readonly DELAYLOADSTATE_NOTLOADED: number;
  668. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  669. static readonly NEVER: number;
  670. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  671. static readonly ALWAYS: number;
  672. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  673. static readonly LESS: number;
  674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  675. static readonly EQUAL: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  677. static readonly LEQUAL: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  679. static readonly GREATER: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  681. static readonly GEQUAL: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  683. static readonly NOTEQUAL: number;
  684. /** Passed to stencilOperation to specify that stencil value must be kept */
  685. static readonly KEEP: number;
  686. /** Passed to stencilOperation to specify that stencil value must be replaced */
  687. static readonly REPLACE: number;
  688. /** Passed to stencilOperation to specify that stencil value must be incremented */
  689. static readonly INCR: number;
  690. /** Passed to stencilOperation to specify that stencil value must be decremented */
  691. static readonly DECR: number;
  692. /** Passed to stencilOperation to specify that stencil value must be inverted */
  693. static readonly INVERT: number;
  694. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  695. static readonly INCR_WRAP: number;
  696. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  697. static readonly DECR_WRAP: number;
  698. /** Texture is not repeating outside of 0..1 UVs */
  699. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  700. /** Texture is repeating outside of 0..1 UVs */
  701. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  702. /** Texture is repeating and mirrored */
  703. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  704. /** ALPHA */
  705. static readonly TEXTUREFORMAT_ALPHA: number;
  706. /** LUMINANCE */
  707. static readonly TEXTUREFORMAT_LUMINANCE: number;
  708. /** LUMINANCE_ALPHA */
  709. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  710. /** RGB */
  711. static readonly TEXTUREFORMAT_RGB: number;
  712. /** RGBA */
  713. static readonly TEXTUREFORMAT_RGBA: number;
  714. /** RED */
  715. static readonly TEXTUREFORMAT_RED: number;
  716. /** RED (2nd reference) */
  717. static readonly TEXTUREFORMAT_R: number;
  718. /** RG */
  719. static readonly TEXTUREFORMAT_RG: number;
  720. /** RED_INTEGER */
  721. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  722. /** RED_INTEGER (2nd reference) */
  723. static readonly TEXTUREFORMAT_R_INTEGER: number;
  724. /** RG_INTEGER */
  725. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  726. /** RGB_INTEGER */
  727. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  728. /** RGBA_INTEGER */
  729. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  730. /** UNSIGNED_BYTE */
  731. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  732. /** UNSIGNED_BYTE (2nd reference) */
  733. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  734. /** FLOAT */
  735. static readonly TEXTURETYPE_FLOAT: number;
  736. /** HALF_FLOAT */
  737. static readonly TEXTURETYPE_HALF_FLOAT: number;
  738. /** BYTE */
  739. static readonly TEXTURETYPE_BYTE: number;
  740. /** SHORT */
  741. static readonly TEXTURETYPE_SHORT: number;
  742. /** UNSIGNED_SHORT */
  743. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  744. /** INT */
  745. static readonly TEXTURETYPE_INT: number;
  746. /** UNSIGNED_INT */
  747. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  748. /** UNSIGNED_SHORT_4_4_4_4 */
  749. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  750. /** UNSIGNED_SHORT_5_5_5_1 */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  752. /** UNSIGNED_SHORT_5_6_5 */
  753. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  754. /** UNSIGNED_INT_2_10_10_10_REV */
  755. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  756. /** UNSIGNED_INT_24_8 */
  757. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  758. /** UNSIGNED_INT_10F_11F_11F_REV */
  759. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  760. /** UNSIGNED_INT_5_9_9_9_REV */
  761. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  762. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  763. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  764. /** nearest is mag = nearest and min = nearest and no mip */
  765. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  766. /** mag = nearest and min = nearest and mip = none */
  767. static readonly TEXTURE_NEAREST_NEAREST: number;
  768. /** Bilinear is mag = linear and min = linear and no mip */
  769. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  770. /** mag = linear and min = linear and mip = none */
  771. static readonly TEXTURE_LINEAR_LINEAR: number;
  772. /** Trilinear is mag = linear and min = linear and mip = linear */
  773. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  774. /** Trilinear is mag = linear and min = linear and mip = linear */
  775. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  776. /** mag = nearest and min = nearest and mip = nearest */
  777. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  778. /** mag = nearest and min = linear and mip = nearest */
  779. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  780. /** mag = nearest and min = linear and mip = linear */
  781. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  782. /** mag = nearest and min = linear and mip = none */
  783. static readonly TEXTURE_NEAREST_LINEAR: number;
  784. /** nearest is mag = nearest and min = nearest and mip = linear */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  786. /** mag = linear and min = nearest and mip = nearest */
  787. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  788. /** mag = linear and min = nearest and mip = linear */
  789. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  790. /** Bilinear is mag = linear and min = linear and mip = nearest */
  791. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  792. /** mag = linear and min = nearest and mip = none */
  793. static readonly TEXTURE_LINEAR_NEAREST: number;
  794. /** Explicit coordinates mode */
  795. static readonly TEXTURE_EXPLICIT_MODE: number;
  796. /** Spherical coordinates mode */
  797. static readonly TEXTURE_SPHERICAL_MODE: number;
  798. /** Planar coordinates mode */
  799. static readonly TEXTURE_PLANAR_MODE: number;
  800. /** Cubic coordinates mode */
  801. static readonly TEXTURE_CUBIC_MODE: number;
  802. /** Projection coordinates mode */
  803. static readonly TEXTURE_PROJECTION_MODE: number;
  804. /** Skybox coordinates mode */
  805. static readonly TEXTURE_SKYBOX_MODE: number;
  806. /** Inverse Cubic coordinates mode */
  807. static readonly TEXTURE_INVCUBIC_MODE: number;
  808. /** Equirectangular coordinates mode */
  809. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  810. /** Equirectangular Fixed coordinates mode */
  811. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  812. /** Equirectangular Fixed Mirrored coordinates mode */
  813. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  814. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  815. static readonly SCALEMODE_FLOOR: number;
  816. /** Defines that texture rescaling will look for the nearest power of 2 size */
  817. static readonly SCALEMODE_NEAREST: number;
  818. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  819. static readonly SCALEMODE_CEILING: number;
  820. /**
  821. * The dirty texture flag value
  822. */
  823. static readonly MATERIAL_TextureDirtyFlag: number;
  824. /**
  825. * The dirty light flag value
  826. */
  827. static readonly MATERIAL_LightDirtyFlag: number;
  828. /**
  829. * The dirty fresnel flag value
  830. */
  831. static readonly MATERIAL_FresnelDirtyFlag: number;
  832. /**
  833. * The dirty attribute flag value
  834. */
  835. static readonly MATERIAL_AttributesDirtyFlag: number;
  836. /**
  837. * The dirty misc flag value
  838. */
  839. static readonly MATERIAL_MiscDirtyFlag: number;
  840. /**
  841. * The all dirty flag value
  842. */
  843. static readonly MATERIAL_AllDirtyFlag: number;
  844. /**
  845. * Returns the triangle fill mode
  846. */
  847. static readonly MATERIAL_TriangleFillMode: number;
  848. /**
  849. * Returns the wireframe mode
  850. */
  851. static readonly MATERIAL_WireFrameFillMode: number;
  852. /**
  853. * Returns the point fill mode
  854. */
  855. static readonly MATERIAL_PointFillMode: number;
  856. /**
  857. * Returns the point list draw mode
  858. */
  859. static readonly MATERIAL_PointListDrawMode: number;
  860. /**
  861. * Returns the line list draw mode
  862. */
  863. static readonly MATERIAL_LineListDrawMode: number;
  864. /**
  865. * Returns the line loop draw mode
  866. */
  867. static readonly MATERIAL_LineLoopDrawMode: number;
  868. /**
  869. * Returns the line strip draw mode
  870. */
  871. static readonly MATERIAL_LineStripDrawMode: number;
  872. /**
  873. * Returns the triangle strip draw mode
  874. */
  875. static readonly MATERIAL_TriangleStripDrawMode: number;
  876. /**
  877. * Returns the triangle fan draw mode
  878. */
  879. static readonly MATERIAL_TriangleFanDrawMode: number;
  880. /**
  881. * Stores the clock-wise side orientation
  882. */
  883. static readonly MATERIAL_ClockWiseSideOrientation: number;
  884. /**
  885. * Stores the counter clock-wise side orientation
  886. */
  887. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  888. /**
  889. * Nothing
  890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  891. */
  892. static readonly ACTION_NothingTrigger: number;
  893. /**
  894. * On pick
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_OnPickTrigger: number;
  898. /**
  899. * On left pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnLeftPickTrigger: number;
  903. /**
  904. * On right pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnRightPickTrigger: number;
  908. /**
  909. * On center pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnCenterPickTrigger: number;
  913. /**
  914. * On pick down
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickDownTrigger: number;
  918. /**
  919. * On double pick
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnDoublePickTrigger: number;
  923. /**
  924. * On pick up
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickUpTrigger: number;
  928. /**
  929. * On pick out.
  930. * This trigger will only be raised if you also declared a OnPickDown
  931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickOutTrigger: number;
  934. /**
  935. * On long press
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnLongPressTrigger: number;
  939. /**
  940. * On pointer over
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPointerOverTrigger: number;
  944. /**
  945. * On pointer out
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOutTrigger: number;
  949. /**
  950. * On every frame
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnEveryFrameTrigger: number;
  954. /**
  955. * On intersection enter
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnIntersectionEnterTrigger: number;
  959. /**
  960. * On intersection exit
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionExitTrigger: number;
  964. /**
  965. * On key down
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnKeyDownTrigger: number;
  969. /**
  970. * On key up
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyUpTrigger: number;
  974. /**
  975. * Billboard mode will only apply to Y axis
  976. */
  977. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  978. /**
  979. * Billboard mode will apply to all axes
  980. */
  981. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  982. /**
  983. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  984. */
  985. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  986. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  987. * Test order :
  988. * Is the bounding sphere outside the frustum ?
  989. * If not, are the bounding box vertices outside the frustum ?
  990. * It not, then the cullable object is in the frustum.
  991. */
  992. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  993. /** Culling strategy : Bounding Sphere Only.
  994. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  995. * It's also less accurate than the standard because some not visible objects can still be selected.
  996. * Test : is the bounding sphere outside the frustum ?
  997. * If not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1000. /** Culling strategy : Optimistic Inclusion.
  1001. * This in an inclusion test first, then the standard exclusion test.
  1002. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1003. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1004. * Anyway, it's as accurate as the standard strategy.
  1005. * Test :
  1006. * Is the cullable object bounding sphere center in the frustum ?
  1007. * If not, apply the default culling strategy.
  1008. */
  1009. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1010. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1011. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1012. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1013. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1014. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1015. * Test :
  1016. * Is the cullable object bounding sphere center in the frustum ?
  1017. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1020. /**
  1021. * No logging while loading
  1022. */
  1023. static readonly SCENELOADER_NO_LOGGING: number;
  1024. /**
  1025. * Minimal logging while loading
  1026. */
  1027. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1028. /**
  1029. * Summary logging while loading
  1030. */
  1031. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1032. /**
  1033. * Detailled logging while loading
  1034. */
  1035. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1036. }
  1037. }
  1038. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1039. import { Nullable } from "babylonjs/types";
  1040. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1041. /**
  1042. * This represents the required contract to create a new type of texture loader.
  1043. */
  1044. export interface IInternalTextureLoader {
  1045. /**
  1046. * Defines wether the loader supports cascade loading the different faces.
  1047. */
  1048. supportCascades: boolean;
  1049. /**
  1050. * This returns if the loader support the current file information.
  1051. * @param extension defines the file extension of the file being loaded
  1052. * @returns true if the loader can load the specified file
  1053. */
  1054. canLoad(extension: string): boolean;
  1055. /**
  1056. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1057. * @param data contains the texture data
  1058. * @param texture defines the BabylonJS internal texture
  1059. * @param createPolynomials will be true if polynomials have been requested
  1060. * @param onLoad defines the callback to trigger once the texture is ready
  1061. * @param onError defines the callback to trigger in case of error
  1062. */
  1063. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1064. /**
  1065. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1066. * @param data contains the texture data
  1067. * @param texture defines the BabylonJS internal texture
  1068. * @param callback defines the method to call once ready to upload
  1069. */
  1070. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1071. }
  1072. }
  1073. declare module "babylonjs/Engines/IPipelineContext" {
  1074. /**
  1075. * Class used to store and describe the pipeline context associated with an effect
  1076. */
  1077. export interface IPipelineContext {
  1078. /**
  1079. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1080. */
  1081. isAsync: boolean;
  1082. /**
  1083. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1084. */
  1085. isReady: boolean;
  1086. /** @hidden */
  1087. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1088. }
  1089. }
  1090. declare module "babylonjs/Meshes/dataBuffer" {
  1091. /**
  1092. * Class used to store gfx data (like WebGLBuffer)
  1093. */
  1094. export class DataBuffer {
  1095. /**
  1096. * Gets or sets the number of objects referencing this buffer
  1097. */
  1098. references: number;
  1099. /** Gets or sets the size of the underlying buffer */
  1100. capacity: number;
  1101. /**
  1102. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1103. */
  1104. is32Bits: boolean;
  1105. /**
  1106. * Gets the underlying buffer
  1107. */
  1108. get underlyingResource(): any;
  1109. }
  1110. }
  1111. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1112. /** @hidden */
  1113. export interface IShaderProcessor {
  1114. attributeProcessor?: (attribute: string) => string;
  1115. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1116. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1117. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1118. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1119. lineProcessor?: (line: string, isFragment: boolean) => string;
  1120. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1121. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1122. }
  1123. }
  1124. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1125. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1126. /** @hidden */
  1127. export interface ProcessingOptions {
  1128. defines: string[];
  1129. indexParameters: any;
  1130. isFragment: boolean;
  1131. shouldUseHighPrecisionShader: boolean;
  1132. supportsUniformBuffers: boolean;
  1133. shadersRepository: string;
  1134. includesShadersStore: {
  1135. [key: string]: string;
  1136. };
  1137. processor?: IShaderProcessor;
  1138. version: string;
  1139. platformName: string;
  1140. lookForClosingBracketForUniformBuffer?: boolean;
  1141. }
  1142. }
  1143. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1144. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1145. /** @hidden */
  1146. export class ShaderCodeNode {
  1147. line: string;
  1148. children: ShaderCodeNode[];
  1149. additionalDefineKey?: string;
  1150. additionalDefineValue?: string;
  1151. isValid(preprocessors: {
  1152. [key: string]: string;
  1153. }): boolean;
  1154. process(preprocessors: {
  1155. [key: string]: string;
  1156. }, options: ProcessingOptions): string;
  1157. }
  1158. }
  1159. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1160. /** @hidden */
  1161. export class ShaderCodeCursor {
  1162. private _lines;
  1163. lineIndex: number;
  1164. get currentLine(): string;
  1165. get canRead(): boolean;
  1166. set lines(value: string[]);
  1167. }
  1168. }
  1169. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1170. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1171. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1172. /** @hidden */
  1173. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1174. process(preprocessors: {
  1175. [key: string]: string;
  1176. }, options: ProcessingOptions): string;
  1177. }
  1178. }
  1179. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1180. /** @hidden */
  1181. export class ShaderDefineExpression {
  1182. isTrue(preprocessors: {
  1183. [key: string]: string;
  1184. }): boolean;
  1185. }
  1186. }
  1187. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1188. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1189. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1190. /** @hidden */
  1191. export class ShaderCodeTestNode extends ShaderCodeNode {
  1192. testExpression: ShaderDefineExpression;
  1193. isValid(preprocessors: {
  1194. [key: string]: string;
  1195. }): boolean;
  1196. }
  1197. }
  1198. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1199. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1200. /** @hidden */
  1201. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1202. define: string;
  1203. not: boolean;
  1204. constructor(define: string, not?: boolean);
  1205. isTrue(preprocessors: {
  1206. [key: string]: string;
  1207. }): boolean;
  1208. }
  1209. }
  1210. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1211. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1212. /** @hidden */
  1213. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1214. leftOperand: ShaderDefineExpression;
  1215. rightOperand: ShaderDefineExpression;
  1216. isTrue(preprocessors: {
  1217. [key: string]: string;
  1218. }): boolean;
  1219. }
  1220. }
  1221. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1222. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1223. /** @hidden */
  1224. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1225. leftOperand: ShaderDefineExpression;
  1226. rightOperand: ShaderDefineExpression;
  1227. isTrue(preprocessors: {
  1228. [key: string]: string;
  1229. }): boolean;
  1230. }
  1231. }
  1232. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1233. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1234. /** @hidden */
  1235. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1236. define: string;
  1237. operand: string;
  1238. testValue: string;
  1239. constructor(define: string, operand: string, testValue: string);
  1240. isTrue(preprocessors: {
  1241. [key: string]: string;
  1242. }): boolean;
  1243. }
  1244. }
  1245. declare module "babylonjs/Offline/IOfflineProvider" {
  1246. /**
  1247. * Class used to enable access to offline support
  1248. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1249. */
  1250. export interface IOfflineProvider {
  1251. /**
  1252. * Gets a boolean indicating if scene must be saved in the database
  1253. */
  1254. enableSceneOffline: boolean;
  1255. /**
  1256. * Gets a boolean indicating if textures must be saved in the database
  1257. */
  1258. enableTexturesOffline: boolean;
  1259. /**
  1260. * Open the offline support and make it available
  1261. * @param successCallback defines the callback to call on success
  1262. * @param errorCallback defines the callback to call on error
  1263. */
  1264. open(successCallback: () => void, errorCallback: () => void): void;
  1265. /**
  1266. * Loads an image from the offline support
  1267. * @param url defines the url to load from
  1268. * @param image defines the target DOM image
  1269. */
  1270. loadImage(url: string, image: HTMLImageElement): void;
  1271. /**
  1272. * Loads a file from offline support
  1273. * @param url defines the URL to load from
  1274. * @param sceneLoaded defines a callback to call on success
  1275. * @param progressCallBack defines a callback to call when progress changed
  1276. * @param errorCallback defines a callback to call on error
  1277. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1278. */
  1279. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1280. }
  1281. }
  1282. declare module "babylonjs/Misc/filesInputStore" {
  1283. /**
  1284. * Class used to help managing file picking and drag'n'drop
  1285. * File Storage
  1286. */
  1287. export class FilesInputStore {
  1288. /**
  1289. * List of files ready to be loaded
  1290. */
  1291. static FilesToLoad: {
  1292. [key: string]: File;
  1293. };
  1294. }
  1295. }
  1296. declare module "babylonjs/Misc/retryStrategy" {
  1297. import { WebRequest } from "babylonjs/Misc/webRequest";
  1298. /**
  1299. * Class used to define a retry strategy when error happens while loading assets
  1300. */
  1301. export class RetryStrategy {
  1302. /**
  1303. * Function used to defines an exponential back off strategy
  1304. * @param maxRetries defines the maximum number of retries (3 by default)
  1305. * @param baseInterval defines the interval between retries
  1306. * @returns the strategy function to use
  1307. */
  1308. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1309. }
  1310. }
  1311. declare module "babylonjs/Misc/baseError" {
  1312. /**
  1313. * @ignore
  1314. * Application error to support additional information when loading a file
  1315. */
  1316. export abstract class BaseError extends Error {
  1317. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1318. }
  1319. }
  1320. declare module "babylonjs/Misc/fileTools" {
  1321. import { WebRequest } from "babylonjs/Misc/webRequest";
  1322. import { Nullable } from "babylonjs/types";
  1323. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1324. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1325. import { BaseError } from "babylonjs/Misc/baseError";
  1326. /** @ignore */
  1327. export class LoadFileError extends BaseError {
  1328. request?: WebRequest;
  1329. file?: File;
  1330. /**
  1331. * Creates a new LoadFileError
  1332. * @param message defines the message of the error
  1333. * @param request defines the optional web request
  1334. * @param file defines the optional file
  1335. */
  1336. constructor(message: string, object?: WebRequest | File);
  1337. }
  1338. /** @ignore */
  1339. export class RequestFileError extends BaseError {
  1340. request: WebRequest;
  1341. /**
  1342. * Creates a new LoadFileError
  1343. * @param message defines the message of the error
  1344. * @param request defines the optional web request
  1345. */
  1346. constructor(message: string, request: WebRequest);
  1347. }
  1348. /** @ignore */
  1349. export class ReadFileError extends BaseError {
  1350. file: File;
  1351. /**
  1352. * Creates a new ReadFileError
  1353. * @param message defines the message of the error
  1354. * @param file defines the optional file
  1355. */
  1356. constructor(message: string, file: File);
  1357. }
  1358. /**
  1359. * @hidden
  1360. */
  1361. export class FileTools {
  1362. /**
  1363. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1364. */
  1365. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1366. /**
  1367. * Gets or sets the base URL to use to load assets
  1368. */
  1369. static BaseUrl: string;
  1370. /**
  1371. * Default behaviour for cors in the application.
  1372. * It can be a string if the expected behavior is identical in the entire app.
  1373. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1374. */
  1375. static CorsBehavior: string | ((url: string | string[]) => string);
  1376. /**
  1377. * Gets or sets a function used to pre-process url before using them to load assets
  1378. */
  1379. static PreprocessUrl: (url: string) => string;
  1380. /**
  1381. * Removes unwanted characters from an url
  1382. * @param url defines the url to clean
  1383. * @returns the cleaned url
  1384. */
  1385. private static _CleanUrl;
  1386. /**
  1387. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1388. * @param url define the url we are trying
  1389. * @param element define the dom element where to configure the cors policy
  1390. */
  1391. static SetCorsBehavior(url: string | string[], element: {
  1392. crossOrigin: string | null;
  1393. }): void;
  1394. /**
  1395. * Loads an image as an HTMLImageElement.
  1396. * @param input url string, ArrayBuffer, or Blob to load
  1397. * @param onLoad callback called when the image successfully loads
  1398. * @param onError callback called when the image fails to load
  1399. * @param offlineProvider offline provider for caching
  1400. * @param mimeType optional mime type
  1401. * @returns the HTMLImageElement of the loaded image
  1402. */
  1403. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1404. /**
  1405. * Reads a file from a File object
  1406. * @param file defines the file to load
  1407. * @param onSuccess defines the callback to call when data is loaded
  1408. * @param onProgress defines the callback to call during loading process
  1409. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1410. * @param onError defines the callback to call when an error occurs
  1411. * @returns a file request object
  1412. */
  1413. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1414. /**
  1415. * Loads a file from a url
  1416. * @param url url to load
  1417. * @param onSuccess callback called when the file successfully loads
  1418. * @param onProgress callback called while file is loading (if the server supports this mode)
  1419. * @param offlineProvider defines the offline provider for caching
  1420. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1421. * @param onError callback called when the file fails to load
  1422. * @returns a file request object
  1423. */
  1424. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1425. /**
  1426. * Loads a file
  1427. * @param url url to load
  1428. * @param onSuccess callback called when the file successfully loads
  1429. * @param onProgress callback called while file is loading (if the server supports this mode)
  1430. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1431. * @param onError callback called when the file fails to load
  1432. * @param onOpened callback called when the web request is opened
  1433. * @returns a file request object
  1434. */
  1435. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1436. /**
  1437. * Checks if the loaded document was accessed via `file:`-Protocol.
  1438. * @returns boolean
  1439. */
  1440. static IsFileURL(): boolean;
  1441. }
  1442. }
  1443. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1444. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1445. import { WebRequest } from "babylonjs/Misc/webRequest";
  1446. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1447. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1448. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1449. /** @hidden */
  1450. export class ShaderProcessor {
  1451. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1452. private static _ProcessPrecision;
  1453. private static _ExtractOperation;
  1454. private static _BuildSubExpression;
  1455. private static _BuildExpression;
  1456. private static _MoveCursorWithinIf;
  1457. private static _MoveCursor;
  1458. private static _EvaluatePreProcessors;
  1459. private static _PreparePreProcessors;
  1460. private static _ProcessShaderConversion;
  1461. private static _ProcessIncludes;
  1462. /**
  1463. * Loads a file from a url
  1464. * @param url url to load
  1465. * @param onSuccess callback called when the file successfully loads
  1466. * @param onProgress callback called while file is loading (if the server supports this mode)
  1467. * @param offlineProvider defines the offline provider for caching
  1468. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1469. * @param onError callback called when the file fails to load
  1470. * @returns a file request object
  1471. * @hidden
  1472. */
  1473. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1474. }
  1475. }
  1476. declare module "babylonjs/Maths/math.like" {
  1477. import { float, int, DeepImmutable } from "babylonjs/types";
  1478. /**
  1479. * @hidden
  1480. */
  1481. export interface IColor4Like {
  1482. r: float;
  1483. g: float;
  1484. b: float;
  1485. a: float;
  1486. }
  1487. /**
  1488. * @hidden
  1489. */
  1490. export interface IColor3Like {
  1491. r: float;
  1492. g: float;
  1493. b: float;
  1494. }
  1495. /**
  1496. * @hidden
  1497. */
  1498. export interface IVector4Like {
  1499. x: float;
  1500. y: float;
  1501. z: float;
  1502. w: float;
  1503. }
  1504. /**
  1505. * @hidden
  1506. */
  1507. export interface IVector3Like {
  1508. x: float;
  1509. y: float;
  1510. z: float;
  1511. }
  1512. /**
  1513. * @hidden
  1514. */
  1515. export interface IVector2Like {
  1516. x: float;
  1517. y: float;
  1518. }
  1519. /**
  1520. * @hidden
  1521. */
  1522. export interface IMatrixLike {
  1523. toArray(): DeepImmutable<Float32Array>;
  1524. updateFlag: int;
  1525. }
  1526. /**
  1527. * @hidden
  1528. */
  1529. export interface IViewportLike {
  1530. x: float;
  1531. y: float;
  1532. width: float;
  1533. height: float;
  1534. }
  1535. /**
  1536. * @hidden
  1537. */
  1538. export interface IPlaneLike {
  1539. normal: IVector3Like;
  1540. d: float;
  1541. normalize(): void;
  1542. }
  1543. }
  1544. declare module "babylonjs/Materials/iEffectFallbacks" {
  1545. import { Effect } from "babylonjs/Materials/effect";
  1546. /**
  1547. * Interface used to define common properties for effect fallbacks
  1548. */
  1549. export interface IEffectFallbacks {
  1550. /**
  1551. * Removes the defines that should be removed when falling back.
  1552. * @param currentDefines defines the current define statements for the shader.
  1553. * @param effect defines the current effect we try to compile
  1554. * @returns The resulting defines with defines of the current rank removed.
  1555. */
  1556. reduce(currentDefines: string, effect: Effect): string;
  1557. /**
  1558. * Removes the fallback from the bound mesh.
  1559. */
  1560. unBindMesh(): void;
  1561. /**
  1562. * Checks to see if more fallbacks are still availible.
  1563. */
  1564. hasMoreFallbacks: boolean;
  1565. }
  1566. }
  1567. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1568. /**
  1569. * Class used to evalaute queries containing `and` and `or` operators
  1570. */
  1571. export class AndOrNotEvaluator {
  1572. /**
  1573. * Evaluate a query
  1574. * @param query defines the query to evaluate
  1575. * @param evaluateCallback defines the callback used to filter result
  1576. * @returns true if the query matches
  1577. */
  1578. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1579. private static _HandleParenthesisContent;
  1580. private static _SimplifyNegation;
  1581. }
  1582. }
  1583. declare module "babylonjs/Misc/tags" {
  1584. /**
  1585. * Class used to store custom tags
  1586. */
  1587. export class Tags {
  1588. /**
  1589. * Adds support for tags on the given object
  1590. * @param obj defines the object to use
  1591. */
  1592. static EnableFor(obj: any): void;
  1593. /**
  1594. * Removes tags support
  1595. * @param obj defines the object to use
  1596. */
  1597. static DisableFor(obj: any): void;
  1598. /**
  1599. * Gets a boolean indicating if the given object has tags
  1600. * @param obj defines the object to use
  1601. * @returns a boolean
  1602. */
  1603. static HasTags(obj: any): boolean;
  1604. /**
  1605. * Gets the tags available on a given object
  1606. * @param obj defines the object to use
  1607. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1608. * @returns the tags
  1609. */
  1610. static GetTags(obj: any, asString?: boolean): any;
  1611. /**
  1612. * Adds tags to an object
  1613. * @param obj defines the object to use
  1614. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1615. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1616. */
  1617. static AddTagsTo(obj: any, tagsString: string): void;
  1618. /**
  1619. * @hidden
  1620. */
  1621. static _AddTagTo(obj: any, tag: string): void;
  1622. /**
  1623. * Removes specific tags from a specific object
  1624. * @param obj defines the object to use
  1625. * @param tagsString defines the tags to remove
  1626. */
  1627. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1628. /**
  1629. * @hidden
  1630. */
  1631. static _RemoveTagFrom(obj: any, tag: string): void;
  1632. /**
  1633. * Defines if tags hosted on an object match a given query
  1634. * @param obj defines the object to use
  1635. * @param tagsQuery defines the tag query
  1636. * @returns a boolean
  1637. */
  1638. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1639. }
  1640. }
  1641. declare module "babylonjs/Maths/math.scalar" {
  1642. /**
  1643. * Scalar computation library
  1644. */
  1645. export class Scalar {
  1646. /**
  1647. * Two pi constants convenient for computation.
  1648. */
  1649. static TwoPi: number;
  1650. /**
  1651. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1652. * @param a number
  1653. * @param b number
  1654. * @param epsilon (default = 1.401298E-45)
  1655. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1656. */
  1657. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1658. /**
  1659. * Returns a string : the upper case translation of the number i to hexadecimal.
  1660. * @param i number
  1661. * @returns the upper case translation of the number i to hexadecimal.
  1662. */
  1663. static ToHex(i: number): string;
  1664. /**
  1665. * Returns -1 if value is negative and +1 is value is positive.
  1666. * @param value the value
  1667. * @returns the value itself if it's equal to zero.
  1668. */
  1669. static Sign(value: number): number;
  1670. /**
  1671. * Returns the value itself if it's between min and max.
  1672. * Returns min if the value is lower than min.
  1673. * Returns max if the value is greater than max.
  1674. * @param value the value to clmap
  1675. * @param min the min value to clamp to (default: 0)
  1676. * @param max the max value to clamp to (default: 1)
  1677. * @returns the clamped value
  1678. */
  1679. static Clamp(value: number, min?: number, max?: number): number;
  1680. /**
  1681. * the log2 of value.
  1682. * @param value the value to compute log2 of
  1683. * @returns the log2 of value.
  1684. */
  1685. static Log2(value: number): number;
  1686. /**
  1687. * Loops the value, so that it is never larger than length and never smaller than 0.
  1688. *
  1689. * This is similar to the modulo operator but it works with floating point numbers.
  1690. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1691. * With t = 5 and length = 2.5, the result would be 0.0.
  1692. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1693. * @param value the value
  1694. * @param length the length
  1695. * @returns the looped value
  1696. */
  1697. static Repeat(value: number, length: number): number;
  1698. /**
  1699. * Normalize the value between 0.0 and 1.0 using min and max values
  1700. * @param value value to normalize
  1701. * @param min max to normalize between
  1702. * @param max min to normalize between
  1703. * @returns the normalized value
  1704. */
  1705. static Normalize(value: number, min: number, max: number): number;
  1706. /**
  1707. * Denormalize the value from 0.0 and 1.0 using min and max values
  1708. * @param normalized value to denormalize
  1709. * @param min max to denormalize between
  1710. * @param max min to denormalize between
  1711. * @returns the denormalized value
  1712. */
  1713. static Denormalize(normalized: number, min: number, max: number): number;
  1714. /**
  1715. * Calculates the shortest difference between two given angles given in degrees.
  1716. * @param current current angle in degrees
  1717. * @param target target angle in degrees
  1718. * @returns the delta
  1719. */
  1720. static DeltaAngle(current: number, target: number): number;
  1721. /**
  1722. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1723. * @param tx value
  1724. * @param length length
  1725. * @returns The returned value will move back and forth between 0 and length
  1726. */
  1727. static PingPong(tx: number, length: number): number;
  1728. /**
  1729. * Interpolates between min and max with smoothing at the limits.
  1730. *
  1731. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1732. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1733. * @param from from
  1734. * @param to to
  1735. * @param tx value
  1736. * @returns the smooth stepped value
  1737. */
  1738. static SmoothStep(from: number, to: number, tx: number): number;
  1739. /**
  1740. * Moves a value current towards target.
  1741. *
  1742. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1743. * Negative values of maxDelta pushes the value away from target.
  1744. * @param current current value
  1745. * @param target target value
  1746. * @param maxDelta max distance to move
  1747. * @returns resulting value
  1748. */
  1749. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1750. /**
  1751. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1752. *
  1753. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1754. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1755. * @param current current value
  1756. * @param target target value
  1757. * @param maxDelta max distance to move
  1758. * @returns resulting angle
  1759. */
  1760. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1761. /**
  1762. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1763. * @param start start value
  1764. * @param end target value
  1765. * @param amount amount to lerp between
  1766. * @returns the lerped value
  1767. */
  1768. static Lerp(start: number, end: number, amount: number): number;
  1769. /**
  1770. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1771. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1772. * @param start start value
  1773. * @param end target value
  1774. * @param amount amount to lerp between
  1775. * @returns the lerped value
  1776. */
  1777. static LerpAngle(start: number, end: number, amount: number): number;
  1778. /**
  1779. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1780. * @param a start value
  1781. * @param b target value
  1782. * @param value value between a and b
  1783. * @returns the inverseLerp value
  1784. */
  1785. static InverseLerp(a: number, b: number, value: number): number;
  1786. /**
  1787. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1788. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1789. * @param value1 spline value
  1790. * @param tangent1 spline value
  1791. * @param value2 spline value
  1792. * @param tangent2 spline value
  1793. * @param amount input value
  1794. * @returns hermite result
  1795. */
  1796. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1797. /**
  1798. * Returns a random float number between and min and max values
  1799. * @param min min value of random
  1800. * @param max max value of random
  1801. * @returns random value
  1802. */
  1803. static RandomRange(min: number, max: number): number;
  1804. /**
  1805. * This function returns percentage of a number in a given range.
  1806. *
  1807. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1808. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1809. * @param number to convert to percentage
  1810. * @param min min range
  1811. * @param max max range
  1812. * @returns the percentage
  1813. */
  1814. static RangeToPercent(number: number, min: number, max: number): number;
  1815. /**
  1816. * This function returns number that corresponds to the percentage in a given range.
  1817. *
  1818. * PercentToRange(0.34,0,100) will return 34.
  1819. * @param percent to convert to number
  1820. * @param min min range
  1821. * @param max max range
  1822. * @returns the number
  1823. */
  1824. static PercentToRange(percent: number, min: number, max: number): number;
  1825. /**
  1826. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1827. * @param angle The angle to normalize in radian.
  1828. * @return The converted angle.
  1829. */
  1830. static NormalizeRadians(angle: number): number;
  1831. }
  1832. }
  1833. declare module "babylonjs/Maths/math.constants" {
  1834. /**
  1835. * Constant used to convert a value to gamma space
  1836. * @ignorenaming
  1837. */
  1838. export const ToGammaSpace: number;
  1839. /**
  1840. * Constant used to convert a value to linear space
  1841. * @ignorenaming
  1842. */
  1843. export const ToLinearSpace = 2.2;
  1844. /**
  1845. * Constant used to define the minimal number value in Babylon.js
  1846. * @ignorenaming
  1847. */
  1848. let Epsilon: number;
  1849. export { Epsilon };
  1850. }
  1851. declare module "babylonjs/Maths/math.viewport" {
  1852. /**
  1853. * Class used to represent a viewport on screen
  1854. */
  1855. export class Viewport {
  1856. /** viewport left coordinate */
  1857. x: number;
  1858. /** viewport top coordinate */
  1859. y: number;
  1860. /**viewport width */
  1861. width: number;
  1862. /** viewport height */
  1863. height: number;
  1864. /**
  1865. * Creates a Viewport object located at (x, y) and sized (width, height)
  1866. * @param x defines viewport left coordinate
  1867. * @param y defines viewport top coordinate
  1868. * @param width defines the viewport width
  1869. * @param height defines the viewport height
  1870. */
  1871. constructor(
  1872. /** viewport left coordinate */
  1873. x: number,
  1874. /** viewport top coordinate */
  1875. y: number,
  1876. /**viewport width */
  1877. width: number,
  1878. /** viewport height */
  1879. height: number);
  1880. /**
  1881. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1882. * @param renderWidth defines the rendering width
  1883. * @param renderHeight defines the rendering height
  1884. * @returns a new Viewport
  1885. */
  1886. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1887. /**
  1888. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1889. * @param renderWidth defines the rendering width
  1890. * @param renderHeight defines the rendering height
  1891. * @param ref defines the target viewport
  1892. * @returns the current viewport
  1893. */
  1894. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1895. /**
  1896. * Returns a new Viewport copied from the current one
  1897. * @returns a new Viewport
  1898. */
  1899. clone(): Viewport;
  1900. }
  1901. }
  1902. declare module "babylonjs/Misc/arrayTools" {
  1903. /**
  1904. * Class containing a set of static utilities functions for arrays.
  1905. */
  1906. export class ArrayTools {
  1907. /**
  1908. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1909. * @param size the number of element to construct and put in the array
  1910. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1911. * @returns a new array filled with new objects
  1912. */
  1913. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1914. }
  1915. }
  1916. declare module "babylonjs/Maths/math.vector" {
  1917. import { Viewport } from "babylonjs/Maths/math.viewport";
  1918. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1919. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1920. /**
  1921. * Class representing a vector containing 2 coordinates
  1922. */
  1923. export class Vector2 {
  1924. /** defines the first coordinate */
  1925. x: number;
  1926. /** defines the second coordinate */
  1927. y: number;
  1928. /**
  1929. * Creates a new Vector2 from the given x and y coordinates
  1930. * @param x defines the first coordinate
  1931. * @param y defines the second coordinate
  1932. */
  1933. constructor(
  1934. /** defines the first coordinate */
  1935. x?: number,
  1936. /** defines the second coordinate */
  1937. y?: number);
  1938. /**
  1939. * Gets a string with the Vector2 coordinates
  1940. * @returns a string with the Vector2 coordinates
  1941. */
  1942. toString(): string;
  1943. /**
  1944. * Gets class name
  1945. * @returns the string "Vector2"
  1946. */
  1947. getClassName(): string;
  1948. /**
  1949. * Gets current vector hash code
  1950. * @returns the Vector2 hash code as a number
  1951. */
  1952. getHashCode(): number;
  1953. /**
  1954. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1955. * @param array defines the source array
  1956. * @param index defines the offset in source array
  1957. * @returns the current Vector2
  1958. */
  1959. toArray(array: FloatArray, index?: number): Vector2;
  1960. /**
  1961. * Copy the current vector to an array
  1962. * @returns a new array with 2 elements: the Vector2 coordinates.
  1963. */
  1964. asArray(): number[];
  1965. /**
  1966. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1967. * @param source defines the source Vector2
  1968. * @returns the current updated Vector2
  1969. */
  1970. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1971. /**
  1972. * Sets the Vector2 coordinates with the given floats
  1973. * @param x defines the first coordinate
  1974. * @param y defines the second coordinate
  1975. * @returns the current updated Vector2
  1976. */
  1977. copyFromFloats(x: number, y: number): Vector2;
  1978. /**
  1979. * Sets the Vector2 coordinates with the given floats
  1980. * @param x defines the first coordinate
  1981. * @param y defines the second coordinate
  1982. * @returns the current updated Vector2
  1983. */
  1984. set(x: number, y: number): Vector2;
  1985. /**
  1986. * Add another vector with the current one
  1987. * @param otherVector defines the other vector
  1988. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1989. */
  1990. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1991. /**
  1992. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1993. * @param otherVector defines the other vector
  1994. * @param result defines the target vector
  1995. * @returns the unmodified current Vector2
  1996. */
  1997. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1998. /**
  1999. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2000. * @param otherVector defines the other vector
  2001. * @returns the current updated Vector2
  2002. */
  2003. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2004. /**
  2005. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2006. * @param otherVector defines the other vector
  2007. * @returns a new Vector2
  2008. */
  2009. addVector3(otherVector: Vector3): Vector2;
  2010. /**
  2011. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2012. * @param otherVector defines the other vector
  2013. * @returns a new Vector2
  2014. */
  2015. subtract(otherVector: Vector2): Vector2;
  2016. /**
  2017. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2018. * @param otherVector defines the other vector
  2019. * @param result defines the target vector
  2020. * @returns the unmodified current Vector2
  2021. */
  2022. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2023. /**
  2024. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2025. * @param otherVector defines the other vector
  2026. * @returns the current updated Vector2
  2027. */
  2028. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2029. /**
  2030. * Multiplies in place the current Vector2 coordinates by the given ones
  2031. * @param otherVector defines the other vector
  2032. * @returns the current updated Vector2
  2033. */
  2034. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2035. /**
  2036. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2037. * @param otherVector defines the other vector
  2038. * @returns a new Vector2
  2039. */
  2040. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2041. /**
  2042. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2043. * @param otherVector defines the other vector
  2044. * @param result defines the target vector
  2045. * @returns the unmodified current Vector2
  2046. */
  2047. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2048. /**
  2049. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2050. * @param x defines the first coordinate
  2051. * @param y defines the second coordinate
  2052. * @returns a new Vector2
  2053. */
  2054. multiplyByFloats(x: number, y: number): Vector2;
  2055. /**
  2056. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2057. * @param otherVector defines the other vector
  2058. * @returns a new Vector2
  2059. */
  2060. divide(otherVector: Vector2): Vector2;
  2061. /**
  2062. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2063. * @param otherVector defines the other vector
  2064. * @param result defines the target vector
  2065. * @returns the unmodified current Vector2
  2066. */
  2067. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2068. /**
  2069. * Divides the current Vector2 coordinates by the given ones
  2070. * @param otherVector defines the other vector
  2071. * @returns the current updated Vector2
  2072. */
  2073. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2074. /**
  2075. * Gets a new Vector2 with current Vector2 negated coordinates
  2076. * @returns a new Vector2
  2077. */
  2078. negate(): Vector2;
  2079. /**
  2080. * Negate this vector in place
  2081. * @returns this
  2082. */
  2083. negateInPlace(): Vector2;
  2084. /**
  2085. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2086. * @param result defines the Vector3 object where to store the result
  2087. * @returns the current Vector2
  2088. */
  2089. negateToRef(result: Vector2): Vector2;
  2090. /**
  2091. * Multiply the Vector2 coordinates by scale
  2092. * @param scale defines the scaling factor
  2093. * @returns the current updated Vector2
  2094. */
  2095. scaleInPlace(scale: number): Vector2;
  2096. /**
  2097. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2098. * @param scale defines the scaling factor
  2099. * @returns a new Vector2
  2100. */
  2101. scale(scale: number): Vector2;
  2102. /**
  2103. * Scale the current Vector2 values by a factor to a given Vector2
  2104. * @param scale defines the scale factor
  2105. * @param result defines the Vector2 object where to store the result
  2106. * @returns the unmodified current Vector2
  2107. */
  2108. scaleToRef(scale: number, result: Vector2): Vector2;
  2109. /**
  2110. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2111. * @param scale defines the scale factor
  2112. * @param result defines the Vector2 object where to store the result
  2113. * @returns the unmodified current Vector2
  2114. */
  2115. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2116. /**
  2117. * Gets a boolean if two vectors are equals
  2118. * @param otherVector defines the other vector
  2119. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2120. */
  2121. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2122. /**
  2123. * Gets a boolean if two vectors are equals (using an epsilon value)
  2124. * @param otherVector defines the other vector
  2125. * @param epsilon defines the minimal distance to consider equality
  2126. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2127. */
  2128. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2129. /**
  2130. * Gets a new Vector2 from current Vector2 floored values
  2131. * @returns a new Vector2
  2132. */
  2133. floor(): Vector2;
  2134. /**
  2135. * Gets a new Vector2 from current Vector2 floored values
  2136. * @returns a new Vector2
  2137. */
  2138. fract(): Vector2;
  2139. /**
  2140. * Gets the length of the vector
  2141. * @returns the vector length (float)
  2142. */
  2143. length(): number;
  2144. /**
  2145. * Gets the vector squared length
  2146. * @returns the vector squared length (float)
  2147. */
  2148. lengthSquared(): number;
  2149. /**
  2150. * Normalize the vector
  2151. * @returns the current updated Vector2
  2152. */
  2153. normalize(): Vector2;
  2154. /**
  2155. * Gets a new Vector2 copied from the Vector2
  2156. * @returns a new Vector2
  2157. */
  2158. clone(): Vector2;
  2159. /**
  2160. * Gets a new Vector2(0, 0)
  2161. * @returns a new Vector2
  2162. */
  2163. static Zero(): Vector2;
  2164. /**
  2165. * Gets a new Vector2(1, 1)
  2166. * @returns a new Vector2
  2167. */
  2168. static One(): Vector2;
  2169. /**
  2170. * Gets a new Vector2 set from the given index element of the given array
  2171. * @param array defines the data source
  2172. * @param offset defines the offset in the data source
  2173. * @returns a new Vector2
  2174. */
  2175. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2176. /**
  2177. * Sets "result" from the given index element of the given array
  2178. * @param array defines the data source
  2179. * @param offset defines the offset in the data source
  2180. * @param result defines the target vector
  2181. */
  2182. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2183. /**
  2184. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2185. * @param value1 defines 1st point of control
  2186. * @param value2 defines 2nd point of control
  2187. * @param value3 defines 3rd point of control
  2188. * @param value4 defines 4th point of control
  2189. * @param amount defines the interpolation factor
  2190. * @returns a new Vector2
  2191. */
  2192. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2193. /**
  2194. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2195. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2196. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2197. * @param value defines the value to clamp
  2198. * @param min defines the lower limit
  2199. * @param max defines the upper limit
  2200. * @returns a new Vector2
  2201. */
  2202. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2203. /**
  2204. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2205. * @param value1 defines the 1st control point
  2206. * @param tangent1 defines the outgoing tangent
  2207. * @param value2 defines the 2nd control point
  2208. * @param tangent2 defines the incoming tangent
  2209. * @param amount defines the interpolation factor
  2210. * @returns a new Vector2
  2211. */
  2212. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2213. /**
  2214. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2215. * @param start defines the start vector
  2216. * @param end defines the end vector
  2217. * @param amount defines the interpolation factor
  2218. * @returns a new Vector2
  2219. */
  2220. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2221. /**
  2222. * Gets the dot product of the vector "left" and the vector "right"
  2223. * @param left defines first vector
  2224. * @param right defines second vector
  2225. * @returns the dot product (float)
  2226. */
  2227. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2228. /**
  2229. * Returns a new Vector2 equal to the normalized given vector
  2230. * @param vector defines the vector to normalize
  2231. * @returns a new Vector2
  2232. */
  2233. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2234. /**
  2235. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2236. * @param left defines 1st vector
  2237. * @param right defines 2nd vector
  2238. * @returns a new Vector2
  2239. */
  2240. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2241. /**
  2242. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2243. * @param left defines 1st vector
  2244. * @param right defines 2nd vector
  2245. * @returns a new Vector2
  2246. */
  2247. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2248. /**
  2249. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2250. * @param vector defines the vector to transform
  2251. * @param transformation defines the matrix to apply
  2252. * @returns a new Vector2
  2253. */
  2254. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2255. /**
  2256. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2257. * @param vector defines the vector to transform
  2258. * @param transformation defines the matrix to apply
  2259. * @param result defines the target vector
  2260. */
  2261. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2262. /**
  2263. * Determines if a given vector is included in a triangle
  2264. * @param p defines the vector to test
  2265. * @param p0 defines 1st triangle point
  2266. * @param p1 defines 2nd triangle point
  2267. * @param p2 defines 3rd triangle point
  2268. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2269. */
  2270. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2271. /**
  2272. * Gets the distance between the vectors "value1" and "value2"
  2273. * @param value1 defines first vector
  2274. * @param value2 defines second vector
  2275. * @returns the distance between vectors
  2276. */
  2277. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2278. /**
  2279. * Returns the squared distance between the vectors "value1" and "value2"
  2280. * @param value1 defines first vector
  2281. * @param value2 defines second vector
  2282. * @returns the squared distance between vectors
  2283. */
  2284. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2285. /**
  2286. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2287. * @param value1 defines first vector
  2288. * @param value2 defines second vector
  2289. * @returns a new Vector2
  2290. */
  2291. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2292. /**
  2293. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2294. * @param p defines the middle point
  2295. * @param segA defines one point of the segment
  2296. * @param segB defines the other point of the segment
  2297. * @returns the shortest distance
  2298. */
  2299. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2300. }
  2301. /**
  2302. * Class used to store (x,y,z) vector representation
  2303. * A Vector3 is the main object used in 3D geometry
  2304. * It can represent etiher the coordinates of a point the space, either a direction
  2305. * Reminder: js uses a left handed forward facing system
  2306. */
  2307. export class Vector3 {
  2308. /**
  2309. * Defines the first coordinates (on X axis)
  2310. */
  2311. x: number;
  2312. /**
  2313. * Defines the second coordinates (on Y axis)
  2314. */
  2315. y: number;
  2316. /**
  2317. * Defines the third coordinates (on Z axis)
  2318. */
  2319. z: number;
  2320. private static _UpReadOnly;
  2321. private static _ZeroReadOnly;
  2322. /**
  2323. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2324. * @param x defines the first coordinates (on X axis)
  2325. * @param y defines the second coordinates (on Y axis)
  2326. * @param z defines the third coordinates (on Z axis)
  2327. */
  2328. constructor(
  2329. /**
  2330. * Defines the first coordinates (on X axis)
  2331. */
  2332. x?: number,
  2333. /**
  2334. * Defines the second coordinates (on Y axis)
  2335. */
  2336. y?: number,
  2337. /**
  2338. * Defines the third coordinates (on Z axis)
  2339. */
  2340. z?: number);
  2341. /**
  2342. * Creates a string representation of the Vector3
  2343. * @returns a string with the Vector3 coordinates.
  2344. */
  2345. toString(): string;
  2346. /**
  2347. * Gets the class name
  2348. * @returns the string "Vector3"
  2349. */
  2350. getClassName(): string;
  2351. /**
  2352. * Creates the Vector3 hash code
  2353. * @returns a number which tends to be unique between Vector3 instances
  2354. */
  2355. getHashCode(): number;
  2356. /**
  2357. * Creates an array containing three elements : the coordinates of the Vector3
  2358. * @returns a new array of numbers
  2359. */
  2360. asArray(): number[];
  2361. /**
  2362. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2363. * @param array defines the destination array
  2364. * @param index defines the offset in the destination array
  2365. * @returns the current Vector3
  2366. */
  2367. toArray(array: FloatArray, index?: number): Vector3;
  2368. /**
  2369. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2370. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2371. */
  2372. toQuaternion(): Quaternion;
  2373. /**
  2374. * Adds the given vector to the current Vector3
  2375. * @param otherVector defines the second operand
  2376. * @returns the current updated Vector3
  2377. */
  2378. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2379. /**
  2380. * Adds the given coordinates to the current Vector3
  2381. * @param x defines the x coordinate of the operand
  2382. * @param y defines the y coordinate of the operand
  2383. * @param z defines the z coordinate of the operand
  2384. * @returns the current updated Vector3
  2385. */
  2386. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2387. /**
  2388. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2389. * @param otherVector defines the second operand
  2390. * @returns the resulting Vector3
  2391. */
  2392. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2393. /**
  2394. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2395. * @param otherVector defines the second operand
  2396. * @param result defines the Vector3 object where to store the result
  2397. * @returns the current Vector3
  2398. */
  2399. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2400. /**
  2401. * Subtract the given vector from the current Vector3
  2402. * @param otherVector defines the second operand
  2403. * @returns the current updated Vector3
  2404. */
  2405. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2406. /**
  2407. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2408. * @param otherVector defines the second operand
  2409. * @returns the resulting Vector3
  2410. */
  2411. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2412. /**
  2413. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2414. * @param otherVector defines the second operand
  2415. * @param result defines the Vector3 object where to store the result
  2416. * @returns the current Vector3
  2417. */
  2418. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2419. /**
  2420. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2421. * @param x defines the x coordinate of the operand
  2422. * @param y defines the y coordinate of the operand
  2423. * @param z defines the z coordinate of the operand
  2424. * @returns the resulting Vector3
  2425. */
  2426. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2427. /**
  2428. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2429. * @param x defines the x coordinate of the operand
  2430. * @param y defines the y coordinate of the operand
  2431. * @param z defines the z coordinate of the operand
  2432. * @param result defines the Vector3 object where to store the result
  2433. * @returns the current Vector3
  2434. */
  2435. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2436. /**
  2437. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2438. * @returns a new Vector3
  2439. */
  2440. negate(): Vector3;
  2441. /**
  2442. * Negate this vector in place
  2443. * @returns this
  2444. */
  2445. negateInPlace(): Vector3;
  2446. /**
  2447. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2448. * @param result defines the Vector3 object where to store the result
  2449. * @returns the current Vector3
  2450. */
  2451. negateToRef(result: Vector3): Vector3;
  2452. /**
  2453. * Multiplies the Vector3 coordinates by the float "scale"
  2454. * @param scale defines the multiplier factor
  2455. * @returns the current updated Vector3
  2456. */
  2457. scaleInPlace(scale: number): Vector3;
  2458. /**
  2459. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2460. * @param scale defines the multiplier factor
  2461. * @returns a new Vector3
  2462. */
  2463. scale(scale: number): Vector3;
  2464. /**
  2465. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2466. * @param scale defines the multiplier factor
  2467. * @param result defines the Vector3 object where to store the result
  2468. * @returns the current Vector3
  2469. */
  2470. scaleToRef(scale: number, result: Vector3): Vector3;
  2471. /**
  2472. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2473. * @param scale defines the scale factor
  2474. * @param result defines the Vector3 object where to store the result
  2475. * @returns the unmodified current Vector3
  2476. */
  2477. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2478. /**
  2479. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2480. * @param otherVector defines the second operand
  2481. * @returns true if both vectors are equals
  2482. */
  2483. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2484. /**
  2485. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2486. * @param otherVector defines the second operand
  2487. * @param epsilon defines the minimal distance to define values as equals
  2488. * @returns true if both vectors are distant less than epsilon
  2489. */
  2490. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2491. /**
  2492. * Returns true if the current Vector3 coordinates equals the given floats
  2493. * @param x defines the x coordinate of the operand
  2494. * @param y defines the y coordinate of the operand
  2495. * @param z defines the z coordinate of the operand
  2496. * @returns true if both vectors are equals
  2497. */
  2498. equalsToFloats(x: number, y: number, z: number): boolean;
  2499. /**
  2500. * Multiplies the current Vector3 coordinates by the given ones
  2501. * @param otherVector defines the second operand
  2502. * @returns the current updated Vector3
  2503. */
  2504. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2505. /**
  2506. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2507. * @param otherVector defines the second operand
  2508. * @returns the new Vector3
  2509. */
  2510. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2511. /**
  2512. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2513. * @param otherVector defines the second operand
  2514. * @param result defines the Vector3 object where to store the result
  2515. * @returns the current Vector3
  2516. */
  2517. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2518. /**
  2519. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2520. * @param x defines the x coordinate of the operand
  2521. * @param y defines the y coordinate of the operand
  2522. * @param z defines the z coordinate of the operand
  2523. * @returns the new Vector3
  2524. */
  2525. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2526. /**
  2527. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2528. * @param otherVector defines the second operand
  2529. * @returns the new Vector3
  2530. */
  2531. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2532. /**
  2533. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2534. * @param otherVector defines the second operand
  2535. * @param result defines the Vector3 object where to store the result
  2536. * @returns the current Vector3
  2537. */
  2538. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2539. /**
  2540. * Divides the current Vector3 coordinates by the given ones.
  2541. * @param otherVector defines the second operand
  2542. * @returns the current updated Vector3
  2543. */
  2544. divideInPlace(otherVector: Vector3): Vector3;
  2545. /**
  2546. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2547. * @param other defines the second operand
  2548. * @returns the current updated Vector3
  2549. */
  2550. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2551. /**
  2552. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2553. * @param other defines the second operand
  2554. * @returns the current updated Vector3
  2555. */
  2556. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2557. /**
  2558. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2559. * @param x defines the x coordinate of the operand
  2560. * @param y defines the y coordinate of the operand
  2561. * @param z defines the z coordinate of the operand
  2562. * @returns the current updated Vector3
  2563. */
  2564. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2565. /**
  2566. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2567. * @param x defines the x coordinate of the operand
  2568. * @param y defines the y coordinate of the operand
  2569. * @param z defines the z coordinate of the operand
  2570. * @returns the current updated Vector3
  2571. */
  2572. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2573. /**
  2574. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2575. * Check if is non uniform within a certain amount of decimal places to account for this
  2576. * @param epsilon the amount the values can differ
  2577. * @returns if the the vector is non uniform to a certain number of decimal places
  2578. */
  2579. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2580. /**
  2581. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2582. */
  2583. get isNonUniform(): boolean;
  2584. /**
  2585. * Gets a new Vector3 from current Vector3 floored values
  2586. * @returns a new Vector3
  2587. */
  2588. floor(): Vector3;
  2589. /**
  2590. * Gets a new Vector3 from current Vector3 floored values
  2591. * @returns a new Vector3
  2592. */
  2593. fract(): Vector3;
  2594. /**
  2595. * Gets the length of the Vector3
  2596. * @returns the length of the Vector3
  2597. */
  2598. length(): number;
  2599. /**
  2600. * Gets the squared length of the Vector3
  2601. * @returns squared length of the Vector3
  2602. */
  2603. lengthSquared(): number;
  2604. /**
  2605. * Normalize the current Vector3.
  2606. * Please note that this is an in place operation.
  2607. * @returns the current updated Vector3
  2608. */
  2609. normalize(): Vector3;
  2610. /**
  2611. * Reorders the x y z properties of the vector in place
  2612. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2613. * @returns the current updated vector
  2614. */
  2615. reorderInPlace(order: string): this;
  2616. /**
  2617. * Rotates the vector around 0,0,0 by a quaternion
  2618. * @param quaternion the rotation quaternion
  2619. * @param result vector to store the result
  2620. * @returns the resulting vector
  2621. */
  2622. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2623. /**
  2624. * Rotates a vector around a given point
  2625. * @param quaternion the rotation quaternion
  2626. * @param point the point to rotate around
  2627. * @param result vector to store the result
  2628. * @returns the resulting vector
  2629. */
  2630. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2631. /**
  2632. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2633. * The cross product is then orthogonal to both current and "other"
  2634. * @param other defines the right operand
  2635. * @returns the cross product
  2636. */
  2637. cross(other: Vector3): Vector3;
  2638. /**
  2639. * Normalize the current Vector3 with the given input length.
  2640. * Please note that this is an in place operation.
  2641. * @param len the length of the vector
  2642. * @returns the current updated Vector3
  2643. */
  2644. normalizeFromLength(len: number): Vector3;
  2645. /**
  2646. * Normalize the current Vector3 to a new vector
  2647. * @returns the new Vector3
  2648. */
  2649. normalizeToNew(): Vector3;
  2650. /**
  2651. * Normalize the current Vector3 to the reference
  2652. * @param reference define the Vector3 to update
  2653. * @returns the updated Vector3
  2654. */
  2655. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2656. /**
  2657. * Creates a new Vector3 copied from the current Vector3
  2658. * @returns the new Vector3
  2659. */
  2660. clone(): Vector3;
  2661. /**
  2662. * Copies the given vector coordinates to the current Vector3 ones
  2663. * @param source defines the source Vector3
  2664. * @returns the current updated Vector3
  2665. */
  2666. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2667. /**
  2668. * Copies the given floats to the current Vector3 coordinates
  2669. * @param x defines the x coordinate of the operand
  2670. * @param y defines the y coordinate of the operand
  2671. * @param z defines the z coordinate of the operand
  2672. * @returns the current updated Vector3
  2673. */
  2674. copyFromFloats(x: number, y: number, z: number): Vector3;
  2675. /**
  2676. * Copies the given floats to the current Vector3 coordinates
  2677. * @param x defines the x coordinate of the operand
  2678. * @param y defines the y coordinate of the operand
  2679. * @param z defines the z coordinate of the operand
  2680. * @returns the current updated Vector3
  2681. */
  2682. set(x: number, y: number, z: number): Vector3;
  2683. /**
  2684. * Copies the given float to the current Vector3 coordinates
  2685. * @param v defines the x, y and z coordinates of the operand
  2686. * @returns the current updated Vector3
  2687. */
  2688. setAll(v: number): Vector3;
  2689. /**
  2690. * Get the clip factor between two vectors
  2691. * @param vector0 defines the first operand
  2692. * @param vector1 defines the second operand
  2693. * @param axis defines the axis to use
  2694. * @param size defines the size along the axis
  2695. * @returns the clip factor
  2696. */
  2697. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2698. /**
  2699. * Get angle between two vectors
  2700. * @param vector0 angle between vector0 and vector1
  2701. * @param vector1 angle between vector0 and vector1
  2702. * @param normal direction of the normal
  2703. * @return the angle between vector0 and vector1
  2704. */
  2705. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2706. /**
  2707. * Returns a new Vector3 set from the index "offset" of the given array
  2708. * @param array defines the source array
  2709. * @param offset defines the offset in the source array
  2710. * @returns the new Vector3
  2711. */
  2712. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2713. /**
  2714. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2715. * @param array defines the source array
  2716. * @param offset defines the offset in the source array
  2717. * @returns the new Vector3
  2718. * @deprecated Please use FromArray instead.
  2719. */
  2720. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2721. /**
  2722. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2723. * @param array defines the source array
  2724. * @param offset defines the offset in the source array
  2725. * @param result defines the Vector3 where to store the result
  2726. */
  2727. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2728. /**
  2729. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2730. * @param array defines the source array
  2731. * @param offset defines the offset in the source array
  2732. * @param result defines the Vector3 where to store the result
  2733. * @deprecated Please use FromArrayToRef instead.
  2734. */
  2735. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2736. /**
  2737. * Sets the given vector "result" with the given floats.
  2738. * @param x defines the x coordinate of the source
  2739. * @param y defines the y coordinate of the source
  2740. * @param z defines the z coordinate of the source
  2741. * @param result defines the Vector3 where to store the result
  2742. */
  2743. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2744. /**
  2745. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2746. * @returns a new empty Vector3
  2747. */
  2748. static Zero(): Vector3;
  2749. /**
  2750. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2751. * @returns a new unit Vector3
  2752. */
  2753. static One(): Vector3;
  2754. /**
  2755. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2756. * @returns a new up Vector3
  2757. */
  2758. static Up(): Vector3;
  2759. /**
  2760. * Gets a up Vector3 that must not be updated
  2761. */
  2762. static get UpReadOnly(): DeepImmutable<Vector3>;
  2763. /**
  2764. * Gets a zero Vector3 that must not be updated
  2765. */
  2766. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2767. /**
  2768. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2769. * @returns a new down Vector3
  2770. */
  2771. static Down(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2774. * @returns a new forward Vector3
  2775. */
  2776. static Forward(): Vector3;
  2777. /**
  2778. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2779. * @returns a new forward Vector3
  2780. */
  2781. static Backward(): Vector3;
  2782. /**
  2783. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2784. * @returns a new right Vector3
  2785. */
  2786. static Right(): Vector3;
  2787. /**
  2788. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2789. * @returns a new left Vector3
  2790. */
  2791. static Left(): Vector3;
  2792. /**
  2793. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2794. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2795. * @param vector defines the Vector3 to transform
  2796. * @param transformation defines the transformation matrix
  2797. * @returns the transformed Vector3
  2798. */
  2799. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2800. /**
  2801. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2802. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2803. * @param vector defines the Vector3 to transform
  2804. * @param transformation defines the transformation matrix
  2805. * @param result defines the Vector3 where to store the result
  2806. */
  2807. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2808. /**
  2809. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2810. * This method computes tranformed coordinates only, not transformed direction vectors
  2811. * @param x define the x coordinate of the source vector
  2812. * @param y define the y coordinate of the source vector
  2813. * @param z define the z coordinate of the source vector
  2814. * @param transformation defines the transformation matrix
  2815. * @param result defines the Vector3 where to store the result
  2816. */
  2817. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2818. /**
  2819. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2820. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2821. * @param vector defines the Vector3 to transform
  2822. * @param transformation defines the transformation matrix
  2823. * @returns the new Vector3
  2824. */
  2825. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2826. /**
  2827. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2828. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2829. * @param vector defines the Vector3 to transform
  2830. * @param transformation defines the transformation matrix
  2831. * @param result defines the Vector3 where to store the result
  2832. */
  2833. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2834. /**
  2835. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2836. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2837. * @param x define the x coordinate of the source vector
  2838. * @param y define the y coordinate of the source vector
  2839. * @param z define the z coordinate of the source vector
  2840. * @param transformation defines the transformation matrix
  2841. * @param result defines the Vector3 where to store the result
  2842. */
  2843. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2844. /**
  2845. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2846. * @param value1 defines the first control point
  2847. * @param value2 defines the second control point
  2848. * @param value3 defines the third control point
  2849. * @param value4 defines the fourth control point
  2850. * @param amount defines the amount on the spline to use
  2851. * @returns the new Vector3
  2852. */
  2853. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2854. /**
  2855. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2856. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2857. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2858. * @param value defines the current value
  2859. * @param min defines the lower range value
  2860. * @param max defines the upper range value
  2861. * @returns the new Vector3
  2862. */
  2863. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2864. /**
  2865. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2866. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2867. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2868. * @param value defines the current value
  2869. * @param min defines the lower range value
  2870. * @param max defines the upper range value
  2871. * @param result defines the Vector3 where to store the result
  2872. */
  2873. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2874. /**
  2875. * Checks if a given vector is inside a specific range
  2876. * @param v defines the vector to test
  2877. * @param min defines the minimum range
  2878. * @param max defines the maximum range
  2879. */
  2880. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2881. /**
  2882. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2883. * @param value1 defines the first control point
  2884. * @param tangent1 defines the first tangent vector
  2885. * @param value2 defines the second control point
  2886. * @param tangent2 defines the second tangent vector
  2887. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2888. * @returns the new Vector3
  2889. */
  2890. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2891. /**
  2892. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2893. * @param start defines the start value
  2894. * @param end defines the end value
  2895. * @param amount max defines amount between both (between 0 and 1)
  2896. * @returns the new Vector3
  2897. */
  2898. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2899. /**
  2900. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2901. * @param start defines the start value
  2902. * @param end defines the end value
  2903. * @param amount max defines amount between both (between 0 and 1)
  2904. * @param result defines the Vector3 where to store the result
  2905. */
  2906. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2907. /**
  2908. * Returns the dot product (float) between the vectors "left" and "right"
  2909. * @param left defines the left operand
  2910. * @param right defines the right operand
  2911. * @returns the dot product
  2912. */
  2913. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2914. /**
  2915. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2916. * The cross product is then orthogonal to both "left" and "right"
  2917. * @param left defines the left operand
  2918. * @param right defines the right operand
  2919. * @returns the cross product
  2920. */
  2921. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2922. /**
  2923. * Sets the given vector "result" with the cross product of "left" and "right"
  2924. * The cross product is then orthogonal to both "left" and "right"
  2925. * @param left defines the left operand
  2926. * @param right defines the right operand
  2927. * @param result defines the Vector3 where to store the result
  2928. */
  2929. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2930. /**
  2931. * Returns a new Vector3 as the normalization of the given vector
  2932. * @param vector defines the Vector3 to normalize
  2933. * @returns the new Vector3
  2934. */
  2935. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2936. /**
  2937. * Sets the given vector "result" with the normalization of the given first vector
  2938. * @param vector defines the Vector3 to normalize
  2939. * @param result defines the Vector3 where to store the result
  2940. */
  2941. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2942. /**
  2943. * Project a Vector3 onto screen space
  2944. * @param vector defines the Vector3 to project
  2945. * @param world defines the world matrix to use
  2946. * @param transform defines the transform (view x projection) matrix to use
  2947. * @param viewport defines the screen viewport to use
  2948. * @returns the new Vector3
  2949. */
  2950. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2951. /** @hidden */
  2952. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2953. /**
  2954. * Unproject from screen space to object space
  2955. * @param source defines the screen space Vector3 to use
  2956. * @param viewportWidth defines the current width of the viewport
  2957. * @param viewportHeight defines the current height of the viewport
  2958. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2959. * @param transform defines the transform (view x projection) matrix to use
  2960. * @returns the new Vector3
  2961. */
  2962. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2963. /**
  2964. * Unproject from screen space to object space
  2965. * @param source defines the screen space Vector3 to use
  2966. * @param viewportWidth defines the current width of the viewport
  2967. * @param viewportHeight defines the current height of the viewport
  2968. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2969. * @param view defines the view matrix to use
  2970. * @param projection defines the projection matrix to use
  2971. * @returns the new Vector3
  2972. */
  2973. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2974. /**
  2975. * Unproject from screen space to object space
  2976. * @param source defines the screen space Vector3 to use
  2977. * @param viewportWidth defines the current width of the viewport
  2978. * @param viewportHeight defines the current height of the viewport
  2979. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2980. * @param view defines the view matrix to use
  2981. * @param projection defines the projection matrix to use
  2982. * @param result defines the Vector3 where to store the result
  2983. */
  2984. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2985. /**
  2986. * Unproject from screen space to object space
  2987. * @param sourceX defines the screen space x coordinate to use
  2988. * @param sourceY defines the screen space y coordinate to use
  2989. * @param sourceZ defines the screen space z coordinate to use
  2990. * @param viewportWidth defines the current width of the viewport
  2991. * @param viewportHeight defines the current height of the viewport
  2992. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2993. * @param view defines the view matrix to use
  2994. * @param projection defines the projection matrix to use
  2995. * @param result defines the Vector3 where to store the result
  2996. */
  2997. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2998. /**
  2999. * Gets the minimal coordinate values between two Vector3
  3000. * @param left defines the first operand
  3001. * @param right defines the second operand
  3002. * @returns the new Vector3
  3003. */
  3004. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3005. /**
  3006. * Gets the maximal coordinate values between two Vector3
  3007. * @param left defines the first operand
  3008. * @param right defines the second operand
  3009. * @returns the new Vector3
  3010. */
  3011. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3012. /**
  3013. * Returns the distance between the vectors "value1" and "value2"
  3014. * @param value1 defines the first operand
  3015. * @param value2 defines the second operand
  3016. * @returns the distance
  3017. */
  3018. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3019. /**
  3020. * Returns the squared distance between the vectors "value1" and "value2"
  3021. * @param value1 defines the first operand
  3022. * @param value2 defines the second operand
  3023. * @returns the squared distance
  3024. */
  3025. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3026. /**
  3027. * Returns a new Vector3 located at the center between "value1" and "value2"
  3028. * @param value1 defines the first operand
  3029. * @param value2 defines the second operand
  3030. * @returns the new Vector3
  3031. */
  3032. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3033. /**
  3034. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3035. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3036. * to something in order to rotate it from its local system to the given target system
  3037. * Note: axis1, axis2 and axis3 are normalized during this operation
  3038. * @param axis1 defines the first axis
  3039. * @param axis2 defines the second axis
  3040. * @param axis3 defines the third axis
  3041. * @returns a new Vector3
  3042. */
  3043. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3044. /**
  3045. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3046. * @param axis1 defines the first axis
  3047. * @param axis2 defines the second axis
  3048. * @param axis3 defines the third axis
  3049. * @param ref defines the Vector3 where to store the result
  3050. */
  3051. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3052. }
  3053. /**
  3054. * Vector4 class created for EulerAngle class conversion to Quaternion
  3055. */
  3056. export class Vector4 {
  3057. /** x value of the vector */
  3058. x: number;
  3059. /** y value of the vector */
  3060. y: number;
  3061. /** z value of the vector */
  3062. z: number;
  3063. /** w value of the vector */
  3064. w: number;
  3065. /**
  3066. * Creates a Vector4 object from the given floats.
  3067. * @param x x value of the vector
  3068. * @param y y value of the vector
  3069. * @param z z value of the vector
  3070. * @param w w value of the vector
  3071. */
  3072. constructor(
  3073. /** x value of the vector */
  3074. x: number,
  3075. /** y value of the vector */
  3076. y: number,
  3077. /** z value of the vector */
  3078. z: number,
  3079. /** w value of the vector */
  3080. w: number);
  3081. /**
  3082. * Returns the string with the Vector4 coordinates.
  3083. * @returns a string containing all the vector values
  3084. */
  3085. toString(): string;
  3086. /**
  3087. * Returns the string "Vector4".
  3088. * @returns "Vector4"
  3089. */
  3090. getClassName(): string;
  3091. /**
  3092. * Returns the Vector4 hash code.
  3093. * @returns a unique hash code
  3094. */
  3095. getHashCode(): number;
  3096. /**
  3097. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3098. * @returns the resulting array
  3099. */
  3100. asArray(): number[];
  3101. /**
  3102. * Populates the given array from the given index with the Vector4 coordinates.
  3103. * @param array array to populate
  3104. * @param index index of the array to start at (default: 0)
  3105. * @returns the Vector4.
  3106. */
  3107. toArray(array: FloatArray, index?: number): Vector4;
  3108. /**
  3109. * Adds the given vector to the current Vector4.
  3110. * @param otherVector the vector to add
  3111. * @returns the updated Vector4.
  3112. */
  3113. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3114. /**
  3115. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3116. * @param otherVector the vector to add
  3117. * @returns the resulting vector
  3118. */
  3119. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3120. /**
  3121. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3122. * @param otherVector the vector to add
  3123. * @param result the vector to store the result
  3124. * @returns the current Vector4.
  3125. */
  3126. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3127. /**
  3128. * Subtract in place the given vector from the current Vector4.
  3129. * @param otherVector the vector to subtract
  3130. * @returns the updated Vector4.
  3131. */
  3132. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3133. /**
  3134. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3135. * @param otherVector the vector to add
  3136. * @returns the new vector with the result
  3137. */
  3138. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3139. /**
  3140. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3141. * @param otherVector the vector to subtract
  3142. * @param result the vector to store the result
  3143. * @returns the current Vector4.
  3144. */
  3145. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3146. /**
  3147. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3148. */
  3149. /**
  3150. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3151. * @param x value to subtract
  3152. * @param y value to subtract
  3153. * @param z value to subtract
  3154. * @param w value to subtract
  3155. * @returns new vector containing the result
  3156. */
  3157. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3158. /**
  3159. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3160. * @param x value to subtract
  3161. * @param y value to subtract
  3162. * @param z value to subtract
  3163. * @param w value to subtract
  3164. * @param result the vector to store the result in
  3165. * @returns the current Vector4.
  3166. */
  3167. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3168. /**
  3169. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3170. * @returns a new vector with the negated values
  3171. */
  3172. negate(): Vector4;
  3173. /**
  3174. * Negate this vector in place
  3175. * @returns this
  3176. */
  3177. negateInPlace(): Vector4;
  3178. /**
  3179. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3180. * @param result defines the Vector3 object where to store the result
  3181. * @returns the current Vector4
  3182. */
  3183. negateToRef(result: Vector4): Vector4;
  3184. /**
  3185. * Multiplies the current Vector4 coordinates by scale (float).
  3186. * @param scale the number to scale with
  3187. * @returns the updated Vector4.
  3188. */
  3189. scaleInPlace(scale: number): Vector4;
  3190. /**
  3191. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3192. * @param scale the number to scale with
  3193. * @returns a new vector with the result
  3194. */
  3195. scale(scale: number): Vector4;
  3196. /**
  3197. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3198. * @param scale the number to scale with
  3199. * @param result a vector to store the result in
  3200. * @returns the current Vector4.
  3201. */
  3202. scaleToRef(scale: number, result: Vector4): Vector4;
  3203. /**
  3204. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3205. * @param scale defines the scale factor
  3206. * @param result defines the Vector4 object where to store the result
  3207. * @returns the unmodified current Vector4
  3208. */
  3209. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3210. /**
  3211. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3212. * @param otherVector the vector to compare against
  3213. * @returns true if they are equal
  3214. */
  3215. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3216. /**
  3217. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3218. * @param otherVector vector to compare against
  3219. * @param epsilon (Default: very small number)
  3220. * @returns true if they are equal
  3221. */
  3222. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3223. /**
  3224. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3225. * @param x x value to compare against
  3226. * @param y y value to compare against
  3227. * @param z z value to compare against
  3228. * @param w w value to compare against
  3229. * @returns true if equal
  3230. */
  3231. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3232. /**
  3233. * Multiplies in place the current Vector4 by the given one.
  3234. * @param otherVector vector to multiple with
  3235. * @returns the updated Vector4.
  3236. */
  3237. multiplyInPlace(otherVector: Vector4): Vector4;
  3238. /**
  3239. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3240. * @param otherVector vector to multiple with
  3241. * @returns resulting new vector
  3242. */
  3243. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3244. /**
  3245. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3246. * @param otherVector vector to multiple with
  3247. * @param result vector to store the result
  3248. * @returns the current Vector4.
  3249. */
  3250. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3251. /**
  3252. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3253. * @param x x value multiply with
  3254. * @param y y value multiply with
  3255. * @param z z value multiply with
  3256. * @param w w value multiply with
  3257. * @returns resulting new vector
  3258. */
  3259. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3260. /**
  3261. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3262. * @param otherVector vector to devide with
  3263. * @returns resulting new vector
  3264. */
  3265. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3266. /**
  3267. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3268. * @param otherVector vector to devide with
  3269. * @param result vector to store the result
  3270. * @returns the current Vector4.
  3271. */
  3272. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3273. /**
  3274. * Divides the current Vector3 coordinates by the given ones.
  3275. * @param otherVector vector to devide with
  3276. * @returns the updated Vector3.
  3277. */
  3278. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3279. /**
  3280. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3281. * @param other defines the second operand
  3282. * @returns the current updated Vector4
  3283. */
  3284. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3285. /**
  3286. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3287. * @param other defines the second operand
  3288. * @returns the current updated Vector4
  3289. */
  3290. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3291. /**
  3292. * Gets a new Vector4 from current Vector4 floored values
  3293. * @returns a new Vector4
  3294. */
  3295. floor(): Vector4;
  3296. /**
  3297. * Gets a new Vector4 from current Vector3 floored values
  3298. * @returns a new Vector4
  3299. */
  3300. fract(): Vector4;
  3301. /**
  3302. * Returns the Vector4 length (float).
  3303. * @returns the length
  3304. */
  3305. length(): number;
  3306. /**
  3307. * Returns the Vector4 squared length (float).
  3308. * @returns the length squared
  3309. */
  3310. lengthSquared(): number;
  3311. /**
  3312. * Normalizes in place the Vector4.
  3313. * @returns the updated Vector4.
  3314. */
  3315. normalize(): Vector4;
  3316. /**
  3317. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3318. * @returns this converted to a new vector3
  3319. */
  3320. toVector3(): Vector3;
  3321. /**
  3322. * Returns a new Vector4 copied from the current one.
  3323. * @returns the new cloned vector
  3324. */
  3325. clone(): Vector4;
  3326. /**
  3327. * Updates the current Vector4 with the given one coordinates.
  3328. * @param source the source vector to copy from
  3329. * @returns the updated Vector4.
  3330. */
  3331. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3332. /**
  3333. * Updates the current Vector4 coordinates with the given floats.
  3334. * @param x float to copy from
  3335. * @param y float to copy from
  3336. * @param z float to copy from
  3337. * @param w float to copy from
  3338. * @returns the updated Vector4.
  3339. */
  3340. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3341. /**
  3342. * Updates the current Vector4 coordinates with the given floats.
  3343. * @param x float to set from
  3344. * @param y float to set from
  3345. * @param z float to set from
  3346. * @param w float to set from
  3347. * @returns the updated Vector4.
  3348. */
  3349. set(x: number, y: number, z: number, w: number): Vector4;
  3350. /**
  3351. * Copies the given float to the current Vector3 coordinates
  3352. * @param v defines the x, y, z and w coordinates of the operand
  3353. * @returns the current updated Vector3
  3354. */
  3355. setAll(v: number): Vector4;
  3356. /**
  3357. * Returns a new Vector4 set from the starting index of the given array.
  3358. * @param array the array to pull values from
  3359. * @param offset the offset into the array to start at
  3360. * @returns the new vector
  3361. */
  3362. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3363. /**
  3364. * Updates the given vector "result" from the starting index of the given array.
  3365. * @param array the array to pull values from
  3366. * @param offset the offset into the array to start at
  3367. * @param result the vector to store the result in
  3368. */
  3369. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3370. /**
  3371. * Updates the given vector "result" from the starting index of the given Float32Array.
  3372. * @param array the array to pull values from
  3373. * @param offset the offset into the array to start at
  3374. * @param result the vector to store the result in
  3375. */
  3376. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3377. /**
  3378. * Updates the given vector "result" coordinates from the given floats.
  3379. * @param x float to set from
  3380. * @param y float to set from
  3381. * @param z float to set from
  3382. * @param w float to set from
  3383. * @param result the vector to the floats in
  3384. */
  3385. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3386. /**
  3387. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3388. * @returns the new vector
  3389. */
  3390. static Zero(): Vector4;
  3391. /**
  3392. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3393. * @returns the new vector
  3394. */
  3395. static One(): Vector4;
  3396. /**
  3397. * Returns a new normalized Vector4 from the given one.
  3398. * @param vector the vector to normalize
  3399. * @returns the vector
  3400. */
  3401. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3402. /**
  3403. * Updates the given vector "result" from the normalization of the given one.
  3404. * @param vector the vector to normalize
  3405. * @param result the vector to store the result in
  3406. */
  3407. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3408. /**
  3409. * Returns a vector with the minimum values from the left and right vectors
  3410. * @param left left vector to minimize
  3411. * @param right right vector to minimize
  3412. * @returns a new vector with the minimum of the left and right vector values
  3413. */
  3414. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3415. /**
  3416. * Returns a vector with the maximum values from the left and right vectors
  3417. * @param left left vector to maximize
  3418. * @param right right vector to maximize
  3419. * @returns a new vector with the maximum of the left and right vector values
  3420. */
  3421. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3422. /**
  3423. * Returns the distance (float) between the vectors "value1" and "value2".
  3424. * @param value1 value to calulate the distance between
  3425. * @param value2 value to calulate the distance between
  3426. * @return the distance between the two vectors
  3427. */
  3428. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3429. /**
  3430. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3431. * @param value1 value to calulate the distance between
  3432. * @param value2 value to calulate the distance between
  3433. * @return the distance between the two vectors squared
  3434. */
  3435. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3436. /**
  3437. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3438. * @param value1 value to calulate the center between
  3439. * @param value2 value to calulate the center between
  3440. * @return the center between the two vectors
  3441. */
  3442. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3443. /**
  3444. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3445. * This methods computes transformed normalized direction vectors only.
  3446. * @param vector the vector to transform
  3447. * @param transformation the transformation matrix to apply
  3448. * @returns the new vector
  3449. */
  3450. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3451. /**
  3452. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3453. * This methods computes transformed normalized direction vectors only.
  3454. * @param vector the vector to transform
  3455. * @param transformation the transformation matrix to apply
  3456. * @param result the vector to store the result in
  3457. */
  3458. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3459. /**
  3460. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3461. * This methods computes transformed normalized direction vectors only.
  3462. * @param x value to transform
  3463. * @param y value to transform
  3464. * @param z value to transform
  3465. * @param w value to transform
  3466. * @param transformation the transformation matrix to apply
  3467. * @param result the vector to store the results in
  3468. */
  3469. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3470. /**
  3471. * Creates a new Vector4 from a Vector3
  3472. * @param source defines the source data
  3473. * @param w defines the 4th component (default is 0)
  3474. * @returns a new Vector4
  3475. */
  3476. static FromVector3(source: Vector3, w?: number): Vector4;
  3477. }
  3478. /**
  3479. * Class used to store quaternion data
  3480. * @see https://en.wikipedia.org/wiki/Quaternion
  3481. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3482. */
  3483. export class Quaternion {
  3484. /** defines the first component (0 by default) */
  3485. x: number;
  3486. /** defines the second component (0 by default) */
  3487. y: number;
  3488. /** defines the third component (0 by default) */
  3489. z: number;
  3490. /** defines the fourth component (1.0 by default) */
  3491. w: number;
  3492. /**
  3493. * Creates a new Quaternion from the given floats
  3494. * @param x defines the first component (0 by default)
  3495. * @param y defines the second component (0 by default)
  3496. * @param z defines the third component (0 by default)
  3497. * @param w defines the fourth component (1.0 by default)
  3498. */
  3499. constructor(
  3500. /** defines the first component (0 by default) */
  3501. x?: number,
  3502. /** defines the second component (0 by default) */
  3503. y?: number,
  3504. /** defines the third component (0 by default) */
  3505. z?: number,
  3506. /** defines the fourth component (1.0 by default) */
  3507. w?: number);
  3508. /**
  3509. * Gets a string representation for the current quaternion
  3510. * @returns a string with the Quaternion coordinates
  3511. */
  3512. toString(): string;
  3513. /**
  3514. * Gets the class name of the quaternion
  3515. * @returns the string "Quaternion"
  3516. */
  3517. getClassName(): string;
  3518. /**
  3519. * Gets a hash code for this quaternion
  3520. * @returns the quaternion hash code
  3521. */
  3522. getHashCode(): number;
  3523. /**
  3524. * Copy the quaternion to an array
  3525. * @returns a new array populated with 4 elements from the quaternion coordinates
  3526. */
  3527. asArray(): number[];
  3528. /**
  3529. * Check if two quaternions are equals
  3530. * @param otherQuaternion defines the second operand
  3531. * @return true if the current quaternion and the given one coordinates are strictly equals
  3532. */
  3533. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3534. /**
  3535. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3536. * @param otherQuaternion defines the other quaternion
  3537. * @param epsilon defines the minimal distance to consider equality
  3538. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3539. */
  3540. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3541. /**
  3542. * Clone the current quaternion
  3543. * @returns a new quaternion copied from the current one
  3544. */
  3545. clone(): Quaternion;
  3546. /**
  3547. * Copy a quaternion to the current one
  3548. * @param other defines the other quaternion
  3549. * @returns the updated current quaternion
  3550. */
  3551. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3552. /**
  3553. * Updates the current quaternion with the given float coordinates
  3554. * @param x defines the x coordinate
  3555. * @param y defines the y coordinate
  3556. * @param z defines the z coordinate
  3557. * @param w defines the w coordinate
  3558. * @returns the updated current quaternion
  3559. */
  3560. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3561. /**
  3562. * Updates the current quaternion from the given float coordinates
  3563. * @param x defines the x coordinate
  3564. * @param y defines the y coordinate
  3565. * @param z defines the z coordinate
  3566. * @param w defines the w coordinate
  3567. * @returns the updated current quaternion
  3568. */
  3569. set(x: number, y: number, z: number, w: number): Quaternion;
  3570. /**
  3571. * Adds two quaternions
  3572. * @param other defines the second operand
  3573. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3574. */
  3575. add(other: DeepImmutable<Quaternion>): Quaternion;
  3576. /**
  3577. * Add a quaternion to the current one
  3578. * @param other defines the quaternion to add
  3579. * @returns the current quaternion
  3580. */
  3581. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3582. /**
  3583. * Subtract two quaternions
  3584. * @param other defines the second operand
  3585. * @returns a new quaternion as the subtraction result of the given one from the current one
  3586. */
  3587. subtract(other: Quaternion): Quaternion;
  3588. /**
  3589. * Multiplies the current quaternion by a scale factor
  3590. * @param value defines the scale factor
  3591. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3592. */
  3593. scale(value: number): Quaternion;
  3594. /**
  3595. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3596. * @param scale defines the scale factor
  3597. * @param result defines the Quaternion object where to store the result
  3598. * @returns the unmodified current quaternion
  3599. */
  3600. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3601. /**
  3602. * Multiplies in place the current quaternion by a scale factor
  3603. * @param value defines the scale factor
  3604. * @returns the current modified quaternion
  3605. */
  3606. scaleInPlace(value: number): Quaternion;
  3607. /**
  3608. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3609. * @param scale defines the scale factor
  3610. * @param result defines the Quaternion object where to store the result
  3611. * @returns the unmodified current quaternion
  3612. */
  3613. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3614. /**
  3615. * Multiplies two quaternions
  3616. * @param q1 defines the second operand
  3617. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3618. */
  3619. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3620. /**
  3621. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3622. * @param q1 defines the second operand
  3623. * @param result defines the target quaternion
  3624. * @returns the current quaternion
  3625. */
  3626. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3627. /**
  3628. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3629. * @param q1 defines the second operand
  3630. * @returns the currentupdated quaternion
  3631. */
  3632. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3633. /**
  3634. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3635. * @param ref defines the target quaternion
  3636. * @returns the current quaternion
  3637. */
  3638. conjugateToRef(ref: Quaternion): Quaternion;
  3639. /**
  3640. * Conjugates in place (1-q) the current quaternion
  3641. * @returns the current updated quaternion
  3642. */
  3643. conjugateInPlace(): Quaternion;
  3644. /**
  3645. * Conjugates in place (1-q) the current quaternion
  3646. * @returns a new quaternion
  3647. */
  3648. conjugate(): Quaternion;
  3649. /**
  3650. * Gets length of current quaternion
  3651. * @returns the quaternion length (float)
  3652. */
  3653. length(): number;
  3654. /**
  3655. * Normalize in place the current quaternion
  3656. * @returns the current updated quaternion
  3657. */
  3658. normalize(): Quaternion;
  3659. /**
  3660. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3661. * @param order is a reserved parameter and is ignore for now
  3662. * @returns a new Vector3 containing the Euler angles
  3663. */
  3664. toEulerAngles(order?: string): Vector3;
  3665. /**
  3666. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3667. * @param result defines the vector which will be filled with the Euler angles
  3668. * @param order is a reserved parameter and is ignore for now
  3669. * @returns the current unchanged quaternion
  3670. */
  3671. toEulerAnglesToRef(result: Vector3): Quaternion;
  3672. /**
  3673. * Updates the given rotation matrix with the current quaternion values
  3674. * @param result defines the target matrix
  3675. * @returns the current unchanged quaternion
  3676. */
  3677. toRotationMatrix(result: Matrix): Quaternion;
  3678. /**
  3679. * Updates the current quaternion from the given rotation matrix values
  3680. * @param matrix defines the source matrix
  3681. * @returns the current updated quaternion
  3682. */
  3683. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3684. /**
  3685. * Creates a new quaternion from a rotation matrix
  3686. * @param matrix defines the source matrix
  3687. * @returns a new quaternion created from the given rotation matrix values
  3688. */
  3689. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3690. /**
  3691. * Updates the given quaternion with the given rotation matrix values
  3692. * @param matrix defines the source matrix
  3693. * @param result defines the target quaternion
  3694. */
  3695. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3696. /**
  3697. * Returns the dot product (float) between the quaternions "left" and "right"
  3698. * @param left defines the left operand
  3699. * @param right defines the right operand
  3700. * @returns the dot product
  3701. */
  3702. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3703. /**
  3704. * Checks if the two quaternions are close to each other
  3705. * @param quat0 defines the first quaternion to check
  3706. * @param quat1 defines the second quaternion to check
  3707. * @returns true if the two quaternions are close to each other
  3708. */
  3709. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3710. /**
  3711. * Creates an empty quaternion
  3712. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3713. */
  3714. static Zero(): Quaternion;
  3715. /**
  3716. * Inverse a given quaternion
  3717. * @param q defines the source quaternion
  3718. * @returns a new quaternion as the inverted current quaternion
  3719. */
  3720. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3721. /**
  3722. * Inverse a given quaternion
  3723. * @param q defines the source quaternion
  3724. * @param result the quaternion the result will be stored in
  3725. * @returns the result quaternion
  3726. */
  3727. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3728. /**
  3729. * Creates an identity quaternion
  3730. * @returns the identity quaternion
  3731. */
  3732. static Identity(): Quaternion;
  3733. /**
  3734. * Gets a boolean indicating if the given quaternion is identity
  3735. * @param quaternion defines the quaternion to check
  3736. * @returns true if the quaternion is identity
  3737. */
  3738. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3739. /**
  3740. * Creates a quaternion from a rotation around an axis
  3741. * @param axis defines the axis to use
  3742. * @param angle defines the angle to use
  3743. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3744. */
  3745. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3746. /**
  3747. * Creates a rotation around an axis and stores it into the given quaternion
  3748. * @param axis defines the axis to use
  3749. * @param angle defines the angle to use
  3750. * @param result defines the target quaternion
  3751. * @returns the target quaternion
  3752. */
  3753. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3754. /**
  3755. * Creates a new quaternion from data stored into an array
  3756. * @param array defines the data source
  3757. * @param offset defines the offset in the source array where the data starts
  3758. * @returns a new quaternion
  3759. */
  3760. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3761. /**
  3762. * Create a quaternion from Euler rotation angles
  3763. * @param x Pitch
  3764. * @param y Yaw
  3765. * @param z Roll
  3766. * @returns the new Quaternion
  3767. */
  3768. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3769. /**
  3770. * Updates a quaternion from Euler rotation angles
  3771. * @param x Pitch
  3772. * @param y Yaw
  3773. * @param z Roll
  3774. * @param result the quaternion to store the result
  3775. * @returns the updated quaternion
  3776. */
  3777. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3778. /**
  3779. * Create a quaternion from Euler rotation vector
  3780. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3781. * @returns the new Quaternion
  3782. */
  3783. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3784. /**
  3785. * Updates a quaternion from Euler rotation vector
  3786. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3787. * @param result the quaternion to store the result
  3788. * @returns the updated quaternion
  3789. */
  3790. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3791. /**
  3792. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3793. * @param yaw defines the rotation around Y axis
  3794. * @param pitch defines the rotation around X axis
  3795. * @param roll defines the rotation around Z axis
  3796. * @returns the new quaternion
  3797. */
  3798. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3799. /**
  3800. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3801. * @param yaw defines the rotation around Y axis
  3802. * @param pitch defines the rotation around X axis
  3803. * @param roll defines the rotation around Z axis
  3804. * @param result defines the target quaternion
  3805. */
  3806. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3807. /**
  3808. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3809. * @param alpha defines the rotation around first axis
  3810. * @param beta defines the rotation around second axis
  3811. * @param gamma defines the rotation around third axis
  3812. * @returns the new quaternion
  3813. */
  3814. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3815. /**
  3816. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3817. * @param alpha defines the rotation around first axis
  3818. * @param beta defines the rotation around second axis
  3819. * @param gamma defines the rotation around third axis
  3820. * @param result defines the target quaternion
  3821. */
  3822. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3823. /**
  3824. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3825. * @param axis1 defines the first axis
  3826. * @param axis2 defines the second axis
  3827. * @param axis3 defines the third axis
  3828. * @returns the new quaternion
  3829. */
  3830. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3831. /**
  3832. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3833. * @param axis1 defines the first axis
  3834. * @param axis2 defines the second axis
  3835. * @param axis3 defines the third axis
  3836. * @param ref defines the target quaternion
  3837. */
  3838. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3839. /**
  3840. * Interpolates between two quaternions
  3841. * @param left defines first quaternion
  3842. * @param right defines second quaternion
  3843. * @param amount defines the gradient to use
  3844. * @returns the new interpolated quaternion
  3845. */
  3846. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3847. /**
  3848. * Interpolates between two quaternions and stores it into a target quaternion
  3849. * @param left defines first quaternion
  3850. * @param right defines second quaternion
  3851. * @param amount defines the gradient to use
  3852. * @param result defines the target quaternion
  3853. */
  3854. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3855. /**
  3856. * Interpolate between two quaternions using Hermite interpolation
  3857. * @param value1 defines first quaternion
  3858. * @param tangent1 defines the incoming tangent
  3859. * @param value2 defines second quaternion
  3860. * @param tangent2 defines the outgoing tangent
  3861. * @param amount defines the target quaternion
  3862. * @returns the new interpolated quaternion
  3863. */
  3864. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3865. }
  3866. /**
  3867. * Class used to store matrix data (4x4)
  3868. */
  3869. export class Matrix {
  3870. private static _updateFlagSeed;
  3871. private static _identityReadOnly;
  3872. private _isIdentity;
  3873. private _isIdentityDirty;
  3874. private _isIdentity3x2;
  3875. private _isIdentity3x2Dirty;
  3876. /**
  3877. * Gets the update flag of the matrix which is an unique number for the matrix.
  3878. * It will be incremented every time the matrix data change.
  3879. * You can use it to speed the comparison between two versions of the same matrix.
  3880. */
  3881. updateFlag: number;
  3882. private readonly _m;
  3883. /**
  3884. * Gets the internal data of the matrix
  3885. */
  3886. get m(): DeepImmutable<Float32Array>;
  3887. /** @hidden */
  3888. _markAsUpdated(): void;
  3889. /** @hidden */
  3890. private _updateIdentityStatus;
  3891. /**
  3892. * Creates an empty matrix (filled with zeros)
  3893. */
  3894. constructor();
  3895. /**
  3896. * Check if the current matrix is identity
  3897. * @returns true is the matrix is the identity matrix
  3898. */
  3899. isIdentity(): boolean;
  3900. /**
  3901. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3902. * @returns true is the matrix is the identity matrix
  3903. */
  3904. isIdentityAs3x2(): boolean;
  3905. /**
  3906. * Gets the determinant of the matrix
  3907. * @returns the matrix determinant
  3908. */
  3909. determinant(): number;
  3910. /**
  3911. * Returns the matrix as a Float32Array
  3912. * @returns the matrix underlying array
  3913. */
  3914. toArray(): DeepImmutable<Float32Array>;
  3915. /**
  3916. * Returns the matrix as a Float32Array
  3917. * @returns the matrix underlying array.
  3918. */
  3919. asArray(): DeepImmutable<Float32Array>;
  3920. /**
  3921. * Inverts the current matrix in place
  3922. * @returns the current inverted matrix
  3923. */
  3924. invert(): Matrix;
  3925. /**
  3926. * Sets all the matrix elements to zero
  3927. * @returns the current matrix
  3928. */
  3929. reset(): Matrix;
  3930. /**
  3931. * Adds the current matrix with a second one
  3932. * @param other defines the matrix to add
  3933. * @returns a new matrix as the addition of the current matrix and the given one
  3934. */
  3935. add(other: DeepImmutable<Matrix>): Matrix;
  3936. /**
  3937. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3938. * @param other defines the matrix to add
  3939. * @param result defines the target matrix
  3940. * @returns the current matrix
  3941. */
  3942. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3943. /**
  3944. * Adds in place the given matrix to the current matrix
  3945. * @param other defines the second operand
  3946. * @returns the current updated matrix
  3947. */
  3948. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3949. /**
  3950. * Sets the given matrix to the current inverted Matrix
  3951. * @param other defines the target matrix
  3952. * @returns the unmodified current matrix
  3953. */
  3954. invertToRef(other: Matrix): Matrix;
  3955. /**
  3956. * add a value at the specified position in the current Matrix
  3957. * @param index the index of the value within the matrix. between 0 and 15.
  3958. * @param value the value to be added
  3959. * @returns the current updated matrix
  3960. */
  3961. addAtIndex(index: number, value: number): Matrix;
  3962. /**
  3963. * mutiply the specified position in the current Matrix by a value
  3964. * @param index the index of the value within the matrix. between 0 and 15.
  3965. * @param value the value to be added
  3966. * @returns the current updated matrix
  3967. */
  3968. multiplyAtIndex(index: number, value: number): Matrix;
  3969. /**
  3970. * Inserts the translation vector (using 3 floats) in the current matrix
  3971. * @param x defines the 1st component of the translation
  3972. * @param y defines the 2nd component of the translation
  3973. * @param z defines the 3rd component of the translation
  3974. * @returns the current updated matrix
  3975. */
  3976. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3977. /**
  3978. * Adds the translation vector (using 3 floats) in the current matrix
  3979. * @param x defines the 1st component of the translation
  3980. * @param y defines the 2nd component of the translation
  3981. * @param z defines the 3rd component of the translation
  3982. * @returns the current updated matrix
  3983. */
  3984. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3985. /**
  3986. * Inserts the translation vector in the current matrix
  3987. * @param vector3 defines the translation to insert
  3988. * @returns the current updated matrix
  3989. */
  3990. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3991. /**
  3992. * Gets the translation value of the current matrix
  3993. * @returns a new Vector3 as the extracted translation from the matrix
  3994. */
  3995. getTranslation(): Vector3;
  3996. /**
  3997. * Fill a Vector3 with the extracted translation from the matrix
  3998. * @param result defines the Vector3 where to store the translation
  3999. * @returns the current matrix
  4000. */
  4001. getTranslationToRef(result: Vector3): Matrix;
  4002. /**
  4003. * Remove rotation and scaling part from the matrix
  4004. * @returns the updated matrix
  4005. */
  4006. removeRotationAndScaling(): Matrix;
  4007. /**
  4008. * Multiply two matrices
  4009. * @param other defines the second operand
  4010. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4011. */
  4012. multiply(other: DeepImmutable<Matrix>): Matrix;
  4013. /**
  4014. * Copy the current matrix from the given one
  4015. * @param other defines the source matrix
  4016. * @returns the current updated matrix
  4017. */
  4018. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4019. /**
  4020. * Populates the given array from the starting index with the current matrix values
  4021. * @param array defines the target array
  4022. * @param offset defines the offset in the target array where to start storing values
  4023. * @returns the current matrix
  4024. */
  4025. copyToArray(array: Float32Array, offset?: number): Matrix;
  4026. /**
  4027. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4028. * @param other defines the second operand
  4029. * @param result defines the matrix where to store the multiplication
  4030. * @returns the current matrix
  4031. */
  4032. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4033. /**
  4034. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4035. * @param other defines the second operand
  4036. * @param result defines the array where to store the multiplication
  4037. * @param offset defines the offset in the target array where to start storing values
  4038. * @returns the current matrix
  4039. */
  4040. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4041. /**
  4042. * Check equality between this matrix and a second one
  4043. * @param value defines the second matrix to compare
  4044. * @returns true is the current matrix and the given one values are strictly equal
  4045. */
  4046. equals(value: DeepImmutable<Matrix>): boolean;
  4047. /**
  4048. * Clone the current matrix
  4049. * @returns a new matrix from the current matrix
  4050. */
  4051. clone(): Matrix;
  4052. /**
  4053. * Returns the name of the current matrix class
  4054. * @returns the string "Matrix"
  4055. */
  4056. getClassName(): string;
  4057. /**
  4058. * Gets the hash code of the current matrix
  4059. * @returns the hash code
  4060. */
  4061. getHashCode(): number;
  4062. /**
  4063. * Decomposes the current Matrix into a translation, rotation and scaling components
  4064. * @param scale defines the scale vector3 given as a reference to update
  4065. * @param rotation defines the rotation quaternion given as a reference to update
  4066. * @param translation defines the translation vector3 given as a reference to update
  4067. * @returns true if operation was successful
  4068. */
  4069. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4070. /**
  4071. * Gets specific row of the matrix
  4072. * @param index defines the number of the row to get
  4073. * @returns the index-th row of the current matrix as a new Vector4
  4074. */
  4075. getRow(index: number): Nullable<Vector4>;
  4076. /**
  4077. * Sets the index-th row of the current matrix to the vector4 values
  4078. * @param index defines the number of the row to set
  4079. * @param row defines the target vector4
  4080. * @returns the updated current matrix
  4081. */
  4082. setRow(index: number, row: Vector4): Matrix;
  4083. /**
  4084. * Compute the transpose of the matrix
  4085. * @returns the new transposed matrix
  4086. */
  4087. transpose(): Matrix;
  4088. /**
  4089. * Compute the transpose of the matrix and store it in a given matrix
  4090. * @param result defines the target matrix
  4091. * @returns the current matrix
  4092. */
  4093. transposeToRef(result: Matrix): Matrix;
  4094. /**
  4095. * Sets the index-th row of the current matrix with the given 4 x float values
  4096. * @param index defines the row index
  4097. * @param x defines the x component to set
  4098. * @param y defines the y component to set
  4099. * @param z defines the z component to set
  4100. * @param w defines the w component to set
  4101. * @returns the updated current matrix
  4102. */
  4103. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4104. /**
  4105. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4106. * @param scale defines the scale factor
  4107. * @returns a new matrix
  4108. */
  4109. scale(scale: number): Matrix;
  4110. /**
  4111. * Scale the current matrix values by a factor to a given result matrix
  4112. * @param scale defines the scale factor
  4113. * @param result defines the matrix to store the result
  4114. * @returns the current matrix
  4115. */
  4116. scaleToRef(scale: number, result: Matrix): Matrix;
  4117. /**
  4118. * Scale the current matrix values by a factor and add the result to a given matrix
  4119. * @param scale defines the scale factor
  4120. * @param result defines the Matrix to store the result
  4121. * @returns the current matrix
  4122. */
  4123. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4124. /**
  4125. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4126. * @param ref matrix to store the result
  4127. */
  4128. toNormalMatrix(ref: Matrix): void;
  4129. /**
  4130. * Gets only rotation part of the current matrix
  4131. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4132. */
  4133. getRotationMatrix(): Matrix;
  4134. /**
  4135. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4136. * @param result defines the target matrix to store data to
  4137. * @returns the current matrix
  4138. */
  4139. getRotationMatrixToRef(result: Matrix): Matrix;
  4140. /**
  4141. * Toggles model matrix from being right handed to left handed in place and vice versa
  4142. */
  4143. toggleModelMatrixHandInPlace(): void;
  4144. /**
  4145. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4146. */
  4147. toggleProjectionMatrixHandInPlace(): void;
  4148. /**
  4149. * Creates a matrix from an array
  4150. * @param array defines the source array
  4151. * @param offset defines an offset in the source array
  4152. * @returns a new Matrix set from the starting index of the given array
  4153. */
  4154. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4155. /**
  4156. * Copy the content of an array into a given matrix
  4157. * @param array defines the source array
  4158. * @param offset defines an offset in the source array
  4159. * @param result defines the target matrix
  4160. */
  4161. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4162. /**
  4163. * Stores an array into a matrix after having multiplied each component by a given factor
  4164. * @param array defines the source array
  4165. * @param offset defines the offset in the source array
  4166. * @param scale defines the scaling factor
  4167. * @param result defines the target matrix
  4168. */
  4169. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4170. /**
  4171. * Gets an identity matrix that must not be updated
  4172. */
  4173. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4174. /**
  4175. * Stores a list of values (16) inside a given matrix
  4176. * @param initialM11 defines 1st value of 1st row
  4177. * @param initialM12 defines 2nd value of 1st row
  4178. * @param initialM13 defines 3rd value of 1st row
  4179. * @param initialM14 defines 4th value of 1st row
  4180. * @param initialM21 defines 1st value of 2nd row
  4181. * @param initialM22 defines 2nd value of 2nd row
  4182. * @param initialM23 defines 3rd value of 2nd row
  4183. * @param initialM24 defines 4th value of 2nd row
  4184. * @param initialM31 defines 1st value of 3rd row
  4185. * @param initialM32 defines 2nd value of 3rd row
  4186. * @param initialM33 defines 3rd value of 3rd row
  4187. * @param initialM34 defines 4th value of 3rd row
  4188. * @param initialM41 defines 1st value of 4th row
  4189. * @param initialM42 defines 2nd value of 4th row
  4190. * @param initialM43 defines 3rd value of 4th row
  4191. * @param initialM44 defines 4th value of 4th row
  4192. * @param result defines the target matrix
  4193. */
  4194. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4195. /**
  4196. * Creates new matrix from a list of values (16)
  4197. * @param initialM11 defines 1st value of 1st row
  4198. * @param initialM12 defines 2nd value of 1st row
  4199. * @param initialM13 defines 3rd value of 1st row
  4200. * @param initialM14 defines 4th value of 1st row
  4201. * @param initialM21 defines 1st value of 2nd row
  4202. * @param initialM22 defines 2nd value of 2nd row
  4203. * @param initialM23 defines 3rd value of 2nd row
  4204. * @param initialM24 defines 4th value of 2nd row
  4205. * @param initialM31 defines 1st value of 3rd row
  4206. * @param initialM32 defines 2nd value of 3rd row
  4207. * @param initialM33 defines 3rd value of 3rd row
  4208. * @param initialM34 defines 4th value of 3rd row
  4209. * @param initialM41 defines 1st value of 4th row
  4210. * @param initialM42 defines 2nd value of 4th row
  4211. * @param initialM43 defines 3rd value of 4th row
  4212. * @param initialM44 defines 4th value of 4th row
  4213. * @returns the new matrix
  4214. */
  4215. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4216. /**
  4217. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4218. * @param scale defines the scale vector3
  4219. * @param rotation defines the rotation quaternion
  4220. * @param translation defines the translation vector3
  4221. * @returns a new matrix
  4222. */
  4223. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4224. /**
  4225. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4226. * @param scale defines the scale vector3
  4227. * @param rotation defines the rotation quaternion
  4228. * @param translation defines the translation vector3
  4229. * @param result defines the target matrix
  4230. */
  4231. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4232. /**
  4233. * Creates a new identity matrix
  4234. * @returns a new identity matrix
  4235. */
  4236. static Identity(): Matrix;
  4237. /**
  4238. * Creates a new identity matrix and stores the result in a given matrix
  4239. * @param result defines the target matrix
  4240. */
  4241. static IdentityToRef(result: Matrix): void;
  4242. /**
  4243. * Creates a new zero matrix
  4244. * @returns a new zero matrix
  4245. */
  4246. static Zero(): Matrix;
  4247. /**
  4248. * Creates a new rotation matrix for "angle" radians around the X axis
  4249. * @param angle defines the angle (in radians) to use
  4250. * @return the new matrix
  4251. */
  4252. static RotationX(angle: number): Matrix;
  4253. /**
  4254. * Creates a new matrix as the invert of a given matrix
  4255. * @param source defines the source matrix
  4256. * @returns the new matrix
  4257. */
  4258. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4259. /**
  4260. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4261. * @param angle defines the angle (in radians) to use
  4262. * @param result defines the target matrix
  4263. */
  4264. static RotationXToRef(angle: number, result: Matrix): void;
  4265. /**
  4266. * Creates a new rotation matrix for "angle" radians around the Y axis
  4267. * @param angle defines the angle (in radians) to use
  4268. * @return the new matrix
  4269. */
  4270. static RotationY(angle: number): Matrix;
  4271. /**
  4272. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4273. * @param angle defines the angle (in radians) to use
  4274. * @param result defines the target matrix
  4275. */
  4276. static RotationYToRef(angle: number, result: Matrix): void;
  4277. /**
  4278. * Creates a new rotation matrix for "angle" radians around the Z axis
  4279. * @param angle defines the angle (in radians) to use
  4280. * @return the new matrix
  4281. */
  4282. static RotationZ(angle: number): Matrix;
  4283. /**
  4284. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4285. * @param angle defines the angle (in radians) to use
  4286. * @param result defines the target matrix
  4287. */
  4288. static RotationZToRef(angle: number, result: Matrix): void;
  4289. /**
  4290. * Creates a new rotation matrix for "angle" radians around the given axis
  4291. * @param axis defines the axis to use
  4292. * @param angle defines the angle (in radians) to use
  4293. * @return the new matrix
  4294. */
  4295. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4296. /**
  4297. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4298. * @param axis defines the axis to use
  4299. * @param angle defines the angle (in radians) to use
  4300. * @param result defines the target matrix
  4301. */
  4302. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4303. /**
  4304. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4305. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4306. * @param from defines the vector to align
  4307. * @param to defines the vector to align to
  4308. * @param result defines the target matrix
  4309. */
  4310. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4311. /**
  4312. * Creates a rotation matrix
  4313. * @param yaw defines the yaw angle in radians (Y axis)
  4314. * @param pitch defines the pitch angle in radians (X axis)
  4315. * @param roll defines the roll angle in radians (X axis)
  4316. * @returns the new rotation matrix
  4317. */
  4318. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4319. /**
  4320. * Creates a rotation matrix and stores it in a given matrix
  4321. * @param yaw defines the yaw angle in radians (Y axis)
  4322. * @param pitch defines the pitch angle in radians (X axis)
  4323. * @param roll defines the roll angle in radians (X axis)
  4324. * @param result defines the target matrix
  4325. */
  4326. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4327. /**
  4328. * Creates a scaling matrix
  4329. * @param x defines the scale factor on X axis
  4330. * @param y defines the scale factor on Y axis
  4331. * @param z defines the scale factor on Z axis
  4332. * @returns the new matrix
  4333. */
  4334. static Scaling(x: number, y: number, z: number): Matrix;
  4335. /**
  4336. * Creates a scaling matrix and stores it in a given matrix
  4337. * @param x defines the scale factor on X axis
  4338. * @param y defines the scale factor on Y axis
  4339. * @param z defines the scale factor on Z axis
  4340. * @param result defines the target matrix
  4341. */
  4342. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4343. /**
  4344. * Creates a translation matrix
  4345. * @param x defines the translation on X axis
  4346. * @param y defines the translation on Y axis
  4347. * @param z defines the translationon Z axis
  4348. * @returns the new matrix
  4349. */
  4350. static Translation(x: number, y: number, z: number): Matrix;
  4351. /**
  4352. * Creates a translation matrix and stores it in a given matrix
  4353. * @param x defines the translation on X axis
  4354. * @param y defines the translation on Y axis
  4355. * @param z defines the translationon Z axis
  4356. * @param result defines the target matrix
  4357. */
  4358. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4359. /**
  4360. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4361. * @param startValue defines the start value
  4362. * @param endValue defines the end value
  4363. * @param gradient defines the gradient factor
  4364. * @returns the new matrix
  4365. */
  4366. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4367. /**
  4368. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4369. * @param startValue defines the start value
  4370. * @param endValue defines the end value
  4371. * @param gradient defines the gradient factor
  4372. * @param result defines the Matrix object where to store data
  4373. */
  4374. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4375. /**
  4376. * Builds a new matrix whose values are computed by:
  4377. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4378. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4379. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4380. * @param startValue defines the first matrix
  4381. * @param endValue defines the second matrix
  4382. * @param gradient defines the gradient between the two matrices
  4383. * @returns the new matrix
  4384. */
  4385. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4386. /**
  4387. * Update a matrix to values which are computed by:
  4388. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4389. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4390. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4391. * @param startValue defines the first matrix
  4392. * @param endValue defines the second matrix
  4393. * @param gradient defines the gradient between the two matrices
  4394. * @param result defines the target matrix
  4395. */
  4396. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4397. /**
  4398. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4399. * This function works in left handed mode
  4400. * @param eye defines the final position of the entity
  4401. * @param target defines where the entity should look at
  4402. * @param up defines the up vector for the entity
  4403. * @returns the new matrix
  4404. */
  4405. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4406. /**
  4407. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4408. * This function works in left handed mode
  4409. * @param eye defines the final position of the entity
  4410. * @param target defines where the entity should look at
  4411. * @param up defines the up vector for the entity
  4412. * @param result defines the target matrix
  4413. */
  4414. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4415. /**
  4416. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4417. * This function works in right handed mode
  4418. * @param eye defines the final position of the entity
  4419. * @param target defines where the entity should look at
  4420. * @param up defines the up vector for the entity
  4421. * @returns the new matrix
  4422. */
  4423. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4424. /**
  4425. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4426. * This function works in right handed mode
  4427. * @param eye defines the final position of the entity
  4428. * @param target defines where the entity should look at
  4429. * @param up defines the up vector for the entity
  4430. * @param result defines the target matrix
  4431. */
  4432. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4433. /**
  4434. * Create a left-handed orthographic projection matrix
  4435. * @param width defines the viewport width
  4436. * @param height defines the viewport height
  4437. * @param znear defines the near clip plane
  4438. * @param zfar defines the far clip plane
  4439. * @returns a new matrix as a left-handed orthographic projection matrix
  4440. */
  4441. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4442. /**
  4443. * Store a left-handed orthographic projection to a given matrix
  4444. * @param width defines the viewport width
  4445. * @param height defines the viewport height
  4446. * @param znear defines the near clip plane
  4447. * @param zfar defines the far clip plane
  4448. * @param result defines the target matrix
  4449. */
  4450. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4451. /**
  4452. * Create a left-handed orthographic projection matrix
  4453. * @param left defines the viewport left coordinate
  4454. * @param right defines the viewport right coordinate
  4455. * @param bottom defines the viewport bottom coordinate
  4456. * @param top defines the viewport top coordinate
  4457. * @param znear defines the near clip plane
  4458. * @param zfar defines the far clip plane
  4459. * @returns a new matrix as a left-handed orthographic projection matrix
  4460. */
  4461. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4462. /**
  4463. * Stores a left-handed orthographic projection into a given matrix
  4464. * @param left defines the viewport left coordinate
  4465. * @param right defines the viewport right coordinate
  4466. * @param bottom defines the viewport bottom coordinate
  4467. * @param top defines the viewport top coordinate
  4468. * @param znear defines the near clip plane
  4469. * @param zfar defines the far clip plane
  4470. * @param result defines the target matrix
  4471. */
  4472. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4473. /**
  4474. * Creates a right-handed orthographic projection matrix
  4475. * @param left defines the viewport left coordinate
  4476. * @param right defines the viewport right coordinate
  4477. * @param bottom defines the viewport bottom coordinate
  4478. * @param top defines the viewport top coordinate
  4479. * @param znear defines the near clip plane
  4480. * @param zfar defines the far clip plane
  4481. * @returns a new matrix as a right-handed orthographic projection matrix
  4482. */
  4483. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4484. /**
  4485. * Stores a right-handed orthographic projection into a given matrix
  4486. * @param left defines the viewport left coordinate
  4487. * @param right defines the viewport right coordinate
  4488. * @param bottom defines the viewport bottom coordinate
  4489. * @param top defines the viewport top coordinate
  4490. * @param znear defines the near clip plane
  4491. * @param zfar defines the far clip plane
  4492. * @param result defines the target matrix
  4493. */
  4494. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4495. /**
  4496. * Creates a left-handed perspective projection matrix
  4497. * @param width defines the viewport width
  4498. * @param height defines the viewport height
  4499. * @param znear defines the near clip plane
  4500. * @param zfar defines the far clip plane
  4501. * @returns a new matrix as a left-handed perspective projection matrix
  4502. */
  4503. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4504. /**
  4505. * Creates a left-handed perspective projection matrix
  4506. * @param fov defines the horizontal field of view
  4507. * @param aspect defines the aspect ratio
  4508. * @param znear defines the near clip plane
  4509. * @param zfar defines the far clip plane
  4510. * @returns a new matrix as a left-handed perspective projection matrix
  4511. */
  4512. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4513. /**
  4514. * Stores a left-handed perspective projection into a given matrix
  4515. * @param fov defines the horizontal field of view
  4516. * @param aspect defines the aspect ratio
  4517. * @param znear defines the near clip plane
  4518. * @param zfar defines the far clip plane
  4519. * @param result defines the target matrix
  4520. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4521. */
  4522. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4523. /**
  4524. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4525. * @param fov defines the horizontal field of view
  4526. * @param aspect defines the aspect ratio
  4527. * @param znear defines the near clip plane
  4528. * @param zfar not used as infinity is used as far clip
  4529. * @param result defines the target matrix
  4530. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4531. */
  4532. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4533. /**
  4534. * Creates a right-handed perspective projection matrix
  4535. * @param fov defines the horizontal field of view
  4536. * @param aspect defines the aspect ratio
  4537. * @param znear defines the near clip plane
  4538. * @param zfar defines the far clip plane
  4539. * @returns a new matrix as a right-handed perspective projection matrix
  4540. */
  4541. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4542. /**
  4543. * Stores a right-handed perspective projection into a given matrix
  4544. * @param fov defines the horizontal field of view
  4545. * @param aspect defines the aspect ratio
  4546. * @param znear defines the near clip plane
  4547. * @param zfar defines the far clip plane
  4548. * @param result defines the target matrix
  4549. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4550. */
  4551. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4552. /**
  4553. * Stores a right-handed perspective projection into a given matrix
  4554. * @param fov defines the horizontal field of view
  4555. * @param aspect defines the aspect ratio
  4556. * @param znear defines the near clip plane
  4557. * @param zfar not used as infinity is used as far clip
  4558. * @param result defines the target matrix
  4559. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4560. */
  4561. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4562. /**
  4563. * Stores a perspective projection for WebVR info a given matrix
  4564. * @param fov defines the field of view
  4565. * @param znear defines the near clip plane
  4566. * @param zfar defines the far clip plane
  4567. * @param result defines the target matrix
  4568. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4569. */
  4570. static PerspectiveFovWebVRToRef(fov: {
  4571. upDegrees: number;
  4572. downDegrees: number;
  4573. leftDegrees: number;
  4574. rightDegrees: number;
  4575. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4576. /**
  4577. * Computes a complete transformation matrix
  4578. * @param viewport defines the viewport to use
  4579. * @param world defines the world matrix
  4580. * @param view defines the view matrix
  4581. * @param projection defines the projection matrix
  4582. * @param zmin defines the near clip plane
  4583. * @param zmax defines the far clip plane
  4584. * @returns the transformation matrix
  4585. */
  4586. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4587. /**
  4588. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4589. * @param matrix defines the matrix to use
  4590. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4591. */
  4592. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4593. /**
  4594. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4595. * @param matrix defines the matrix to use
  4596. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4597. */
  4598. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4599. /**
  4600. * Compute the transpose of a given matrix
  4601. * @param matrix defines the matrix to transpose
  4602. * @returns the new matrix
  4603. */
  4604. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4605. /**
  4606. * Compute the transpose of a matrix and store it in a target matrix
  4607. * @param matrix defines the matrix to transpose
  4608. * @param result defines the target matrix
  4609. */
  4610. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4611. /**
  4612. * Computes a reflection matrix from a plane
  4613. * @param plane defines the reflection plane
  4614. * @returns a new matrix
  4615. */
  4616. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4617. /**
  4618. * Computes a reflection matrix from a plane
  4619. * @param plane defines the reflection plane
  4620. * @param result defines the target matrix
  4621. */
  4622. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4623. /**
  4624. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4625. * @param xaxis defines the value of the 1st axis
  4626. * @param yaxis defines the value of the 2nd axis
  4627. * @param zaxis defines the value of the 3rd axis
  4628. * @param result defines the target matrix
  4629. */
  4630. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4631. /**
  4632. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4633. * @param quat defines the quaternion to use
  4634. * @param result defines the target matrix
  4635. */
  4636. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4637. }
  4638. /**
  4639. * @hidden
  4640. */
  4641. export class TmpVectors {
  4642. static Vector2: Vector2[];
  4643. static Vector3: Vector3[];
  4644. static Vector4: Vector4[];
  4645. static Quaternion: Quaternion[];
  4646. static Matrix: Matrix[];
  4647. }
  4648. }
  4649. declare module "babylonjs/Maths/math.path" {
  4650. import { DeepImmutable, Nullable } from "babylonjs/types";
  4651. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4652. /**
  4653. * Defines potential orientation for back face culling
  4654. */
  4655. export enum Orientation {
  4656. /**
  4657. * Clockwise
  4658. */
  4659. CW = 0,
  4660. /** Counter clockwise */
  4661. CCW = 1
  4662. }
  4663. /** Class used to represent a Bezier curve */
  4664. export class BezierCurve {
  4665. /**
  4666. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4667. * @param t defines the time
  4668. * @param x1 defines the left coordinate on X axis
  4669. * @param y1 defines the left coordinate on Y axis
  4670. * @param x2 defines the right coordinate on X axis
  4671. * @param y2 defines the right coordinate on Y axis
  4672. * @returns the interpolated value
  4673. */
  4674. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4675. }
  4676. /**
  4677. * Defines angle representation
  4678. */
  4679. export class Angle {
  4680. private _radians;
  4681. /**
  4682. * Creates an Angle object of "radians" radians (float).
  4683. * @param radians the angle in radians
  4684. */
  4685. constructor(radians: number);
  4686. /**
  4687. * Get value in degrees
  4688. * @returns the Angle value in degrees (float)
  4689. */
  4690. degrees(): number;
  4691. /**
  4692. * Get value in radians
  4693. * @returns the Angle value in radians (float)
  4694. */
  4695. radians(): number;
  4696. /**
  4697. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4698. * @param a defines first vector
  4699. * @param b defines second vector
  4700. * @returns a new Angle
  4701. */
  4702. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4703. /**
  4704. * Gets a new Angle object from the given float in radians
  4705. * @param radians defines the angle value in radians
  4706. * @returns a new Angle
  4707. */
  4708. static FromRadians(radians: number): Angle;
  4709. /**
  4710. * Gets a new Angle object from the given float in degrees
  4711. * @param degrees defines the angle value in degrees
  4712. * @returns a new Angle
  4713. */
  4714. static FromDegrees(degrees: number): Angle;
  4715. }
  4716. /**
  4717. * This represents an arc in a 2d space.
  4718. */
  4719. export class Arc2 {
  4720. /** Defines the start point of the arc */
  4721. startPoint: Vector2;
  4722. /** Defines the mid point of the arc */
  4723. midPoint: Vector2;
  4724. /** Defines the end point of the arc */
  4725. endPoint: Vector2;
  4726. /**
  4727. * Defines the center point of the arc.
  4728. */
  4729. centerPoint: Vector2;
  4730. /**
  4731. * Defines the radius of the arc.
  4732. */
  4733. radius: number;
  4734. /**
  4735. * Defines the angle of the arc (from mid point to end point).
  4736. */
  4737. angle: Angle;
  4738. /**
  4739. * Defines the start angle of the arc (from start point to middle point).
  4740. */
  4741. startAngle: Angle;
  4742. /**
  4743. * Defines the orientation of the arc (clock wise/counter clock wise).
  4744. */
  4745. orientation: Orientation;
  4746. /**
  4747. * Creates an Arc object from the three given points : start, middle and end.
  4748. * @param startPoint Defines the start point of the arc
  4749. * @param midPoint Defines the midlle point of the arc
  4750. * @param endPoint Defines the end point of the arc
  4751. */
  4752. constructor(
  4753. /** Defines the start point of the arc */
  4754. startPoint: Vector2,
  4755. /** Defines the mid point of the arc */
  4756. midPoint: Vector2,
  4757. /** Defines the end point of the arc */
  4758. endPoint: Vector2);
  4759. }
  4760. /**
  4761. * Represents a 2D path made up of multiple 2D points
  4762. */
  4763. export class Path2 {
  4764. private _points;
  4765. private _length;
  4766. /**
  4767. * If the path start and end point are the same
  4768. */
  4769. closed: boolean;
  4770. /**
  4771. * Creates a Path2 object from the starting 2D coordinates x and y.
  4772. * @param x the starting points x value
  4773. * @param y the starting points y value
  4774. */
  4775. constructor(x: number, y: number);
  4776. /**
  4777. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4778. * @param x the added points x value
  4779. * @param y the added points y value
  4780. * @returns the updated Path2.
  4781. */
  4782. addLineTo(x: number, y: number): Path2;
  4783. /**
  4784. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4785. * @param midX middle point x value
  4786. * @param midY middle point y value
  4787. * @param endX end point x value
  4788. * @param endY end point y value
  4789. * @param numberOfSegments (default: 36)
  4790. * @returns the updated Path2.
  4791. */
  4792. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4793. /**
  4794. * Closes the Path2.
  4795. * @returns the Path2.
  4796. */
  4797. close(): Path2;
  4798. /**
  4799. * Gets the sum of the distance between each sequential point in the path
  4800. * @returns the Path2 total length (float).
  4801. */
  4802. length(): number;
  4803. /**
  4804. * Gets the points which construct the path
  4805. * @returns the Path2 internal array of points.
  4806. */
  4807. getPoints(): Vector2[];
  4808. /**
  4809. * Retreives the point at the distance aways from the starting point
  4810. * @param normalizedLengthPosition the length along the path to retreive the point from
  4811. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4812. */
  4813. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4814. /**
  4815. * Creates a new path starting from an x and y position
  4816. * @param x starting x value
  4817. * @param y starting y value
  4818. * @returns a new Path2 starting at the coordinates (x, y).
  4819. */
  4820. static StartingAt(x: number, y: number): Path2;
  4821. }
  4822. /**
  4823. * Represents a 3D path made up of multiple 3D points
  4824. */
  4825. export class Path3D {
  4826. /**
  4827. * an array of Vector3, the curve axis of the Path3D
  4828. */
  4829. path: Vector3[];
  4830. private _curve;
  4831. private _distances;
  4832. private _tangents;
  4833. private _normals;
  4834. private _binormals;
  4835. private _raw;
  4836. private _alignTangentsWithPath;
  4837. private readonly _pointAtData;
  4838. /**
  4839. * new Path3D(path, normal, raw)
  4840. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4841. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4842. * @param path an array of Vector3, the curve axis of the Path3D
  4843. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4844. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4845. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4846. */
  4847. constructor(
  4848. /**
  4849. * an array of Vector3, the curve axis of the Path3D
  4850. */
  4851. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4852. /**
  4853. * Returns the Path3D array of successive Vector3 designing its curve.
  4854. * @returns the Path3D array of successive Vector3 designing its curve.
  4855. */
  4856. getCurve(): Vector3[];
  4857. /**
  4858. * Returns the Path3D array of successive Vector3 designing its curve.
  4859. * @returns the Path3D array of successive Vector3 designing its curve.
  4860. */
  4861. getPoints(): Vector3[];
  4862. /**
  4863. * @returns the computed length (float) of the path.
  4864. */
  4865. length(): number;
  4866. /**
  4867. * Returns an array populated with tangent vectors on each Path3D curve point.
  4868. * @returns an array populated with tangent vectors on each Path3D curve point.
  4869. */
  4870. getTangents(): Vector3[];
  4871. /**
  4872. * Returns an array populated with normal vectors on each Path3D curve point.
  4873. * @returns an array populated with normal vectors on each Path3D curve point.
  4874. */
  4875. getNormals(): Vector3[];
  4876. /**
  4877. * Returns an array populated with binormal vectors on each Path3D curve point.
  4878. * @returns an array populated with binormal vectors on each Path3D curve point.
  4879. */
  4880. getBinormals(): Vector3[];
  4881. /**
  4882. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4883. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4884. */
  4885. getDistances(): number[];
  4886. /**
  4887. * Returns an interpolated point along this path
  4888. * @param position the position of the point along this path, from 0.0 to 1.0
  4889. * @returns a new Vector3 as the point
  4890. */
  4891. getPointAt(position: number): Vector3;
  4892. /**
  4893. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4894. * @param position the position of the point along this path, from 0.0 to 1.0
  4895. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4896. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4897. */
  4898. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4899. /**
  4900. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4901. * @param position the position of the point along this path, from 0.0 to 1.0
  4902. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4903. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4904. */
  4905. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4906. /**
  4907. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4908. * @param position the position of the point along this path, from 0.0 to 1.0
  4909. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4910. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4911. */
  4912. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4913. /**
  4914. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4915. * @param position the position of the point along this path, from 0.0 to 1.0
  4916. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4917. */
  4918. getDistanceAt(position: number): number;
  4919. /**
  4920. * Returns the array index of the previous point of an interpolated point along this path
  4921. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4922. * @returns the array index
  4923. */
  4924. getPreviousPointIndexAt(position: number): number;
  4925. /**
  4926. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4927. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4928. * @returns the sub position
  4929. */
  4930. getSubPositionAt(position: number): number;
  4931. /**
  4932. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4933. * @param target the vector of which to get the closest position to
  4934. * @returns the position of the closest virtual point on this path to the target vector
  4935. */
  4936. getClosestPositionTo(target: Vector3): number;
  4937. /**
  4938. * Returns a sub path (slice) of this path
  4939. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4940. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4941. * @returns a sub path (slice) of this path
  4942. */
  4943. slice(start?: number, end?: number): Path3D;
  4944. /**
  4945. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4946. * @param path path which all values are copied into the curves points
  4947. * @param firstNormal which should be projected onto the curve
  4948. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4949. * @returns the same object updated.
  4950. */
  4951. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4952. private _compute;
  4953. private _getFirstNonNullVector;
  4954. private _getLastNonNullVector;
  4955. private _normalVector;
  4956. /**
  4957. * Updates the point at data for an interpolated point along this curve
  4958. * @param position the position of the point along this curve, from 0.0 to 1.0
  4959. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4960. * @returns the (updated) point at data
  4961. */
  4962. private _updatePointAtData;
  4963. /**
  4964. * Updates the point at data from the specified parameters
  4965. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4966. * @param point the interpolated point
  4967. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4968. */
  4969. private _setPointAtData;
  4970. /**
  4971. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4972. */
  4973. private _updateInterpolationMatrix;
  4974. }
  4975. /**
  4976. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4977. * A Curve3 is designed from a series of successive Vector3.
  4978. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4979. */
  4980. export class Curve3 {
  4981. private _points;
  4982. private _length;
  4983. /**
  4984. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4985. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4986. * @param v1 (Vector3) the control point
  4987. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4988. * @param nbPoints (integer) the wanted number of points in the curve
  4989. * @returns the created Curve3
  4990. */
  4991. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4992. /**
  4993. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4994. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4995. * @param v1 (Vector3) the first control point
  4996. * @param v2 (Vector3) the second control point
  4997. * @param v3 (Vector3) the end point of the Cubic Bezier
  4998. * @param nbPoints (integer) the wanted number of points in the curve
  4999. * @returns the created Curve3
  5000. */
  5001. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5002. /**
  5003. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5004. * @param p1 (Vector3) the origin point of the Hermite Spline
  5005. * @param t1 (Vector3) the tangent vector at the origin point
  5006. * @param p2 (Vector3) the end point of the Hermite Spline
  5007. * @param t2 (Vector3) the tangent vector at the end point
  5008. * @param nbPoints (integer) the wanted number of points in the curve
  5009. * @returns the created Curve3
  5010. */
  5011. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5012. /**
  5013. * Returns a Curve3 object along a CatmullRom Spline curve :
  5014. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5015. * @param nbPoints (integer) the wanted number of points between each curve control points
  5016. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5017. * @returns the created Curve3
  5018. */
  5019. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5020. /**
  5021. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5022. * A Curve3 is designed from a series of successive Vector3.
  5023. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5024. * @param points points which make up the curve
  5025. */
  5026. constructor(points: Vector3[]);
  5027. /**
  5028. * @returns the Curve3 stored array of successive Vector3
  5029. */
  5030. getPoints(): Vector3[];
  5031. /**
  5032. * @returns the computed length (float) of the curve.
  5033. */
  5034. length(): number;
  5035. /**
  5036. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5037. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5038. * curveA and curveB keep unchanged.
  5039. * @param curve the curve to continue from this curve
  5040. * @returns the newly constructed curve
  5041. */
  5042. continue(curve: DeepImmutable<Curve3>): Curve3;
  5043. private _computeLength;
  5044. }
  5045. }
  5046. declare module "babylonjs/Animations/easing" {
  5047. /**
  5048. * This represents the main contract an easing function should follow.
  5049. * Easing functions are used throughout the animation system.
  5050. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5051. */
  5052. export interface IEasingFunction {
  5053. /**
  5054. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5055. * of the easing function.
  5056. * The link below provides some of the most common examples of easing functions.
  5057. * @see https://easings.net/
  5058. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5059. * @returns the corresponding value on the curve defined by the easing function
  5060. */
  5061. ease(gradient: number): number;
  5062. }
  5063. /**
  5064. * Base class used for every default easing function.
  5065. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5066. */
  5067. export class EasingFunction implements IEasingFunction {
  5068. /**
  5069. * Interpolation follows the mathematical formula associated with the easing function.
  5070. */
  5071. static readonly EASINGMODE_EASEIN: number;
  5072. /**
  5073. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5074. */
  5075. static readonly EASINGMODE_EASEOUT: number;
  5076. /**
  5077. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5078. */
  5079. static readonly EASINGMODE_EASEINOUT: number;
  5080. private _easingMode;
  5081. /**
  5082. * Sets the easing mode of the current function.
  5083. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5084. */
  5085. setEasingMode(easingMode: number): void;
  5086. /**
  5087. * Gets the current easing mode.
  5088. * @returns the easing mode
  5089. */
  5090. getEasingMode(): number;
  5091. /**
  5092. * @hidden
  5093. */
  5094. easeInCore(gradient: number): number;
  5095. /**
  5096. * Given an input gradient between 0 and 1, this returns the corresponding value
  5097. * of the easing function.
  5098. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5099. * @returns the corresponding value on the curve defined by the easing function
  5100. */
  5101. ease(gradient: number): number;
  5102. }
  5103. /**
  5104. * Easing function with a circle shape (see link below).
  5105. * @see https://easings.net/#easeInCirc
  5106. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5107. */
  5108. export class CircleEase extends EasingFunction implements IEasingFunction {
  5109. /** @hidden */
  5110. easeInCore(gradient: number): number;
  5111. }
  5112. /**
  5113. * Easing function with a ease back shape (see link below).
  5114. * @see https://easings.net/#easeInBack
  5115. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5116. */
  5117. export class BackEase extends EasingFunction implements IEasingFunction {
  5118. /** Defines the amplitude of the function */
  5119. amplitude: number;
  5120. /**
  5121. * Instantiates a back ease easing
  5122. * @see https://easings.net/#easeInBack
  5123. * @param amplitude Defines the amplitude of the function
  5124. */
  5125. constructor(
  5126. /** Defines the amplitude of the function */
  5127. amplitude?: number);
  5128. /** @hidden */
  5129. easeInCore(gradient: number): number;
  5130. }
  5131. /**
  5132. * Easing function with a bouncing shape (see link below).
  5133. * @see https://easings.net/#easeInBounce
  5134. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5135. */
  5136. export class BounceEase extends EasingFunction implements IEasingFunction {
  5137. /** Defines the number of bounces */
  5138. bounces: number;
  5139. /** Defines the amplitude of the bounce */
  5140. bounciness: number;
  5141. /**
  5142. * Instantiates a bounce easing
  5143. * @see https://easings.net/#easeInBounce
  5144. * @param bounces Defines the number of bounces
  5145. * @param bounciness Defines the amplitude of the bounce
  5146. */
  5147. constructor(
  5148. /** Defines the number of bounces */
  5149. bounces?: number,
  5150. /** Defines the amplitude of the bounce */
  5151. bounciness?: number);
  5152. /** @hidden */
  5153. easeInCore(gradient: number): number;
  5154. }
  5155. /**
  5156. * Easing function with a power of 3 shape (see link below).
  5157. * @see https://easings.net/#easeInCubic
  5158. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5159. */
  5160. export class CubicEase extends EasingFunction implements IEasingFunction {
  5161. /** @hidden */
  5162. easeInCore(gradient: number): number;
  5163. }
  5164. /**
  5165. * Easing function with an elastic shape (see link below).
  5166. * @see https://easings.net/#easeInElastic
  5167. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5168. */
  5169. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5170. /** Defines the number of oscillations*/
  5171. oscillations: number;
  5172. /** Defines the amplitude of the oscillations*/
  5173. springiness: number;
  5174. /**
  5175. * Instantiates an elastic easing function
  5176. * @see https://easings.net/#easeInElastic
  5177. * @param oscillations Defines the number of oscillations
  5178. * @param springiness Defines the amplitude of the oscillations
  5179. */
  5180. constructor(
  5181. /** Defines the number of oscillations*/
  5182. oscillations?: number,
  5183. /** Defines the amplitude of the oscillations*/
  5184. springiness?: number);
  5185. /** @hidden */
  5186. easeInCore(gradient: number): number;
  5187. }
  5188. /**
  5189. * Easing function with an exponential shape (see link below).
  5190. * @see https://easings.net/#easeInExpo
  5191. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5192. */
  5193. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5194. /** Defines the exponent of the function */
  5195. exponent: number;
  5196. /**
  5197. * Instantiates an exponential easing function
  5198. * @see https://easings.net/#easeInExpo
  5199. * @param exponent Defines the exponent of the function
  5200. */
  5201. constructor(
  5202. /** Defines the exponent of the function */
  5203. exponent?: number);
  5204. /** @hidden */
  5205. easeInCore(gradient: number): number;
  5206. }
  5207. /**
  5208. * Easing function with a power shape (see link below).
  5209. * @see https://easings.net/#easeInQuad
  5210. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5211. */
  5212. export class PowerEase extends EasingFunction implements IEasingFunction {
  5213. /** Defines the power of the function */
  5214. power: number;
  5215. /**
  5216. * Instantiates an power base easing function
  5217. * @see https://easings.net/#easeInQuad
  5218. * @param power Defines the power of the function
  5219. */
  5220. constructor(
  5221. /** Defines the power of the function */
  5222. power?: number);
  5223. /** @hidden */
  5224. easeInCore(gradient: number): number;
  5225. }
  5226. /**
  5227. * Easing function with a power of 2 shape (see link below).
  5228. * @see https://easings.net/#easeInQuad
  5229. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5230. */
  5231. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5232. /** @hidden */
  5233. easeInCore(gradient: number): number;
  5234. }
  5235. /**
  5236. * Easing function with a power of 4 shape (see link below).
  5237. * @see https://easings.net/#easeInQuart
  5238. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5239. */
  5240. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5241. /** @hidden */
  5242. easeInCore(gradient: number): number;
  5243. }
  5244. /**
  5245. * Easing function with a power of 5 shape (see link below).
  5246. * @see https://easings.net/#easeInQuint
  5247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5248. */
  5249. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5250. /** @hidden */
  5251. easeInCore(gradient: number): number;
  5252. }
  5253. /**
  5254. * Easing function with a sin shape (see link below).
  5255. * @see https://easings.net/#easeInSine
  5256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5257. */
  5258. export class SineEase extends EasingFunction implements IEasingFunction {
  5259. /** @hidden */
  5260. easeInCore(gradient: number): number;
  5261. }
  5262. /**
  5263. * Easing function with a bezier shape (see link below).
  5264. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5265. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5266. */
  5267. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5268. /** Defines the x component of the start tangent in the bezier curve */
  5269. x1: number;
  5270. /** Defines the y component of the start tangent in the bezier curve */
  5271. y1: number;
  5272. /** Defines the x component of the end tangent in the bezier curve */
  5273. x2: number;
  5274. /** Defines the y component of the end tangent in the bezier curve */
  5275. y2: number;
  5276. /**
  5277. * Instantiates a bezier function
  5278. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5279. * @param x1 Defines the x component of the start tangent in the bezier curve
  5280. * @param y1 Defines the y component of the start tangent in the bezier curve
  5281. * @param x2 Defines the x component of the end tangent in the bezier curve
  5282. * @param y2 Defines the y component of the end tangent in the bezier curve
  5283. */
  5284. constructor(
  5285. /** Defines the x component of the start tangent in the bezier curve */
  5286. x1?: number,
  5287. /** Defines the y component of the start tangent in the bezier curve */
  5288. y1?: number,
  5289. /** Defines the x component of the end tangent in the bezier curve */
  5290. x2?: number,
  5291. /** Defines the y component of the end tangent in the bezier curve */
  5292. y2?: number);
  5293. /** @hidden */
  5294. easeInCore(gradient: number): number;
  5295. }
  5296. }
  5297. declare module "babylonjs/Maths/math.color" {
  5298. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5299. /**
  5300. * Class used to hold a RBG color
  5301. */
  5302. export class Color3 {
  5303. /**
  5304. * Defines the red component (between 0 and 1, default is 0)
  5305. */
  5306. r: number;
  5307. /**
  5308. * Defines the green component (between 0 and 1, default is 0)
  5309. */
  5310. g: number;
  5311. /**
  5312. * Defines the blue component (between 0 and 1, default is 0)
  5313. */
  5314. b: number;
  5315. /**
  5316. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5317. * @param r defines the red component (between 0 and 1, default is 0)
  5318. * @param g defines the green component (between 0 and 1, default is 0)
  5319. * @param b defines the blue component (between 0 and 1, default is 0)
  5320. */
  5321. constructor(
  5322. /**
  5323. * Defines the red component (between 0 and 1, default is 0)
  5324. */
  5325. r?: number,
  5326. /**
  5327. * Defines the green component (between 0 and 1, default is 0)
  5328. */
  5329. g?: number,
  5330. /**
  5331. * Defines the blue component (between 0 and 1, default is 0)
  5332. */
  5333. b?: number);
  5334. /**
  5335. * Creates a string with the Color3 current values
  5336. * @returns the string representation of the Color3 object
  5337. */
  5338. toString(): string;
  5339. /**
  5340. * Returns the string "Color3"
  5341. * @returns "Color3"
  5342. */
  5343. getClassName(): string;
  5344. /**
  5345. * Compute the Color3 hash code
  5346. * @returns an unique number that can be used to hash Color3 objects
  5347. */
  5348. getHashCode(): number;
  5349. /**
  5350. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5351. * @param array defines the array where to store the r,g,b components
  5352. * @param index defines an optional index in the target array to define where to start storing values
  5353. * @returns the current Color3 object
  5354. */
  5355. toArray(array: FloatArray, index?: number): Color3;
  5356. /**
  5357. * Returns a new Color4 object from the current Color3 and the given alpha
  5358. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5359. * @returns a new Color4 object
  5360. */
  5361. toColor4(alpha?: number): Color4;
  5362. /**
  5363. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5364. * @returns the new array
  5365. */
  5366. asArray(): number[];
  5367. /**
  5368. * Returns the luminance value
  5369. * @returns a float value
  5370. */
  5371. toLuminance(): number;
  5372. /**
  5373. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5374. * @param otherColor defines the second operand
  5375. * @returns the new Color3 object
  5376. */
  5377. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5378. /**
  5379. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5380. * @param otherColor defines the second operand
  5381. * @param result defines the Color3 object where to store the result
  5382. * @returns the current Color3
  5383. */
  5384. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5385. /**
  5386. * Determines equality between Color3 objects
  5387. * @param otherColor defines the second operand
  5388. * @returns true if the rgb values are equal to the given ones
  5389. */
  5390. equals(otherColor: DeepImmutable<Color3>): boolean;
  5391. /**
  5392. * Determines equality between the current Color3 object and a set of r,b,g values
  5393. * @param r defines the red component to check
  5394. * @param g defines the green component to check
  5395. * @param b defines the blue component to check
  5396. * @returns true if the rgb values are equal to the given ones
  5397. */
  5398. equalsFloats(r: number, g: number, b: number): boolean;
  5399. /**
  5400. * Multiplies in place each rgb value by scale
  5401. * @param scale defines the scaling factor
  5402. * @returns the updated Color3
  5403. */
  5404. scale(scale: number): Color3;
  5405. /**
  5406. * Multiplies the rgb values by scale and stores the result into "result"
  5407. * @param scale defines the scaling factor
  5408. * @param result defines the Color3 object where to store the result
  5409. * @returns the unmodified current Color3
  5410. */
  5411. scaleToRef(scale: number, result: Color3): Color3;
  5412. /**
  5413. * Scale the current Color3 values by a factor and add the result to a given Color3
  5414. * @param scale defines the scale factor
  5415. * @param result defines color to store the result into
  5416. * @returns the unmodified current Color3
  5417. */
  5418. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5419. /**
  5420. * Clamps the rgb values by the min and max values and stores the result into "result"
  5421. * @param min defines minimum clamping value (default is 0)
  5422. * @param max defines maximum clamping value (default is 1)
  5423. * @param result defines color to store the result into
  5424. * @returns the original Color3
  5425. */
  5426. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5427. /**
  5428. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5429. * @param otherColor defines the second operand
  5430. * @returns the new Color3
  5431. */
  5432. add(otherColor: DeepImmutable<Color3>): Color3;
  5433. /**
  5434. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5435. * @param otherColor defines the second operand
  5436. * @param result defines Color3 object to store the result into
  5437. * @returns the unmodified current Color3
  5438. */
  5439. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5440. /**
  5441. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5442. * @param otherColor defines the second operand
  5443. * @returns the new Color3
  5444. */
  5445. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5446. /**
  5447. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5448. * @param otherColor defines the second operand
  5449. * @param result defines Color3 object to store the result into
  5450. * @returns the unmodified current Color3
  5451. */
  5452. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5453. /**
  5454. * Copy the current object
  5455. * @returns a new Color3 copied the current one
  5456. */
  5457. clone(): Color3;
  5458. /**
  5459. * Copies the rgb values from the source in the current Color3
  5460. * @param source defines the source Color3 object
  5461. * @returns the updated Color3 object
  5462. */
  5463. copyFrom(source: DeepImmutable<Color3>): Color3;
  5464. /**
  5465. * Updates the Color3 rgb values from the given floats
  5466. * @param r defines the red component to read from
  5467. * @param g defines the green component to read from
  5468. * @param b defines the blue component to read from
  5469. * @returns the current Color3 object
  5470. */
  5471. copyFromFloats(r: number, g: number, b: number): Color3;
  5472. /**
  5473. * Updates the Color3 rgb values from the given floats
  5474. * @param r defines the red component to read from
  5475. * @param g defines the green component to read from
  5476. * @param b defines the blue component to read from
  5477. * @returns the current Color3 object
  5478. */
  5479. set(r: number, g: number, b: number): Color3;
  5480. /**
  5481. * Compute the Color3 hexadecimal code as a string
  5482. * @returns a string containing the hexadecimal representation of the Color3 object
  5483. */
  5484. toHexString(): string;
  5485. /**
  5486. * Computes a new Color3 converted from the current one to linear space
  5487. * @returns a new Color3 object
  5488. */
  5489. toLinearSpace(): Color3;
  5490. /**
  5491. * Converts current color in rgb space to HSV values
  5492. * @returns a new color3 representing the HSV values
  5493. */
  5494. toHSV(): Color3;
  5495. /**
  5496. * Converts current color in rgb space to HSV values
  5497. * @param result defines the Color3 where to store the HSV values
  5498. */
  5499. toHSVToRef(result: Color3): void;
  5500. /**
  5501. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5502. * @param convertedColor defines the Color3 object where to store the linear space version
  5503. * @returns the unmodified Color3
  5504. */
  5505. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5506. /**
  5507. * Computes a new Color3 converted from the current one to gamma space
  5508. * @returns a new Color3 object
  5509. */
  5510. toGammaSpace(): Color3;
  5511. /**
  5512. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5513. * @param convertedColor defines the Color3 object where to store the gamma space version
  5514. * @returns the unmodified Color3
  5515. */
  5516. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5517. private static _BlackReadOnly;
  5518. /**
  5519. * Convert Hue, saturation and value to a Color3 (RGB)
  5520. * @param hue defines the hue
  5521. * @param saturation defines the saturation
  5522. * @param value defines the value
  5523. * @param result defines the Color3 where to store the RGB values
  5524. */
  5525. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5526. /**
  5527. * Creates a new Color3 from the string containing valid hexadecimal values
  5528. * @param hex defines a string containing valid hexadecimal values
  5529. * @returns a new Color3 object
  5530. */
  5531. static FromHexString(hex: string): Color3;
  5532. /**
  5533. * Creates a new Color3 from the starting index of the given array
  5534. * @param array defines the source array
  5535. * @param offset defines an offset in the source array
  5536. * @returns a new Color3 object
  5537. */
  5538. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5539. /**
  5540. * Creates a new Color3 from integer values (< 256)
  5541. * @param r defines the red component to read from (value between 0 and 255)
  5542. * @param g defines the green component to read from (value between 0 and 255)
  5543. * @param b defines the blue component to read from (value between 0 and 255)
  5544. * @returns a new Color3 object
  5545. */
  5546. static FromInts(r: number, g: number, b: number): Color3;
  5547. /**
  5548. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5549. * @param start defines the start Color3 value
  5550. * @param end defines the end Color3 value
  5551. * @param amount defines the gradient value between start and end
  5552. * @returns a new Color3 object
  5553. */
  5554. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5555. /**
  5556. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5557. * @param left defines the start value
  5558. * @param right defines the end value
  5559. * @param amount defines the gradient factor
  5560. * @param result defines the Color3 object where to store the result
  5561. */
  5562. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5563. /**
  5564. * Returns a Color3 value containing a red color
  5565. * @returns a new Color3 object
  5566. */
  5567. static Red(): Color3;
  5568. /**
  5569. * Returns a Color3 value containing a green color
  5570. * @returns a new Color3 object
  5571. */
  5572. static Green(): Color3;
  5573. /**
  5574. * Returns a Color3 value containing a blue color
  5575. * @returns a new Color3 object
  5576. */
  5577. static Blue(): Color3;
  5578. /**
  5579. * Returns a Color3 value containing a black color
  5580. * @returns a new Color3 object
  5581. */
  5582. static Black(): Color3;
  5583. /**
  5584. * Gets a Color3 value containing a black color that must not be updated
  5585. */
  5586. static get BlackReadOnly(): DeepImmutable<Color3>;
  5587. /**
  5588. * Returns a Color3 value containing a white color
  5589. * @returns a new Color3 object
  5590. */
  5591. static White(): Color3;
  5592. /**
  5593. * Returns a Color3 value containing a purple color
  5594. * @returns a new Color3 object
  5595. */
  5596. static Purple(): Color3;
  5597. /**
  5598. * Returns a Color3 value containing a magenta color
  5599. * @returns a new Color3 object
  5600. */
  5601. static Magenta(): Color3;
  5602. /**
  5603. * Returns a Color3 value containing a yellow color
  5604. * @returns a new Color3 object
  5605. */
  5606. static Yellow(): Color3;
  5607. /**
  5608. * Returns a Color3 value containing a gray color
  5609. * @returns a new Color3 object
  5610. */
  5611. static Gray(): Color3;
  5612. /**
  5613. * Returns a Color3 value containing a teal color
  5614. * @returns a new Color3 object
  5615. */
  5616. static Teal(): Color3;
  5617. /**
  5618. * Returns a Color3 value containing a random color
  5619. * @returns a new Color3 object
  5620. */
  5621. static Random(): Color3;
  5622. }
  5623. /**
  5624. * Class used to hold a RBGA color
  5625. */
  5626. export class Color4 {
  5627. /**
  5628. * Defines the red component (between 0 and 1, default is 0)
  5629. */
  5630. r: number;
  5631. /**
  5632. * Defines the green component (between 0 and 1, default is 0)
  5633. */
  5634. g: number;
  5635. /**
  5636. * Defines the blue component (between 0 and 1, default is 0)
  5637. */
  5638. b: number;
  5639. /**
  5640. * Defines the alpha component (between 0 and 1, default is 1)
  5641. */
  5642. a: number;
  5643. /**
  5644. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5645. * @param r defines the red component (between 0 and 1, default is 0)
  5646. * @param g defines the green component (between 0 and 1, default is 0)
  5647. * @param b defines the blue component (between 0 and 1, default is 0)
  5648. * @param a defines the alpha component (between 0 and 1, default is 1)
  5649. */
  5650. constructor(
  5651. /**
  5652. * Defines the red component (between 0 and 1, default is 0)
  5653. */
  5654. r?: number,
  5655. /**
  5656. * Defines the green component (between 0 and 1, default is 0)
  5657. */
  5658. g?: number,
  5659. /**
  5660. * Defines the blue component (between 0 and 1, default is 0)
  5661. */
  5662. b?: number,
  5663. /**
  5664. * Defines the alpha component (between 0 and 1, default is 1)
  5665. */
  5666. a?: number);
  5667. /**
  5668. * Adds in place the given Color4 values to the current Color4 object
  5669. * @param right defines the second operand
  5670. * @returns the current updated Color4 object
  5671. */
  5672. addInPlace(right: DeepImmutable<Color4>): Color4;
  5673. /**
  5674. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5675. * @returns the new array
  5676. */
  5677. asArray(): number[];
  5678. /**
  5679. * Stores from the starting index in the given array the Color4 successive values
  5680. * @param array defines the array where to store the r,g,b components
  5681. * @param index defines an optional index in the target array to define where to start storing values
  5682. * @returns the current Color4 object
  5683. */
  5684. toArray(array: number[], index?: number): Color4;
  5685. /**
  5686. * Determines equality between Color4 objects
  5687. * @param otherColor defines the second operand
  5688. * @returns true if the rgba values are equal to the given ones
  5689. */
  5690. equals(otherColor: DeepImmutable<Color4>): boolean;
  5691. /**
  5692. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5693. * @param right defines the second operand
  5694. * @returns a new Color4 object
  5695. */
  5696. add(right: DeepImmutable<Color4>): Color4;
  5697. /**
  5698. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5699. * @param right defines the second operand
  5700. * @returns a new Color4 object
  5701. */
  5702. subtract(right: DeepImmutable<Color4>): Color4;
  5703. /**
  5704. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5705. * @param right defines the second operand
  5706. * @param result defines the Color4 object where to store the result
  5707. * @returns the current Color4 object
  5708. */
  5709. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5710. /**
  5711. * Creates a new Color4 with the current Color4 values multiplied by scale
  5712. * @param scale defines the scaling factor to apply
  5713. * @returns a new Color4 object
  5714. */
  5715. scale(scale: number): Color4;
  5716. /**
  5717. * Multiplies the current Color4 values by scale and stores the result in "result"
  5718. * @param scale defines the scaling factor to apply
  5719. * @param result defines the Color4 object where to store the result
  5720. * @returns the current unmodified Color4
  5721. */
  5722. scaleToRef(scale: number, result: Color4): Color4;
  5723. /**
  5724. * Scale the current Color4 values by a factor and add the result to a given Color4
  5725. * @param scale defines the scale factor
  5726. * @param result defines the Color4 object where to store the result
  5727. * @returns the unmodified current Color4
  5728. */
  5729. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5730. /**
  5731. * Clamps the rgb values by the min and max values and stores the result into "result"
  5732. * @param min defines minimum clamping value (default is 0)
  5733. * @param max defines maximum clamping value (default is 1)
  5734. * @param result defines color to store the result into.
  5735. * @returns the cuurent Color4
  5736. */
  5737. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5738. /**
  5739. * Multipy an Color4 value by another and return a new Color4 object
  5740. * @param color defines the Color4 value to multiply by
  5741. * @returns a new Color4 object
  5742. */
  5743. multiply(color: Color4): Color4;
  5744. /**
  5745. * Multipy a Color4 value by another and push the result in a reference value
  5746. * @param color defines the Color4 value to multiply by
  5747. * @param result defines the Color4 to fill the result in
  5748. * @returns the result Color4
  5749. */
  5750. multiplyToRef(color: Color4, result: Color4): Color4;
  5751. /**
  5752. * Creates a string with the Color4 current values
  5753. * @returns the string representation of the Color4 object
  5754. */
  5755. toString(): string;
  5756. /**
  5757. * Returns the string "Color4"
  5758. * @returns "Color4"
  5759. */
  5760. getClassName(): string;
  5761. /**
  5762. * Compute the Color4 hash code
  5763. * @returns an unique number that can be used to hash Color4 objects
  5764. */
  5765. getHashCode(): number;
  5766. /**
  5767. * Creates a new Color4 copied from the current one
  5768. * @returns a new Color4 object
  5769. */
  5770. clone(): Color4;
  5771. /**
  5772. * Copies the given Color4 values into the current one
  5773. * @param source defines the source Color4 object
  5774. * @returns the current updated Color4 object
  5775. */
  5776. copyFrom(source: Color4): Color4;
  5777. /**
  5778. * Copies the given float values into the current one
  5779. * @param r defines the red component to read from
  5780. * @param g defines the green component to read from
  5781. * @param b defines the blue component to read from
  5782. * @param a defines the alpha component to read from
  5783. * @returns the current updated Color4 object
  5784. */
  5785. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5786. /**
  5787. * Copies the given float values into the current one
  5788. * @param r defines the red component to read from
  5789. * @param g defines the green component to read from
  5790. * @param b defines the blue component to read from
  5791. * @param a defines the alpha component to read from
  5792. * @returns the current updated Color4 object
  5793. */
  5794. set(r: number, g: number, b: number, a: number): Color4;
  5795. /**
  5796. * Compute the Color4 hexadecimal code as a string
  5797. * @returns a string containing the hexadecimal representation of the Color4 object
  5798. */
  5799. toHexString(): string;
  5800. /**
  5801. * Computes a new Color4 converted from the current one to linear space
  5802. * @returns a new Color4 object
  5803. */
  5804. toLinearSpace(): Color4;
  5805. /**
  5806. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5807. * @param convertedColor defines the Color4 object where to store the linear space version
  5808. * @returns the unmodified Color4
  5809. */
  5810. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5811. /**
  5812. * Computes a new Color4 converted from the current one to gamma space
  5813. * @returns a new Color4 object
  5814. */
  5815. toGammaSpace(): Color4;
  5816. /**
  5817. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5818. * @param convertedColor defines the Color4 object where to store the gamma space version
  5819. * @returns the unmodified Color4
  5820. */
  5821. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5822. /**
  5823. * Creates a new Color4 from the string containing valid hexadecimal values
  5824. * @param hex defines a string containing valid hexadecimal values
  5825. * @returns a new Color4 object
  5826. */
  5827. static FromHexString(hex: string): Color4;
  5828. /**
  5829. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5830. * @param left defines the start value
  5831. * @param right defines the end value
  5832. * @param amount defines the gradient factor
  5833. * @returns a new Color4 object
  5834. */
  5835. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5836. /**
  5837. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5838. * @param left defines the start value
  5839. * @param right defines the end value
  5840. * @param amount defines the gradient factor
  5841. * @param result defines the Color4 object where to store data
  5842. */
  5843. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5844. /**
  5845. * Creates a new Color4 from a Color3 and an alpha value
  5846. * @param color3 defines the source Color3 to read from
  5847. * @param alpha defines the alpha component (1.0 by default)
  5848. * @returns a new Color4 object
  5849. */
  5850. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5851. /**
  5852. * Creates a new Color4 from the starting index element of the given array
  5853. * @param array defines the source array to read from
  5854. * @param offset defines the offset in the source array
  5855. * @returns a new Color4 object
  5856. */
  5857. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5858. /**
  5859. * Creates a new Color3 from integer values (< 256)
  5860. * @param r defines the red component to read from (value between 0 and 255)
  5861. * @param g defines the green component to read from (value between 0 and 255)
  5862. * @param b defines the blue component to read from (value between 0 and 255)
  5863. * @param a defines the alpha component to read from (value between 0 and 255)
  5864. * @returns a new Color3 object
  5865. */
  5866. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5867. /**
  5868. * Check the content of a given array and convert it to an array containing RGBA data
  5869. * If the original array was already containing count * 4 values then it is returned directly
  5870. * @param colors defines the array to check
  5871. * @param count defines the number of RGBA data to expect
  5872. * @returns an array containing count * 4 values (RGBA)
  5873. */
  5874. static CheckColors4(colors: number[], count: number): number[];
  5875. }
  5876. /**
  5877. * @hidden
  5878. */
  5879. export class TmpColors {
  5880. static Color3: Color3[];
  5881. static Color4: Color4[];
  5882. }
  5883. }
  5884. declare module "babylonjs/Animations/animationKey" {
  5885. /**
  5886. * Defines an interface which represents an animation key frame
  5887. */
  5888. export interface IAnimationKey {
  5889. /**
  5890. * Frame of the key frame
  5891. */
  5892. frame: number;
  5893. /**
  5894. * Value at the specifies key frame
  5895. */
  5896. value: any;
  5897. /**
  5898. * The input tangent for the cubic hermite spline
  5899. */
  5900. inTangent?: any;
  5901. /**
  5902. * The output tangent for the cubic hermite spline
  5903. */
  5904. outTangent?: any;
  5905. /**
  5906. * The animation interpolation type
  5907. */
  5908. interpolation?: AnimationKeyInterpolation;
  5909. }
  5910. /**
  5911. * Enum for the animation key frame interpolation type
  5912. */
  5913. export enum AnimationKeyInterpolation {
  5914. /**
  5915. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5916. */
  5917. STEP = 1
  5918. }
  5919. }
  5920. declare module "babylonjs/Animations/animationRange" {
  5921. /**
  5922. * Represents the range of an animation
  5923. */
  5924. export class AnimationRange {
  5925. /**The name of the animation range**/
  5926. name: string;
  5927. /**The starting frame of the animation */
  5928. from: number;
  5929. /**The ending frame of the animation*/
  5930. to: number;
  5931. /**
  5932. * Initializes the range of an animation
  5933. * @param name The name of the animation range
  5934. * @param from The starting frame of the animation
  5935. * @param to The ending frame of the animation
  5936. */
  5937. constructor(
  5938. /**The name of the animation range**/
  5939. name: string,
  5940. /**The starting frame of the animation */
  5941. from: number,
  5942. /**The ending frame of the animation*/
  5943. to: number);
  5944. /**
  5945. * Makes a copy of the animation range
  5946. * @returns A copy of the animation range
  5947. */
  5948. clone(): AnimationRange;
  5949. }
  5950. }
  5951. declare module "babylonjs/Animations/animationEvent" {
  5952. /**
  5953. * Composed of a frame, and an action function
  5954. */
  5955. export class AnimationEvent {
  5956. /** The frame for which the event is triggered **/
  5957. frame: number;
  5958. /** The event to perform when triggered **/
  5959. action: (currentFrame: number) => void;
  5960. /** Specifies if the event should be triggered only once**/
  5961. onlyOnce?: boolean | undefined;
  5962. /**
  5963. * Specifies if the animation event is done
  5964. */
  5965. isDone: boolean;
  5966. /**
  5967. * Initializes the animation event
  5968. * @param frame The frame for which the event is triggered
  5969. * @param action The event to perform when triggered
  5970. * @param onlyOnce Specifies if the event should be triggered only once
  5971. */
  5972. constructor(
  5973. /** The frame for which the event is triggered **/
  5974. frame: number,
  5975. /** The event to perform when triggered **/
  5976. action: (currentFrame: number) => void,
  5977. /** Specifies if the event should be triggered only once**/
  5978. onlyOnce?: boolean | undefined);
  5979. /** @hidden */
  5980. _clone(): AnimationEvent;
  5981. }
  5982. }
  5983. declare module "babylonjs/Behaviors/behavior" {
  5984. import { Nullable } from "babylonjs/types";
  5985. /**
  5986. * Interface used to define a behavior
  5987. */
  5988. export interface Behavior<T> {
  5989. /** gets or sets behavior's name */
  5990. name: string;
  5991. /**
  5992. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5993. */
  5994. init(): void;
  5995. /**
  5996. * Called when the behavior is attached to a target
  5997. * @param target defines the target where the behavior is attached to
  5998. */
  5999. attach(target: T): void;
  6000. /**
  6001. * Called when the behavior is detached from its target
  6002. */
  6003. detach(): void;
  6004. }
  6005. /**
  6006. * Interface implemented by classes supporting behaviors
  6007. */
  6008. export interface IBehaviorAware<T> {
  6009. /**
  6010. * Attach a behavior
  6011. * @param behavior defines the behavior to attach
  6012. * @returns the current host
  6013. */
  6014. addBehavior(behavior: Behavior<T>): T;
  6015. /**
  6016. * Remove a behavior from the current object
  6017. * @param behavior defines the behavior to detach
  6018. * @returns the current host
  6019. */
  6020. removeBehavior(behavior: Behavior<T>): T;
  6021. /**
  6022. * Gets a behavior using its name to search
  6023. * @param name defines the name to search
  6024. * @returns the behavior or null if not found
  6025. */
  6026. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6027. }
  6028. }
  6029. declare module "babylonjs/Misc/smartArray" {
  6030. /**
  6031. * Defines an array and its length.
  6032. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6033. */
  6034. export interface ISmartArrayLike<T> {
  6035. /**
  6036. * The data of the array.
  6037. */
  6038. data: Array<T>;
  6039. /**
  6040. * The active length of the array.
  6041. */
  6042. length: number;
  6043. }
  6044. /**
  6045. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6046. */
  6047. export class SmartArray<T> implements ISmartArrayLike<T> {
  6048. /**
  6049. * The full set of data from the array.
  6050. */
  6051. data: Array<T>;
  6052. /**
  6053. * The active length of the array.
  6054. */
  6055. length: number;
  6056. protected _id: number;
  6057. /**
  6058. * Instantiates a Smart Array.
  6059. * @param capacity defines the default capacity of the array.
  6060. */
  6061. constructor(capacity: number);
  6062. /**
  6063. * Pushes a value at the end of the active data.
  6064. * @param value defines the object to push in the array.
  6065. */
  6066. push(value: T): void;
  6067. /**
  6068. * Iterates over the active data and apply the lambda to them.
  6069. * @param func defines the action to apply on each value.
  6070. */
  6071. forEach(func: (content: T) => void): void;
  6072. /**
  6073. * Sorts the full sets of data.
  6074. * @param compareFn defines the comparison function to apply.
  6075. */
  6076. sort(compareFn: (a: T, b: T) => number): void;
  6077. /**
  6078. * Resets the active data to an empty array.
  6079. */
  6080. reset(): void;
  6081. /**
  6082. * Releases all the data from the array as well as the array.
  6083. */
  6084. dispose(): void;
  6085. /**
  6086. * Concats the active data with a given array.
  6087. * @param array defines the data to concatenate with.
  6088. */
  6089. concat(array: any): void;
  6090. /**
  6091. * Returns the position of a value in the active data.
  6092. * @param value defines the value to find the index for
  6093. * @returns the index if found in the active data otherwise -1
  6094. */
  6095. indexOf(value: T): number;
  6096. /**
  6097. * Returns whether an element is part of the active data.
  6098. * @param value defines the value to look for
  6099. * @returns true if found in the active data otherwise false
  6100. */
  6101. contains(value: T): boolean;
  6102. private static _GlobalId;
  6103. }
  6104. /**
  6105. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6106. * The data in this array can only be present once
  6107. */
  6108. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6109. private _duplicateId;
  6110. /**
  6111. * Pushes a value at the end of the active data.
  6112. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6113. * @param value defines the object to push in the array.
  6114. */
  6115. push(value: T): void;
  6116. /**
  6117. * Pushes a value at the end of the active data.
  6118. * If the data is already present, it won t be added again
  6119. * @param value defines the object to push in the array.
  6120. * @returns true if added false if it was already present
  6121. */
  6122. pushNoDuplicate(value: T): boolean;
  6123. /**
  6124. * Resets the active data to an empty array.
  6125. */
  6126. reset(): void;
  6127. /**
  6128. * Concats the active data with a given array.
  6129. * This ensures no dupplicate will be present in the result.
  6130. * @param array defines the data to concatenate with.
  6131. */
  6132. concatWithNoDuplicate(array: any): void;
  6133. }
  6134. }
  6135. declare module "babylonjs/Cameras/cameraInputsManager" {
  6136. import { Nullable } from "babylonjs/types";
  6137. import { Camera } from "babylonjs/Cameras/camera";
  6138. /**
  6139. * @ignore
  6140. * This is a list of all the different input types that are available in the application.
  6141. * Fo instance: ArcRotateCameraGamepadInput...
  6142. */
  6143. export var CameraInputTypes: {};
  6144. /**
  6145. * This is the contract to implement in order to create a new input class.
  6146. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6147. */
  6148. export interface ICameraInput<TCamera extends Camera> {
  6149. /**
  6150. * Defines the camera the input is attached to.
  6151. */
  6152. camera: Nullable<TCamera>;
  6153. /**
  6154. * Gets the class name of the current intput.
  6155. * @returns the class name
  6156. */
  6157. getClassName(): string;
  6158. /**
  6159. * Get the friendly name associated with the input class.
  6160. * @returns the input friendly name
  6161. */
  6162. getSimpleName(): string;
  6163. /**
  6164. * Attach the input controls to a specific dom element to get the input from.
  6165. * @param element Defines the element the controls should be listened from
  6166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6167. */
  6168. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6169. /**
  6170. * Detach the current controls from the specified dom element.
  6171. * @param element Defines the element to stop listening the inputs from
  6172. */
  6173. detachControl(element: Nullable<HTMLElement>): void;
  6174. /**
  6175. * Update the current camera state depending on the inputs that have been used this frame.
  6176. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6177. */
  6178. checkInputs?: () => void;
  6179. }
  6180. /**
  6181. * Represents a map of input types to input instance or input index to input instance.
  6182. */
  6183. export interface CameraInputsMap<TCamera extends Camera> {
  6184. /**
  6185. * Accessor to the input by input type.
  6186. */
  6187. [name: string]: ICameraInput<TCamera>;
  6188. /**
  6189. * Accessor to the input by input index.
  6190. */
  6191. [idx: number]: ICameraInput<TCamera>;
  6192. }
  6193. /**
  6194. * This represents the input manager used within a camera.
  6195. * It helps dealing with all the different kind of input attached to a camera.
  6196. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6197. */
  6198. export class CameraInputsManager<TCamera extends Camera> {
  6199. /**
  6200. * Defines the list of inputs attahed to the camera.
  6201. */
  6202. attached: CameraInputsMap<TCamera>;
  6203. /**
  6204. * Defines the dom element the camera is collecting inputs from.
  6205. * This is null if the controls have not been attached.
  6206. */
  6207. attachedElement: Nullable<HTMLElement>;
  6208. /**
  6209. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6210. */
  6211. noPreventDefault: boolean;
  6212. /**
  6213. * Defined the camera the input manager belongs to.
  6214. */
  6215. camera: TCamera;
  6216. /**
  6217. * Update the current camera state depending on the inputs that have been used this frame.
  6218. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6219. */
  6220. checkInputs: () => void;
  6221. /**
  6222. * Instantiate a new Camera Input Manager.
  6223. * @param camera Defines the camera the input manager blongs to
  6224. */
  6225. constructor(camera: TCamera);
  6226. /**
  6227. * Add an input method to a camera
  6228. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6229. * @param input camera input method
  6230. */
  6231. add(input: ICameraInput<TCamera>): void;
  6232. /**
  6233. * Remove a specific input method from a camera
  6234. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6235. * @param inputToRemove camera input method
  6236. */
  6237. remove(inputToRemove: ICameraInput<TCamera>): void;
  6238. /**
  6239. * Remove a specific input type from a camera
  6240. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6241. * @param inputType the type of the input to remove
  6242. */
  6243. removeByType(inputType: string): void;
  6244. private _addCheckInputs;
  6245. /**
  6246. * Attach the input controls to the currently attached dom element to listen the events from.
  6247. * @param input Defines the input to attach
  6248. */
  6249. attachInput(input: ICameraInput<TCamera>): void;
  6250. /**
  6251. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6252. * @param element Defines the dom element to collect the events from
  6253. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6254. */
  6255. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6256. /**
  6257. * Detach the current manager inputs controls from a specific dom element.
  6258. * @param element Defines the dom element to collect the events from
  6259. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6260. */
  6261. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6262. /**
  6263. * Rebuild the dynamic inputCheck function from the current list of
  6264. * defined inputs in the manager.
  6265. */
  6266. rebuildInputCheck(): void;
  6267. /**
  6268. * Remove all attached input methods from a camera
  6269. */
  6270. clear(): void;
  6271. /**
  6272. * Serialize the current input manager attached to a camera.
  6273. * This ensures than once parsed,
  6274. * the input associated to the camera will be identical to the current ones
  6275. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6276. */
  6277. serialize(serializedCamera: any): void;
  6278. /**
  6279. * Parses an input manager serialized JSON to restore the previous list of inputs
  6280. * and states associated to a camera.
  6281. * @param parsedCamera Defines the JSON to parse
  6282. */
  6283. parse(parsedCamera: any): void;
  6284. }
  6285. }
  6286. declare module "babylonjs/Meshes/buffer" {
  6287. import { Nullable, DataArray } from "babylonjs/types";
  6288. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6289. /**
  6290. * Class used to store data that will be store in GPU memory
  6291. */
  6292. export class Buffer {
  6293. private _engine;
  6294. private _buffer;
  6295. /** @hidden */
  6296. _data: Nullable<DataArray>;
  6297. private _updatable;
  6298. private _instanced;
  6299. private _divisor;
  6300. /**
  6301. * Gets the byte stride.
  6302. */
  6303. readonly byteStride: number;
  6304. /**
  6305. * Constructor
  6306. * @param engine the engine
  6307. * @param data the data to use for this buffer
  6308. * @param updatable whether the data is updatable
  6309. * @param stride the stride (optional)
  6310. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6311. * @param instanced whether the buffer is instanced (optional)
  6312. * @param useBytes set to true if the stride in in bytes (optional)
  6313. * @param divisor sets an optional divisor for instances (1 by default)
  6314. */
  6315. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6316. /**
  6317. * Create a new VertexBuffer based on the current buffer
  6318. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6319. * @param offset defines offset in the buffer (0 by default)
  6320. * @param size defines the size in floats of attributes (position is 3 for instance)
  6321. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6322. * @param instanced defines if the vertex buffer contains indexed data
  6323. * @param useBytes defines if the offset and stride are in bytes *
  6324. * @param divisor sets an optional divisor for instances (1 by default)
  6325. * @returns the new vertex buffer
  6326. */
  6327. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6328. /**
  6329. * Gets a boolean indicating if the Buffer is updatable?
  6330. * @returns true if the buffer is updatable
  6331. */
  6332. isUpdatable(): boolean;
  6333. /**
  6334. * Gets current buffer's data
  6335. * @returns a DataArray or null
  6336. */
  6337. getData(): Nullable<DataArray>;
  6338. /**
  6339. * Gets underlying native buffer
  6340. * @returns underlying native buffer
  6341. */
  6342. getBuffer(): Nullable<DataBuffer>;
  6343. /**
  6344. * Gets the stride in float32 units (i.e. byte stride / 4).
  6345. * May not be an integer if the byte stride is not divisible by 4.
  6346. * @returns the stride in float32 units
  6347. * @deprecated Please use byteStride instead.
  6348. */
  6349. getStrideSize(): number;
  6350. /**
  6351. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6352. * @param data defines the data to store
  6353. */
  6354. create(data?: Nullable<DataArray>): void;
  6355. /** @hidden */
  6356. _rebuild(): void;
  6357. /**
  6358. * Update current buffer data
  6359. * @param data defines the data to store
  6360. */
  6361. update(data: DataArray): void;
  6362. /**
  6363. * Updates the data directly.
  6364. * @param data the new data
  6365. * @param offset the new offset
  6366. * @param vertexCount the vertex count (optional)
  6367. * @param useBytes set to true if the offset is in bytes
  6368. */
  6369. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6370. /**
  6371. * Release all resources
  6372. */
  6373. dispose(): void;
  6374. }
  6375. /**
  6376. * Specialized buffer used to store vertex data
  6377. */
  6378. export class VertexBuffer {
  6379. /** @hidden */
  6380. _buffer: Buffer;
  6381. private _kind;
  6382. private _size;
  6383. private _ownsBuffer;
  6384. private _instanced;
  6385. private _instanceDivisor;
  6386. /**
  6387. * The byte type.
  6388. */
  6389. static readonly BYTE: number;
  6390. /**
  6391. * The unsigned byte type.
  6392. */
  6393. static readonly UNSIGNED_BYTE: number;
  6394. /**
  6395. * The short type.
  6396. */
  6397. static readonly SHORT: number;
  6398. /**
  6399. * The unsigned short type.
  6400. */
  6401. static readonly UNSIGNED_SHORT: number;
  6402. /**
  6403. * The integer type.
  6404. */
  6405. static readonly INT: number;
  6406. /**
  6407. * The unsigned integer type.
  6408. */
  6409. static readonly UNSIGNED_INT: number;
  6410. /**
  6411. * The float type.
  6412. */
  6413. static readonly FLOAT: number;
  6414. /**
  6415. * Gets or sets the instance divisor when in instanced mode
  6416. */
  6417. get instanceDivisor(): number;
  6418. set instanceDivisor(value: number);
  6419. /**
  6420. * Gets the byte stride.
  6421. */
  6422. readonly byteStride: number;
  6423. /**
  6424. * Gets the byte offset.
  6425. */
  6426. readonly byteOffset: number;
  6427. /**
  6428. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6429. */
  6430. readonly normalized: boolean;
  6431. /**
  6432. * Gets the data type of each component in the array.
  6433. */
  6434. readonly type: number;
  6435. /**
  6436. * Constructor
  6437. * @param engine the engine
  6438. * @param data the data to use for this vertex buffer
  6439. * @param kind the vertex buffer kind
  6440. * @param updatable whether the data is updatable
  6441. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6442. * @param stride the stride (optional)
  6443. * @param instanced whether the buffer is instanced (optional)
  6444. * @param offset the offset of the data (optional)
  6445. * @param size the number of components (optional)
  6446. * @param type the type of the component (optional)
  6447. * @param normalized whether the data contains normalized data (optional)
  6448. * @param useBytes set to true if stride and offset are in bytes (optional)
  6449. * @param divisor defines the instance divisor to use (1 by default)
  6450. */
  6451. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6452. /** @hidden */
  6453. _rebuild(): void;
  6454. /**
  6455. * Returns the kind of the VertexBuffer (string)
  6456. * @returns a string
  6457. */
  6458. getKind(): string;
  6459. /**
  6460. * Gets a boolean indicating if the VertexBuffer is updatable?
  6461. * @returns true if the buffer is updatable
  6462. */
  6463. isUpdatable(): boolean;
  6464. /**
  6465. * Gets current buffer's data
  6466. * @returns a DataArray or null
  6467. */
  6468. getData(): Nullable<DataArray>;
  6469. /**
  6470. * Gets underlying native buffer
  6471. * @returns underlying native buffer
  6472. */
  6473. getBuffer(): Nullable<DataBuffer>;
  6474. /**
  6475. * Gets the stride in float32 units (i.e. byte stride / 4).
  6476. * May not be an integer if the byte stride is not divisible by 4.
  6477. * @returns the stride in float32 units
  6478. * @deprecated Please use byteStride instead.
  6479. */
  6480. getStrideSize(): number;
  6481. /**
  6482. * Returns the offset as a multiple of the type byte length.
  6483. * @returns the offset in bytes
  6484. * @deprecated Please use byteOffset instead.
  6485. */
  6486. getOffset(): number;
  6487. /**
  6488. * Returns the number of components per vertex attribute (integer)
  6489. * @returns the size in float
  6490. */
  6491. getSize(): number;
  6492. /**
  6493. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6494. * @returns true if this buffer is instanced
  6495. */
  6496. getIsInstanced(): boolean;
  6497. /**
  6498. * Returns the instancing divisor, zero for non-instanced (integer).
  6499. * @returns a number
  6500. */
  6501. getInstanceDivisor(): number;
  6502. /**
  6503. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6504. * @param data defines the data to store
  6505. */
  6506. create(data?: DataArray): void;
  6507. /**
  6508. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6509. * This function will create a new buffer if the current one is not updatable
  6510. * @param data defines the data to store
  6511. */
  6512. update(data: DataArray): void;
  6513. /**
  6514. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6515. * Returns the directly updated WebGLBuffer.
  6516. * @param data the new data
  6517. * @param offset the new offset
  6518. * @param useBytes set to true if the offset is in bytes
  6519. */
  6520. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6521. /**
  6522. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6523. */
  6524. dispose(): void;
  6525. /**
  6526. * Enumerates each value of this vertex buffer as numbers.
  6527. * @param count the number of values to enumerate
  6528. * @param callback the callback function called for each value
  6529. */
  6530. forEach(count: number, callback: (value: number, index: number) => void): void;
  6531. /**
  6532. * Positions
  6533. */
  6534. static readonly PositionKind: string;
  6535. /**
  6536. * Normals
  6537. */
  6538. static readonly NormalKind: string;
  6539. /**
  6540. * Tangents
  6541. */
  6542. static readonly TangentKind: string;
  6543. /**
  6544. * Texture coordinates
  6545. */
  6546. static readonly UVKind: string;
  6547. /**
  6548. * Texture coordinates 2
  6549. */
  6550. static readonly UV2Kind: string;
  6551. /**
  6552. * Texture coordinates 3
  6553. */
  6554. static readonly UV3Kind: string;
  6555. /**
  6556. * Texture coordinates 4
  6557. */
  6558. static readonly UV4Kind: string;
  6559. /**
  6560. * Texture coordinates 5
  6561. */
  6562. static readonly UV5Kind: string;
  6563. /**
  6564. * Texture coordinates 6
  6565. */
  6566. static readonly UV6Kind: string;
  6567. /**
  6568. * Colors
  6569. */
  6570. static readonly ColorKind: string;
  6571. /**
  6572. * Matrix indices (for bones)
  6573. */
  6574. static readonly MatricesIndicesKind: string;
  6575. /**
  6576. * Matrix weights (for bones)
  6577. */
  6578. static readonly MatricesWeightsKind: string;
  6579. /**
  6580. * Additional matrix indices (for bones)
  6581. */
  6582. static readonly MatricesIndicesExtraKind: string;
  6583. /**
  6584. * Additional matrix weights (for bones)
  6585. */
  6586. static readonly MatricesWeightsExtraKind: string;
  6587. /**
  6588. * Deduces the stride given a kind.
  6589. * @param kind The kind string to deduce
  6590. * @returns The deduced stride
  6591. */
  6592. static DeduceStride(kind: string): number;
  6593. /**
  6594. * Gets the byte length of the given type.
  6595. * @param type the type
  6596. * @returns the number of bytes
  6597. */
  6598. static GetTypeByteLength(type: number): number;
  6599. /**
  6600. * Enumerates each value of the given parameters as numbers.
  6601. * @param data the data to enumerate
  6602. * @param byteOffset the byte offset of the data
  6603. * @param byteStride the byte stride of the data
  6604. * @param componentCount the number of components per element
  6605. * @param componentType the type of the component
  6606. * @param count the number of values to enumerate
  6607. * @param normalized whether the data is normalized
  6608. * @param callback the callback function called for each value
  6609. */
  6610. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6611. private static _GetFloatValue;
  6612. }
  6613. }
  6614. declare module "babylonjs/Collisions/intersectionInfo" {
  6615. import { Nullable } from "babylonjs/types";
  6616. /**
  6617. * @hidden
  6618. */
  6619. export class IntersectionInfo {
  6620. bu: Nullable<number>;
  6621. bv: Nullable<number>;
  6622. distance: number;
  6623. faceId: number;
  6624. subMeshId: number;
  6625. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6626. }
  6627. }
  6628. declare module "babylonjs/Maths/math.plane" {
  6629. import { DeepImmutable } from "babylonjs/types";
  6630. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6631. /**
  6632. * Represens a plane by the equation ax + by + cz + d = 0
  6633. */
  6634. export class Plane {
  6635. private static _TmpMatrix;
  6636. /**
  6637. * Normal of the plane (a,b,c)
  6638. */
  6639. normal: Vector3;
  6640. /**
  6641. * d component of the plane
  6642. */
  6643. d: number;
  6644. /**
  6645. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6646. * @param a a component of the plane
  6647. * @param b b component of the plane
  6648. * @param c c component of the plane
  6649. * @param d d component of the plane
  6650. */
  6651. constructor(a: number, b: number, c: number, d: number);
  6652. /**
  6653. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6654. */
  6655. asArray(): number[];
  6656. /**
  6657. * @returns a new plane copied from the current Plane.
  6658. */
  6659. clone(): Plane;
  6660. /**
  6661. * @returns the string "Plane".
  6662. */
  6663. getClassName(): string;
  6664. /**
  6665. * @returns the Plane hash code.
  6666. */
  6667. getHashCode(): number;
  6668. /**
  6669. * Normalize the current Plane in place.
  6670. * @returns the updated Plane.
  6671. */
  6672. normalize(): Plane;
  6673. /**
  6674. * Applies a transformation the plane and returns the result
  6675. * @param transformation the transformation matrix to be applied to the plane
  6676. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6677. */
  6678. transform(transformation: DeepImmutable<Matrix>): Plane;
  6679. /**
  6680. * Calcualtte the dot product between the point and the plane normal
  6681. * @param point point to calculate the dot product with
  6682. * @returns the dot product (float) of the point coordinates and the plane normal.
  6683. */
  6684. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6685. /**
  6686. * Updates the current Plane from the plane defined by the three given points.
  6687. * @param point1 one of the points used to contruct the plane
  6688. * @param point2 one of the points used to contruct the plane
  6689. * @param point3 one of the points used to contruct the plane
  6690. * @returns the updated Plane.
  6691. */
  6692. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6693. /**
  6694. * Checks if the plane is facing a given direction
  6695. * @param direction the direction to check if the plane is facing
  6696. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6697. * @returns True is the vector "direction" is the same side than the plane normal.
  6698. */
  6699. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6700. /**
  6701. * Calculates the distance to a point
  6702. * @param point point to calculate distance to
  6703. * @returns the signed distance (float) from the given point to the Plane.
  6704. */
  6705. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6706. /**
  6707. * Creates a plane from an array
  6708. * @param array the array to create a plane from
  6709. * @returns a new Plane from the given array.
  6710. */
  6711. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6712. /**
  6713. * Creates a plane from three points
  6714. * @param point1 point used to create the plane
  6715. * @param point2 point used to create the plane
  6716. * @param point3 point used to create the plane
  6717. * @returns a new Plane defined by the three given points.
  6718. */
  6719. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6720. /**
  6721. * Creates a plane from an origin point and a normal
  6722. * @param origin origin of the plane to be constructed
  6723. * @param normal normal of the plane to be constructed
  6724. * @returns a new Plane the normal vector to this plane at the given origin point.
  6725. * Note : the vector "normal" is updated because normalized.
  6726. */
  6727. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6728. /**
  6729. * Calculates the distance from a plane and a point
  6730. * @param origin origin of the plane to be constructed
  6731. * @param normal normal of the plane to be constructed
  6732. * @param point point to calculate distance to
  6733. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6734. */
  6735. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6736. }
  6737. }
  6738. declare module "babylonjs/Culling/boundingSphere" {
  6739. import { DeepImmutable } from "babylonjs/types";
  6740. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6741. import { Plane } from "babylonjs/Maths/math.plane";
  6742. /**
  6743. * Class used to store bounding sphere information
  6744. */
  6745. export class BoundingSphere {
  6746. /**
  6747. * Gets the center of the bounding sphere in local space
  6748. */
  6749. readonly center: Vector3;
  6750. /**
  6751. * Radius of the bounding sphere in local space
  6752. */
  6753. radius: number;
  6754. /**
  6755. * Gets the center of the bounding sphere in world space
  6756. */
  6757. readonly centerWorld: Vector3;
  6758. /**
  6759. * Radius of the bounding sphere in world space
  6760. */
  6761. radiusWorld: number;
  6762. /**
  6763. * Gets the minimum vector in local space
  6764. */
  6765. readonly minimum: Vector3;
  6766. /**
  6767. * Gets the maximum vector in local space
  6768. */
  6769. readonly maximum: Vector3;
  6770. private _worldMatrix;
  6771. private static readonly TmpVector3;
  6772. /**
  6773. * Creates a new bounding sphere
  6774. * @param min defines the minimum vector (in local space)
  6775. * @param max defines the maximum vector (in local space)
  6776. * @param worldMatrix defines the new world matrix
  6777. */
  6778. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6779. /**
  6780. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6781. * @param min defines the new minimum vector (in local space)
  6782. * @param max defines the new maximum vector (in local space)
  6783. * @param worldMatrix defines the new world matrix
  6784. */
  6785. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6786. /**
  6787. * Scale the current bounding sphere by applying a scale factor
  6788. * @param factor defines the scale factor to apply
  6789. * @returns the current bounding box
  6790. */
  6791. scale(factor: number): BoundingSphere;
  6792. /**
  6793. * Gets the world matrix of the bounding box
  6794. * @returns a matrix
  6795. */
  6796. getWorldMatrix(): DeepImmutable<Matrix>;
  6797. /** @hidden */
  6798. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6799. /**
  6800. * Tests if the bounding sphere is intersecting the frustum planes
  6801. * @param frustumPlanes defines the frustum planes to test
  6802. * @returns true if there is an intersection
  6803. */
  6804. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6805. /**
  6806. * Tests if the bounding sphere center is in between the frustum planes.
  6807. * Used for optimistic fast inclusion.
  6808. * @param frustumPlanes defines the frustum planes to test
  6809. * @returns true if the sphere center is in between the frustum planes
  6810. */
  6811. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6812. /**
  6813. * Tests if a point is inside the bounding sphere
  6814. * @param point defines the point to test
  6815. * @returns true if the point is inside the bounding sphere
  6816. */
  6817. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6818. /**
  6819. * Checks if two sphere intersct
  6820. * @param sphere0 sphere 0
  6821. * @param sphere1 sphere 1
  6822. * @returns true if the speres intersect
  6823. */
  6824. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6825. }
  6826. }
  6827. declare module "babylonjs/Culling/boundingBox" {
  6828. import { DeepImmutable } from "babylonjs/types";
  6829. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6830. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6831. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6832. import { Plane } from "babylonjs/Maths/math.plane";
  6833. /**
  6834. * Class used to store bounding box information
  6835. */
  6836. export class BoundingBox implements ICullable {
  6837. /**
  6838. * Gets the 8 vectors representing the bounding box in local space
  6839. */
  6840. readonly vectors: Vector3[];
  6841. /**
  6842. * Gets the center of the bounding box in local space
  6843. */
  6844. readonly center: Vector3;
  6845. /**
  6846. * Gets the center of the bounding box in world space
  6847. */
  6848. readonly centerWorld: Vector3;
  6849. /**
  6850. * Gets the extend size in local space
  6851. */
  6852. readonly extendSize: Vector3;
  6853. /**
  6854. * Gets the extend size in world space
  6855. */
  6856. readonly extendSizeWorld: Vector3;
  6857. /**
  6858. * Gets the OBB (object bounding box) directions
  6859. */
  6860. readonly directions: Vector3[];
  6861. /**
  6862. * Gets the 8 vectors representing the bounding box in world space
  6863. */
  6864. readonly vectorsWorld: Vector3[];
  6865. /**
  6866. * Gets the minimum vector in world space
  6867. */
  6868. readonly minimumWorld: Vector3;
  6869. /**
  6870. * Gets the maximum vector in world space
  6871. */
  6872. readonly maximumWorld: Vector3;
  6873. /**
  6874. * Gets the minimum vector in local space
  6875. */
  6876. readonly minimum: Vector3;
  6877. /**
  6878. * Gets the maximum vector in local space
  6879. */
  6880. readonly maximum: Vector3;
  6881. private _worldMatrix;
  6882. private static readonly TmpVector3;
  6883. /**
  6884. * @hidden
  6885. */
  6886. _tag: number;
  6887. /**
  6888. * Creates a new bounding box
  6889. * @param min defines the minimum vector (in local space)
  6890. * @param max defines the maximum vector (in local space)
  6891. * @param worldMatrix defines the new world matrix
  6892. */
  6893. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6894. /**
  6895. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6896. * @param min defines the new minimum vector (in local space)
  6897. * @param max defines the new maximum vector (in local space)
  6898. * @param worldMatrix defines the new world matrix
  6899. */
  6900. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6901. /**
  6902. * Scale the current bounding box by applying a scale factor
  6903. * @param factor defines the scale factor to apply
  6904. * @returns the current bounding box
  6905. */
  6906. scale(factor: number): BoundingBox;
  6907. /**
  6908. * Gets the world matrix of the bounding box
  6909. * @returns a matrix
  6910. */
  6911. getWorldMatrix(): DeepImmutable<Matrix>;
  6912. /** @hidden */
  6913. _update(world: DeepImmutable<Matrix>): void;
  6914. /**
  6915. * Tests if the bounding box is intersecting the frustum planes
  6916. * @param frustumPlanes defines the frustum planes to test
  6917. * @returns true if there is an intersection
  6918. */
  6919. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6920. /**
  6921. * Tests if the bounding box is entirely inside the frustum planes
  6922. * @param frustumPlanes defines the frustum planes to test
  6923. * @returns true if there is an inclusion
  6924. */
  6925. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6926. /**
  6927. * Tests if a point is inside the bounding box
  6928. * @param point defines the point to test
  6929. * @returns true if the point is inside the bounding box
  6930. */
  6931. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6932. /**
  6933. * Tests if the bounding box intersects with a bounding sphere
  6934. * @param sphere defines the sphere to test
  6935. * @returns true if there is an intersection
  6936. */
  6937. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6938. /**
  6939. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6940. * @param min defines the min vector to use
  6941. * @param max defines the max vector to use
  6942. * @returns true if there is an intersection
  6943. */
  6944. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6945. /**
  6946. * Tests if two bounding boxes are intersections
  6947. * @param box0 defines the first box to test
  6948. * @param box1 defines the second box to test
  6949. * @returns true if there is an intersection
  6950. */
  6951. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6952. /**
  6953. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6954. * @param minPoint defines the minimum vector of the bounding box
  6955. * @param maxPoint defines the maximum vector of the bounding box
  6956. * @param sphereCenter defines the sphere center
  6957. * @param sphereRadius defines the sphere radius
  6958. * @returns true if there is an intersection
  6959. */
  6960. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6961. /**
  6962. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6963. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6964. * @param frustumPlanes defines the frustum planes to test
  6965. * @return true if there is an inclusion
  6966. */
  6967. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6968. /**
  6969. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6970. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6971. * @param frustumPlanes defines the frustum planes to test
  6972. * @return true if there is an intersection
  6973. */
  6974. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6975. }
  6976. }
  6977. declare module "babylonjs/Collisions/collider" {
  6978. import { Nullable, IndicesArray } from "babylonjs/types";
  6979. import { Vector3 } from "babylonjs/Maths/math.vector";
  6980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6981. import { Plane } from "babylonjs/Maths/math.plane";
  6982. /** @hidden */
  6983. export class Collider {
  6984. /** Define if a collision was found */
  6985. collisionFound: boolean;
  6986. /**
  6987. * Define last intersection point in local space
  6988. */
  6989. intersectionPoint: Vector3;
  6990. /**
  6991. * Define last collided mesh
  6992. */
  6993. collidedMesh: Nullable<AbstractMesh>;
  6994. private _collisionPoint;
  6995. private _planeIntersectionPoint;
  6996. private _tempVector;
  6997. private _tempVector2;
  6998. private _tempVector3;
  6999. private _tempVector4;
  7000. private _edge;
  7001. private _baseToVertex;
  7002. private _destinationPoint;
  7003. private _slidePlaneNormal;
  7004. private _displacementVector;
  7005. /** @hidden */
  7006. _radius: Vector3;
  7007. /** @hidden */
  7008. _retry: number;
  7009. private _velocity;
  7010. private _basePoint;
  7011. private _epsilon;
  7012. /** @hidden */
  7013. _velocityWorldLength: number;
  7014. /** @hidden */
  7015. _basePointWorld: Vector3;
  7016. private _velocityWorld;
  7017. private _normalizedVelocity;
  7018. /** @hidden */
  7019. _initialVelocity: Vector3;
  7020. /** @hidden */
  7021. _initialPosition: Vector3;
  7022. private _nearestDistance;
  7023. private _collisionMask;
  7024. get collisionMask(): number;
  7025. set collisionMask(mask: number);
  7026. /**
  7027. * Gets the plane normal used to compute the sliding response (in local space)
  7028. */
  7029. get slidePlaneNormal(): Vector3;
  7030. /** @hidden */
  7031. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7032. /** @hidden */
  7033. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7034. /** @hidden */
  7035. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7036. /** @hidden */
  7037. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7038. /** @hidden */
  7039. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7040. /** @hidden */
  7041. _getResponse(pos: Vector3, vel: Vector3): void;
  7042. }
  7043. }
  7044. declare module "babylonjs/Culling/boundingInfo" {
  7045. import { DeepImmutable } from "babylonjs/types";
  7046. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7047. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7048. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7049. import { Plane } from "babylonjs/Maths/math.plane";
  7050. import { Collider } from "babylonjs/Collisions/collider";
  7051. /**
  7052. * Interface for cullable objects
  7053. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7054. */
  7055. export interface ICullable {
  7056. /**
  7057. * Checks if the object or part of the object is in the frustum
  7058. * @param frustumPlanes Camera near/planes
  7059. * @returns true if the object is in frustum otherwise false
  7060. */
  7061. isInFrustum(frustumPlanes: Plane[]): boolean;
  7062. /**
  7063. * Checks if a cullable object (mesh...) is in the camera frustum
  7064. * Unlike isInFrustum this cheks the full bounding box
  7065. * @param frustumPlanes Camera near/planes
  7066. * @returns true if the object is in frustum otherwise false
  7067. */
  7068. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7069. }
  7070. /**
  7071. * Info for a bounding data of a mesh
  7072. */
  7073. export class BoundingInfo implements ICullable {
  7074. /**
  7075. * Bounding box for the mesh
  7076. */
  7077. readonly boundingBox: BoundingBox;
  7078. /**
  7079. * Bounding sphere for the mesh
  7080. */
  7081. readonly boundingSphere: BoundingSphere;
  7082. private _isLocked;
  7083. private static readonly TmpVector3;
  7084. /**
  7085. * Constructs bounding info
  7086. * @param minimum min vector of the bounding box/sphere
  7087. * @param maximum max vector of the bounding box/sphere
  7088. * @param worldMatrix defines the new world matrix
  7089. */
  7090. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7091. /**
  7092. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7093. * @param min defines the new minimum vector (in local space)
  7094. * @param max defines the new maximum vector (in local space)
  7095. * @param worldMatrix defines the new world matrix
  7096. */
  7097. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7098. /**
  7099. * min vector of the bounding box/sphere
  7100. */
  7101. get minimum(): Vector3;
  7102. /**
  7103. * max vector of the bounding box/sphere
  7104. */
  7105. get maximum(): Vector3;
  7106. /**
  7107. * If the info is locked and won't be updated to avoid perf overhead
  7108. */
  7109. get isLocked(): boolean;
  7110. set isLocked(value: boolean);
  7111. /**
  7112. * Updates the bounding sphere and box
  7113. * @param world world matrix to be used to update
  7114. */
  7115. update(world: DeepImmutable<Matrix>): void;
  7116. /**
  7117. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7118. * @param center New center of the bounding info
  7119. * @param extend New extend of the bounding info
  7120. * @returns the current bounding info
  7121. */
  7122. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7123. /**
  7124. * Scale the current bounding info by applying a scale factor
  7125. * @param factor defines the scale factor to apply
  7126. * @returns the current bounding info
  7127. */
  7128. scale(factor: number): BoundingInfo;
  7129. /**
  7130. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7131. * @param frustumPlanes defines the frustum to test
  7132. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7133. * @returns true if the bounding info is in the frustum planes
  7134. */
  7135. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7136. /**
  7137. * Gets the world distance between the min and max points of the bounding box
  7138. */
  7139. get diagonalLength(): number;
  7140. /**
  7141. * Checks if a cullable object (mesh...) is in the camera frustum
  7142. * Unlike isInFrustum this cheks the full bounding box
  7143. * @param frustumPlanes Camera near/planes
  7144. * @returns true if the object is in frustum otherwise false
  7145. */
  7146. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7147. /** @hidden */
  7148. _checkCollision(collider: Collider): boolean;
  7149. /**
  7150. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7151. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7152. * @param point the point to check intersection with
  7153. * @returns if the point intersects
  7154. */
  7155. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7156. /**
  7157. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7158. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7159. * @param boundingInfo the bounding info to check intersection with
  7160. * @param precise if the intersection should be done using OBB
  7161. * @returns if the bounding info intersects
  7162. */
  7163. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7164. }
  7165. }
  7166. declare module "babylonjs/Maths/math.functions" {
  7167. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7168. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7169. /**
  7170. * Extracts minimum and maximum values from a list of indexed positions
  7171. * @param positions defines the positions to use
  7172. * @param indices defines the indices to the positions
  7173. * @param indexStart defines the start index
  7174. * @param indexCount defines the end index
  7175. * @param bias defines bias value to add to the result
  7176. * @return minimum and maximum values
  7177. */
  7178. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7179. minimum: Vector3;
  7180. maximum: Vector3;
  7181. };
  7182. /**
  7183. * Extracts minimum and maximum values from a list of positions
  7184. * @param positions defines the positions to use
  7185. * @param start defines the start index in the positions array
  7186. * @param count defines the number of positions to handle
  7187. * @param bias defines bias value to add to the result
  7188. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7189. * @return minimum and maximum values
  7190. */
  7191. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7192. minimum: Vector3;
  7193. maximum: Vector3;
  7194. };
  7195. }
  7196. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7197. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7198. /** @hidden */
  7199. export class WebGLDataBuffer extends DataBuffer {
  7200. private _buffer;
  7201. constructor(resource: WebGLBuffer);
  7202. get underlyingResource(): any;
  7203. }
  7204. }
  7205. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7206. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7207. import { Nullable } from "babylonjs/types";
  7208. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7209. /** @hidden */
  7210. export class WebGLPipelineContext implements IPipelineContext {
  7211. engine: ThinEngine;
  7212. program: Nullable<WebGLProgram>;
  7213. context?: WebGLRenderingContext;
  7214. vertexShader?: WebGLShader;
  7215. fragmentShader?: WebGLShader;
  7216. isParallelCompiled: boolean;
  7217. onCompiled?: () => void;
  7218. transformFeedback?: WebGLTransformFeedback | null;
  7219. vertexCompilationError: Nullable<string>;
  7220. fragmentCompilationError: Nullable<string>;
  7221. programLinkError: Nullable<string>;
  7222. programValidationError: Nullable<string>;
  7223. get isAsync(): boolean;
  7224. get isReady(): boolean;
  7225. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7226. }
  7227. }
  7228. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7229. import { FloatArray, Nullable } from "babylonjs/types";
  7230. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7231. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7232. module "babylonjs/Engines/thinEngine" {
  7233. interface ThinEngine {
  7234. /**
  7235. * Create an uniform buffer
  7236. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7237. * @param elements defines the content of the uniform buffer
  7238. * @returns the webGL uniform buffer
  7239. */
  7240. createUniformBuffer(elements: FloatArray): DataBuffer;
  7241. /**
  7242. * Create a dynamic uniform buffer
  7243. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7244. * @param elements defines the content of the uniform buffer
  7245. * @returns the webGL uniform buffer
  7246. */
  7247. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7248. /**
  7249. * Update an existing uniform buffer
  7250. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7251. * @param uniformBuffer defines the target uniform buffer
  7252. * @param elements defines the content to update
  7253. * @param offset defines the offset in the uniform buffer where update should start
  7254. * @param count defines the size of the data to update
  7255. */
  7256. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7257. /**
  7258. * Bind an uniform buffer to the current webGL context
  7259. * @param buffer defines the buffer to bind
  7260. */
  7261. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7262. /**
  7263. * Bind a buffer to the current webGL context at a given location
  7264. * @param buffer defines the buffer to bind
  7265. * @param location defines the index where to bind the buffer
  7266. */
  7267. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7268. /**
  7269. * Bind a specific block at a given index in a specific shader program
  7270. * @param pipelineContext defines the pipeline context to use
  7271. * @param blockName defines the block name
  7272. * @param index defines the index where to bind the block
  7273. */
  7274. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7275. }
  7276. }
  7277. }
  7278. declare module "babylonjs/Materials/uniformBuffer" {
  7279. import { Nullable, FloatArray } from "babylonjs/types";
  7280. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7281. import { Engine } from "babylonjs/Engines/engine";
  7282. import { Effect } from "babylonjs/Materials/effect";
  7283. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7284. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7285. import { Color3 } from "babylonjs/Maths/math.color";
  7286. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7287. /**
  7288. * Uniform buffer objects.
  7289. *
  7290. * Handles blocks of uniform on the GPU.
  7291. *
  7292. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7293. *
  7294. * For more information, please refer to :
  7295. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7296. */
  7297. export class UniformBuffer {
  7298. private _engine;
  7299. private _buffer;
  7300. private _data;
  7301. private _bufferData;
  7302. private _dynamic?;
  7303. private _uniformLocations;
  7304. private _uniformSizes;
  7305. private _uniformLocationPointer;
  7306. private _needSync;
  7307. private _noUBO;
  7308. private _currentEffect;
  7309. /** @hidden */
  7310. _alreadyBound: boolean;
  7311. private static _MAX_UNIFORM_SIZE;
  7312. private static _tempBuffer;
  7313. /**
  7314. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7315. * This is dynamic to allow compat with webgl 1 and 2.
  7316. * You will need to pass the name of the uniform as well as the value.
  7317. */
  7318. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7319. /**
  7320. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7321. * This is dynamic to allow compat with webgl 1 and 2.
  7322. * You will need to pass the name of the uniform as well as the value.
  7323. */
  7324. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7325. /**
  7326. * Lambda to Update a single float in a uniform buffer.
  7327. * This is dynamic to allow compat with webgl 1 and 2.
  7328. * You will need to pass the name of the uniform as well as the value.
  7329. */
  7330. updateFloat: (name: string, x: number) => void;
  7331. /**
  7332. * Lambda to Update a vec2 of float in a uniform buffer.
  7333. * This is dynamic to allow compat with webgl 1 and 2.
  7334. * You will need to pass the name of the uniform as well as the value.
  7335. */
  7336. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7337. /**
  7338. * Lambda to Update a vec3 of float in a uniform buffer.
  7339. * This is dynamic to allow compat with webgl 1 and 2.
  7340. * You will need to pass the name of the uniform as well as the value.
  7341. */
  7342. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7343. /**
  7344. * Lambda to Update a vec4 of float in a uniform buffer.
  7345. * This is dynamic to allow compat with webgl 1 and 2.
  7346. * You will need to pass the name of the uniform as well as the value.
  7347. */
  7348. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7349. /**
  7350. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7351. * This is dynamic to allow compat with webgl 1 and 2.
  7352. * You will need to pass the name of the uniform as well as the value.
  7353. */
  7354. updateMatrix: (name: string, mat: Matrix) => void;
  7355. /**
  7356. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7357. * This is dynamic to allow compat with webgl 1 and 2.
  7358. * You will need to pass the name of the uniform as well as the value.
  7359. */
  7360. updateVector3: (name: string, vector: Vector3) => void;
  7361. /**
  7362. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7363. * This is dynamic to allow compat with webgl 1 and 2.
  7364. * You will need to pass the name of the uniform as well as the value.
  7365. */
  7366. updateVector4: (name: string, vector: Vector4) => void;
  7367. /**
  7368. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7369. * This is dynamic to allow compat with webgl 1 and 2.
  7370. * You will need to pass the name of the uniform as well as the value.
  7371. */
  7372. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7373. /**
  7374. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7375. * This is dynamic to allow compat with webgl 1 and 2.
  7376. * You will need to pass the name of the uniform as well as the value.
  7377. */
  7378. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7379. /**
  7380. * Instantiates a new Uniform buffer objects.
  7381. *
  7382. * Handles blocks of uniform on the GPU.
  7383. *
  7384. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7385. *
  7386. * For more information, please refer to :
  7387. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7388. * @param engine Define the engine the buffer is associated with
  7389. * @param data Define the data contained in the buffer
  7390. * @param dynamic Define if the buffer is updatable
  7391. */
  7392. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7393. /**
  7394. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7395. * or just falling back on setUniformXXX calls.
  7396. */
  7397. get useUbo(): boolean;
  7398. /**
  7399. * Indicates if the WebGL underlying uniform buffer is in sync
  7400. * with the javascript cache data.
  7401. */
  7402. get isSync(): boolean;
  7403. /**
  7404. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7405. * Also, a dynamic UniformBuffer will disable cache verification and always
  7406. * update the underlying WebGL uniform buffer to the GPU.
  7407. * @returns if Dynamic, otherwise false
  7408. */
  7409. isDynamic(): boolean;
  7410. /**
  7411. * The data cache on JS side.
  7412. * @returns the underlying data as a float array
  7413. */
  7414. getData(): Float32Array;
  7415. /**
  7416. * The underlying WebGL Uniform buffer.
  7417. * @returns the webgl buffer
  7418. */
  7419. getBuffer(): Nullable<DataBuffer>;
  7420. /**
  7421. * std140 layout specifies how to align data within an UBO structure.
  7422. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7423. * for specs.
  7424. */
  7425. private _fillAlignment;
  7426. /**
  7427. * Adds an uniform in the buffer.
  7428. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7429. * for the layout to be correct !
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. * @param size Data size, or data directly.
  7432. */
  7433. addUniform(name: string, size: number | number[]): void;
  7434. /**
  7435. * Adds a Matrix 4x4 to the uniform buffer.
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. * @param mat A 4x4 matrix.
  7438. */
  7439. addMatrix(name: string, mat: Matrix): void;
  7440. /**
  7441. * Adds a vec2 to the uniform buffer.
  7442. * @param name Name of the uniform, as used in the uniform block in the shader.
  7443. * @param x Define the x component value of the vec2
  7444. * @param y Define the y component value of the vec2
  7445. */
  7446. addFloat2(name: string, x: number, y: number): void;
  7447. /**
  7448. * Adds a vec3 to the uniform buffer.
  7449. * @param name Name of the uniform, as used in the uniform block in the shader.
  7450. * @param x Define the x component value of the vec3
  7451. * @param y Define the y component value of the vec3
  7452. * @param z Define the z component value of the vec3
  7453. */
  7454. addFloat3(name: string, x: number, y: number, z: number): void;
  7455. /**
  7456. * Adds a vec3 to the uniform buffer.
  7457. * @param name Name of the uniform, as used in the uniform block in the shader.
  7458. * @param color Define the vec3 from a Color
  7459. */
  7460. addColor3(name: string, color: Color3): void;
  7461. /**
  7462. * Adds a vec4 to the uniform buffer.
  7463. * @param name Name of the uniform, as used in the uniform block in the shader.
  7464. * @param color Define the rgb components from a Color
  7465. * @param alpha Define the a component of the vec4
  7466. */
  7467. addColor4(name: string, color: Color3, alpha: number): void;
  7468. /**
  7469. * Adds a vec3 to the uniform buffer.
  7470. * @param name Name of the uniform, as used in the uniform block in the shader.
  7471. * @param vector Define the vec3 components from a Vector
  7472. */
  7473. addVector3(name: string, vector: Vector3): void;
  7474. /**
  7475. * Adds a Matrix 3x3 to the uniform buffer.
  7476. * @param name Name of the uniform, as used in the uniform block in the shader.
  7477. */
  7478. addMatrix3x3(name: string): void;
  7479. /**
  7480. * Adds a Matrix 2x2 to the uniform buffer.
  7481. * @param name Name of the uniform, as used in the uniform block in the shader.
  7482. */
  7483. addMatrix2x2(name: string): void;
  7484. /**
  7485. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7486. */
  7487. create(): void;
  7488. /** @hidden */
  7489. _rebuild(): void;
  7490. /**
  7491. * Updates the WebGL Uniform Buffer on the GPU.
  7492. * If the `dynamic` flag is set to true, no cache comparison is done.
  7493. * Otherwise, the buffer will be updated only if the cache differs.
  7494. */
  7495. update(): void;
  7496. /**
  7497. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7498. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7499. * @param data Define the flattened data
  7500. * @param size Define the size of the data.
  7501. */
  7502. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7503. private _valueCache;
  7504. private _cacheMatrix;
  7505. private _updateMatrix3x3ForUniform;
  7506. private _updateMatrix3x3ForEffect;
  7507. private _updateMatrix2x2ForEffect;
  7508. private _updateMatrix2x2ForUniform;
  7509. private _updateFloatForEffect;
  7510. private _updateFloatForUniform;
  7511. private _updateFloat2ForEffect;
  7512. private _updateFloat2ForUniform;
  7513. private _updateFloat3ForEffect;
  7514. private _updateFloat3ForUniform;
  7515. private _updateFloat4ForEffect;
  7516. private _updateFloat4ForUniform;
  7517. private _updateMatrixForEffect;
  7518. private _updateMatrixForUniform;
  7519. private _updateVector3ForEffect;
  7520. private _updateVector3ForUniform;
  7521. private _updateVector4ForEffect;
  7522. private _updateVector4ForUniform;
  7523. private _updateColor3ForEffect;
  7524. private _updateColor3ForUniform;
  7525. private _updateColor4ForEffect;
  7526. private _updateColor4ForUniform;
  7527. /**
  7528. * Sets a sampler uniform on the effect.
  7529. * @param name Define the name of the sampler.
  7530. * @param texture Define the texture to set in the sampler
  7531. */
  7532. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7533. /**
  7534. * Directly updates the value of the uniform in the cache AND on the GPU.
  7535. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7536. * @param data Define the flattened data
  7537. */
  7538. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7539. /**
  7540. * Binds this uniform buffer to an effect.
  7541. * @param effect Define the effect to bind the buffer to
  7542. * @param name Name of the uniform block in the shader.
  7543. */
  7544. bindToEffect(effect: Effect, name: string): void;
  7545. /**
  7546. * Disposes the uniform buffer.
  7547. */
  7548. dispose(): void;
  7549. }
  7550. }
  7551. declare module "babylonjs/Misc/iInspectable" {
  7552. /**
  7553. * Enum that determines the text-wrapping mode to use.
  7554. */
  7555. export enum InspectableType {
  7556. /**
  7557. * Checkbox for booleans
  7558. */
  7559. Checkbox = 0,
  7560. /**
  7561. * Sliders for numbers
  7562. */
  7563. Slider = 1,
  7564. /**
  7565. * Vector3
  7566. */
  7567. Vector3 = 2,
  7568. /**
  7569. * Quaternions
  7570. */
  7571. Quaternion = 3,
  7572. /**
  7573. * Color3
  7574. */
  7575. Color3 = 4,
  7576. /**
  7577. * String
  7578. */
  7579. String = 5
  7580. }
  7581. /**
  7582. * Interface used to define custom inspectable properties.
  7583. * This interface is used by the inspector to display custom property grids
  7584. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7585. */
  7586. export interface IInspectable {
  7587. /**
  7588. * Gets the label to display
  7589. */
  7590. label: string;
  7591. /**
  7592. * Gets the name of the property to edit
  7593. */
  7594. propertyName: string;
  7595. /**
  7596. * Gets the type of the editor to use
  7597. */
  7598. type: InspectableType;
  7599. /**
  7600. * Gets the minimum value of the property when using in "slider" mode
  7601. */
  7602. min?: number;
  7603. /**
  7604. * Gets the maximum value of the property when using in "slider" mode
  7605. */
  7606. max?: number;
  7607. /**
  7608. * Gets the setp to use when using in "slider" mode
  7609. */
  7610. step?: number;
  7611. }
  7612. }
  7613. declare module "babylonjs/Misc/timingTools" {
  7614. /**
  7615. * Class used to provide helper for timing
  7616. */
  7617. export class TimingTools {
  7618. /**
  7619. * Polyfill for setImmediate
  7620. * @param action defines the action to execute after the current execution block
  7621. */
  7622. static SetImmediate(action: () => void): void;
  7623. }
  7624. }
  7625. declare module "babylonjs/Misc/instantiationTools" {
  7626. /**
  7627. * Class used to enable instatition of objects by class name
  7628. */
  7629. export class InstantiationTools {
  7630. /**
  7631. * Use this object to register external classes like custom textures or material
  7632. * to allow the laoders to instantiate them
  7633. */
  7634. static RegisteredExternalClasses: {
  7635. [key: string]: Object;
  7636. };
  7637. /**
  7638. * Tries to instantiate a new object from a given class name
  7639. * @param className defines the class name to instantiate
  7640. * @returns the new object or null if the system was not able to do the instantiation
  7641. */
  7642. static Instantiate(className: string): any;
  7643. }
  7644. }
  7645. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7646. /**
  7647. * Define options used to create a depth texture
  7648. */
  7649. export class DepthTextureCreationOptions {
  7650. /** Specifies whether or not a stencil should be allocated in the texture */
  7651. generateStencil?: boolean;
  7652. /** Specifies whether or not bilinear filtering is enable on the texture */
  7653. bilinearFiltering?: boolean;
  7654. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7655. comparisonFunction?: number;
  7656. /** Specifies if the created texture is a cube texture */
  7657. isCube?: boolean;
  7658. }
  7659. }
  7660. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7661. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7662. import { Nullable } from "babylonjs/types";
  7663. import { Scene } from "babylonjs/scene";
  7664. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7665. module "babylonjs/Engines/thinEngine" {
  7666. interface ThinEngine {
  7667. /**
  7668. * Creates a depth stencil cube texture.
  7669. * This is only available in WebGL 2.
  7670. * @param size The size of face edge in the cube texture.
  7671. * @param options The options defining the cube texture.
  7672. * @returns The cube texture
  7673. */
  7674. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7675. /**
  7676. * Creates a cube texture
  7677. * @param rootUrl defines the url where the files to load is located
  7678. * @param scene defines the current scene
  7679. * @param files defines the list of files to load (1 per face)
  7680. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7681. * @param onLoad defines an optional callback raised when the texture is loaded
  7682. * @param onError defines an optional callback raised if there is an issue to load the texture
  7683. * @param format defines the format of the data
  7684. * @param forcedExtension defines the extension to use to pick the right loader
  7685. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7686. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7687. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7688. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7689. * @returns the cube texture as an InternalTexture
  7690. */
  7691. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  7692. /**
  7693. * Creates a cube texture
  7694. * @param rootUrl defines the url where the files to load is located
  7695. * @param scene defines the current scene
  7696. * @param files defines the list of files to load (1 per face)
  7697. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7698. * @param onLoad defines an optional callback raised when the texture is loaded
  7699. * @param onError defines an optional callback raised if there is an issue to load the texture
  7700. * @param format defines the format of the data
  7701. * @param forcedExtension defines the extension to use to pick the right loader
  7702. * @returns the cube texture as an InternalTexture
  7703. */
  7704. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7705. /**
  7706. * Creates a cube texture
  7707. * @param rootUrl defines the url where the files to load is located
  7708. * @param scene defines the current scene
  7709. * @param files defines the list of files to load (1 per face)
  7710. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7711. * @param onLoad defines an optional callback raised when the texture is loaded
  7712. * @param onError defines an optional callback raised if there is an issue to load the texture
  7713. * @param format defines the format of the data
  7714. * @param forcedExtension defines the extension to use to pick the right loader
  7715. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7716. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7717. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7718. * @returns the cube texture as an InternalTexture
  7719. */
  7720. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7721. /** @hidden */
  7722. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7723. /** @hidden */
  7724. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7725. /** @hidden */
  7726. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7727. /** @hidden */
  7728. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7729. /**
  7730. * @hidden
  7731. */
  7732. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7733. }
  7734. }
  7735. }
  7736. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7737. import { Nullable } from "babylonjs/types";
  7738. import { Scene } from "babylonjs/scene";
  7739. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7740. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7741. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7742. import { Observable } from "babylonjs/Misc/observable";
  7743. /**
  7744. * Class for creating a cube texture
  7745. */
  7746. export class CubeTexture extends BaseTexture {
  7747. private _delayedOnLoad;
  7748. /**
  7749. * Observable triggered once the texture has been loaded.
  7750. */
  7751. onLoadObservable: Observable<CubeTexture>;
  7752. /**
  7753. * The url of the texture
  7754. */
  7755. url: string;
  7756. /**
  7757. * Gets or sets the center of the bounding box associated with the cube texture.
  7758. * It must define where the camera used to render the texture was set
  7759. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7760. */
  7761. boundingBoxPosition: Vector3;
  7762. private _boundingBoxSize;
  7763. /**
  7764. * Gets or sets the size of the bounding box associated with the cube texture
  7765. * When defined, the cubemap will switch to local mode
  7766. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7767. * @example https://www.babylonjs-playground.com/#RNASML
  7768. */
  7769. set boundingBoxSize(value: Vector3);
  7770. /**
  7771. * Returns the bounding box size
  7772. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7773. */
  7774. get boundingBoxSize(): Vector3;
  7775. protected _rotationY: number;
  7776. /**
  7777. * Sets texture matrix rotation angle around Y axis in radians.
  7778. */
  7779. set rotationY(value: number);
  7780. /**
  7781. * Gets texture matrix rotation angle around Y axis radians.
  7782. */
  7783. get rotationY(): number;
  7784. /**
  7785. * Are mip maps generated for this texture or not.
  7786. */
  7787. get noMipmap(): boolean;
  7788. private _noMipmap;
  7789. private _files;
  7790. protected _forcedExtension: Nullable<string>;
  7791. private _extensions;
  7792. private _textureMatrix;
  7793. private _format;
  7794. private _createPolynomials;
  7795. /** @hidden */
  7796. _prefiltered: boolean;
  7797. /**
  7798. * Creates a cube texture from an array of image urls
  7799. * @param files defines an array of image urls
  7800. * @param scene defines the hosting scene
  7801. * @param noMipmap specifies if mip maps are not used
  7802. * @returns a cube texture
  7803. */
  7804. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7805. /**
  7806. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7807. * @param url defines the url of the prefiltered texture
  7808. * @param scene defines the scene the texture is attached to
  7809. * @param forcedExtension defines the extension of the file if different from the url
  7810. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7811. * @return the prefiltered texture
  7812. */
  7813. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7814. /**
  7815. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7816. * as prefiltered data.
  7817. * @param rootUrl defines the url of the texture or the root name of the six images
  7818. * @param scene defines the scene the texture is attached to
  7819. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7820. * @param noMipmap defines if mipmaps should be created or not
  7821. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7822. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7823. * @param onError defines a callback triggered in case of error during load
  7824. * @param format defines the internal format to use for the texture once loaded
  7825. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7826. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7827. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7828. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7829. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7830. * @return the cube texture
  7831. */
  7832. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7833. /**
  7834. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7835. */
  7836. get isPrefiltered(): boolean;
  7837. /**
  7838. * Get the current class name of the texture useful for serialization or dynamic coding.
  7839. * @returns "CubeTexture"
  7840. */
  7841. getClassName(): string;
  7842. /**
  7843. * Update the url (and optional buffer) of this texture if url was null during construction.
  7844. * @param url the url of the texture
  7845. * @param forcedExtension defines the extension to use
  7846. * @param onLoad callback called when the texture is loaded (defaults to null)
  7847. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7848. */
  7849. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7850. /**
  7851. * Delays loading of the cube texture
  7852. * @param forcedExtension defines the extension to use
  7853. */
  7854. delayLoad(forcedExtension?: string): void;
  7855. /**
  7856. * Returns the reflection texture matrix
  7857. * @returns the reflection texture matrix
  7858. */
  7859. getReflectionTextureMatrix(): Matrix;
  7860. /**
  7861. * Sets the reflection texture matrix
  7862. * @param value Reflection texture matrix
  7863. */
  7864. setReflectionTextureMatrix(value: Matrix): void;
  7865. /**
  7866. * Parses text to create a cube texture
  7867. * @param parsedTexture define the serialized text to read from
  7868. * @param scene defines the hosting scene
  7869. * @param rootUrl defines the root url of the cube texture
  7870. * @returns a cube texture
  7871. */
  7872. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7873. /**
  7874. * Makes a clone, or deep copy, of the cube texture
  7875. * @returns a new cube texture
  7876. */
  7877. clone(): CubeTexture;
  7878. }
  7879. }
  7880. declare module "babylonjs/Materials/materialDefines" {
  7881. /**
  7882. * Manages the defines for the Material
  7883. */
  7884. export class MaterialDefines {
  7885. /** @hidden */
  7886. protected _keys: string[];
  7887. private _isDirty;
  7888. /** @hidden */
  7889. _renderId: number;
  7890. /** @hidden */
  7891. _areLightsDirty: boolean;
  7892. /** @hidden */
  7893. _areLightsDisposed: boolean;
  7894. /** @hidden */
  7895. _areAttributesDirty: boolean;
  7896. /** @hidden */
  7897. _areTexturesDirty: boolean;
  7898. /** @hidden */
  7899. _areFresnelDirty: boolean;
  7900. /** @hidden */
  7901. _areMiscDirty: boolean;
  7902. /** @hidden */
  7903. _areImageProcessingDirty: boolean;
  7904. /** @hidden */
  7905. _normals: boolean;
  7906. /** @hidden */
  7907. _uvs: boolean;
  7908. /** @hidden */
  7909. _needNormals: boolean;
  7910. /** @hidden */
  7911. _needUVs: boolean;
  7912. [id: string]: any;
  7913. /**
  7914. * Specifies if the material needs to be re-calculated
  7915. */
  7916. get isDirty(): boolean;
  7917. /**
  7918. * Marks the material to indicate that it has been re-calculated
  7919. */
  7920. markAsProcessed(): void;
  7921. /**
  7922. * Marks the material to indicate that it needs to be re-calculated
  7923. */
  7924. markAsUnprocessed(): void;
  7925. /**
  7926. * Marks the material to indicate all of its defines need to be re-calculated
  7927. */
  7928. markAllAsDirty(): void;
  7929. /**
  7930. * Marks the material to indicate that image processing needs to be re-calculated
  7931. */
  7932. markAsImageProcessingDirty(): void;
  7933. /**
  7934. * Marks the material to indicate the lights need to be re-calculated
  7935. * @param disposed Defines whether the light is dirty due to dispose or not
  7936. */
  7937. markAsLightDirty(disposed?: boolean): void;
  7938. /**
  7939. * Marks the attribute state as changed
  7940. */
  7941. markAsAttributesDirty(): void;
  7942. /**
  7943. * Marks the texture state as changed
  7944. */
  7945. markAsTexturesDirty(): void;
  7946. /**
  7947. * Marks the fresnel state as changed
  7948. */
  7949. markAsFresnelDirty(): void;
  7950. /**
  7951. * Marks the misc state as changed
  7952. */
  7953. markAsMiscDirty(): void;
  7954. /**
  7955. * Rebuilds the material defines
  7956. */
  7957. rebuild(): void;
  7958. /**
  7959. * Specifies if two material defines are equal
  7960. * @param other - A material define instance to compare to
  7961. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7962. */
  7963. isEqual(other: MaterialDefines): boolean;
  7964. /**
  7965. * Clones this instance's defines to another instance
  7966. * @param other - material defines to clone values to
  7967. */
  7968. cloneTo(other: MaterialDefines): void;
  7969. /**
  7970. * Resets the material define values
  7971. */
  7972. reset(): void;
  7973. /**
  7974. * Converts the material define values to a string
  7975. * @returns - String of material define information
  7976. */
  7977. toString(): string;
  7978. }
  7979. }
  7980. declare module "babylonjs/Materials/colorCurves" {
  7981. import { Effect } from "babylonjs/Materials/effect";
  7982. /**
  7983. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7984. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7985. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  7986. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7987. */
  7988. export class ColorCurves {
  7989. private _dirty;
  7990. private _tempColor;
  7991. private _globalCurve;
  7992. private _highlightsCurve;
  7993. private _midtonesCurve;
  7994. private _shadowsCurve;
  7995. private _positiveCurve;
  7996. private _negativeCurve;
  7997. private _globalHue;
  7998. private _globalDensity;
  7999. private _globalSaturation;
  8000. private _globalExposure;
  8001. /**
  8002. * Gets the global Hue value.
  8003. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8004. */
  8005. get globalHue(): number;
  8006. /**
  8007. * Sets the global Hue value.
  8008. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8009. */
  8010. set globalHue(value: number);
  8011. /**
  8012. * Gets the global Density value.
  8013. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8014. * Values less than zero provide a filter of opposite hue.
  8015. */
  8016. get globalDensity(): number;
  8017. /**
  8018. * Sets the global Density value.
  8019. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8020. * Values less than zero provide a filter of opposite hue.
  8021. */
  8022. set globalDensity(value: number);
  8023. /**
  8024. * Gets the global Saturation value.
  8025. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8026. */
  8027. get globalSaturation(): number;
  8028. /**
  8029. * Sets the global Saturation value.
  8030. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8031. */
  8032. set globalSaturation(value: number);
  8033. /**
  8034. * Gets the global Exposure value.
  8035. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8036. */
  8037. get globalExposure(): number;
  8038. /**
  8039. * Sets the global Exposure value.
  8040. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8041. */
  8042. set globalExposure(value: number);
  8043. private _highlightsHue;
  8044. private _highlightsDensity;
  8045. private _highlightsSaturation;
  8046. private _highlightsExposure;
  8047. /**
  8048. * Gets the highlights Hue value.
  8049. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8050. */
  8051. get highlightsHue(): number;
  8052. /**
  8053. * Sets the highlights Hue value.
  8054. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8055. */
  8056. set highlightsHue(value: number);
  8057. /**
  8058. * Gets the highlights Density value.
  8059. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8060. * Values less than zero provide a filter of opposite hue.
  8061. */
  8062. get highlightsDensity(): number;
  8063. /**
  8064. * Sets the highlights Density value.
  8065. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8066. * Values less than zero provide a filter of opposite hue.
  8067. */
  8068. set highlightsDensity(value: number);
  8069. /**
  8070. * Gets the highlights Saturation value.
  8071. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8072. */
  8073. get highlightsSaturation(): number;
  8074. /**
  8075. * Sets the highlights Saturation value.
  8076. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8077. */
  8078. set highlightsSaturation(value: number);
  8079. /**
  8080. * Gets the highlights Exposure value.
  8081. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8082. */
  8083. get highlightsExposure(): number;
  8084. /**
  8085. * Sets the highlights Exposure value.
  8086. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8087. */
  8088. set highlightsExposure(value: number);
  8089. private _midtonesHue;
  8090. private _midtonesDensity;
  8091. private _midtonesSaturation;
  8092. private _midtonesExposure;
  8093. /**
  8094. * Gets the midtones Hue value.
  8095. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8096. */
  8097. get midtonesHue(): number;
  8098. /**
  8099. * Sets the midtones Hue value.
  8100. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8101. */
  8102. set midtonesHue(value: number);
  8103. /**
  8104. * Gets the midtones Density value.
  8105. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8106. * Values less than zero provide a filter of opposite hue.
  8107. */
  8108. get midtonesDensity(): number;
  8109. /**
  8110. * Sets the midtones Density value.
  8111. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8112. * Values less than zero provide a filter of opposite hue.
  8113. */
  8114. set midtonesDensity(value: number);
  8115. /**
  8116. * Gets the midtones Saturation value.
  8117. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8118. */
  8119. get midtonesSaturation(): number;
  8120. /**
  8121. * Sets the midtones Saturation value.
  8122. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8123. */
  8124. set midtonesSaturation(value: number);
  8125. /**
  8126. * Gets the midtones Exposure value.
  8127. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8128. */
  8129. get midtonesExposure(): number;
  8130. /**
  8131. * Sets the midtones Exposure value.
  8132. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8133. */
  8134. set midtonesExposure(value: number);
  8135. private _shadowsHue;
  8136. private _shadowsDensity;
  8137. private _shadowsSaturation;
  8138. private _shadowsExposure;
  8139. /**
  8140. * Gets the shadows Hue value.
  8141. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8142. */
  8143. get shadowsHue(): number;
  8144. /**
  8145. * Sets the shadows Hue value.
  8146. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8147. */
  8148. set shadowsHue(value: number);
  8149. /**
  8150. * Gets the shadows Density value.
  8151. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8152. * Values less than zero provide a filter of opposite hue.
  8153. */
  8154. get shadowsDensity(): number;
  8155. /**
  8156. * Sets the shadows Density value.
  8157. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8158. * Values less than zero provide a filter of opposite hue.
  8159. */
  8160. set shadowsDensity(value: number);
  8161. /**
  8162. * Gets the shadows Saturation value.
  8163. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8164. */
  8165. get shadowsSaturation(): number;
  8166. /**
  8167. * Sets the shadows Saturation value.
  8168. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8169. */
  8170. set shadowsSaturation(value: number);
  8171. /**
  8172. * Gets the shadows Exposure value.
  8173. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8174. */
  8175. get shadowsExposure(): number;
  8176. /**
  8177. * Sets the shadows Exposure value.
  8178. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8179. */
  8180. set shadowsExposure(value: number);
  8181. /**
  8182. * Returns the class name
  8183. * @returns The class name
  8184. */
  8185. getClassName(): string;
  8186. /**
  8187. * Binds the color curves to the shader.
  8188. * @param colorCurves The color curve to bind
  8189. * @param effect The effect to bind to
  8190. * @param positiveUniform The positive uniform shader parameter
  8191. * @param neutralUniform The neutral uniform shader parameter
  8192. * @param negativeUniform The negative uniform shader parameter
  8193. */
  8194. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8195. /**
  8196. * Prepare the list of uniforms associated with the ColorCurves effects.
  8197. * @param uniformsList The list of uniforms used in the effect
  8198. */
  8199. static PrepareUniforms(uniformsList: string[]): void;
  8200. /**
  8201. * Returns color grading data based on a hue, density, saturation and exposure value.
  8202. * @param filterHue The hue of the color filter.
  8203. * @param filterDensity The density of the color filter.
  8204. * @param saturation The saturation.
  8205. * @param exposure The exposure.
  8206. * @param result The result data container.
  8207. */
  8208. private getColorGradingDataToRef;
  8209. /**
  8210. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8211. * @param value The input slider value in range [-100,100].
  8212. * @returns Adjusted value.
  8213. */
  8214. private static applyColorGradingSliderNonlinear;
  8215. /**
  8216. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8217. * @param hue The hue (H) input.
  8218. * @param saturation The saturation (S) input.
  8219. * @param brightness The brightness (B) input.
  8220. * @result An RGBA color represented as Vector4.
  8221. */
  8222. private static fromHSBToRef;
  8223. /**
  8224. * Returns a value clamped between min and max
  8225. * @param value The value to clamp
  8226. * @param min The minimum of value
  8227. * @param max The maximum of value
  8228. * @returns The clamped value.
  8229. */
  8230. private static clamp;
  8231. /**
  8232. * Clones the current color curve instance.
  8233. * @return The cloned curves
  8234. */
  8235. clone(): ColorCurves;
  8236. /**
  8237. * Serializes the current color curve instance to a json representation.
  8238. * @return a JSON representation
  8239. */
  8240. serialize(): any;
  8241. /**
  8242. * Parses the color curve from a json representation.
  8243. * @param source the JSON source to parse
  8244. * @return The parsed curves
  8245. */
  8246. static Parse(source: any): ColorCurves;
  8247. }
  8248. }
  8249. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8250. import { Observable } from "babylonjs/Misc/observable";
  8251. import { Nullable } from "babylonjs/types";
  8252. import { Color4 } from "babylonjs/Maths/math.color";
  8253. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8254. import { Effect } from "babylonjs/Materials/effect";
  8255. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8256. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8257. /**
  8258. * Interface to follow in your material defines to integrate easily the
  8259. * Image proccessing functions.
  8260. * @hidden
  8261. */
  8262. export interface IImageProcessingConfigurationDefines {
  8263. IMAGEPROCESSING: boolean;
  8264. VIGNETTE: boolean;
  8265. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8266. VIGNETTEBLENDMODEOPAQUE: boolean;
  8267. TONEMAPPING: boolean;
  8268. TONEMAPPING_ACES: boolean;
  8269. CONTRAST: boolean;
  8270. EXPOSURE: boolean;
  8271. COLORCURVES: boolean;
  8272. COLORGRADING: boolean;
  8273. COLORGRADING3D: boolean;
  8274. SAMPLER3DGREENDEPTH: boolean;
  8275. SAMPLER3DBGRMAP: boolean;
  8276. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8277. }
  8278. /**
  8279. * @hidden
  8280. */
  8281. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8282. IMAGEPROCESSING: boolean;
  8283. VIGNETTE: boolean;
  8284. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8285. VIGNETTEBLENDMODEOPAQUE: boolean;
  8286. TONEMAPPING: boolean;
  8287. TONEMAPPING_ACES: boolean;
  8288. CONTRAST: boolean;
  8289. COLORCURVES: boolean;
  8290. COLORGRADING: boolean;
  8291. COLORGRADING3D: boolean;
  8292. SAMPLER3DGREENDEPTH: boolean;
  8293. SAMPLER3DBGRMAP: boolean;
  8294. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8295. EXPOSURE: boolean;
  8296. constructor();
  8297. }
  8298. /**
  8299. * This groups together the common properties used for image processing either in direct forward pass
  8300. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8301. * or not.
  8302. */
  8303. export class ImageProcessingConfiguration {
  8304. /**
  8305. * Default tone mapping applied in BabylonJS.
  8306. */
  8307. static readonly TONEMAPPING_STANDARD: number;
  8308. /**
  8309. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8310. * to other engines rendering to increase portability.
  8311. */
  8312. static readonly TONEMAPPING_ACES: number;
  8313. /**
  8314. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8315. */
  8316. colorCurves: Nullable<ColorCurves>;
  8317. private _colorCurvesEnabled;
  8318. /**
  8319. * Gets wether the color curves effect is enabled.
  8320. */
  8321. get colorCurvesEnabled(): boolean;
  8322. /**
  8323. * Sets wether the color curves effect is enabled.
  8324. */
  8325. set colorCurvesEnabled(value: boolean);
  8326. private _colorGradingTexture;
  8327. /**
  8328. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8329. */
  8330. get colorGradingTexture(): Nullable<BaseTexture>;
  8331. /**
  8332. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8333. */
  8334. set colorGradingTexture(value: Nullable<BaseTexture>);
  8335. private _colorGradingEnabled;
  8336. /**
  8337. * Gets wether the color grading effect is enabled.
  8338. */
  8339. get colorGradingEnabled(): boolean;
  8340. /**
  8341. * Sets wether the color grading effect is enabled.
  8342. */
  8343. set colorGradingEnabled(value: boolean);
  8344. private _colorGradingWithGreenDepth;
  8345. /**
  8346. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8347. */
  8348. get colorGradingWithGreenDepth(): boolean;
  8349. /**
  8350. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8351. */
  8352. set colorGradingWithGreenDepth(value: boolean);
  8353. private _colorGradingBGR;
  8354. /**
  8355. * Gets wether the color grading texture contains BGR values.
  8356. */
  8357. get colorGradingBGR(): boolean;
  8358. /**
  8359. * Sets wether the color grading texture contains BGR values.
  8360. */
  8361. set colorGradingBGR(value: boolean);
  8362. /** @hidden */
  8363. _exposure: number;
  8364. /**
  8365. * Gets the Exposure used in the effect.
  8366. */
  8367. get exposure(): number;
  8368. /**
  8369. * Sets the Exposure used in the effect.
  8370. */
  8371. set exposure(value: number);
  8372. private _toneMappingEnabled;
  8373. /**
  8374. * Gets wether the tone mapping effect is enabled.
  8375. */
  8376. get toneMappingEnabled(): boolean;
  8377. /**
  8378. * Sets wether the tone mapping effect is enabled.
  8379. */
  8380. set toneMappingEnabled(value: boolean);
  8381. private _toneMappingType;
  8382. /**
  8383. * Gets the type of tone mapping effect.
  8384. */
  8385. get toneMappingType(): number;
  8386. /**
  8387. * Sets the type of tone mapping effect used in BabylonJS.
  8388. */
  8389. set toneMappingType(value: number);
  8390. protected _contrast: number;
  8391. /**
  8392. * Gets the contrast used in the effect.
  8393. */
  8394. get contrast(): number;
  8395. /**
  8396. * Sets the contrast used in the effect.
  8397. */
  8398. set contrast(value: number);
  8399. /**
  8400. * Vignette stretch size.
  8401. */
  8402. vignetteStretch: number;
  8403. /**
  8404. * Vignette centre X Offset.
  8405. */
  8406. vignetteCentreX: number;
  8407. /**
  8408. * Vignette centre Y Offset.
  8409. */
  8410. vignetteCentreY: number;
  8411. /**
  8412. * Vignette weight or intensity of the vignette effect.
  8413. */
  8414. vignetteWeight: number;
  8415. /**
  8416. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8417. * if vignetteEnabled is set to true.
  8418. */
  8419. vignetteColor: Color4;
  8420. /**
  8421. * Camera field of view used by the Vignette effect.
  8422. */
  8423. vignetteCameraFov: number;
  8424. private _vignetteBlendMode;
  8425. /**
  8426. * Gets the vignette blend mode allowing different kind of effect.
  8427. */
  8428. get vignetteBlendMode(): number;
  8429. /**
  8430. * Sets the vignette blend mode allowing different kind of effect.
  8431. */
  8432. set vignetteBlendMode(value: number);
  8433. private _vignetteEnabled;
  8434. /**
  8435. * Gets wether the vignette effect is enabled.
  8436. */
  8437. get vignetteEnabled(): boolean;
  8438. /**
  8439. * Sets wether the vignette effect is enabled.
  8440. */
  8441. set vignetteEnabled(value: boolean);
  8442. private _applyByPostProcess;
  8443. /**
  8444. * Gets wether the image processing is applied through a post process or not.
  8445. */
  8446. get applyByPostProcess(): boolean;
  8447. /**
  8448. * Sets wether the image processing is applied through a post process or not.
  8449. */
  8450. set applyByPostProcess(value: boolean);
  8451. private _isEnabled;
  8452. /**
  8453. * Gets wether the image processing is enabled or not.
  8454. */
  8455. get isEnabled(): boolean;
  8456. /**
  8457. * Sets wether the image processing is enabled or not.
  8458. */
  8459. set isEnabled(value: boolean);
  8460. /**
  8461. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8462. */
  8463. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8464. /**
  8465. * Method called each time the image processing information changes requires to recompile the effect.
  8466. */
  8467. protected _updateParameters(): void;
  8468. /**
  8469. * Gets the current class name.
  8470. * @return "ImageProcessingConfiguration"
  8471. */
  8472. getClassName(): string;
  8473. /**
  8474. * Prepare the list of uniforms associated with the Image Processing effects.
  8475. * @param uniforms The list of uniforms used in the effect
  8476. * @param defines the list of defines currently in use
  8477. */
  8478. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8479. /**
  8480. * Prepare the list of samplers associated with the Image Processing effects.
  8481. * @param samplersList The list of uniforms used in the effect
  8482. * @param defines the list of defines currently in use
  8483. */
  8484. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8485. /**
  8486. * Prepare the list of defines associated to the shader.
  8487. * @param defines the list of defines to complete
  8488. * @param forPostProcess Define if we are currently in post process mode or not
  8489. */
  8490. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8491. /**
  8492. * Returns true if all the image processing information are ready.
  8493. * @returns True if ready, otherwise, false
  8494. */
  8495. isReady(): boolean;
  8496. /**
  8497. * Binds the image processing to the shader.
  8498. * @param effect The effect to bind to
  8499. * @param overrideAspectRatio Override the aspect ratio of the effect
  8500. */
  8501. bind(effect: Effect, overrideAspectRatio?: number): void;
  8502. /**
  8503. * Clones the current image processing instance.
  8504. * @return The cloned image processing
  8505. */
  8506. clone(): ImageProcessingConfiguration;
  8507. /**
  8508. * Serializes the current image processing instance to a json representation.
  8509. * @return a JSON representation
  8510. */
  8511. serialize(): any;
  8512. /**
  8513. * Parses the image processing from a json representation.
  8514. * @param source the JSON source to parse
  8515. * @return The parsed image processing
  8516. */
  8517. static Parse(source: any): ImageProcessingConfiguration;
  8518. private static _VIGNETTEMODE_MULTIPLY;
  8519. private static _VIGNETTEMODE_OPAQUE;
  8520. /**
  8521. * Used to apply the vignette as a mix with the pixel color.
  8522. */
  8523. static get VIGNETTEMODE_MULTIPLY(): number;
  8524. /**
  8525. * Used to apply the vignette as a replacement of the pixel color.
  8526. */
  8527. static get VIGNETTEMODE_OPAQUE(): number;
  8528. }
  8529. }
  8530. declare module "babylonjs/Shaders/postprocess.vertex" {
  8531. /** @hidden */
  8532. export var postprocessVertexShader: {
  8533. name: string;
  8534. shader: string;
  8535. };
  8536. }
  8537. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8538. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8539. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8540. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8541. module "babylonjs/Engines/thinEngine" {
  8542. interface ThinEngine {
  8543. /**
  8544. * Creates a new render target texture
  8545. * @param size defines the size of the texture
  8546. * @param options defines the options used to create the texture
  8547. * @returns a new render target texture stored in an InternalTexture
  8548. */
  8549. createRenderTargetTexture(size: number | {
  8550. width: number;
  8551. height: number;
  8552. layers?: number;
  8553. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8554. /**
  8555. * Creates a depth stencil texture.
  8556. * This is only available in WebGL 2 or with the depth texture extension available.
  8557. * @param size The size of face edge in the texture.
  8558. * @param options The options defining the texture.
  8559. * @returns The texture
  8560. */
  8561. createDepthStencilTexture(size: number | {
  8562. width: number;
  8563. height: number;
  8564. layers?: number;
  8565. }, options: DepthTextureCreationOptions): InternalTexture;
  8566. /** @hidden */
  8567. _createDepthStencilTexture(size: number | {
  8568. width: number;
  8569. height: number;
  8570. layers?: number;
  8571. }, options: DepthTextureCreationOptions): InternalTexture;
  8572. }
  8573. }
  8574. }
  8575. declare module "babylonjs/Maths/math.axis" {
  8576. import { Vector3 } from "babylonjs/Maths/math.vector";
  8577. /** Defines supported spaces */
  8578. export enum Space {
  8579. /** Local (object) space */
  8580. LOCAL = 0,
  8581. /** World space */
  8582. WORLD = 1,
  8583. /** Bone space */
  8584. BONE = 2
  8585. }
  8586. /** Defines the 3 main axes */
  8587. export class Axis {
  8588. /** X axis */
  8589. static X: Vector3;
  8590. /** Y axis */
  8591. static Y: Vector3;
  8592. /** Z axis */
  8593. static Z: Vector3;
  8594. }
  8595. }
  8596. declare module "babylonjs/Cameras/targetCamera" {
  8597. import { Nullable } from "babylonjs/types";
  8598. import { Camera } from "babylonjs/Cameras/camera";
  8599. import { Scene } from "babylonjs/scene";
  8600. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8601. /**
  8602. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8603. * This is the base of the follow, arc rotate cameras and Free camera
  8604. * @see http://doc.babylonjs.com/features/cameras
  8605. */
  8606. export class TargetCamera extends Camera {
  8607. private static _RigCamTransformMatrix;
  8608. private static _TargetTransformMatrix;
  8609. private static _TargetFocalPoint;
  8610. /**
  8611. * Define the current direction the camera is moving to
  8612. */
  8613. cameraDirection: Vector3;
  8614. /**
  8615. * Define the current rotation the camera is rotating to
  8616. */
  8617. cameraRotation: Vector2;
  8618. /**
  8619. * When set, the up vector of the camera will be updated by the rotation of the camera
  8620. */
  8621. updateUpVectorFromRotation: boolean;
  8622. private _tmpQuaternion;
  8623. /**
  8624. * Define the current rotation of the camera
  8625. */
  8626. rotation: Vector3;
  8627. /**
  8628. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8629. */
  8630. rotationQuaternion: Quaternion;
  8631. /**
  8632. * Define the current speed of the camera
  8633. */
  8634. speed: number;
  8635. /**
  8636. * Add constraint to the camera to prevent it to move freely in all directions and
  8637. * around all axis.
  8638. */
  8639. noRotationConstraint: boolean;
  8640. /**
  8641. * Define the current target of the camera as an object or a position.
  8642. */
  8643. lockedTarget: any;
  8644. /** @hidden */
  8645. _currentTarget: Vector3;
  8646. /** @hidden */
  8647. _initialFocalDistance: number;
  8648. /** @hidden */
  8649. _viewMatrix: Matrix;
  8650. /** @hidden */
  8651. _camMatrix: Matrix;
  8652. /** @hidden */
  8653. _cameraTransformMatrix: Matrix;
  8654. /** @hidden */
  8655. _cameraRotationMatrix: Matrix;
  8656. /** @hidden */
  8657. _referencePoint: Vector3;
  8658. /** @hidden */
  8659. _transformedReferencePoint: Vector3;
  8660. protected _globalCurrentTarget: Vector3;
  8661. protected _globalCurrentUpVector: Vector3;
  8662. /** @hidden */
  8663. _reset: () => void;
  8664. private _defaultUp;
  8665. /**
  8666. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8667. * This is the base of the follow, arc rotate cameras and Free camera
  8668. * @see http://doc.babylonjs.com/features/cameras
  8669. * @param name Defines the name of the camera in the scene
  8670. * @param position Defines the start position of the camera in the scene
  8671. * @param scene Defines the scene the camera belongs to
  8672. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8673. */
  8674. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8675. /**
  8676. * Gets the position in front of the camera at a given distance.
  8677. * @param distance The distance from the camera we want the position to be
  8678. * @returns the position
  8679. */
  8680. getFrontPosition(distance: number): Vector3;
  8681. /** @hidden */
  8682. _getLockedTargetPosition(): Nullable<Vector3>;
  8683. private _storedPosition;
  8684. private _storedRotation;
  8685. private _storedRotationQuaternion;
  8686. /**
  8687. * Store current camera state of the camera (fov, position, rotation, etc..)
  8688. * @returns the camera
  8689. */
  8690. storeState(): Camera;
  8691. /**
  8692. * Restored camera state. You must call storeState() first
  8693. * @returns whether it was successful or not
  8694. * @hidden
  8695. */
  8696. _restoreStateValues(): boolean;
  8697. /** @hidden */
  8698. _initCache(): void;
  8699. /** @hidden */
  8700. _updateCache(ignoreParentClass?: boolean): void;
  8701. /** @hidden */
  8702. _isSynchronizedViewMatrix(): boolean;
  8703. /** @hidden */
  8704. _computeLocalCameraSpeed(): number;
  8705. /**
  8706. * Defines the target the camera should look at.
  8707. * @param target Defines the new target as a Vector or a mesh
  8708. */
  8709. setTarget(target: Vector3): void;
  8710. /**
  8711. * Return the current target position of the camera. This value is expressed in local space.
  8712. * @returns the target position
  8713. */
  8714. getTarget(): Vector3;
  8715. /** @hidden */
  8716. _decideIfNeedsToMove(): boolean;
  8717. /** @hidden */
  8718. _updatePosition(): void;
  8719. /** @hidden */
  8720. _checkInputs(): void;
  8721. protected _updateCameraRotationMatrix(): void;
  8722. /**
  8723. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8724. * @returns the current camera
  8725. */
  8726. private _rotateUpVectorWithCameraRotationMatrix;
  8727. private _cachedRotationZ;
  8728. private _cachedQuaternionRotationZ;
  8729. /** @hidden */
  8730. _getViewMatrix(): Matrix;
  8731. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8732. /**
  8733. * @hidden
  8734. */
  8735. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8736. /**
  8737. * @hidden
  8738. */
  8739. _updateRigCameras(): void;
  8740. private _getRigCamPositionAndTarget;
  8741. /**
  8742. * Gets the current object class name.
  8743. * @return the class name
  8744. */
  8745. getClassName(): string;
  8746. }
  8747. }
  8748. declare module "babylonjs/Events/keyboardEvents" {
  8749. /**
  8750. * Gather the list of keyboard event types as constants.
  8751. */
  8752. export class KeyboardEventTypes {
  8753. /**
  8754. * The keydown event is fired when a key becomes active (pressed).
  8755. */
  8756. static readonly KEYDOWN: number;
  8757. /**
  8758. * The keyup event is fired when a key has been released.
  8759. */
  8760. static readonly KEYUP: number;
  8761. }
  8762. /**
  8763. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8764. */
  8765. export class KeyboardInfo {
  8766. /**
  8767. * Defines the type of event (KeyboardEventTypes)
  8768. */
  8769. type: number;
  8770. /**
  8771. * Defines the related dom event
  8772. */
  8773. event: KeyboardEvent;
  8774. /**
  8775. * Instantiates a new keyboard info.
  8776. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8777. * @param type Defines the type of event (KeyboardEventTypes)
  8778. * @param event Defines the related dom event
  8779. */
  8780. constructor(
  8781. /**
  8782. * Defines the type of event (KeyboardEventTypes)
  8783. */
  8784. type: number,
  8785. /**
  8786. * Defines the related dom event
  8787. */
  8788. event: KeyboardEvent);
  8789. }
  8790. /**
  8791. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8792. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8793. */
  8794. export class KeyboardInfoPre extends KeyboardInfo {
  8795. /**
  8796. * Defines the type of event (KeyboardEventTypes)
  8797. */
  8798. type: number;
  8799. /**
  8800. * Defines the related dom event
  8801. */
  8802. event: KeyboardEvent;
  8803. /**
  8804. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8805. */
  8806. skipOnPointerObservable: boolean;
  8807. /**
  8808. * Instantiates a new keyboard pre info.
  8809. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8810. * @param type Defines the type of event (KeyboardEventTypes)
  8811. * @param event Defines the related dom event
  8812. */
  8813. constructor(
  8814. /**
  8815. * Defines the type of event (KeyboardEventTypes)
  8816. */
  8817. type: number,
  8818. /**
  8819. * Defines the related dom event
  8820. */
  8821. event: KeyboardEvent);
  8822. }
  8823. }
  8824. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8825. import { Nullable } from "babylonjs/types";
  8826. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8827. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8828. /**
  8829. * Manage the keyboard inputs to control the movement of a free camera.
  8830. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8831. */
  8832. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8833. /**
  8834. * Defines the camera the input is attached to.
  8835. */
  8836. camera: FreeCamera;
  8837. /**
  8838. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8839. */
  8840. keysUp: number[];
  8841. /**
  8842. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8843. */
  8844. keysDown: number[];
  8845. /**
  8846. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8847. */
  8848. keysLeft: number[];
  8849. /**
  8850. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8851. */
  8852. keysRight: number[];
  8853. private _keys;
  8854. private _onCanvasBlurObserver;
  8855. private _onKeyboardObserver;
  8856. private _engine;
  8857. private _scene;
  8858. /**
  8859. * Attach the input controls to a specific dom element to get the input from.
  8860. * @param element Defines the element the controls should be listened from
  8861. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8862. */
  8863. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8864. /**
  8865. * Detach the current controls from the specified dom element.
  8866. * @param element Defines the element to stop listening the inputs from
  8867. */
  8868. detachControl(element: Nullable<HTMLElement>): void;
  8869. /**
  8870. * Update the current camera state depending on the inputs that have been used this frame.
  8871. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8872. */
  8873. checkInputs(): void;
  8874. /**
  8875. * Gets the class name of the current intput.
  8876. * @returns the class name
  8877. */
  8878. getClassName(): string;
  8879. /** @hidden */
  8880. _onLostFocus(): void;
  8881. /**
  8882. * Get the friendly name associated with the input class.
  8883. * @returns the input friendly name
  8884. */
  8885. getSimpleName(): string;
  8886. }
  8887. }
  8888. declare module "babylonjs/Lights/shadowLight" {
  8889. import { Camera } from "babylonjs/Cameras/camera";
  8890. import { Scene } from "babylonjs/scene";
  8891. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8893. import { Light } from "babylonjs/Lights/light";
  8894. /**
  8895. * Interface describing all the common properties and methods a shadow light needs to implement.
  8896. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8897. * as well as binding the different shadow properties to the effects.
  8898. */
  8899. export interface IShadowLight extends Light {
  8900. /**
  8901. * The light id in the scene (used in scene.findLighById for instance)
  8902. */
  8903. id: string;
  8904. /**
  8905. * The position the shdow will be casted from.
  8906. */
  8907. position: Vector3;
  8908. /**
  8909. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8910. */
  8911. direction: Vector3;
  8912. /**
  8913. * The transformed position. Position of the light in world space taking parenting in account.
  8914. */
  8915. transformedPosition: Vector3;
  8916. /**
  8917. * The transformed direction. Direction of the light in world space taking parenting in account.
  8918. */
  8919. transformedDirection: Vector3;
  8920. /**
  8921. * The friendly name of the light in the scene.
  8922. */
  8923. name: string;
  8924. /**
  8925. * Defines the shadow projection clipping minimum z value.
  8926. */
  8927. shadowMinZ: number;
  8928. /**
  8929. * Defines the shadow projection clipping maximum z value.
  8930. */
  8931. shadowMaxZ: number;
  8932. /**
  8933. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8934. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8935. */
  8936. computeTransformedInformation(): boolean;
  8937. /**
  8938. * Gets the scene the light belongs to.
  8939. * @returns The scene
  8940. */
  8941. getScene(): Scene;
  8942. /**
  8943. * Callback defining a custom Projection Matrix Builder.
  8944. * This can be used to override the default projection matrix computation.
  8945. */
  8946. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8947. /**
  8948. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8949. * @param matrix The materix to updated with the projection information
  8950. * @param viewMatrix The transform matrix of the light
  8951. * @param renderList The list of mesh to render in the map
  8952. * @returns The current light
  8953. */
  8954. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8955. /**
  8956. * Gets the current depth scale used in ESM.
  8957. * @returns The scale
  8958. */
  8959. getDepthScale(): number;
  8960. /**
  8961. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8962. * @returns true if a cube texture needs to be use
  8963. */
  8964. needCube(): boolean;
  8965. /**
  8966. * Detects if the projection matrix requires to be recomputed this frame.
  8967. * @returns true if it requires to be recomputed otherwise, false.
  8968. */
  8969. needProjectionMatrixCompute(): boolean;
  8970. /**
  8971. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8972. */
  8973. forceProjectionMatrixCompute(): void;
  8974. /**
  8975. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8976. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8977. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8978. */
  8979. getShadowDirection(faceIndex?: number): Vector3;
  8980. /**
  8981. * Gets the minZ used for shadow according to both the scene and the light.
  8982. * @param activeCamera The camera we are returning the min for
  8983. * @returns the depth min z
  8984. */
  8985. getDepthMinZ(activeCamera: Camera): number;
  8986. /**
  8987. * Gets the maxZ used for shadow according to both the scene and the light.
  8988. * @param activeCamera The camera we are returning the max for
  8989. * @returns the depth max z
  8990. */
  8991. getDepthMaxZ(activeCamera: Camera): number;
  8992. }
  8993. /**
  8994. * Base implementation IShadowLight
  8995. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8996. */
  8997. export abstract class ShadowLight extends Light implements IShadowLight {
  8998. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8999. protected _position: Vector3;
  9000. protected _setPosition(value: Vector3): void;
  9001. /**
  9002. * Sets the position the shadow will be casted from. Also use as the light position for both
  9003. * point and spot lights.
  9004. */
  9005. get position(): Vector3;
  9006. /**
  9007. * Sets the position the shadow will be casted from. Also use as the light position for both
  9008. * point and spot lights.
  9009. */
  9010. set position(value: Vector3);
  9011. protected _direction: Vector3;
  9012. protected _setDirection(value: Vector3): void;
  9013. /**
  9014. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9015. * Also use as the light direction on spot and directional lights.
  9016. */
  9017. get direction(): Vector3;
  9018. /**
  9019. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9020. * Also use as the light direction on spot and directional lights.
  9021. */
  9022. set direction(value: Vector3);
  9023. protected _shadowMinZ: number;
  9024. /**
  9025. * Gets the shadow projection clipping minimum z value.
  9026. */
  9027. get shadowMinZ(): number;
  9028. /**
  9029. * Sets the shadow projection clipping minimum z value.
  9030. */
  9031. set shadowMinZ(value: number);
  9032. protected _shadowMaxZ: number;
  9033. /**
  9034. * Sets the shadow projection clipping maximum z value.
  9035. */
  9036. get shadowMaxZ(): number;
  9037. /**
  9038. * Gets the shadow projection clipping maximum z value.
  9039. */
  9040. set shadowMaxZ(value: number);
  9041. /**
  9042. * Callback defining a custom Projection Matrix Builder.
  9043. * This can be used to override the default projection matrix computation.
  9044. */
  9045. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9046. /**
  9047. * The transformed position. Position of the light in world space taking parenting in account.
  9048. */
  9049. transformedPosition: Vector3;
  9050. /**
  9051. * The transformed direction. Direction of the light in world space taking parenting in account.
  9052. */
  9053. transformedDirection: Vector3;
  9054. private _needProjectionMatrixCompute;
  9055. /**
  9056. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9057. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9058. */
  9059. computeTransformedInformation(): boolean;
  9060. /**
  9061. * Return the depth scale used for the shadow map.
  9062. * @returns the depth scale.
  9063. */
  9064. getDepthScale(): number;
  9065. /**
  9066. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9067. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9068. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9069. */
  9070. getShadowDirection(faceIndex?: number): Vector3;
  9071. /**
  9072. * Returns the ShadowLight absolute position in the World.
  9073. * @returns the position vector in world space
  9074. */
  9075. getAbsolutePosition(): Vector3;
  9076. /**
  9077. * Sets the ShadowLight direction toward the passed target.
  9078. * @param target The point to target in local space
  9079. * @returns the updated ShadowLight direction
  9080. */
  9081. setDirectionToTarget(target: Vector3): Vector3;
  9082. /**
  9083. * Returns the light rotation in euler definition.
  9084. * @returns the x y z rotation in local space.
  9085. */
  9086. getRotation(): Vector3;
  9087. /**
  9088. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9089. * @returns true if a cube texture needs to be use
  9090. */
  9091. needCube(): boolean;
  9092. /**
  9093. * Detects if the projection matrix requires to be recomputed this frame.
  9094. * @returns true if it requires to be recomputed otherwise, false.
  9095. */
  9096. needProjectionMatrixCompute(): boolean;
  9097. /**
  9098. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9099. */
  9100. forceProjectionMatrixCompute(): void;
  9101. /** @hidden */
  9102. _initCache(): void;
  9103. /** @hidden */
  9104. _isSynchronized(): boolean;
  9105. /**
  9106. * Computes the world matrix of the node
  9107. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9108. * @returns the world matrix
  9109. */
  9110. computeWorldMatrix(force?: boolean): Matrix;
  9111. /**
  9112. * Gets the minZ used for shadow according to both the scene and the light.
  9113. * @param activeCamera The camera we are returning the min for
  9114. * @returns the depth min z
  9115. */
  9116. getDepthMinZ(activeCamera: Camera): number;
  9117. /**
  9118. * Gets the maxZ used for shadow according to both the scene and the light.
  9119. * @param activeCamera The camera we are returning the max for
  9120. * @returns the depth max z
  9121. */
  9122. getDepthMaxZ(activeCamera: Camera): number;
  9123. /**
  9124. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9125. * @param matrix The materix to updated with the projection information
  9126. * @param viewMatrix The transform matrix of the light
  9127. * @param renderList The list of mesh to render in the map
  9128. * @returns The current light
  9129. */
  9130. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9131. }
  9132. }
  9133. declare module "babylonjs/Materials/effectFallbacks" {
  9134. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9135. import { Effect } from "babylonjs/Materials/effect";
  9136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9137. /**
  9138. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9139. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9140. */
  9141. export class EffectFallbacks implements IEffectFallbacks {
  9142. private _defines;
  9143. private _currentRank;
  9144. private _maxRank;
  9145. private _mesh;
  9146. /**
  9147. * Removes the fallback from the bound mesh.
  9148. */
  9149. unBindMesh(): void;
  9150. /**
  9151. * Adds a fallback on the specified property.
  9152. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9153. * @param define The name of the define in the shader
  9154. */
  9155. addFallback(rank: number, define: string): void;
  9156. /**
  9157. * Sets the mesh to use CPU skinning when needing to fallback.
  9158. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9159. * @param mesh The mesh to use the fallbacks.
  9160. */
  9161. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9162. /**
  9163. * Checks to see if more fallbacks are still availible.
  9164. */
  9165. get hasMoreFallbacks(): boolean;
  9166. /**
  9167. * Removes the defines that should be removed when falling back.
  9168. * @param currentDefines defines the current define statements for the shader.
  9169. * @param effect defines the current effect we try to compile
  9170. * @returns The resulting defines with defines of the current rank removed.
  9171. */
  9172. reduce(currentDefines: string, effect: Effect): string;
  9173. }
  9174. }
  9175. declare module "babylonjs/Materials/materialHelper" {
  9176. import { Nullable } from "babylonjs/types";
  9177. import { Scene } from "babylonjs/scene";
  9178. import { Engine } from "babylonjs/Engines/engine";
  9179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9180. import { Light } from "babylonjs/Lights/light";
  9181. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9182. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9183. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9184. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9185. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9186. /**
  9187. * "Static Class" containing the most commonly used helper while dealing with material for
  9188. * rendering purpose.
  9189. *
  9190. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9191. *
  9192. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9193. */
  9194. export class MaterialHelper {
  9195. /**
  9196. * Bind the current view position to an effect.
  9197. * @param effect The effect to be bound
  9198. * @param scene The scene the eyes position is used from
  9199. */
  9200. static BindEyePosition(effect: Effect, scene: Scene): void;
  9201. /**
  9202. * Helps preparing the defines values about the UVs in used in the effect.
  9203. * UVs are shared as much as we can accross channels in the shaders.
  9204. * @param texture The texture we are preparing the UVs for
  9205. * @param defines The defines to update
  9206. * @param key The channel key "diffuse", "specular"... used in the shader
  9207. */
  9208. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9209. /**
  9210. * Binds a texture matrix value to its corrsponding uniform
  9211. * @param texture The texture to bind the matrix for
  9212. * @param uniformBuffer The uniform buffer receivin the data
  9213. * @param key The channel key "diffuse", "specular"... used in the shader
  9214. */
  9215. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9216. /**
  9217. * Gets the current status of the fog (should it be enabled?)
  9218. * @param mesh defines the mesh to evaluate for fog support
  9219. * @param scene defines the hosting scene
  9220. * @returns true if fog must be enabled
  9221. */
  9222. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9223. /**
  9224. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9225. * @param mesh defines the current mesh
  9226. * @param scene defines the current scene
  9227. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9228. * @param pointsCloud defines if point cloud rendering has to be turned on
  9229. * @param fogEnabled defines if fog has to be turned on
  9230. * @param alphaTest defines if alpha testing has to be turned on
  9231. * @param defines defines the current list of defines
  9232. */
  9233. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9234. /**
  9235. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9236. * @param scene defines the current scene
  9237. * @param engine defines the current engine
  9238. * @param defines specifies the list of active defines
  9239. * @param useInstances defines if instances have to be turned on
  9240. * @param useClipPlane defines if clip plane have to be turned on
  9241. */
  9242. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9243. /**
  9244. * Prepares the defines for bones
  9245. * @param mesh The mesh containing the geometry data we will draw
  9246. * @param defines The defines to update
  9247. */
  9248. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9249. /**
  9250. * Prepares the defines for morph targets
  9251. * @param mesh The mesh containing the geometry data we will draw
  9252. * @param defines The defines to update
  9253. */
  9254. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9255. /**
  9256. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9257. * @param mesh The mesh containing the geometry data we will draw
  9258. * @param defines The defines to update
  9259. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9260. * @param useBones Precise whether bones should be used or not (override mesh info)
  9261. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9262. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9263. * @returns false if defines are considered not dirty and have not been checked
  9264. */
  9265. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9266. /**
  9267. * Prepares the defines related to multiview
  9268. * @param scene The scene we are intending to draw
  9269. * @param defines The defines to update
  9270. */
  9271. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9272. /**
  9273. * Prepares the defines related to the light information passed in parameter
  9274. * @param scene The scene we are intending to draw
  9275. * @param mesh The mesh the effect is compiling for
  9276. * @param light The light the effect is compiling for
  9277. * @param lightIndex The index of the light
  9278. * @param defines The defines to update
  9279. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9280. * @param state Defines the current state regarding what is needed (normals, etc...)
  9281. */
  9282. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9283. needNormals: boolean;
  9284. needRebuild: boolean;
  9285. shadowEnabled: boolean;
  9286. specularEnabled: boolean;
  9287. lightmapMode: boolean;
  9288. }): void;
  9289. /**
  9290. * Prepares the defines related to the light information passed in parameter
  9291. * @param scene The scene we are intending to draw
  9292. * @param mesh The mesh the effect is compiling for
  9293. * @param defines The defines to update
  9294. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9295. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9296. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9297. * @returns true if normals will be required for the rest of the effect
  9298. */
  9299. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9300. /**
  9301. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9302. * @param lightIndex defines the light index
  9303. * @param uniformsList The uniform list
  9304. * @param samplersList The sampler list
  9305. * @param projectedLightTexture defines if projected texture must be used
  9306. * @param uniformBuffersList defines an optional list of uniform buffers
  9307. */
  9308. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9309. /**
  9310. * Prepares the uniforms and samplers list to be used in the effect
  9311. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9312. * @param samplersList The sampler list
  9313. * @param defines The defines helping in the list generation
  9314. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9315. */
  9316. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9317. /**
  9318. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9319. * @param defines The defines to update while falling back
  9320. * @param fallbacks The authorized effect fallbacks
  9321. * @param maxSimultaneousLights The maximum number of lights allowed
  9322. * @param rank the current rank of the Effect
  9323. * @returns The newly affected rank
  9324. */
  9325. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9326. private static _TmpMorphInfluencers;
  9327. /**
  9328. * Prepares the list of attributes required for morph targets according to the effect defines.
  9329. * @param attribs The current list of supported attribs
  9330. * @param mesh The mesh to prepare the morph targets attributes for
  9331. * @param influencers The number of influencers
  9332. */
  9333. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9334. /**
  9335. * Prepares the list of attributes required for morph targets according to the effect defines.
  9336. * @param attribs The current list of supported attribs
  9337. * @param mesh The mesh to prepare the morph targets attributes for
  9338. * @param defines The current Defines of the effect
  9339. */
  9340. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9341. /**
  9342. * Prepares the list of attributes required for bones according to the effect defines.
  9343. * @param attribs The current list of supported attribs
  9344. * @param mesh The mesh to prepare the bones attributes for
  9345. * @param defines The current Defines of the effect
  9346. * @param fallbacks The current efffect fallback strategy
  9347. */
  9348. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9349. /**
  9350. * Check and prepare the list of attributes required for instances according to the effect defines.
  9351. * @param attribs The current list of supported attribs
  9352. * @param defines The current MaterialDefines of the effect
  9353. */
  9354. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9355. /**
  9356. * Add the list of attributes required for instances to the attribs array.
  9357. * @param attribs The current list of supported attribs
  9358. */
  9359. static PushAttributesForInstances(attribs: string[]): void;
  9360. /**
  9361. * Binds the light information to the effect.
  9362. * @param light The light containing the generator
  9363. * @param effect The effect we are binding the data to
  9364. * @param lightIndex The light index in the effect used to render
  9365. */
  9366. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9367. /**
  9368. * Binds the lights information from the scene to the effect for the given mesh.
  9369. * @param light Light to bind
  9370. * @param lightIndex Light index
  9371. * @param scene The scene where the light belongs to
  9372. * @param effect The effect we are binding the data to
  9373. * @param useSpecular Defines if specular is supported
  9374. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9375. */
  9376. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9377. /**
  9378. * Binds the lights information from the scene to the effect for the given mesh.
  9379. * @param scene The scene the lights belongs to
  9380. * @param mesh The mesh we are binding the information to render
  9381. * @param effect The effect we are binding the data to
  9382. * @param defines The generated defines for the effect
  9383. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9384. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9385. */
  9386. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9387. private static _tempFogColor;
  9388. /**
  9389. * Binds the fog information from the scene to the effect for the given mesh.
  9390. * @param scene The scene the lights belongs to
  9391. * @param mesh The mesh we are binding the information to render
  9392. * @param effect The effect we are binding the data to
  9393. * @param linearSpace Defines if the fog effect is applied in linear space
  9394. */
  9395. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9396. /**
  9397. * Binds the bones information from the mesh to the effect.
  9398. * @param mesh The mesh we are binding the information to render
  9399. * @param effect The effect we are binding the data to
  9400. */
  9401. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9402. /**
  9403. * Binds the morph targets information from the mesh to the effect.
  9404. * @param abstractMesh The mesh we are binding the information to render
  9405. * @param effect The effect we are binding the data to
  9406. */
  9407. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9408. /**
  9409. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9410. * @param defines The generated defines used in the effect
  9411. * @param effect The effect we are binding the data to
  9412. * @param scene The scene we are willing to render with logarithmic scale for
  9413. */
  9414. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9415. /**
  9416. * Binds the clip plane information from the scene to the effect.
  9417. * @param scene The scene the clip plane information are extracted from
  9418. * @param effect The effect we are binding the data to
  9419. */
  9420. static BindClipPlane(effect: Effect, scene: Scene): void;
  9421. }
  9422. }
  9423. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9424. /** @hidden */
  9425. export var packingFunctions: {
  9426. name: string;
  9427. shader: string;
  9428. };
  9429. }
  9430. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9431. /** @hidden */
  9432. export var clipPlaneFragmentDeclaration: {
  9433. name: string;
  9434. shader: string;
  9435. };
  9436. }
  9437. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9438. /** @hidden */
  9439. export var clipPlaneFragment: {
  9440. name: string;
  9441. shader: string;
  9442. };
  9443. }
  9444. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9445. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9446. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9447. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9448. /** @hidden */
  9449. export var shadowMapPixelShader: {
  9450. name: string;
  9451. shader: string;
  9452. };
  9453. }
  9454. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9455. /** @hidden */
  9456. export var bonesDeclaration: {
  9457. name: string;
  9458. shader: string;
  9459. };
  9460. }
  9461. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9462. /** @hidden */
  9463. export var morphTargetsVertexGlobalDeclaration: {
  9464. name: string;
  9465. shader: string;
  9466. };
  9467. }
  9468. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9469. /** @hidden */
  9470. export var morphTargetsVertexDeclaration: {
  9471. name: string;
  9472. shader: string;
  9473. };
  9474. }
  9475. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9476. /** @hidden */
  9477. export var instancesDeclaration: {
  9478. name: string;
  9479. shader: string;
  9480. };
  9481. }
  9482. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9483. /** @hidden */
  9484. export var helperFunctions: {
  9485. name: string;
  9486. shader: string;
  9487. };
  9488. }
  9489. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9490. /** @hidden */
  9491. export var clipPlaneVertexDeclaration: {
  9492. name: string;
  9493. shader: string;
  9494. };
  9495. }
  9496. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9497. /** @hidden */
  9498. export var morphTargetsVertex: {
  9499. name: string;
  9500. shader: string;
  9501. };
  9502. }
  9503. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9504. /** @hidden */
  9505. export var instancesVertex: {
  9506. name: string;
  9507. shader: string;
  9508. };
  9509. }
  9510. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9511. /** @hidden */
  9512. export var bonesVertex: {
  9513. name: string;
  9514. shader: string;
  9515. };
  9516. }
  9517. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9518. /** @hidden */
  9519. export var clipPlaneVertex: {
  9520. name: string;
  9521. shader: string;
  9522. };
  9523. }
  9524. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9525. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9526. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9527. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9528. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9529. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9530. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9531. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9532. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9533. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9534. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9535. /** @hidden */
  9536. export var shadowMapVertexShader: {
  9537. name: string;
  9538. shader: string;
  9539. };
  9540. }
  9541. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9542. /** @hidden */
  9543. export var depthBoxBlurPixelShader: {
  9544. name: string;
  9545. shader: string;
  9546. };
  9547. }
  9548. declare module "babylonjs/Culling/ray" {
  9549. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9550. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9551. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9552. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9553. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9554. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9555. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9556. import { Plane } from "babylonjs/Maths/math.plane";
  9557. /**
  9558. * Class representing a ray with position and direction
  9559. */
  9560. export class Ray {
  9561. /** origin point */
  9562. origin: Vector3;
  9563. /** direction */
  9564. direction: Vector3;
  9565. /** length of the ray */
  9566. length: number;
  9567. private static readonly TmpVector3;
  9568. private _tmpRay;
  9569. /**
  9570. * Creates a new ray
  9571. * @param origin origin point
  9572. * @param direction direction
  9573. * @param length length of the ray
  9574. */
  9575. constructor(
  9576. /** origin point */
  9577. origin: Vector3,
  9578. /** direction */
  9579. direction: Vector3,
  9580. /** length of the ray */
  9581. length?: number);
  9582. /**
  9583. * Checks if the ray intersects a box
  9584. * @param minimum bound of the box
  9585. * @param maximum bound of the box
  9586. * @param intersectionTreshold extra extend to be added to the box in all direction
  9587. * @returns if the box was hit
  9588. */
  9589. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9590. /**
  9591. * Checks if the ray intersects a box
  9592. * @param box the bounding box to check
  9593. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9594. * @returns if the box was hit
  9595. */
  9596. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9597. /**
  9598. * If the ray hits a sphere
  9599. * @param sphere the bounding sphere to check
  9600. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9601. * @returns true if it hits the sphere
  9602. */
  9603. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9604. /**
  9605. * If the ray hits a triange
  9606. * @param vertex0 triangle vertex
  9607. * @param vertex1 triangle vertex
  9608. * @param vertex2 triangle vertex
  9609. * @returns intersection information if hit
  9610. */
  9611. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9612. /**
  9613. * Checks if ray intersects a plane
  9614. * @param plane the plane to check
  9615. * @returns the distance away it was hit
  9616. */
  9617. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9618. /**
  9619. * Calculate the intercept of a ray on a given axis
  9620. * @param axis to check 'x' | 'y' | 'z'
  9621. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9622. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9623. */
  9624. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9625. /**
  9626. * Checks if ray intersects a mesh
  9627. * @param mesh the mesh to check
  9628. * @param fastCheck if only the bounding box should checked
  9629. * @returns picking info of the intersecton
  9630. */
  9631. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9632. /**
  9633. * Checks if ray intersects a mesh
  9634. * @param meshes the meshes to check
  9635. * @param fastCheck if only the bounding box should checked
  9636. * @param results array to store result in
  9637. * @returns Array of picking infos
  9638. */
  9639. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9640. private _comparePickingInfo;
  9641. private static smallnum;
  9642. private static rayl;
  9643. /**
  9644. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9645. * @param sega the first point of the segment to test the intersection against
  9646. * @param segb the second point of the segment to test the intersection against
  9647. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9648. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9649. */
  9650. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9651. /**
  9652. * Update the ray from viewport position
  9653. * @param x position
  9654. * @param y y position
  9655. * @param viewportWidth viewport width
  9656. * @param viewportHeight viewport height
  9657. * @param world world matrix
  9658. * @param view view matrix
  9659. * @param projection projection matrix
  9660. * @returns this ray updated
  9661. */
  9662. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9663. /**
  9664. * Creates a ray with origin and direction of 0,0,0
  9665. * @returns the new ray
  9666. */
  9667. static Zero(): Ray;
  9668. /**
  9669. * Creates a new ray from screen space and viewport
  9670. * @param x position
  9671. * @param y y position
  9672. * @param viewportWidth viewport width
  9673. * @param viewportHeight viewport height
  9674. * @param world world matrix
  9675. * @param view view matrix
  9676. * @param projection projection matrix
  9677. * @returns new ray
  9678. */
  9679. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9680. /**
  9681. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  9682. * transformed to the given world matrix.
  9683. * @param origin The origin point
  9684. * @param end The end point
  9685. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9686. * @returns the new ray
  9687. */
  9688. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9689. /**
  9690. * Transforms a ray by a matrix
  9691. * @param ray ray to transform
  9692. * @param matrix matrix to apply
  9693. * @returns the resulting new ray
  9694. */
  9695. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9696. /**
  9697. * Transforms a ray by a matrix
  9698. * @param ray ray to transform
  9699. * @param matrix matrix to apply
  9700. * @param result ray to store result in
  9701. */
  9702. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9703. /**
  9704. * Unproject a ray from screen space to object space
  9705. * @param sourceX defines the screen space x coordinate to use
  9706. * @param sourceY defines the screen space y coordinate to use
  9707. * @param viewportWidth defines the current width of the viewport
  9708. * @param viewportHeight defines the current height of the viewport
  9709. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9710. * @param view defines the view matrix to use
  9711. * @param projection defines the projection matrix to use
  9712. */
  9713. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9714. }
  9715. /**
  9716. * Type used to define predicate used to select faces when a mesh intersection is detected
  9717. */
  9718. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9719. module "babylonjs/scene" {
  9720. interface Scene {
  9721. /** @hidden */
  9722. _tempPickingRay: Nullable<Ray>;
  9723. /** @hidden */
  9724. _cachedRayForTransform: Ray;
  9725. /** @hidden */
  9726. _pickWithRayInverseMatrix: Matrix;
  9727. /** @hidden */
  9728. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9729. /** @hidden */
  9730. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9731. }
  9732. }
  9733. }
  9734. declare module "babylonjs/sceneComponent" {
  9735. import { Scene } from "babylonjs/scene";
  9736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9737. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9738. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9739. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9740. import { Nullable } from "babylonjs/types";
  9741. import { Camera } from "babylonjs/Cameras/camera";
  9742. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9743. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9744. import { AbstractScene } from "babylonjs/abstractScene";
  9745. import { Mesh } from "babylonjs/Meshes/mesh";
  9746. /**
  9747. * Groups all the scene component constants in one place to ease maintenance.
  9748. * @hidden
  9749. */
  9750. export class SceneComponentConstants {
  9751. static readonly NAME_EFFECTLAYER: string;
  9752. static readonly NAME_LAYER: string;
  9753. static readonly NAME_LENSFLARESYSTEM: string;
  9754. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9755. static readonly NAME_PARTICLESYSTEM: string;
  9756. static readonly NAME_GAMEPAD: string;
  9757. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9758. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9759. static readonly NAME_DEPTHRENDERER: string;
  9760. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9761. static readonly NAME_SPRITE: string;
  9762. static readonly NAME_OUTLINERENDERER: string;
  9763. static readonly NAME_PROCEDURALTEXTURE: string;
  9764. static readonly NAME_SHADOWGENERATOR: string;
  9765. static readonly NAME_OCTREE: string;
  9766. static readonly NAME_PHYSICSENGINE: string;
  9767. static readonly NAME_AUDIO: string;
  9768. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9769. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9770. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9771. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9772. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9773. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9774. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9775. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9776. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9777. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9778. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9779. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9780. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9781. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9782. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9783. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9784. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9785. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9786. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9787. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9788. static readonly STEP_AFTERRENDER_AUDIO: number;
  9789. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9790. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9791. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9792. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9793. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9794. static readonly STEP_POINTERMOVE_SPRITE: number;
  9795. static readonly STEP_POINTERDOWN_SPRITE: number;
  9796. static readonly STEP_POINTERUP_SPRITE: number;
  9797. }
  9798. /**
  9799. * This represents a scene component.
  9800. *
  9801. * This is used to decouple the dependency the scene is having on the different workloads like
  9802. * layers, post processes...
  9803. */
  9804. export interface ISceneComponent {
  9805. /**
  9806. * The name of the component. Each component must have a unique name.
  9807. */
  9808. name: string;
  9809. /**
  9810. * The scene the component belongs to.
  9811. */
  9812. scene: Scene;
  9813. /**
  9814. * Register the component to one instance of a scene.
  9815. */
  9816. register(): void;
  9817. /**
  9818. * Rebuilds the elements related to this component in case of
  9819. * context lost for instance.
  9820. */
  9821. rebuild(): void;
  9822. /**
  9823. * Disposes the component and the associated ressources.
  9824. */
  9825. dispose(): void;
  9826. }
  9827. /**
  9828. * This represents a SERIALIZABLE scene component.
  9829. *
  9830. * This extends Scene Component to add Serialization methods on top.
  9831. */
  9832. export interface ISceneSerializableComponent extends ISceneComponent {
  9833. /**
  9834. * Adds all the elements from the container to the scene
  9835. * @param container the container holding the elements
  9836. */
  9837. addFromContainer(container: AbstractScene): void;
  9838. /**
  9839. * Removes all the elements in the container from the scene
  9840. * @param container contains the elements to remove
  9841. * @param dispose if the removed element should be disposed (default: false)
  9842. */
  9843. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9844. /**
  9845. * Serializes the component data to the specified json object
  9846. * @param serializationObject The object to serialize to
  9847. */
  9848. serialize(serializationObject: any): void;
  9849. }
  9850. /**
  9851. * Strong typing of a Mesh related stage step action
  9852. */
  9853. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9854. /**
  9855. * Strong typing of a Evaluate Sub Mesh related stage step action
  9856. */
  9857. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9858. /**
  9859. * Strong typing of a Active Mesh related stage step action
  9860. */
  9861. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9862. /**
  9863. * Strong typing of a Camera related stage step action
  9864. */
  9865. export type CameraStageAction = (camera: Camera) => void;
  9866. /**
  9867. * Strong typing of a Camera Frame buffer related stage step action
  9868. */
  9869. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9870. /**
  9871. * Strong typing of a Render Target related stage step action
  9872. */
  9873. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9874. /**
  9875. * Strong typing of a RenderingGroup related stage step action
  9876. */
  9877. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9878. /**
  9879. * Strong typing of a Mesh Render related stage step action
  9880. */
  9881. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9882. /**
  9883. * Strong typing of a simple stage step action
  9884. */
  9885. export type SimpleStageAction = () => void;
  9886. /**
  9887. * Strong typing of a render target action.
  9888. */
  9889. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9890. /**
  9891. * Strong typing of a pointer move action.
  9892. */
  9893. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9894. /**
  9895. * Strong typing of a pointer up/down action.
  9896. */
  9897. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9898. /**
  9899. * Representation of a stage in the scene (Basically a list of ordered steps)
  9900. * @hidden
  9901. */
  9902. export class Stage<T extends Function> extends Array<{
  9903. index: number;
  9904. component: ISceneComponent;
  9905. action: T;
  9906. }> {
  9907. /**
  9908. * Hide ctor from the rest of the world.
  9909. * @param items The items to add.
  9910. */
  9911. private constructor();
  9912. /**
  9913. * Creates a new Stage.
  9914. * @returns A new instance of a Stage
  9915. */
  9916. static Create<T extends Function>(): Stage<T>;
  9917. /**
  9918. * Registers a step in an ordered way in the targeted stage.
  9919. * @param index Defines the position to register the step in
  9920. * @param component Defines the component attached to the step
  9921. * @param action Defines the action to launch during the step
  9922. */
  9923. registerStep(index: number, component: ISceneComponent, action: T): void;
  9924. /**
  9925. * Clears all the steps from the stage.
  9926. */
  9927. clear(): void;
  9928. }
  9929. }
  9930. declare module "babylonjs/Sprites/spriteSceneComponent" {
  9931. import { Nullable } from "babylonjs/types";
  9932. import { Observable } from "babylonjs/Misc/observable";
  9933. import { Scene } from "babylonjs/scene";
  9934. import { Sprite } from "babylonjs/Sprites/sprite";
  9935. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  9936. import { Ray } from "babylonjs/Culling/ray";
  9937. import { Camera } from "babylonjs/Cameras/camera";
  9938. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9939. import { ISceneComponent } from "babylonjs/sceneComponent";
  9940. module "babylonjs/scene" {
  9941. interface Scene {
  9942. /** @hidden */
  9943. _pointerOverSprite: Nullable<Sprite>;
  9944. /** @hidden */
  9945. _pickedDownSprite: Nullable<Sprite>;
  9946. /** @hidden */
  9947. _tempSpritePickingRay: Nullable<Ray>;
  9948. /**
  9949. * All of the sprite managers added to this scene
  9950. * @see http://doc.babylonjs.com/babylon101/sprites
  9951. */
  9952. spriteManagers: Array<ISpriteManager>;
  9953. /**
  9954. * An event triggered when sprites rendering is about to start
  9955. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9956. */
  9957. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9958. /**
  9959. * An event triggered when sprites rendering is done
  9960. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9961. */
  9962. onAfterSpritesRenderingObservable: Observable<Scene>;
  9963. /** @hidden */
  9964. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9965. /** Launch a ray to try to pick a sprite in the scene
  9966. * @param x position on screen
  9967. * @param y position on screen
  9968. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9969. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9970. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9971. * @returns a PickingInfo
  9972. */
  9973. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9974. /** Use the given ray to pick a sprite in the scene
  9975. * @param ray The ray (in world space) to use to pick meshes
  9976. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9977. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9978. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9979. * @returns a PickingInfo
  9980. */
  9981. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9982. /** @hidden */
  9983. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9984. /** Launch a ray to try to pick sprites in the scene
  9985. * @param x position on screen
  9986. * @param y position on screen
  9987. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9988. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9989. * @returns a PickingInfo array
  9990. */
  9991. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9992. /** Use the given ray to pick sprites in the scene
  9993. * @param ray The ray (in world space) to use to pick meshes
  9994. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9995. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9996. * @returns a PickingInfo array
  9997. */
  9998. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  9999. /**
  10000. * Force the sprite under the pointer
  10001. * @param sprite defines the sprite to use
  10002. */
  10003. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10004. /**
  10005. * Gets the sprite under the pointer
  10006. * @returns a Sprite or null if no sprite is under the pointer
  10007. */
  10008. getPointerOverSprite(): Nullable<Sprite>;
  10009. }
  10010. }
  10011. /**
  10012. * Defines the sprite scene component responsible to manage sprites
  10013. * in a given scene.
  10014. */
  10015. export class SpriteSceneComponent implements ISceneComponent {
  10016. /**
  10017. * The component name helpfull to identify the component in the list of scene components.
  10018. */
  10019. readonly name: string;
  10020. /**
  10021. * The scene the component belongs to.
  10022. */
  10023. scene: Scene;
  10024. /** @hidden */
  10025. private _spritePredicate;
  10026. /**
  10027. * Creates a new instance of the component for the given scene
  10028. * @param scene Defines the scene to register the component in
  10029. */
  10030. constructor(scene: Scene);
  10031. /**
  10032. * Registers the component in a given scene
  10033. */
  10034. register(): void;
  10035. /**
  10036. * Rebuilds the elements related to this component in case of
  10037. * context lost for instance.
  10038. */
  10039. rebuild(): void;
  10040. /**
  10041. * Disposes the component and the associated ressources.
  10042. */
  10043. dispose(): void;
  10044. private _pickSpriteButKeepRay;
  10045. private _pointerMove;
  10046. private _pointerDown;
  10047. private _pointerUp;
  10048. }
  10049. }
  10050. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10051. /** @hidden */
  10052. export var fogFragmentDeclaration: {
  10053. name: string;
  10054. shader: string;
  10055. };
  10056. }
  10057. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10058. /** @hidden */
  10059. export var fogFragment: {
  10060. name: string;
  10061. shader: string;
  10062. };
  10063. }
  10064. declare module "babylonjs/Shaders/sprites.fragment" {
  10065. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10066. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10067. /** @hidden */
  10068. export var spritesPixelShader: {
  10069. name: string;
  10070. shader: string;
  10071. };
  10072. }
  10073. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10074. /** @hidden */
  10075. export var fogVertexDeclaration: {
  10076. name: string;
  10077. shader: string;
  10078. };
  10079. }
  10080. declare module "babylonjs/Shaders/sprites.vertex" {
  10081. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10082. /** @hidden */
  10083. export var spritesVertexShader: {
  10084. name: string;
  10085. shader: string;
  10086. };
  10087. }
  10088. declare module "babylonjs/Sprites/spriteManager" {
  10089. import { IDisposable, Scene } from "babylonjs/scene";
  10090. import { Nullable } from "babylonjs/types";
  10091. import { Observable } from "babylonjs/Misc/observable";
  10092. import { Sprite } from "babylonjs/Sprites/sprite";
  10093. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10094. import { Camera } from "babylonjs/Cameras/camera";
  10095. import { Texture } from "babylonjs/Materials/Textures/texture";
  10096. import "babylonjs/Shaders/sprites.fragment";
  10097. import "babylonjs/Shaders/sprites.vertex";
  10098. import { Ray } from "babylonjs/Culling/ray";
  10099. /**
  10100. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10101. */
  10102. export interface ISpriteManager extends IDisposable {
  10103. /**
  10104. * Restricts the camera to viewing objects with the same layerMask.
  10105. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10106. */
  10107. layerMask: number;
  10108. /**
  10109. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10110. */
  10111. isPickable: boolean;
  10112. /**
  10113. * Specifies the rendering group id for this mesh (0 by default)
  10114. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10115. */
  10116. renderingGroupId: number;
  10117. /**
  10118. * Defines the list of sprites managed by the manager.
  10119. */
  10120. sprites: Array<Sprite>;
  10121. /**
  10122. * Tests the intersection of a sprite with a specific ray.
  10123. * @param ray The ray we are sending to test the collision
  10124. * @param camera The camera space we are sending rays in
  10125. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10126. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10127. * @returns picking info or null.
  10128. */
  10129. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10130. /**
  10131. * Intersects the sprites with a ray
  10132. * @param ray defines the ray to intersect with
  10133. * @param camera defines the current active camera
  10134. * @param predicate defines a predicate used to select candidate sprites
  10135. * @returns null if no hit or a PickingInfo array
  10136. */
  10137. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10138. /**
  10139. * Renders the list of sprites on screen.
  10140. */
  10141. render(): void;
  10142. }
  10143. /**
  10144. * Class used to manage multiple sprites on the same spritesheet
  10145. * @see http://doc.babylonjs.com/babylon101/sprites
  10146. */
  10147. export class SpriteManager implements ISpriteManager {
  10148. /** defines the manager's name */
  10149. name: string;
  10150. /** Gets the list of sprites */
  10151. sprites: Sprite[];
  10152. /** Gets or sets the rendering group id (0 by default) */
  10153. renderingGroupId: number;
  10154. /** Gets or sets camera layer mask */
  10155. layerMask: number;
  10156. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10157. fogEnabled: boolean;
  10158. /** Gets or sets a boolean indicating if the sprites are pickable */
  10159. isPickable: boolean;
  10160. /** Defines the default width of a cell in the spritesheet */
  10161. cellWidth: number;
  10162. /** Defines the default height of a cell in the spritesheet */
  10163. cellHeight: number;
  10164. /** Associative array from JSON sprite data file */
  10165. private _cellData;
  10166. /** Array of sprite names from JSON sprite data file */
  10167. private _spriteMap;
  10168. /** True when packed cell data from JSON file is ready*/
  10169. private _packedAndReady;
  10170. /**
  10171. * An event triggered when the manager is disposed.
  10172. */
  10173. onDisposeObservable: Observable<SpriteManager>;
  10174. private _onDisposeObserver;
  10175. /**
  10176. * Callback called when the manager is disposed
  10177. */
  10178. set onDispose(callback: () => void);
  10179. private _capacity;
  10180. private _fromPacked;
  10181. private _spriteTexture;
  10182. private _epsilon;
  10183. private _scene;
  10184. private _vertexData;
  10185. private _buffer;
  10186. private _vertexBuffers;
  10187. private _indexBuffer;
  10188. private _effectBase;
  10189. private _effectFog;
  10190. /**
  10191. * Gets or sets the spritesheet texture
  10192. */
  10193. get texture(): Texture;
  10194. set texture(value: Texture);
  10195. private _blendMode;
  10196. /**
  10197. * Blend mode use to render the particle, it can be any of
  10198. * the static Constants.ALPHA_x properties provided in this class.
  10199. * Default value is Constants.ALPHA_COMBINE
  10200. */
  10201. get blendMode(): number;
  10202. set blendMode(blendMode: number);
  10203. /** Disables writing to the depth buffer when rendering the sprites.
  10204. * It can be handy to disable depth writing when using textures without alpha channel
  10205. * and setting some specific blend modes.
  10206. */
  10207. disableDepthWrite: boolean;
  10208. /**
  10209. * Creates a new sprite manager
  10210. * @param name defines the manager's name
  10211. * @param imgUrl defines the sprite sheet url
  10212. * @param capacity defines the maximum allowed number of sprites
  10213. * @param cellSize defines the size of a sprite cell
  10214. * @param scene defines the hosting scene
  10215. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10216. * @param samplingMode defines the smapling mode to use with spritesheet
  10217. * @param fromPacked set to false; do not alter
  10218. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10219. */
  10220. constructor(
  10221. /** defines the manager's name */
  10222. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10223. private _makePacked;
  10224. private _appendSpriteVertex;
  10225. /**
  10226. * Intersects the sprites with a ray
  10227. * @param ray defines the ray to intersect with
  10228. * @param camera defines the current active camera
  10229. * @param predicate defines a predicate used to select candidate sprites
  10230. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10231. * @returns null if no hit or a PickingInfo
  10232. */
  10233. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10234. /**
  10235. * Intersects the sprites with a ray
  10236. * @param ray defines the ray to intersect with
  10237. * @param camera defines the current active camera
  10238. * @param predicate defines a predicate used to select candidate sprites
  10239. * @returns null if no hit or a PickingInfo array
  10240. */
  10241. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10242. /**
  10243. * Render all child sprites
  10244. */
  10245. render(): void;
  10246. /**
  10247. * Release associated resources
  10248. */
  10249. dispose(): void;
  10250. }
  10251. }
  10252. declare module "babylonjs/Misc/gradients" {
  10253. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10254. /** Interface used by value gradients (color, factor, ...) */
  10255. export interface IValueGradient {
  10256. /**
  10257. * Gets or sets the gradient value (between 0 and 1)
  10258. */
  10259. gradient: number;
  10260. }
  10261. /** Class used to store color4 gradient */
  10262. export class ColorGradient implements IValueGradient {
  10263. /**
  10264. * Gets or sets the gradient value (between 0 and 1)
  10265. */
  10266. gradient: number;
  10267. /**
  10268. * Gets or sets first associated color
  10269. */
  10270. color1: Color4;
  10271. /**
  10272. * Gets or sets second associated color
  10273. */
  10274. color2?: Color4;
  10275. /**
  10276. * Will get a color picked randomly between color1 and color2.
  10277. * If color2 is undefined then color1 will be used
  10278. * @param result defines the target Color4 to store the result in
  10279. */
  10280. getColorToRef(result: Color4): void;
  10281. }
  10282. /** Class used to store color 3 gradient */
  10283. export class Color3Gradient implements IValueGradient {
  10284. /**
  10285. * Gets or sets the gradient value (between 0 and 1)
  10286. */
  10287. gradient: number;
  10288. /**
  10289. * Gets or sets the associated color
  10290. */
  10291. color: Color3;
  10292. }
  10293. /** Class used to store factor gradient */
  10294. export class FactorGradient implements IValueGradient {
  10295. /**
  10296. * Gets or sets the gradient value (between 0 and 1)
  10297. */
  10298. gradient: number;
  10299. /**
  10300. * Gets or sets first associated factor
  10301. */
  10302. factor1: number;
  10303. /**
  10304. * Gets or sets second associated factor
  10305. */
  10306. factor2?: number;
  10307. /**
  10308. * Will get a number picked randomly between factor1 and factor2.
  10309. * If factor2 is undefined then factor1 will be used
  10310. * @returns the picked number
  10311. */
  10312. getFactor(): number;
  10313. }
  10314. /**
  10315. * Helper used to simplify some generic gradient tasks
  10316. */
  10317. export class GradientHelper {
  10318. /**
  10319. * Gets the current gradient from an array of IValueGradient
  10320. * @param ratio defines the current ratio to get
  10321. * @param gradients defines the array of IValueGradient
  10322. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10323. */
  10324. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10325. }
  10326. }
  10327. declare module "babylonjs/Maths/math.size" {
  10328. /**
  10329. * Interface for the size containing width and height
  10330. */
  10331. export interface ISize {
  10332. /**
  10333. * Width
  10334. */
  10335. width: number;
  10336. /**
  10337. * Heighht
  10338. */
  10339. height: number;
  10340. }
  10341. /**
  10342. * Size containing widht and height
  10343. */
  10344. export class Size implements ISize {
  10345. /**
  10346. * Width
  10347. */
  10348. width: number;
  10349. /**
  10350. * Height
  10351. */
  10352. height: number;
  10353. /**
  10354. * Creates a Size object from the given width and height (floats).
  10355. * @param width width of the new size
  10356. * @param height height of the new size
  10357. */
  10358. constructor(width: number, height: number);
  10359. /**
  10360. * Returns a string with the Size width and height
  10361. * @returns a string with the Size width and height
  10362. */
  10363. toString(): string;
  10364. /**
  10365. * "Size"
  10366. * @returns the string "Size"
  10367. */
  10368. getClassName(): string;
  10369. /**
  10370. * Returns the Size hash code.
  10371. * @returns a hash code for a unique width and height
  10372. */
  10373. getHashCode(): number;
  10374. /**
  10375. * Updates the current size from the given one.
  10376. * @param src the given size
  10377. */
  10378. copyFrom(src: Size): void;
  10379. /**
  10380. * Updates in place the current Size from the given floats.
  10381. * @param width width of the new size
  10382. * @param height height of the new size
  10383. * @returns the updated Size.
  10384. */
  10385. copyFromFloats(width: number, height: number): Size;
  10386. /**
  10387. * Updates in place the current Size from the given floats.
  10388. * @param width width to set
  10389. * @param height height to set
  10390. * @returns the updated Size.
  10391. */
  10392. set(width: number, height: number): Size;
  10393. /**
  10394. * Multiplies the width and height by numbers
  10395. * @param w factor to multiple the width by
  10396. * @param h factor to multiple the height by
  10397. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10398. */
  10399. multiplyByFloats(w: number, h: number): Size;
  10400. /**
  10401. * Clones the size
  10402. * @returns a new Size copied from the given one.
  10403. */
  10404. clone(): Size;
  10405. /**
  10406. * True if the current Size and the given one width and height are strictly equal.
  10407. * @param other the other size to compare against
  10408. * @returns True if the current Size and the given one width and height are strictly equal.
  10409. */
  10410. equals(other: Size): boolean;
  10411. /**
  10412. * The surface of the Size : width * height (float).
  10413. */
  10414. get surface(): number;
  10415. /**
  10416. * Create a new size of zero
  10417. * @returns a new Size set to (0.0, 0.0)
  10418. */
  10419. static Zero(): Size;
  10420. /**
  10421. * Sums the width and height of two sizes
  10422. * @param otherSize size to add to this size
  10423. * @returns a new Size set as the addition result of the current Size and the given one.
  10424. */
  10425. add(otherSize: Size): Size;
  10426. /**
  10427. * Subtracts the width and height of two
  10428. * @param otherSize size to subtract to this size
  10429. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10430. */
  10431. subtract(otherSize: Size): Size;
  10432. /**
  10433. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10434. * @param start starting size to lerp between
  10435. * @param end end size to lerp between
  10436. * @param amount amount to lerp between the start and end values
  10437. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10438. */
  10439. static Lerp(start: Size, end: Size, amount: number): Size;
  10440. }
  10441. }
  10442. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10443. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10444. import { Nullable } from "babylonjs/types";
  10445. module "babylonjs/Engines/thinEngine" {
  10446. interface ThinEngine {
  10447. /**
  10448. * Creates a dynamic texture
  10449. * @param width defines the width of the texture
  10450. * @param height defines the height of the texture
  10451. * @param generateMipMaps defines if the engine should generate the mip levels
  10452. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10453. * @returns the dynamic texture inside an InternalTexture
  10454. */
  10455. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10456. /**
  10457. * Update the content of a dynamic texture
  10458. * @param texture defines the texture to update
  10459. * @param canvas defines the canvas containing the source
  10460. * @param invertY defines if data must be stored with Y axis inverted
  10461. * @param premulAlpha defines if alpha is stored as premultiplied
  10462. * @param format defines the format of the data
  10463. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10464. */
  10465. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10466. }
  10467. }
  10468. }
  10469. declare module "babylonjs/Misc/canvasGenerator" {
  10470. /**
  10471. * Helper class used to generate a canvas to manipulate images
  10472. */
  10473. export class CanvasGenerator {
  10474. /**
  10475. * Create a new canvas (or offscreen canvas depending on the context)
  10476. * @param width defines the expected width
  10477. * @param height defines the expected height
  10478. * @return a new canvas or offscreen canvas
  10479. */
  10480. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10481. }
  10482. }
  10483. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10484. import { Scene } from "babylonjs/scene";
  10485. import { Texture } from "babylonjs/Materials/Textures/texture";
  10486. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10487. /**
  10488. * A class extending Texture allowing drawing on a texture
  10489. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10490. */
  10491. export class DynamicTexture extends Texture {
  10492. private _generateMipMaps;
  10493. private _canvas;
  10494. private _context;
  10495. private _engine;
  10496. /**
  10497. * Creates a DynamicTexture
  10498. * @param name defines the name of the texture
  10499. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  10500. * @param scene defines the scene where you want the texture
  10501. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10502. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10503. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10504. */
  10505. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10506. /**
  10507. * Get the current class name of the texture useful for serialization or dynamic coding.
  10508. * @returns "DynamicTexture"
  10509. */
  10510. getClassName(): string;
  10511. /**
  10512. * Gets the current state of canRescale
  10513. */
  10514. get canRescale(): boolean;
  10515. private _recreate;
  10516. /**
  10517. * Scales the texture
  10518. * @param ratio the scale factor to apply to both width and height
  10519. */
  10520. scale(ratio: number): void;
  10521. /**
  10522. * Resizes the texture
  10523. * @param width the new width
  10524. * @param height the new height
  10525. */
  10526. scaleTo(width: number, height: number): void;
  10527. /**
  10528. * Gets the context of the canvas used by the texture
  10529. * @returns the canvas context of the dynamic texture
  10530. */
  10531. getContext(): CanvasRenderingContext2D;
  10532. /**
  10533. * Clears the texture
  10534. */
  10535. clear(): void;
  10536. /**
  10537. * Updates the texture
  10538. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10539. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10540. */
  10541. update(invertY?: boolean, premulAlpha?: boolean): void;
  10542. /**
  10543. * Draws text onto the texture
  10544. * @param text defines the text to be drawn
  10545. * @param x defines the placement of the text from the left
  10546. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10547. * @param font defines the font to be used with font-style, font-size, font-name
  10548. * @param color defines the color used for the text
  10549. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10550. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10551. * @param update defines whether texture is immediately update (default is true)
  10552. */
  10553. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10554. /**
  10555. * Clones the texture
  10556. * @returns the clone of the texture.
  10557. */
  10558. clone(): DynamicTexture;
  10559. /**
  10560. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10561. * @returns a serialized dynamic texture object
  10562. */
  10563. serialize(): any;
  10564. /** @hidden */
  10565. _rebuild(): void;
  10566. }
  10567. }
  10568. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10569. import { Nullable } from "babylonjs/types";
  10570. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10571. import { Scene } from "babylonjs/scene";
  10572. module "babylonjs/Engines/engine" {
  10573. interface Engine {
  10574. /**
  10575. * Creates a raw texture
  10576. * @param data defines the data to store in the texture
  10577. * @param width defines the width of the texture
  10578. * @param height defines the height of the texture
  10579. * @param format defines the format of the data
  10580. * @param generateMipMaps defines if the engine should generate the mip levels
  10581. * @param invertY defines if data must be stored with Y axis inverted
  10582. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10583. * @param compression defines the compression used (null by default)
  10584. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10585. * @returns the raw texture inside an InternalTexture
  10586. */
  10587. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10588. /**
  10589. * Update a raw texture
  10590. * @param texture defines the texture to update
  10591. * @param data defines the data to store in the texture
  10592. * @param format defines the format of the data
  10593. * @param invertY defines if data must be stored with Y axis inverted
  10594. */
  10595. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10596. /**
  10597. * Update a raw texture
  10598. * @param texture defines the texture to update
  10599. * @param data defines the data to store in the texture
  10600. * @param format defines the format of the data
  10601. * @param invertY defines if data must be stored with Y axis inverted
  10602. * @param compression defines the compression used (null by default)
  10603. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10604. */
  10605. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10606. /**
  10607. * Creates a new raw cube texture
  10608. * @param data defines the array of data to use to create each face
  10609. * @param size defines the size of the textures
  10610. * @param format defines the format of the data
  10611. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10612. * @param generateMipMaps defines if the engine should generate the mip levels
  10613. * @param invertY defines if data must be stored with Y axis inverted
  10614. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10615. * @param compression defines the compression used (null by default)
  10616. * @returns the cube texture as an InternalTexture
  10617. */
  10618. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10619. /**
  10620. * Update a raw cube texture
  10621. * @param texture defines the texture to udpdate
  10622. * @param data defines the data to store
  10623. * @param format defines the data format
  10624. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10625. * @param invertY defines if data must be stored with Y axis inverted
  10626. */
  10627. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10628. /**
  10629. * Update a raw cube texture
  10630. * @param texture defines the texture to udpdate
  10631. * @param data defines the data to store
  10632. * @param format defines the data format
  10633. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10634. * @param invertY defines if data must be stored with Y axis inverted
  10635. * @param compression defines the compression used (null by default)
  10636. */
  10637. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10638. /**
  10639. * Update a raw cube texture
  10640. * @param texture defines the texture to udpdate
  10641. * @param data defines the data to store
  10642. * @param format defines the data format
  10643. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10644. * @param invertY defines if data must be stored with Y axis inverted
  10645. * @param compression defines the compression used (null by default)
  10646. * @param level defines which level of the texture to update
  10647. */
  10648. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10649. /**
  10650. * Creates a new raw cube texture from a specified url
  10651. * @param url defines the url where the data is located
  10652. * @param scene defines the current scene
  10653. * @param size defines the size of the textures
  10654. * @param format defines the format of the data
  10655. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10656. * @param noMipmap defines if the engine should avoid generating the mip levels
  10657. * @param callback defines a callback used to extract texture data from loaded data
  10658. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10659. * @param onLoad defines a callback called when texture is loaded
  10660. * @param onError defines a callback called if there is an error
  10661. * @returns the cube texture as an InternalTexture
  10662. */
  10663. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  10664. /**
  10665. * Creates a new raw cube texture from a specified url
  10666. * @param url defines the url where the data is located
  10667. * @param scene defines the current scene
  10668. * @param size defines the size of the textures
  10669. * @param format defines the format of the data
  10670. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10671. * @param noMipmap defines if the engine should avoid generating the mip levels
  10672. * @param callback defines a callback used to extract texture data from loaded data
  10673. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10674. * @param onLoad defines a callback called when texture is loaded
  10675. * @param onError defines a callback called if there is an error
  10676. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10677. * @param invertY defines if data must be stored with Y axis inverted
  10678. * @returns the cube texture as an InternalTexture
  10679. */
  10680. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  10681. /**
  10682. * Creates a new raw 3D texture
  10683. * @param data defines the data used to create the texture
  10684. * @param width defines the width of the texture
  10685. * @param height defines the height of the texture
  10686. * @param depth defines the depth of the texture
  10687. * @param format defines the format of the texture
  10688. * @param generateMipMaps defines if the engine must generate mip levels
  10689. * @param invertY defines if data must be stored with Y axis inverted
  10690. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10691. * @param compression defines the compressed used (can be null)
  10692. * @param textureType defines the compressed used (can be null)
  10693. * @returns a new raw 3D texture (stored in an InternalTexture)
  10694. */
  10695. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10696. /**
  10697. * Update a raw 3D texture
  10698. * @param texture defines the texture to update
  10699. * @param data defines the data to store
  10700. * @param format defines the data format
  10701. * @param invertY defines if data must be stored with Y axis inverted
  10702. */
  10703. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10704. /**
  10705. * Update a raw 3D texture
  10706. * @param texture defines the texture to update
  10707. * @param data defines the data to store
  10708. * @param format defines the data format
  10709. * @param invertY defines if data must be stored with Y axis inverted
  10710. * @param compression defines the used compression (can be null)
  10711. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10712. */
  10713. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10714. /**
  10715. * Creates a new raw 2D array texture
  10716. * @param data defines the data used to create the texture
  10717. * @param width defines the width of the texture
  10718. * @param height defines the height of the texture
  10719. * @param depth defines the number of layers of the texture
  10720. * @param format defines the format of the texture
  10721. * @param generateMipMaps defines if the engine must generate mip levels
  10722. * @param invertY defines if data must be stored with Y axis inverted
  10723. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10724. * @param compression defines the compressed used (can be null)
  10725. * @param textureType defines the compressed used (can be null)
  10726. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10727. */
  10728. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10729. /**
  10730. * Update a raw 2D array texture
  10731. * @param texture defines the texture to update
  10732. * @param data defines the data to store
  10733. * @param format defines the data format
  10734. * @param invertY defines if data must be stored with Y axis inverted
  10735. */
  10736. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10737. /**
  10738. * Update a raw 2D array texture
  10739. * @param texture defines the texture to update
  10740. * @param data defines the data to store
  10741. * @param format defines the data format
  10742. * @param invertY defines if data must be stored with Y axis inverted
  10743. * @param compression defines the used compression (can be null)
  10744. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10745. */
  10746. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10747. }
  10748. }
  10749. }
  10750. declare module "babylonjs/Materials/Textures/rawTexture" {
  10751. import { Scene } from "babylonjs/scene";
  10752. import { Texture } from "babylonjs/Materials/Textures/texture";
  10753. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10754. /**
  10755. * Raw texture can help creating a texture directly from an array of data.
  10756. * This can be super useful if you either get the data from an uncompressed source or
  10757. * if you wish to create your texture pixel by pixel.
  10758. */
  10759. export class RawTexture extends Texture {
  10760. /**
  10761. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10762. */
  10763. format: number;
  10764. private _engine;
  10765. /**
  10766. * Instantiates a new RawTexture.
  10767. * Raw texture can help creating a texture directly from an array of data.
  10768. * This can be super useful if you either get the data from an uncompressed source or
  10769. * if you wish to create your texture pixel by pixel.
  10770. * @param data define the array of data to use to create the texture
  10771. * @param width define the width of the texture
  10772. * @param height define the height of the texture
  10773. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10774. * @param scene define the scene the texture belongs to
  10775. * @param generateMipMaps define whether mip maps should be generated or not
  10776. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10777. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10778. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10779. */
  10780. constructor(data: ArrayBufferView, width: number, height: number,
  10781. /**
  10782. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10783. */
  10784. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10785. /**
  10786. * Updates the texture underlying data.
  10787. * @param data Define the new data of the texture
  10788. */
  10789. update(data: ArrayBufferView): void;
  10790. /**
  10791. * Creates a luminance texture from some data.
  10792. * @param data Define the texture data
  10793. * @param width Define the width of the texture
  10794. * @param height Define the height of the texture
  10795. * @param scene Define the scene the texture belongs to
  10796. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10797. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10798. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10799. * @returns the luminance texture
  10800. */
  10801. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10802. /**
  10803. * Creates a luminance alpha texture from some data.
  10804. * @param data Define the texture data
  10805. * @param width Define the width of the texture
  10806. * @param height Define the height of the texture
  10807. * @param scene Define the scene the texture belongs to
  10808. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10809. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10810. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10811. * @returns the luminance alpha texture
  10812. */
  10813. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10814. /**
  10815. * Creates an alpha texture from some data.
  10816. * @param data Define the texture data
  10817. * @param width Define the width of the texture
  10818. * @param height Define the height of the texture
  10819. * @param scene Define the scene the texture belongs to
  10820. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10821. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10822. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10823. * @returns the alpha texture
  10824. */
  10825. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10826. /**
  10827. * Creates a RGB texture from some data.
  10828. * @param data Define the texture data
  10829. * @param width Define the width of the texture
  10830. * @param height Define the height of the texture
  10831. * @param scene Define the scene the texture belongs to
  10832. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10833. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10834. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10835. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10836. * @returns the RGB alpha texture
  10837. */
  10838. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10839. /**
  10840. * Creates a RGBA texture from some data.
  10841. * @param data Define the texture data
  10842. * @param width Define the width of the texture
  10843. * @param height Define the height of the texture
  10844. * @param scene Define the scene the texture belongs to
  10845. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10846. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10847. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10848. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10849. * @returns the RGBA texture
  10850. */
  10851. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10852. /**
  10853. * Creates a R texture from some data.
  10854. * @param data Define the texture data
  10855. * @param width Define the width of the texture
  10856. * @param height Define the height of the texture
  10857. * @param scene Define the scene the texture belongs to
  10858. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10859. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10860. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10861. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10862. * @returns the R texture
  10863. */
  10864. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10865. }
  10866. }
  10867. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  10868. import { Scene } from "babylonjs/scene";
  10869. import { ISceneComponent } from "babylonjs/sceneComponent";
  10870. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  10871. module "babylonjs/abstractScene" {
  10872. interface AbstractScene {
  10873. /**
  10874. * The list of procedural textures added to the scene
  10875. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10876. */
  10877. proceduralTextures: Array<ProceduralTexture>;
  10878. }
  10879. }
  10880. /**
  10881. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10882. * in a given scene.
  10883. */
  10884. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10885. /**
  10886. * The component name helpfull to identify the component in the list of scene components.
  10887. */
  10888. readonly name: string;
  10889. /**
  10890. * The scene the component belongs to.
  10891. */
  10892. scene: Scene;
  10893. /**
  10894. * Creates a new instance of the component for the given scene
  10895. * @param scene Defines the scene to register the component in
  10896. */
  10897. constructor(scene: Scene);
  10898. /**
  10899. * Registers the component in a given scene
  10900. */
  10901. register(): void;
  10902. /**
  10903. * Rebuilds the elements related to this component in case of
  10904. * context lost for instance.
  10905. */
  10906. rebuild(): void;
  10907. /**
  10908. * Disposes the component and the associated ressources.
  10909. */
  10910. dispose(): void;
  10911. private _beforeClear;
  10912. }
  10913. }
  10914. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  10915. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10916. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  10917. module "babylonjs/Engines/thinEngine" {
  10918. interface ThinEngine {
  10919. /**
  10920. * Creates a new render target cube texture
  10921. * @param size defines the size of the texture
  10922. * @param options defines the options used to create the texture
  10923. * @returns a new render target cube texture stored in an InternalTexture
  10924. */
  10925. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10926. }
  10927. }
  10928. }
  10929. declare module "babylonjs/Shaders/procedural.vertex" {
  10930. /** @hidden */
  10931. export var proceduralVertexShader: {
  10932. name: string;
  10933. shader: string;
  10934. };
  10935. }
  10936. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  10937. import { Observable } from "babylonjs/Misc/observable";
  10938. import { Nullable } from "babylonjs/types";
  10939. import { Scene } from "babylonjs/scene";
  10940. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10941. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  10942. import { Effect } from "babylonjs/Materials/effect";
  10943. import { Texture } from "babylonjs/Materials/Textures/texture";
  10944. import "babylonjs/Engines/Extensions/engine.renderTarget";
  10945. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  10946. import "babylonjs/Shaders/procedural.vertex";
  10947. /**
  10948. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  10949. * This is the base class of any Procedural texture and contains most of the shareable code.
  10950. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10951. */
  10952. export class ProceduralTexture extends Texture {
  10953. isCube: boolean;
  10954. /**
  10955. * Define if the texture is enabled or not (disabled texture will not render)
  10956. */
  10957. isEnabled: boolean;
  10958. /**
  10959. * Define if the texture must be cleared before rendering (default is true)
  10960. */
  10961. autoClear: boolean;
  10962. /**
  10963. * Callback called when the texture is generated
  10964. */
  10965. onGenerated: () => void;
  10966. /**
  10967. * Event raised when the texture is generated
  10968. */
  10969. onGeneratedObservable: Observable<ProceduralTexture>;
  10970. /** @hidden */
  10971. _generateMipMaps: boolean;
  10972. /** @hidden **/
  10973. _effect: Effect;
  10974. /** @hidden */
  10975. _textures: {
  10976. [key: string]: Texture;
  10977. };
  10978. private _size;
  10979. private _currentRefreshId;
  10980. private _frameId;
  10981. private _refreshRate;
  10982. private _vertexBuffers;
  10983. private _indexBuffer;
  10984. private _uniforms;
  10985. private _samplers;
  10986. private _fragment;
  10987. private _floats;
  10988. private _ints;
  10989. private _floatsArrays;
  10990. private _colors3;
  10991. private _colors4;
  10992. private _vectors2;
  10993. private _vectors3;
  10994. private _matrices;
  10995. private _fallbackTexture;
  10996. private _fallbackTextureUsed;
  10997. private _engine;
  10998. private _cachedDefines;
  10999. private _contentUpdateId;
  11000. private _contentData;
  11001. /**
  11002. * Instantiates a new procedural texture.
  11003. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  11004. * This is the base class of any Procedural texture and contains most of the shareable code.
  11005. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11006. * @param name Define the name of the texture
  11007. * @param size Define the size of the texture to create
  11008. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11009. * @param scene Define the scene the texture belongs to
  11010. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11011. * @param generateMipMaps Define if the texture should creates mip maps or not
  11012. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11013. */
  11014. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11015. /**
  11016. * The effect that is created when initializing the post process.
  11017. * @returns The created effect corresponding the the postprocess.
  11018. */
  11019. getEffect(): Effect;
  11020. /**
  11021. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11022. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11023. */
  11024. getContent(): Nullable<ArrayBufferView>;
  11025. private _createIndexBuffer;
  11026. /** @hidden */
  11027. _rebuild(): void;
  11028. /**
  11029. * Resets the texture in order to recreate its associated resources.
  11030. * This can be called in case of context loss
  11031. */
  11032. reset(): void;
  11033. protected _getDefines(): string;
  11034. /**
  11035. * Is the texture ready to be used ? (rendered at least once)
  11036. * @returns true if ready, otherwise, false.
  11037. */
  11038. isReady(): boolean;
  11039. /**
  11040. * Resets the refresh counter of the texture and start bak from scratch.
  11041. * Could be useful to regenerate the texture if it is setup to render only once.
  11042. */
  11043. resetRefreshCounter(): void;
  11044. /**
  11045. * Set the fragment shader to use in order to render the texture.
  11046. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11047. */
  11048. setFragment(fragment: any): void;
  11049. /**
  11050. * Define the refresh rate of the texture or the rendering frequency.
  11051. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11052. */
  11053. get refreshRate(): number;
  11054. set refreshRate(value: number);
  11055. /** @hidden */
  11056. _shouldRender(): boolean;
  11057. /**
  11058. * Get the size the texture is rendering at.
  11059. * @returns the size (texture is always squared)
  11060. */
  11061. getRenderSize(): number;
  11062. /**
  11063. * Resize the texture to new value.
  11064. * @param size Define the new size the texture should have
  11065. * @param generateMipMaps Define whether the new texture should create mip maps
  11066. */
  11067. resize(size: number, generateMipMaps: boolean): void;
  11068. private _checkUniform;
  11069. /**
  11070. * Set a texture in the shader program used to render.
  11071. * @param name Define the name of the uniform samplers as defined in the shader
  11072. * @param texture Define the texture to bind to this sampler
  11073. * @return the texture itself allowing "fluent" like uniform updates
  11074. */
  11075. setTexture(name: string, texture: Texture): ProceduralTexture;
  11076. /**
  11077. * Set a float in the shader.
  11078. * @param name Define the name of the uniform as defined in the shader
  11079. * @param value Define the value to give to the uniform
  11080. * @return the texture itself allowing "fluent" like uniform updates
  11081. */
  11082. setFloat(name: string, value: number): ProceduralTexture;
  11083. /**
  11084. * Set a int in the shader.
  11085. * @param name Define the name of the uniform as defined in the shader
  11086. * @param value Define the value to give to the uniform
  11087. * @return the texture itself allowing "fluent" like uniform updates
  11088. */
  11089. setInt(name: string, value: number): ProceduralTexture;
  11090. /**
  11091. * Set an array of floats in the shader.
  11092. * @param name Define the name of the uniform as defined in the shader
  11093. * @param value Define the value to give to the uniform
  11094. * @return the texture itself allowing "fluent" like uniform updates
  11095. */
  11096. setFloats(name: string, value: number[]): ProceduralTexture;
  11097. /**
  11098. * Set a vec3 in the shader from a Color3.
  11099. * @param name Define the name of the uniform as defined in the shader
  11100. * @param value Define the value to give to the uniform
  11101. * @return the texture itself allowing "fluent" like uniform updates
  11102. */
  11103. setColor3(name: string, value: Color3): ProceduralTexture;
  11104. /**
  11105. * Set a vec4 in the shader from a Color4.
  11106. * @param name Define the name of the uniform as defined in the shader
  11107. * @param value Define the value to give to the uniform
  11108. * @return the texture itself allowing "fluent" like uniform updates
  11109. */
  11110. setColor4(name: string, value: Color4): ProceduralTexture;
  11111. /**
  11112. * Set a vec2 in the shader from a Vector2.
  11113. * @param name Define the name of the uniform as defined in the shader
  11114. * @param value Define the value to give to the uniform
  11115. * @return the texture itself allowing "fluent" like uniform updates
  11116. */
  11117. setVector2(name: string, value: Vector2): ProceduralTexture;
  11118. /**
  11119. * Set a vec3 in the shader from a Vector3.
  11120. * @param name Define the name of the uniform as defined in the shader
  11121. * @param value Define the value to give to the uniform
  11122. * @return the texture itself allowing "fluent" like uniform updates
  11123. */
  11124. setVector3(name: string, value: Vector3): ProceduralTexture;
  11125. /**
  11126. * Set a mat4 in the shader from a MAtrix.
  11127. * @param name Define the name of the uniform as defined in the shader
  11128. * @param value Define the value to give to the uniform
  11129. * @return the texture itself allowing "fluent" like uniform updates
  11130. */
  11131. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11132. /**
  11133. * Render the texture to its associated render target.
  11134. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11135. */
  11136. render(useCameraPostProcess?: boolean): void;
  11137. /**
  11138. * Clone the texture.
  11139. * @returns the cloned texture
  11140. */
  11141. clone(): ProceduralTexture;
  11142. /**
  11143. * Dispose the texture and release its asoociated resources.
  11144. */
  11145. dispose(): void;
  11146. }
  11147. }
  11148. declare module "babylonjs/Particles/baseParticleSystem" {
  11149. import { Nullable } from "babylonjs/types";
  11150. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11152. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11153. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11154. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11155. import { Scene } from "babylonjs/scene";
  11156. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11157. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11158. import { Texture } from "babylonjs/Materials/Textures/texture";
  11159. import { Color4 } from "babylonjs/Maths/math.color";
  11160. import { Animation } from "babylonjs/Animations/animation";
  11161. /**
  11162. * This represents the base class for particle system in Babylon.
  11163. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11164. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11165. * @example https://doc.babylonjs.com/babylon101/particles
  11166. */
  11167. export class BaseParticleSystem {
  11168. /**
  11169. * Source color is added to the destination color without alpha affecting the result
  11170. */
  11171. static BLENDMODE_ONEONE: number;
  11172. /**
  11173. * Blend current color and particle color using particle’s alpha
  11174. */
  11175. static BLENDMODE_STANDARD: number;
  11176. /**
  11177. * Add current color and particle color multiplied by particle’s alpha
  11178. */
  11179. static BLENDMODE_ADD: number;
  11180. /**
  11181. * Multiply current color with particle color
  11182. */
  11183. static BLENDMODE_MULTIPLY: number;
  11184. /**
  11185. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11186. */
  11187. static BLENDMODE_MULTIPLYADD: number;
  11188. /**
  11189. * List of animations used by the particle system.
  11190. */
  11191. animations: Animation[];
  11192. /**
  11193. * The id of the Particle system.
  11194. */
  11195. id: string;
  11196. /**
  11197. * The friendly name of the Particle system.
  11198. */
  11199. name: string;
  11200. /**
  11201. * The rendering group used by the Particle system to chose when to render.
  11202. */
  11203. renderingGroupId: number;
  11204. /**
  11205. * The emitter represents the Mesh or position we are attaching the particle system to.
  11206. */
  11207. emitter: Nullable<AbstractMesh | Vector3>;
  11208. /**
  11209. * The maximum number of particles to emit per frame
  11210. */
  11211. emitRate: number;
  11212. /**
  11213. * If you want to launch only a few particles at once, that can be done, as well.
  11214. */
  11215. manualEmitCount: number;
  11216. /**
  11217. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11218. */
  11219. updateSpeed: number;
  11220. /**
  11221. * The amount of time the particle system is running (depends of the overall update speed).
  11222. */
  11223. targetStopDuration: number;
  11224. /**
  11225. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11226. */
  11227. disposeOnStop: boolean;
  11228. /**
  11229. * Minimum power of emitting particles.
  11230. */
  11231. minEmitPower: number;
  11232. /**
  11233. * Maximum power of emitting particles.
  11234. */
  11235. maxEmitPower: number;
  11236. /**
  11237. * Minimum life time of emitting particles.
  11238. */
  11239. minLifeTime: number;
  11240. /**
  11241. * Maximum life time of emitting particles.
  11242. */
  11243. maxLifeTime: number;
  11244. /**
  11245. * Minimum Size of emitting particles.
  11246. */
  11247. minSize: number;
  11248. /**
  11249. * Maximum Size of emitting particles.
  11250. */
  11251. maxSize: number;
  11252. /**
  11253. * Minimum scale of emitting particles on X axis.
  11254. */
  11255. minScaleX: number;
  11256. /**
  11257. * Maximum scale of emitting particles on X axis.
  11258. */
  11259. maxScaleX: number;
  11260. /**
  11261. * Minimum scale of emitting particles on Y axis.
  11262. */
  11263. minScaleY: number;
  11264. /**
  11265. * Maximum scale of emitting particles on Y axis.
  11266. */
  11267. maxScaleY: number;
  11268. /**
  11269. * Gets or sets the minimal initial rotation in radians.
  11270. */
  11271. minInitialRotation: number;
  11272. /**
  11273. * Gets or sets the maximal initial rotation in radians.
  11274. */
  11275. maxInitialRotation: number;
  11276. /**
  11277. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11278. */
  11279. minAngularSpeed: number;
  11280. /**
  11281. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11282. */
  11283. maxAngularSpeed: number;
  11284. /**
  11285. * The texture used to render each particle. (this can be a spritesheet)
  11286. */
  11287. particleTexture: Nullable<Texture>;
  11288. /**
  11289. * The layer mask we are rendering the particles through.
  11290. */
  11291. layerMask: number;
  11292. /**
  11293. * This can help using your own shader to render the particle system.
  11294. * The according effect will be created
  11295. */
  11296. customShader: any;
  11297. /**
  11298. * By default particle system starts as soon as they are created. This prevents the
  11299. * automatic start to happen and let you decide when to start emitting particles.
  11300. */
  11301. preventAutoStart: boolean;
  11302. private _noiseTexture;
  11303. /**
  11304. * Gets or sets a texture used to add random noise to particle positions
  11305. */
  11306. get noiseTexture(): Nullable<ProceduralTexture>;
  11307. set noiseTexture(value: Nullable<ProceduralTexture>);
  11308. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11309. noiseStrength: Vector3;
  11310. /**
  11311. * Callback triggered when the particle animation is ending.
  11312. */
  11313. onAnimationEnd: Nullable<() => void>;
  11314. /**
  11315. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11316. */
  11317. blendMode: number;
  11318. /**
  11319. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11320. * to override the particles.
  11321. */
  11322. forceDepthWrite: boolean;
  11323. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  11324. preWarmCycles: number;
  11325. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11326. preWarmStepOffset: number;
  11327. /**
  11328. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  11329. */
  11330. spriteCellChangeSpeed: number;
  11331. /**
  11332. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11333. */
  11334. startSpriteCellID: number;
  11335. /**
  11336. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11337. */
  11338. endSpriteCellID: number;
  11339. /**
  11340. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11341. */
  11342. spriteCellWidth: number;
  11343. /**
  11344. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11345. */
  11346. spriteCellHeight: number;
  11347. /**
  11348. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11349. */
  11350. spriteRandomStartCell: boolean;
  11351. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11352. translationPivot: Vector2;
  11353. /** @hidden */
  11354. protected _isAnimationSheetEnabled: boolean;
  11355. /**
  11356. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11357. */
  11358. beginAnimationOnStart: boolean;
  11359. /**
  11360. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11361. */
  11362. beginAnimationFrom: number;
  11363. /**
  11364. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11365. */
  11366. beginAnimationTo: number;
  11367. /**
  11368. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11369. */
  11370. beginAnimationLoop: boolean;
  11371. /**
  11372. * Gets or sets a world offset applied to all particles
  11373. */
  11374. worldOffset: Vector3;
  11375. /**
  11376. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11377. */
  11378. get isAnimationSheetEnabled(): boolean;
  11379. set isAnimationSheetEnabled(value: boolean);
  11380. /**
  11381. * Get hosting scene
  11382. * @returns the scene
  11383. */
  11384. getScene(): Scene;
  11385. /**
  11386. * You can use gravity if you want to give an orientation to your particles.
  11387. */
  11388. gravity: Vector3;
  11389. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11390. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11391. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11392. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11393. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11394. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11395. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11396. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11397. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11398. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11399. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11400. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11401. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11402. /**
  11403. * Defines the delay in milliseconds before starting the system (0 by default)
  11404. */
  11405. startDelay: number;
  11406. /**
  11407. * Gets the current list of drag gradients.
  11408. * You must use addDragGradient and removeDragGradient to udpate this list
  11409. * @returns the list of drag gradients
  11410. */
  11411. getDragGradients(): Nullable<Array<FactorGradient>>;
  11412. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11413. limitVelocityDamping: number;
  11414. /**
  11415. * Gets the current list of limit velocity gradients.
  11416. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11417. * @returns the list of limit velocity gradients
  11418. */
  11419. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11420. /**
  11421. * Gets the current list of color gradients.
  11422. * You must use addColorGradient and removeColorGradient to udpate this list
  11423. * @returns the list of color gradients
  11424. */
  11425. getColorGradients(): Nullable<Array<ColorGradient>>;
  11426. /**
  11427. * Gets the current list of size gradients.
  11428. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11429. * @returns the list of size gradients
  11430. */
  11431. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11432. /**
  11433. * Gets the current list of color remap gradients.
  11434. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11435. * @returns the list of color remap gradients
  11436. */
  11437. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11438. /**
  11439. * Gets the current list of alpha remap gradients.
  11440. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11441. * @returns the list of alpha remap gradients
  11442. */
  11443. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11444. /**
  11445. * Gets the current list of life time gradients.
  11446. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11447. * @returns the list of life time gradients
  11448. */
  11449. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11450. /**
  11451. * Gets the current list of angular speed gradients.
  11452. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11453. * @returns the list of angular speed gradients
  11454. */
  11455. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11456. /**
  11457. * Gets the current list of velocity gradients.
  11458. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11459. * @returns the list of velocity gradients
  11460. */
  11461. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11462. /**
  11463. * Gets the current list of start size gradients.
  11464. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11465. * @returns the list of start size gradients
  11466. */
  11467. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11468. /**
  11469. * Gets the current list of emit rate gradients.
  11470. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11471. * @returns the list of emit rate gradients
  11472. */
  11473. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11474. /**
  11475. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11476. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11477. */
  11478. get direction1(): Vector3;
  11479. set direction1(value: Vector3);
  11480. /**
  11481. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11482. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11483. */
  11484. get direction2(): Vector3;
  11485. set direction2(value: Vector3);
  11486. /**
  11487. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11488. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11489. */
  11490. get minEmitBox(): Vector3;
  11491. set minEmitBox(value: Vector3);
  11492. /**
  11493. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11494. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11495. */
  11496. get maxEmitBox(): Vector3;
  11497. set maxEmitBox(value: Vector3);
  11498. /**
  11499. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11500. */
  11501. color1: Color4;
  11502. /**
  11503. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11504. */
  11505. color2: Color4;
  11506. /**
  11507. * Color the particle will have at the end of its lifetime
  11508. */
  11509. colorDead: Color4;
  11510. /**
  11511. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11512. */
  11513. textureMask: Color4;
  11514. /**
  11515. * The particle emitter type defines the emitter used by the particle system.
  11516. * It can be for example box, sphere, or cone...
  11517. */
  11518. particleEmitterType: IParticleEmitterType;
  11519. /** @hidden */
  11520. _isSubEmitter: boolean;
  11521. /**
  11522. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11523. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11524. */
  11525. billboardMode: number;
  11526. protected _isBillboardBased: boolean;
  11527. /**
  11528. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11529. */
  11530. get isBillboardBased(): boolean;
  11531. set isBillboardBased(value: boolean);
  11532. /**
  11533. * The scene the particle system belongs to.
  11534. */
  11535. protected _scene: Scene;
  11536. /**
  11537. * Local cache of defines for image processing.
  11538. */
  11539. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11540. /**
  11541. * Default configuration related to image processing available in the standard Material.
  11542. */
  11543. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11544. /**
  11545. * Gets the image processing configuration used either in this material.
  11546. */
  11547. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11548. /**
  11549. * Sets the Default image processing configuration used either in the this material.
  11550. *
  11551. * If sets to null, the scene one is in use.
  11552. */
  11553. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11554. /**
  11555. * Attaches a new image processing configuration to the Standard Material.
  11556. * @param configuration
  11557. */
  11558. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11559. /** @hidden */
  11560. protected _reset(): void;
  11561. /** @hidden */
  11562. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11563. /**
  11564. * Instantiates a particle system.
  11565. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11566. * @param name The name of the particle system
  11567. */
  11568. constructor(name: string);
  11569. /**
  11570. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11571. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11572. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11573. * @returns the emitter
  11574. */
  11575. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11576. /**
  11577. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11578. * @param radius The radius of the hemisphere to emit from
  11579. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11580. * @returns the emitter
  11581. */
  11582. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11583. /**
  11584. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11585. * @param radius The radius of the sphere to emit from
  11586. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11587. * @returns the emitter
  11588. */
  11589. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11590. /**
  11591. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11592. * @param radius The radius of the sphere to emit from
  11593. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11594. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11595. * @returns the emitter
  11596. */
  11597. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11598. /**
  11599. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11600. * @param radius The radius of the emission cylinder
  11601. * @param height The height of the emission cylinder
  11602. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11603. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11604. * @returns the emitter
  11605. */
  11606. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11607. /**
  11608. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11609. * @param radius The radius of the cylinder to emit from
  11610. * @param height The height of the emission cylinder
  11611. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11612. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11613. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11614. * @returns the emitter
  11615. */
  11616. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11617. /**
  11618. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11619. * @param radius The radius of the cone to emit from
  11620. * @param angle The base angle of the cone
  11621. * @returns the emitter
  11622. */
  11623. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11624. /**
  11625. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11626. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11627. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11628. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11629. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11630. * @returns the emitter
  11631. */
  11632. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11633. }
  11634. }
  11635. declare module "babylonjs/Particles/subEmitter" {
  11636. import { Scene } from "babylonjs/scene";
  11637. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11638. /**
  11639. * Type of sub emitter
  11640. */
  11641. export enum SubEmitterType {
  11642. /**
  11643. * Attached to the particle over it's lifetime
  11644. */
  11645. ATTACHED = 0,
  11646. /**
  11647. * Created when the particle dies
  11648. */
  11649. END = 1
  11650. }
  11651. /**
  11652. * Sub emitter class used to emit particles from an existing particle
  11653. */
  11654. export class SubEmitter {
  11655. /**
  11656. * the particle system to be used by the sub emitter
  11657. */
  11658. particleSystem: ParticleSystem;
  11659. /**
  11660. * Type of the submitter (Default: END)
  11661. */
  11662. type: SubEmitterType;
  11663. /**
  11664. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  11665. * Note: This only is supported when using an emitter of type Mesh
  11666. */
  11667. inheritDirection: boolean;
  11668. /**
  11669. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11670. */
  11671. inheritedVelocityAmount: number;
  11672. /**
  11673. * Creates a sub emitter
  11674. * @param particleSystem the particle system to be used by the sub emitter
  11675. */
  11676. constructor(
  11677. /**
  11678. * the particle system to be used by the sub emitter
  11679. */
  11680. particleSystem: ParticleSystem);
  11681. /**
  11682. * Clones the sub emitter
  11683. * @returns the cloned sub emitter
  11684. */
  11685. clone(): SubEmitter;
  11686. /**
  11687. * Serialize current object to a JSON object
  11688. * @returns the serialized object
  11689. */
  11690. serialize(): any;
  11691. /** @hidden */
  11692. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11693. /**
  11694. * Creates a new SubEmitter from a serialized JSON version
  11695. * @param serializationObject defines the JSON object to read from
  11696. * @param scene defines the hosting scene
  11697. * @param rootUrl defines the rootUrl for data loading
  11698. * @returns a new SubEmitter
  11699. */
  11700. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11701. /** Release associated resources */
  11702. dispose(): void;
  11703. }
  11704. }
  11705. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11706. /** @hidden */
  11707. export var imageProcessingDeclaration: {
  11708. name: string;
  11709. shader: string;
  11710. };
  11711. }
  11712. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11713. /** @hidden */
  11714. export var imageProcessingFunctions: {
  11715. name: string;
  11716. shader: string;
  11717. };
  11718. }
  11719. declare module "babylonjs/Shaders/particles.fragment" {
  11720. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11721. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11722. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11723. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11724. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11725. /** @hidden */
  11726. export var particlesPixelShader: {
  11727. name: string;
  11728. shader: string;
  11729. };
  11730. }
  11731. declare module "babylonjs/Shaders/particles.vertex" {
  11732. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11733. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11734. /** @hidden */
  11735. export var particlesVertexShader: {
  11736. name: string;
  11737. shader: string;
  11738. };
  11739. }
  11740. declare module "babylonjs/Particles/particleSystem" {
  11741. import { Nullable } from "babylonjs/types";
  11742. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11743. import { Observable } from "babylonjs/Misc/observable";
  11744. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11745. import { Effect } from "babylonjs/Materials/effect";
  11746. import { Scene, IDisposable } from "babylonjs/scene";
  11747. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11748. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11749. import { Particle } from "babylonjs/Particles/particle";
  11750. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11751. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11752. import "babylonjs/Shaders/particles.fragment";
  11753. import "babylonjs/Shaders/particles.vertex";
  11754. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11755. /**
  11756. * This represents a particle system in Babylon.
  11757. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11758. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11759. * @example https://doc.babylonjs.com/babylon101/particles
  11760. */
  11761. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11762. /**
  11763. * Billboard mode will only apply to Y axis
  11764. */
  11765. static readonly BILLBOARDMODE_Y: number;
  11766. /**
  11767. * Billboard mode will apply to all axes
  11768. */
  11769. static readonly BILLBOARDMODE_ALL: number;
  11770. /**
  11771. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11772. */
  11773. static readonly BILLBOARDMODE_STRETCHED: number;
  11774. /**
  11775. * This function can be defined to provide custom update for active particles.
  11776. * This function will be called instead of regular update (age, position, color, etc.).
  11777. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11778. */
  11779. updateFunction: (particles: Particle[]) => void;
  11780. private _emitterWorldMatrix;
  11781. /**
  11782. * This function can be defined to specify initial direction for every new particle.
  11783. * It by default use the emitterType defined function
  11784. */
  11785. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  11786. /**
  11787. * This function can be defined to specify initial position for every new particle.
  11788. * It by default use the emitterType defined function
  11789. */
  11790. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  11791. /**
  11792. * @hidden
  11793. */
  11794. _inheritedVelocityOffset: Vector3;
  11795. /**
  11796. * An event triggered when the system is disposed
  11797. */
  11798. onDisposeObservable: Observable<ParticleSystem>;
  11799. private _onDisposeObserver;
  11800. /**
  11801. * Sets a callback that will be triggered when the system is disposed
  11802. */
  11803. set onDispose(callback: () => void);
  11804. private _particles;
  11805. private _epsilon;
  11806. private _capacity;
  11807. private _stockParticles;
  11808. private _newPartsExcess;
  11809. private _vertexData;
  11810. private _vertexBuffer;
  11811. private _vertexBuffers;
  11812. private _spriteBuffer;
  11813. private _indexBuffer;
  11814. private _effect;
  11815. private _customEffect;
  11816. private _cachedDefines;
  11817. private _scaledColorStep;
  11818. private _colorDiff;
  11819. private _scaledDirection;
  11820. private _scaledGravity;
  11821. private _currentRenderId;
  11822. private _alive;
  11823. private _useInstancing;
  11824. private _started;
  11825. private _stopped;
  11826. private _actualFrame;
  11827. private _scaledUpdateSpeed;
  11828. private _vertexBufferSize;
  11829. /** @hidden */
  11830. _currentEmitRateGradient: Nullable<FactorGradient>;
  11831. /** @hidden */
  11832. _currentEmitRate1: number;
  11833. /** @hidden */
  11834. _currentEmitRate2: number;
  11835. /** @hidden */
  11836. _currentStartSizeGradient: Nullable<FactorGradient>;
  11837. /** @hidden */
  11838. _currentStartSize1: number;
  11839. /** @hidden */
  11840. _currentStartSize2: number;
  11841. private readonly _rawTextureWidth;
  11842. private _rampGradientsTexture;
  11843. private _useRampGradients;
  11844. /** Gets or sets a boolean indicating that ramp gradients must be used
  11845. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11846. */
  11847. get useRampGradients(): boolean;
  11848. set useRampGradients(value: boolean);
  11849. /**
  11850. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  11851. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  11852. */
  11853. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11854. private _subEmitters;
  11855. /**
  11856. * @hidden
  11857. * If the particle systems emitter should be disposed when the particle system is disposed
  11858. */
  11859. _disposeEmitterOnDispose: boolean;
  11860. /**
  11861. * The current active Sub-systems, this property is used by the root particle system only.
  11862. */
  11863. activeSubSystems: Array<ParticleSystem>;
  11864. private _rootParticleSystem;
  11865. /**
  11866. * Gets the current list of active particles
  11867. */
  11868. get particles(): Particle[];
  11869. /**
  11870. * Returns the string "ParticleSystem"
  11871. * @returns a string containing the class name
  11872. */
  11873. getClassName(): string;
  11874. /**
  11875. * Instantiates a particle system.
  11876. * 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.
  11877. * @param name The name of the particle system
  11878. * @param capacity The max number of particles alive at the same time
  11879. * @param scene The scene the particle system belongs to
  11880. * @param customEffect a custom effect used to change the way particles are rendered by default
  11881. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11882. * @param epsilon Offset used to render the particles
  11883. */
  11884. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11885. private _addFactorGradient;
  11886. private _removeFactorGradient;
  11887. /**
  11888. * Adds a new life time gradient
  11889. * @param gradient defines the gradient to use (between 0 and 1)
  11890. * @param factor defines the life time factor to affect to the specified gradient
  11891. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11892. * @returns the current particle system
  11893. */
  11894. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11895. /**
  11896. * Remove a specific life time gradient
  11897. * @param gradient defines the gradient to remove
  11898. * @returns the current particle system
  11899. */
  11900. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11901. /**
  11902. * Adds a new size gradient
  11903. * @param gradient defines the gradient to use (between 0 and 1)
  11904. * @param factor defines the size factor to affect to the specified gradient
  11905. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11906. * @returns the current particle system
  11907. */
  11908. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11909. /**
  11910. * Remove a specific size gradient
  11911. * @param gradient defines the gradient to remove
  11912. * @returns the current particle system
  11913. */
  11914. removeSizeGradient(gradient: number): IParticleSystem;
  11915. /**
  11916. * Adds a new color remap gradient
  11917. * @param gradient defines the gradient to use (between 0 and 1)
  11918. * @param min defines the color remap minimal range
  11919. * @param max defines the color remap maximal range
  11920. * @returns the current particle system
  11921. */
  11922. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11923. /**
  11924. * Remove a specific color remap gradient
  11925. * @param gradient defines the gradient to remove
  11926. * @returns the current particle system
  11927. */
  11928. removeColorRemapGradient(gradient: number): IParticleSystem;
  11929. /**
  11930. * Adds a new alpha remap gradient
  11931. * @param gradient defines the gradient to use (between 0 and 1)
  11932. * @param min defines the alpha remap minimal range
  11933. * @param max defines the alpha remap maximal range
  11934. * @returns the current particle system
  11935. */
  11936. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11937. /**
  11938. * Remove a specific alpha remap gradient
  11939. * @param gradient defines the gradient to remove
  11940. * @returns the current particle system
  11941. */
  11942. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11943. /**
  11944. * Adds a new angular speed gradient
  11945. * @param gradient defines the gradient to use (between 0 and 1)
  11946. * @param factor defines the angular speed to affect to the specified gradient
  11947. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11948. * @returns the current particle system
  11949. */
  11950. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11951. /**
  11952. * Remove a specific angular speed gradient
  11953. * @param gradient defines the gradient to remove
  11954. * @returns the current particle system
  11955. */
  11956. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11957. /**
  11958. * Adds a new velocity gradient
  11959. * @param gradient defines the gradient to use (between 0 and 1)
  11960. * @param factor defines the velocity to affect to the specified gradient
  11961. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11962. * @returns the current particle system
  11963. */
  11964. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11965. /**
  11966. * Remove a specific velocity gradient
  11967. * @param gradient defines the gradient to remove
  11968. * @returns the current particle system
  11969. */
  11970. removeVelocityGradient(gradient: number): IParticleSystem;
  11971. /**
  11972. * Adds a new limit velocity gradient
  11973. * @param gradient defines the gradient to use (between 0 and 1)
  11974. * @param factor defines the limit velocity value to affect to the specified gradient
  11975. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11976. * @returns the current particle system
  11977. */
  11978. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11979. /**
  11980. * Remove a specific limit velocity gradient
  11981. * @param gradient defines the gradient to remove
  11982. * @returns the current particle system
  11983. */
  11984. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11985. /**
  11986. * Adds a new drag gradient
  11987. * @param gradient defines the gradient to use (between 0 and 1)
  11988. * @param factor defines the drag value to affect to the specified gradient
  11989. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11990. * @returns the current particle system
  11991. */
  11992. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11993. /**
  11994. * Remove a specific drag gradient
  11995. * @param gradient defines the gradient to remove
  11996. * @returns the current particle system
  11997. */
  11998. removeDragGradient(gradient: number): IParticleSystem;
  11999. /**
  12000. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12001. * @param gradient defines the gradient to use (between 0 and 1)
  12002. * @param factor defines the emit rate value to affect to the specified gradient
  12003. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12004. * @returns the current particle system
  12005. */
  12006. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12007. /**
  12008. * Remove a specific emit rate gradient
  12009. * @param gradient defines the gradient to remove
  12010. * @returns the current particle system
  12011. */
  12012. removeEmitRateGradient(gradient: number): IParticleSystem;
  12013. /**
  12014. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12015. * @param gradient defines the gradient to use (between 0 and 1)
  12016. * @param factor defines the start size value to affect to the specified gradient
  12017. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12018. * @returns the current particle system
  12019. */
  12020. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12021. /**
  12022. * Remove a specific start size gradient
  12023. * @param gradient defines the gradient to remove
  12024. * @returns the current particle system
  12025. */
  12026. removeStartSizeGradient(gradient: number): IParticleSystem;
  12027. private _createRampGradientTexture;
  12028. /**
  12029. * Gets the current list of ramp gradients.
  12030. * You must use addRampGradient and removeRampGradient to udpate this list
  12031. * @returns the list of ramp gradients
  12032. */
  12033. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12034. /**
  12035. * Adds a new ramp gradient used to remap particle colors
  12036. * @param gradient defines the gradient to use (between 0 and 1)
  12037. * @param color defines the color to affect to the specified gradient
  12038. * @returns the current particle system
  12039. */
  12040. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12041. /**
  12042. * Remove a specific ramp gradient
  12043. * @param gradient defines the gradient to remove
  12044. * @returns the current particle system
  12045. */
  12046. removeRampGradient(gradient: number): ParticleSystem;
  12047. /**
  12048. * Adds a new color gradient
  12049. * @param gradient defines the gradient to use (between 0 and 1)
  12050. * @param color1 defines the color to affect to the specified gradient
  12051. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12052. * @returns this particle system
  12053. */
  12054. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12055. /**
  12056. * Remove a specific color gradient
  12057. * @param gradient defines the gradient to remove
  12058. * @returns this particle system
  12059. */
  12060. removeColorGradient(gradient: number): IParticleSystem;
  12061. private _fetchR;
  12062. protected _reset(): void;
  12063. private _resetEffect;
  12064. private _createVertexBuffers;
  12065. private _createIndexBuffer;
  12066. /**
  12067. * Gets the maximum number of particles active at the same time.
  12068. * @returns The max number of active particles.
  12069. */
  12070. getCapacity(): number;
  12071. /**
  12072. * Gets whether there are still active particles in the system.
  12073. * @returns True if it is alive, otherwise false.
  12074. */
  12075. isAlive(): boolean;
  12076. /**
  12077. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12078. * @returns True if it has been started, otherwise false.
  12079. */
  12080. isStarted(): boolean;
  12081. private _prepareSubEmitterInternalArray;
  12082. /**
  12083. * Starts the particle system and begins to emit
  12084. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12085. */
  12086. start(delay?: number): void;
  12087. /**
  12088. * Stops the particle system.
  12089. * @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.
  12090. */
  12091. stop(stopSubEmitters?: boolean): void;
  12092. /**
  12093. * Remove all active particles
  12094. */
  12095. reset(): void;
  12096. /**
  12097. * @hidden (for internal use only)
  12098. */
  12099. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12100. /**
  12101. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12102. * Its lifetime will start back at 0.
  12103. */
  12104. recycleParticle: (particle: Particle) => void;
  12105. private _stopSubEmitters;
  12106. private _createParticle;
  12107. private _removeFromRoot;
  12108. private _emitFromParticle;
  12109. private _update;
  12110. /** @hidden */
  12111. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12112. /** @hidden */
  12113. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12114. /** @hidden */
  12115. private _getEffect;
  12116. /**
  12117. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12118. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12119. */
  12120. animate(preWarmOnly?: boolean): void;
  12121. private _appendParticleVertices;
  12122. /**
  12123. * Rebuilds the particle system.
  12124. */
  12125. rebuild(): void;
  12126. /**
  12127. * Is this system ready to be used/rendered
  12128. * @return true if the system is ready
  12129. */
  12130. isReady(): boolean;
  12131. private _render;
  12132. /**
  12133. * Renders the particle system in its current state.
  12134. * @returns the current number of particles
  12135. */
  12136. render(): number;
  12137. /**
  12138. * Disposes the particle system and free the associated resources
  12139. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12140. */
  12141. dispose(disposeTexture?: boolean): void;
  12142. /**
  12143. * Clones the particle system.
  12144. * @param name The name of the cloned object
  12145. * @param newEmitter The new emitter to use
  12146. * @returns the cloned particle system
  12147. */
  12148. clone(name: string, newEmitter: any): ParticleSystem;
  12149. /**
  12150. * Serializes the particle system to a JSON object.
  12151. * @returns the JSON object
  12152. */
  12153. serialize(): any;
  12154. /** @hidden */
  12155. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  12156. /** @hidden */
  12157. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12158. /**
  12159. * Parses a JSON object to create a particle system.
  12160. * @param parsedParticleSystem The JSON object to parse
  12161. * @param scene The scene to create the particle system in
  12162. * @param rootUrl The root url to use to load external dependencies like texture
  12163. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12164. * @returns the Parsed particle system
  12165. */
  12166. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12167. }
  12168. }
  12169. declare module "babylonjs/Particles/particle" {
  12170. import { Nullable } from "babylonjs/types";
  12171. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12172. import { Color4 } from "babylonjs/Maths/math.color";
  12173. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12174. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12175. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12176. /**
  12177. * A particle represents one of the element emitted by a particle system.
  12178. * This is mainly define by its coordinates, direction, velocity and age.
  12179. */
  12180. export class Particle {
  12181. /**
  12182. * The particle system the particle belongs to.
  12183. */
  12184. particleSystem: ParticleSystem;
  12185. private static _Count;
  12186. /**
  12187. * Unique ID of the particle
  12188. */
  12189. id: number;
  12190. /**
  12191. * The world position of the particle in the scene.
  12192. */
  12193. position: Vector3;
  12194. /**
  12195. * The world direction of the particle in the scene.
  12196. */
  12197. direction: Vector3;
  12198. /**
  12199. * The color of the particle.
  12200. */
  12201. color: Color4;
  12202. /**
  12203. * The color change of the particle per step.
  12204. */
  12205. colorStep: Color4;
  12206. /**
  12207. * Defines how long will the life of the particle be.
  12208. */
  12209. lifeTime: number;
  12210. /**
  12211. * The current age of the particle.
  12212. */
  12213. age: number;
  12214. /**
  12215. * The current size of the particle.
  12216. */
  12217. size: number;
  12218. /**
  12219. * The current scale of the particle.
  12220. */
  12221. scale: Vector2;
  12222. /**
  12223. * The current angle of the particle.
  12224. */
  12225. angle: number;
  12226. /**
  12227. * Defines how fast is the angle changing.
  12228. */
  12229. angularSpeed: number;
  12230. /**
  12231. * Defines the cell index used by the particle to be rendered from a sprite.
  12232. */
  12233. cellIndex: number;
  12234. /**
  12235. * The information required to support color remapping
  12236. */
  12237. remapData: Vector4;
  12238. /** @hidden */
  12239. _randomCellOffset?: number;
  12240. /** @hidden */
  12241. _initialDirection: Nullable<Vector3>;
  12242. /** @hidden */
  12243. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12244. /** @hidden */
  12245. _initialStartSpriteCellID: number;
  12246. /** @hidden */
  12247. _initialEndSpriteCellID: number;
  12248. /** @hidden */
  12249. _currentColorGradient: Nullable<ColorGradient>;
  12250. /** @hidden */
  12251. _currentColor1: Color4;
  12252. /** @hidden */
  12253. _currentColor2: Color4;
  12254. /** @hidden */
  12255. _currentSizeGradient: Nullable<FactorGradient>;
  12256. /** @hidden */
  12257. _currentSize1: number;
  12258. /** @hidden */
  12259. _currentSize2: number;
  12260. /** @hidden */
  12261. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12262. /** @hidden */
  12263. _currentAngularSpeed1: number;
  12264. /** @hidden */
  12265. _currentAngularSpeed2: number;
  12266. /** @hidden */
  12267. _currentVelocityGradient: Nullable<FactorGradient>;
  12268. /** @hidden */
  12269. _currentVelocity1: number;
  12270. /** @hidden */
  12271. _currentVelocity2: number;
  12272. /** @hidden */
  12273. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12274. /** @hidden */
  12275. _currentLimitVelocity1: number;
  12276. /** @hidden */
  12277. _currentLimitVelocity2: number;
  12278. /** @hidden */
  12279. _currentDragGradient: Nullable<FactorGradient>;
  12280. /** @hidden */
  12281. _currentDrag1: number;
  12282. /** @hidden */
  12283. _currentDrag2: number;
  12284. /** @hidden */
  12285. _randomNoiseCoordinates1: Vector3;
  12286. /** @hidden */
  12287. _randomNoiseCoordinates2: Vector3;
  12288. /**
  12289. * Creates a new instance Particle
  12290. * @param particleSystem the particle system the particle belongs to
  12291. */
  12292. constructor(
  12293. /**
  12294. * The particle system the particle belongs to.
  12295. */
  12296. particleSystem: ParticleSystem);
  12297. private updateCellInfoFromSystem;
  12298. /**
  12299. * Defines how the sprite cell index is updated for the particle
  12300. */
  12301. updateCellIndex(): void;
  12302. /** @hidden */
  12303. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12304. /** @hidden */
  12305. _inheritParticleInfoToSubEmitters(): void;
  12306. /** @hidden */
  12307. _reset(): void;
  12308. /**
  12309. * Copy the properties of particle to another one.
  12310. * @param other the particle to copy the information to.
  12311. */
  12312. copyTo(other: Particle): void;
  12313. }
  12314. }
  12315. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12316. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12317. import { Effect } from "babylonjs/Materials/effect";
  12318. import { Particle } from "babylonjs/Particles/particle";
  12319. import { Scene } from "babylonjs/scene";
  12320. /**
  12321. * Particle emitter represents a volume emitting particles.
  12322. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12323. */
  12324. export interface IParticleEmitterType {
  12325. /**
  12326. * Called by the particle System when the direction is computed for the created particle.
  12327. * @param worldMatrix is the world matrix of the particle system
  12328. * @param directionToUpdate is the direction vector to update with the result
  12329. * @param particle is the particle we are computed the direction for
  12330. */
  12331. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12332. /**
  12333. * Called by the particle System when the position is computed for the created particle.
  12334. * @param worldMatrix is the world matrix of the particle system
  12335. * @param positionToUpdate is the position vector to update with the result
  12336. * @param particle is the particle we are computed the position for
  12337. */
  12338. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12339. /**
  12340. * Clones the current emitter and returns a copy of it
  12341. * @returns the new emitter
  12342. */
  12343. clone(): IParticleEmitterType;
  12344. /**
  12345. * Called by the GPUParticleSystem to setup the update shader
  12346. * @param effect defines the update shader
  12347. */
  12348. applyToShader(effect: Effect): void;
  12349. /**
  12350. * Returns a string to use to update the GPU particles update shader
  12351. * @returns the effect defines string
  12352. */
  12353. getEffectDefines(): string;
  12354. /**
  12355. * Returns a string representing the class name
  12356. * @returns a string containing the class name
  12357. */
  12358. getClassName(): string;
  12359. /**
  12360. * Serializes the particle system to a JSON object.
  12361. * @returns the JSON object
  12362. */
  12363. serialize(): any;
  12364. /**
  12365. * Parse properties from a JSON object
  12366. * @param serializationObject defines the JSON object
  12367. * @param scene defines the hosting scene
  12368. */
  12369. parse(serializationObject: any, scene: Scene): void;
  12370. }
  12371. }
  12372. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12373. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12374. import { Effect } from "babylonjs/Materials/effect";
  12375. import { Particle } from "babylonjs/Particles/particle";
  12376. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12377. /**
  12378. * Particle emitter emitting particles from the inside of a box.
  12379. * It emits the particles randomly between 2 given directions.
  12380. */
  12381. export class BoxParticleEmitter implements IParticleEmitterType {
  12382. /**
  12383. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12384. */
  12385. direction1: Vector3;
  12386. /**
  12387. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12388. */
  12389. direction2: Vector3;
  12390. /**
  12391. * 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.
  12392. */
  12393. minEmitBox: Vector3;
  12394. /**
  12395. * 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.
  12396. */
  12397. maxEmitBox: Vector3;
  12398. /**
  12399. * Creates a new instance BoxParticleEmitter
  12400. */
  12401. constructor();
  12402. /**
  12403. * Called by the particle System when the direction is computed for the created particle.
  12404. * @param worldMatrix is the world matrix of the particle system
  12405. * @param directionToUpdate is the direction vector to update with the result
  12406. * @param particle is the particle we are computed the direction for
  12407. */
  12408. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12409. /**
  12410. * Called by the particle System when the position is computed for the created particle.
  12411. * @param worldMatrix is the world matrix of the particle system
  12412. * @param positionToUpdate is the position vector to update with the result
  12413. * @param particle is the particle we are computed the position for
  12414. */
  12415. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12416. /**
  12417. * Clones the current emitter and returns a copy of it
  12418. * @returns the new emitter
  12419. */
  12420. clone(): BoxParticleEmitter;
  12421. /**
  12422. * Called by the GPUParticleSystem to setup the update shader
  12423. * @param effect defines the update shader
  12424. */
  12425. applyToShader(effect: Effect): void;
  12426. /**
  12427. * Returns a string to use to update the GPU particles update shader
  12428. * @returns a string containng the defines string
  12429. */
  12430. getEffectDefines(): string;
  12431. /**
  12432. * Returns the string "BoxParticleEmitter"
  12433. * @returns a string containing the class name
  12434. */
  12435. getClassName(): string;
  12436. /**
  12437. * Serializes the particle system to a JSON object.
  12438. * @returns the JSON object
  12439. */
  12440. serialize(): any;
  12441. /**
  12442. * Parse properties from a JSON object
  12443. * @param serializationObject defines the JSON object
  12444. */
  12445. parse(serializationObject: any): void;
  12446. }
  12447. }
  12448. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12449. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12450. import { Effect } from "babylonjs/Materials/effect";
  12451. import { Particle } from "babylonjs/Particles/particle";
  12452. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12453. /**
  12454. * Particle emitter emitting particles from the inside of a cone.
  12455. * It emits the particles alongside the cone volume from the base to the particle.
  12456. * The emission direction might be randomized.
  12457. */
  12458. export class ConeParticleEmitter implements IParticleEmitterType {
  12459. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12460. directionRandomizer: number;
  12461. private _radius;
  12462. private _angle;
  12463. private _height;
  12464. /**
  12465. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12466. */
  12467. radiusRange: number;
  12468. /**
  12469. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12470. */
  12471. heightRange: number;
  12472. /**
  12473. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12474. */
  12475. emitFromSpawnPointOnly: boolean;
  12476. /**
  12477. * Gets or sets the radius of the emission cone
  12478. */
  12479. get radius(): number;
  12480. set radius(value: number);
  12481. /**
  12482. * Gets or sets the angle of the emission cone
  12483. */
  12484. get angle(): number;
  12485. set angle(value: number);
  12486. private _buildHeight;
  12487. /**
  12488. * Creates a new instance ConeParticleEmitter
  12489. * @param radius the radius of the emission cone (1 by default)
  12490. * @param angle the cone base angle (PI by default)
  12491. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12492. */
  12493. constructor(radius?: number, angle?: number,
  12494. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12495. directionRandomizer?: number);
  12496. /**
  12497. * Called by the particle System when the direction is computed for the created particle.
  12498. * @param worldMatrix is the world matrix of the particle system
  12499. * @param directionToUpdate is the direction vector to update with the result
  12500. * @param particle is the particle we are computed the direction for
  12501. */
  12502. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12503. /**
  12504. * Called by the particle System when the position is computed for the created particle.
  12505. * @param worldMatrix is the world matrix of the particle system
  12506. * @param positionToUpdate is the position vector to update with the result
  12507. * @param particle is the particle we are computed the position for
  12508. */
  12509. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12510. /**
  12511. * Clones the current emitter and returns a copy of it
  12512. * @returns the new emitter
  12513. */
  12514. clone(): ConeParticleEmitter;
  12515. /**
  12516. * Called by the GPUParticleSystem to setup the update shader
  12517. * @param effect defines the update shader
  12518. */
  12519. applyToShader(effect: Effect): void;
  12520. /**
  12521. * Returns a string to use to update the GPU particles update shader
  12522. * @returns a string containng the defines string
  12523. */
  12524. getEffectDefines(): string;
  12525. /**
  12526. * Returns the string "ConeParticleEmitter"
  12527. * @returns a string containing the class name
  12528. */
  12529. getClassName(): string;
  12530. /**
  12531. * Serializes the particle system to a JSON object.
  12532. * @returns the JSON object
  12533. */
  12534. serialize(): any;
  12535. /**
  12536. * Parse properties from a JSON object
  12537. * @param serializationObject defines the JSON object
  12538. */
  12539. parse(serializationObject: any): void;
  12540. }
  12541. }
  12542. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12543. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12544. import { Effect } from "babylonjs/Materials/effect";
  12545. import { Particle } from "babylonjs/Particles/particle";
  12546. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12547. /**
  12548. * Particle emitter emitting particles from the inside of a cylinder.
  12549. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12550. */
  12551. export class CylinderParticleEmitter implements IParticleEmitterType {
  12552. /**
  12553. * The radius of the emission cylinder.
  12554. */
  12555. radius: number;
  12556. /**
  12557. * The height of the emission cylinder.
  12558. */
  12559. height: number;
  12560. /**
  12561. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12562. */
  12563. radiusRange: number;
  12564. /**
  12565. * How much to randomize the particle direction [0-1].
  12566. */
  12567. directionRandomizer: number;
  12568. /**
  12569. * Creates a new instance CylinderParticleEmitter
  12570. * @param radius the radius of the emission cylinder (1 by default)
  12571. * @param height the height of the emission cylinder (1 by default)
  12572. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12573. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12574. */
  12575. constructor(
  12576. /**
  12577. * The radius of the emission cylinder.
  12578. */
  12579. radius?: number,
  12580. /**
  12581. * The height of the emission cylinder.
  12582. */
  12583. height?: number,
  12584. /**
  12585. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12586. */
  12587. radiusRange?: number,
  12588. /**
  12589. * How much to randomize the particle direction [0-1].
  12590. */
  12591. directionRandomizer?: number);
  12592. /**
  12593. * Called by the particle System when the direction is computed for the created particle.
  12594. * @param worldMatrix is the world matrix of the particle system
  12595. * @param directionToUpdate is the direction vector to update with the result
  12596. * @param particle is the particle we are computed the direction for
  12597. */
  12598. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12599. /**
  12600. * Called by the particle System when the position is computed for the created particle.
  12601. * @param worldMatrix is the world matrix of the particle system
  12602. * @param positionToUpdate is the position vector to update with the result
  12603. * @param particle is the particle we are computed the position for
  12604. */
  12605. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12606. /**
  12607. * Clones the current emitter and returns a copy of it
  12608. * @returns the new emitter
  12609. */
  12610. clone(): CylinderParticleEmitter;
  12611. /**
  12612. * Called by the GPUParticleSystem to setup the update shader
  12613. * @param effect defines the update shader
  12614. */
  12615. applyToShader(effect: Effect): void;
  12616. /**
  12617. * Returns a string to use to update the GPU particles update shader
  12618. * @returns a string containng the defines string
  12619. */
  12620. getEffectDefines(): string;
  12621. /**
  12622. * Returns the string "CylinderParticleEmitter"
  12623. * @returns a string containing the class name
  12624. */
  12625. getClassName(): string;
  12626. /**
  12627. * Serializes the particle system to a JSON object.
  12628. * @returns the JSON object
  12629. */
  12630. serialize(): any;
  12631. /**
  12632. * Parse properties from a JSON object
  12633. * @param serializationObject defines the JSON object
  12634. */
  12635. parse(serializationObject: any): void;
  12636. }
  12637. /**
  12638. * Particle emitter emitting particles from the inside of a cylinder.
  12639. * It emits the particles randomly between two vectors.
  12640. */
  12641. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12642. /**
  12643. * The min limit of the emission direction.
  12644. */
  12645. direction1: Vector3;
  12646. /**
  12647. * The max limit of the emission direction.
  12648. */
  12649. direction2: Vector3;
  12650. /**
  12651. * Creates a new instance CylinderDirectedParticleEmitter
  12652. * @param radius the radius of the emission cylinder (1 by default)
  12653. * @param height the height of the emission cylinder (1 by default)
  12654. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12655. * @param direction1 the min limit of the emission direction (up vector by default)
  12656. * @param direction2 the max limit of the emission direction (up vector by default)
  12657. */
  12658. constructor(radius?: number, height?: number, radiusRange?: number,
  12659. /**
  12660. * The min limit of the emission direction.
  12661. */
  12662. direction1?: Vector3,
  12663. /**
  12664. * The max limit of the emission direction.
  12665. */
  12666. direction2?: Vector3);
  12667. /**
  12668. * Called by the particle System when the direction is computed for the created particle.
  12669. * @param worldMatrix is the world matrix of the particle system
  12670. * @param directionToUpdate is the direction vector to update with the result
  12671. * @param particle is the particle we are computed the direction for
  12672. */
  12673. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12674. /**
  12675. * Clones the current emitter and returns a copy of it
  12676. * @returns the new emitter
  12677. */
  12678. clone(): CylinderDirectedParticleEmitter;
  12679. /**
  12680. * Called by the GPUParticleSystem to setup the update shader
  12681. * @param effect defines the update shader
  12682. */
  12683. applyToShader(effect: Effect): void;
  12684. /**
  12685. * Returns a string to use to update the GPU particles update shader
  12686. * @returns a string containng the defines string
  12687. */
  12688. getEffectDefines(): string;
  12689. /**
  12690. * Returns the string "CylinderDirectedParticleEmitter"
  12691. * @returns a string containing the class name
  12692. */
  12693. getClassName(): string;
  12694. /**
  12695. * Serializes the particle system to a JSON object.
  12696. * @returns the JSON object
  12697. */
  12698. serialize(): any;
  12699. /**
  12700. * Parse properties from a JSON object
  12701. * @param serializationObject defines the JSON object
  12702. */
  12703. parse(serializationObject: any): void;
  12704. }
  12705. }
  12706. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12707. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12708. import { Effect } from "babylonjs/Materials/effect";
  12709. import { Particle } from "babylonjs/Particles/particle";
  12710. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12711. /**
  12712. * Particle emitter emitting particles from the inside of a hemisphere.
  12713. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12714. */
  12715. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12716. /**
  12717. * The radius of the emission hemisphere.
  12718. */
  12719. radius: number;
  12720. /**
  12721. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12722. */
  12723. radiusRange: number;
  12724. /**
  12725. * How much to randomize the particle direction [0-1].
  12726. */
  12727. directionRandomizer: number;
  12728. /**
  12729. * Creates a new instance HemisphericParticleEmitter
  12730. * @param radius the radius of the emission hemisphere (1 by default)
  12731. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12732. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12733. */
  12734. constructor(
  12735. /**
  12736. * The radius of the emission hemisphere.
  12737. */
  12738. radius?: number,
  12739. /**
  12740. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12741. */
  12742. radiusRange?: number,
  12743. /**
  12744. * How much to randomize the particle direction [0-1].
  12745. */
  12746. directionRandomizer?: number);
  12747. /**
  12748. * Called by the particle System when the direction is computed for the created particle.
  12749. * @param worldMatrix is the world matrix of the particle system
  12750. * @param directionToUpdate is the direction vector to update with the result
  12751. * @param particle is the particle we are computed the direction for
  12752. */
  12753. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12754. /**
  12755. * Called by the particle System when the position is computed for the created particle.
  12756. * @param worldMatrix is the world matrix of the particle system
  12757. * @param positionToUpdate is the position vector to update with the result
  12758. * @param particle is the particle we are computed the position for
  12759. */
  12760. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12761. /**
  12762. * Clones the current emitter and returns a copy of it
  12763. * @returns the new emitter
  12764. */
  12765. clone(): HemisphericParticleEmitter;
  12766. /**
  12767. * Called by the GPUParticleSystem to setup the update shader
  12768. * @param effect defines the update shader
  12769. */
  12770. applyToShader(effect: Effect): void;
  12771. /**
  12772. * Returns a string to use to update the GPU particles update shader
  12773. * @returns a string containng the defines string
  12774. */
  12775. getEffectDefines(): string;
  12776. /**
  12777. * Returns the string "HemisphericParticleEmitter"
  12778. * @returns a string containing the class name
  12779. */
  12780. getClassName(): string;
  12781. /**
  12782. * Serializes the particle system to a JSON object.
  12783. * @returns the JSON object
  12784. */
  12785. serialize(): any;
  12786. /**
  12787. * Parse properties from a JSON object
  12788. * @param serializationObject defines the JSON object
  12789. */
  12790. parse(serializationObject: any): void;
  12791. }
  12792. }
  12793. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12794. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12795. import { Effect } from "babylonjs/Materials/effect";
  12796. import { Particle } from "babylonjs/Particles/particle";
  12797. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12798. /**
  12799. * Particle emitter emitting particles from a point.
  12800. * It emits the particles randomly between 2 given directions.
  12801. */
  12802. export class PointParticleEmitter implements IParticleEmitterType {
  12803. /**
  12804. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12805. */
  12806. direction1: Vector3;
  12807. /**
  12808. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12809. */
  12810. direction2: Vector3;
  12811. /**
  12812. * Creates a new instance PointParticleEmitter
  12813. */
  12814. constructor();
  12815. /**
  12816. * Called by the particle System when the direction is computed for the created particle.
  12817. * @param worldMatrix is the world matrix of the particle system
  12818. * @param directionToUpdate is the direction vector to update with the result
  12819. * @param particle is the particle we are computed the direction for
  12820. */
  12821. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12822. /**
  12823. * Called by the particle System when the position is computed for the created particle.
  12824. * @param worldMatrix is the world matrix of the particle system
  12825. * @param positionToUpdate is the position vector to update with the result
  12826. * @param particle is the particle we are computed the position for
  12827. */
  12828. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12829. /**
  12830. * Clones the current emitter and returns a copy of it
  12831. * @returns the new emitter
  12832. */
  12833. clone(): PointParticleEmitter;
  12834. /**
  12835. * Called by the GPUParticleSystem to setup the update shader
  12836. * @param effect defines the update shader
  12837. */
  12838. applyToShader(effect: Effect): void;
  12839. /**
  12840. * Returns a string to use to update the GPU particles update shader
  12841. * @returns a string containng the defines string
  12842. */
  12843. getEffectDefines(): string;
  12844. /**
  12845. * Returns the string "PointParticleEmitter"
  12846. * @returns a string containing the class name
  12847. */
  12848. getClassName(): string;
  12849. /**
  12850. * Serializes the particle system to a JSON object.
  12851. * @returns the JSON object
  12852. */
  12853. serialize(): any;
  12854. /**
  12855. * Parse properties from a JSON object
  12856. * @param serializationObject defines the JSON object
  12857. */
  12858. parse(serializationObject: any): void;
  12859. }
  12860. }
  12861. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  12862. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12863. import { Effect } from "babylonjs/Materials/effect";
  12864. import { Particle } from "babylonjs/Particles/particle";
  12865. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12866. /**
  12867. * Particle emitter emitting particles from the inside of a sphere.
  12868. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12869. */
  12870. export class SphereParticleEmitter implements IParticleEmitterType {
  12871. /**
  12872. * The radius of the emission sphere.
  12873. */
  12874. radius: number;
  12875. /**
  12876. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12877. */
  12878. radiusRange: number;
  12879. /**
  12880. * How much to randomize the particle direction [0-1].
  12881. */
  12882. directionRandomizer: number;
  12883. /**
  12884. * Creates a new instance SphereParticleEmitter
  12885. * @param radius the radius of the emission sphere (1 by default)
  12886. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12887. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12888. */
  12889. constructor(
  12890. /**
  12891. * The radius of the emission sphere.
  12892. */
  12893. radius?: number,
  12894. /**
  12895. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12896. */
  12897. radiusRange?: number,
  12898. /**
  12899. * How much to randomize the particle direction [0-1].
  12900. */
  12901. directionRandomizer?: number);
  12902. /**
  12903. * Called by the particle System when the direction is computed for the created particle.
  12904. * @param worldMatrix is the world matrix of the particle system
  12905. * @param directionToUpdate is the direction vector to update with the result
  12906. * @param particle is the particle we are computed the direction for
  12907. */
  12908. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12909. /**
  12910. * Called by the particle System when the position is computed for the created particle.
  12911. * @param worldMatrix is the world matrix of the particle system
  12912. * @param positionToUpdate is the position vector to update with the result
  12913. * @param particle is the particle we are computed the position for
  12914. */
  12915. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12916. /**
  12917. * Clones the current emitter and returns a copy of it
  12918. * @returns the new emitter
  12919. */
  12920. clone(): SphereParticleEmitter;
  12921. /**
  12922. * Called by the GPUParticleSystem to setup the update shader
  12923. * @param effect defines the update shader
  12924. */
  12925. applyToShader(effect: Effect): void;
  12926. /**
  12927. * Returns a string to use to update the GPU particles update shader
  12928. * @returns a string containng the defines string
  12929. */
  12930. getEffectDefines(): string;
  12931. /**
  12932. * Returns the string "SphereParticleEmitter"
  12933. * @returns a string containing the class name
  12934. */
  12935. getClassName(): string;
  12936. /**
  12937. * Serializes the particle system to a JSON object.
  12938. * @returns the JSON object
  12939. */
  12940. serialize(): any;
  12941. /**
  12942. * Parse properties from a JSON object
  12943. * @param serializationObject defines the JSON object
  12944. */
  12945. parse(serializationObject: any): void;
  12946. }
  12947. /**
  12948. * Particle emitter emitting particles from the inside of a sphere.
  12949. * It emits the particles randomly between two vectors.
  12950. */
  12951. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12952. /**
  12953. * The min limit of the emission direction.
  12954. */
  12955. direction1: Vector3;
  12956. /**
  12957. * The max limit of the emission direction.
  12958. */
  12959. direction2: Vector3;
  12960. /**
  12961. * Creates a new instance SphereDirectedParticleEmitter
  12962. * @param radius the radius of the emission sphere (1 by default)
  12963. * @param direction1 the min limit of the emission direction (up vector by default)
  12964. * @param direction2 the max limit of the emission direction (up vector by default)
  12965. */
  12966. constructor(radius?: number,
  12967. /**
  12968. * The min limit of the emission direction.
  12969. */
  12970. direction1?: Vector3,
  12971. /**
  12972. * The max limit of the emission direction.
  12973. */
  12974. direction2?: Vector3);
  12975. /**
  12976. * Called by the particle System when the direction is computed for the created particle.
  12977. * @param worldMatrix is the world matrix of the particle system
  12978. * @param directionToUpdate is the direction vector to update with the result
  12979. * @param particle is the particle we are computed the direction for
  12980. */
  12981. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12982. /**
  12983. * Clones the current emitter and returns a copy of it
  12984. * @returns the new emitter
  12985. */
  12986. clone(): SphereDirectedParticleEmitter;
  12987. /**
  12988. * Called by the GPUParticleSystem to setup the update shader
  12989. * @param effect defines the update shader
  12990. */
  12991. applyToShader(effect: Effect): void;
  12992. /**
  12993. * Returns a string to use to update the GPU particles update shader
  12994. * @returns a string containng the defines string
  12995. */
  12996. getEffectDefines(): string;
  12997. /**
  12998. * Returns the string "SphereDirectedParticleEmitter"
  12999. * @returns a string containing the class name
  13000. */
  13001. getClassName(): string;
  13002. /**
  13003. * Serializes the particle system to a JSON object.
  13004. * @returns the JSON object
  13005. */
  13006. serialize(): any;
  13007. /**
  13008. * Parse properties from a JSON object
  13009. * @param serializationObject defines the JSON object
  13010. */
  13011. parse(serializationObject: any): void;
  13012. }
  13013. }
  13014. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13015. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13016. import { Effect } from "babylonjs/Materials/effect";
  13017. import { Particle } from "babylonjs/Particles/particle";
  13018. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13019. import { Nullable } from "babylonjs/types";
  13020. /**
  13021. * Particle emitter emitting particles from a custom list of positions.
  13022. */
  13023. export class CustomParticleEmitter implements IParticleEmitterType {
  13024. /**
  13025. * Gets or sets the position generator that will create the inital position of each particle.
  13026. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13027. */
  13028. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13029. /**
  13030. * Gets or sets the destination generator that will create the final destination of each particle.
  13031. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13032. */
  13033. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13034. /**
  13035. * Creates a new instance CustomParticleEmitter
  13036. */
  13037. constructor();
  13038. /**
  13039. * Called by the particle System when the direction is computed for the created particle.
  13040. * @param worldMatrix is the world matrix of the particle system
  13041. * @param directionToUpdate is the direction vector to update with the result
  13042. * @param particle is the particle we are computed the direction for
  13043. */
  13044. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13045. /**
  13046. * Called by the particle System when the position is computed for the created particle.
  13047. * @param worldMatrix is the world matrix of the particle system
  13048. * @param positionToUpdate is the position vector to update with the result
  13049. * @param particle is the particle we are computed the position for
  13050. */
  13051. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  13052. /**
  13053. * Clones the current emitter and returns a copy of it
  13054. * @returns the new emitter
  13055. */
  13056. clone(): CustomParticleEmitter;
  13057. /**
  13058. * Called by the GPUParticleSystem to setup the update shader
  13059. * @param effect defines the update shader
  13060. */
  13061. applyToShader(effect: Effect): void;
  13062. /**
  13063. * Returns a string to use to update the GPU particles update shader
  13064. * @returns a string containng the defines string
  13065. */
  13066. getEffectDefines(): string;
  13067. /**
  13068. * Returns the string "PointParticleEmitter"
  13069. * @returns a string containing the class name
  13070. */
  13071. getClassName(): string;
  13072. /**
  13073. * Serializes the particle system to a JSON object.
  13074. * @returns the JSON object
  13075. */
  13076. serialize(): any;
  13077. /**
  13078. * Parse properties from a JSON object
  13079. * @param serializationObject defines the JSON object
  13080. */
  13081. parse(serializationObject: any): void;
  13082. }
  13083. }
  13084. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13085. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13086. import { Effect } from "babylonjs/Materials/effect";
  13087. import { Particle } from "babylonjs/Particles/particle";
  13088. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13089. import { Scene } from "babylonjs/scene";
  13090. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13091. /**
  13092. * Particle emitter emitting particles from the inside of a box.
  13093. * It emits the particles randomly between 2 given directions.
  13094. */
  13095. export class MeshParticleEmitter implements IParticleEmitterType {
  13096. /** Defines the mesh to use as source */
  13097. mesh?: AbstractMesh | undefined;
  13098. private _indices;
  13099. private _positions;
  13100. private _normals;
  13101. private _storedNormal;
  13102. /**
  13103. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13104. */
  13105. direction1: Vector3;
  13106. /**
  13107. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13108. */
  13109. direction2: Vector3;
  13110. /**
  13111. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13112. */
  13113. useMeshNormalsForDirection: boolean;
  13114. /**
  13115. * Creates a new instance MeshParticleEmitter
  13116. * @param mesh defines the mesh to use as source
  13117. */
  13118. constructor(
  13119. /** Defines the mesh to use as source */
  13120. mesh?: AbstractMesh | undefined);
  13121. /**
  13122. * Called by the particle System when the direction is computed for the created particle.
  13123. * @param worldMatrix is the world matrix of the particle system
  13124. * @param directionToUpdate is the direction vector to update with the result
  13125. * @param particle is the particle we are computed the direction for
  13126. */
  13127. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13128. /**
  13129. * Called by the particle System when the position is computed for the created particle.
  13130. * @param worldMatrix is the world matrix of the particle system
  13131. * @param positionToUpdate is the position vector to update with the result
  13132. * @param particle is the particle we are computed the position for
  13133. */
  13134. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  13135. /**
  13136. * Clones the current emitter and returns a copy of it
  13137. * @returns the new emitter
  13138. */
  13139. clone(): MeshParticleEmitter;
  13140. /**
  13141. * Called by the GPUParticleSystem to setup the update shader
  13142. * @param effect defines the update shader
  13143. */
  13144. applyToShader(effect: Effect): void;
  13145. /**
  13146. * Returns a string to use to update the GPU particles update shader
  13147. * @returns a string containng the defines string
  13148. */
  13149. getEffectDefines(): string;
  13150. /**
  13151. * Returns the string "BoxParticleEmitter"
  13152. * @returns a string containing the class name
  13153. */
  13154. getClassName(): string;
  13155. /**
  13156. * Serializes the particle system to a JSON object.
  13157. * @returns the JSON object
  13158. */
  13159. serialize(): any;
  13160. /**
  13161. * Parse properties from a JSON object
  13162. * @param serializationObject defines the JSON object
  13163. * @param scene defines the hosting scene
  13164. */
  13165. parse(serializationObject: any, scene: Scene): void;
  13166. }
  13167. }
  13168. declare module "babylonjs/Particles/EmitterTypes/index" {
  13169. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13170. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13171. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13172. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13173. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13174. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13175. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13176. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13177. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13178. }
  13179. declare module "babylonjs/Particles/IParticleSystem" {
  13180. import { Nullable } from "babylonjs/types";
  13181. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13182. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13183. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13184. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13185. import { Texture } from "babylonjs/Materials/Textures/texture";
  13186. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13187. import { Scene } from "babylonjs/scene";
  13188. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13189. import { Animation } from "babylonjs/Animations/animation";
  13190. /**
  13191. * Interface representing a particle system in Babylon.js.
  13192. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13193. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13194. */
  13195. export interface IParticleSystem {
  13196. /**
  13197. * List of animations used by the particle system.
  13198. */
  13199. animations: Animation[];
  13200. /**
  13201. * The id of the Particle system.
  13202. */
  13203. id: string;
  13204. /**
  13205. * The name of the Particle system.
  13206. */
  13207. name: string;
  13208. /**
  13209. * The emitter represents the Mesh or position we are attaching the particle system to.
  13210. */
  13211. emitter: Nullable<AbstractMesh | Vector3>;
  13212. /**
  13213. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13214. */
  13215. isBillboardBased: boolean;
  13216. /**
  13217. * The rendering group used by the Particle system to chose when to render.
  13218. */
  13219. renderingGroupId: number;
  13220. /**
  13221. * The layer mask we are rendering the particles through.
  13222. */
  13223. layerMask: number;
  13224. /**
  13225. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13226. */
  13227. updateSpeed: number;
  13228. /**
  13229. * The amount of time the particle system is running (depends of the overall update speed).
  13230. */
  13231. targetStopDuration: number;
  13232. /**
  13233. * The texture used to render each particle. (this can be a spritesheet)
  13234. */
  13235. particleTexture: Nullable<Texture>;
  13236. /**
  13237. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13238. */
  13239. blendMode: number;
  13240. /**
  13241. * Minimum life time of emitting particles.
  13242. */
  13243. minLifeTime: number;
  13244. /**
  13245. * Maximum life time of emitting particles.
  13246. */
  13247. maxLifeTime: number;
  13248. /**
  13249. * Minimum Size of emitting particles.
  13250. */
  13251. minSize: number;
  13252. /**
  13253. * Maximum Size of emitting particles.
  13254. */
  13255. maxSize: number;
  13256. /**
  13257. * Minimum scale of emitting particles on X axis.
  13258. */
  13259. minScaleX: number;
  13260. /**
  13261. * Maximum scale of emitting particles on X axis.
  13262. */
  13263. maxScaleX: number;
  13264. /**
  13265. * Minimum scale of emitting particles on Y axis.
  13266. */
  13267. minScaleY: number;
  13268. /**
  13269. * Maximum scale of emitting particles on Y axis.
  13270. */
  13271. maxScaleY: number;
  13272. /**
  13273. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13274. */
  13275. color1: Color4;
  13276. /**
  13277. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13278. */
  13279. color2: Color4;
  13280. /**
  13281. * Color the particle will have at the end of its lifetime.
  13282. */
  13283. colorDead: Color4;
  13284. /**
  13285. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13286. */
  13287. emitRate: number;
  13288. /**
  13289. * You can use gravity if you want to give an orientation to your particles.
  13290. */
  13291. gravity: Vector3;
  13292. /**
  13293. * Minimum power of emitting particles.
  13294. */
  13295. minEmitPower: number;
  13296. /**
  13297. * Maximum power of emitting particles.
  13298. */
  13299. maxEmitPower: number;
  13300. /**
  13301. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13302. */
  13303. minAngularSpeed: number;
  13304. /**
  13305. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13306. */
  13307. maxAngularSpeed: number;
  13308. /**
  13309. * Gets or sets the minimal initial rotation in radians.
  13310. */
  13311. minInitialRotation: number;
  13312. /**
  13313. * Gets or sets the maximal initial rotation in radians.
  13314. */
  13315. maxInitialRotation: number;
  13316. /**
  13317. * The particle emitter type defines the emitter used by the particle system.
  13318. * It can be for example box, sphere, or cone...
  13319. */
  13320. particleEmitterType: Nullable<IParticleEmitterType>;
  13321. /**
  13322. * Defines the delay in milliseconds before starting the system (0 by default)
  13323. */
  13324. startDelay: number;
  13325. /**
  13326. * 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
  13327. */
  13328. preWarmCycles: number;
  13329. /**
  13330. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13331. */
  13332. preWarmStepOffset: number;
  13333. /**
  13334. * 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)
  13335. */
  13336. spriteCellChangeSpeed: number;
  13337. /**
  13338. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13339. */
  13340. startSpriteCellID: number;
  13341. /**
  13342. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13343. */
  13344. endSpriteCellID: number;
  13345. /**
  13346. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13347. */
  13348. spriteCellWidth: number;
  13349. /**
  13350. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13351. */
  13352. spriteCellHeight: number;
  13353. /**
  13354. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13355. */
  13356. spriteRandomStartCell: boolean;
  13357. /**
  13358. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13359. */
  13360. isAnimationSheetEnabled: boolean;
  13361. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13362. translationPivot: Vector2;
  13363. /**
  13364. * Gets or sets a texture used to add random noise to particle positions
  13365. */
  13366. noiseTexture: Nullable<BaseTexture>;
  13367. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13368. noiseStrength: Vector3;
  13369. /**
  13370. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13371. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13372. */
  13373. billboardMode: number;
  13374. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13375. limitVelocityDamping: number;
  13376. /**
  13377. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13378. */
  13379. beginAnimationOnStart: boolean;
  13380. /**
  13381. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13382. */
  13383. beginAnimationFrom: number;
  13384. /**
  13385. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13386. */
  13387. beginAnimationTo: number;
  13388. /**
  13389. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13390. */
  13391. beginAnimationLoop: boolean;
  13392. /**
  13393. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13394. */
  13395. disposeOnStop: boolean;
  13396. /**
  13397. * Gets the maximum number of particles active at the same time.
  13398. * @returns The max number of active particles.
  13399. */
  13400. getCapacity(): number;
  13401. /**
  13402. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13403. * @returns True if it has been started, otherwise false.
  13404. */
  13405. isStarted(): boolean;
  13406. /**
  13407. * Animates the particle system for this frame.
  13408. */
  13409. animate(): void;
  13410. /**
  13411. * Renders the particle system in its current state.
  13412. * @returns the current number of particles
  13413. */
  13414. render(): number;
  13415. /**
  13416. * Dispose the particle system and frees its associated resources.
  13417. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13418. */
  13419. dispose(disposeTexture?: boolean): void;
  13420. /**
  13421. * Clones the particle system.
  13422. * @param name The name of the cloned object
  13423. * @param newEmitter The new emitter to use
  13424. * @returns the cloned particle system
  13425. */
  13426. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13427. /**
  13428. * Serializes the particle system to a JSON object.
  13429. * @returns the JSON object
  13430. */
  13431. serialize(): any;
  13432. /**
  13433. * Rebuild the particle system
  13434. */
  13435. rebuild(): void;
  13436. /**
  13437. * Starts the particle system and begins to emit
  13438. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13439. */
  13440. start(delay?: number): void;
  13441. /**
  13442. * Stops the particle system.
  13443. */
  13444. stop(): void;
  13445. /**
  13446. * Remove all active particles
  13447. */
  13448. reset(): void;
  13449. /**
  13450. * Is this system ready to be used/rendered
  13451. * @return true if the system is ready
  13452. */
  13453. isReady(): boolean;
  13454. /**
  13455. * Adds a new color gradient
  13456. * @param gradient defines the gradient to use (between 0 and 1)
  13457. * @param color1 defines the color to affect to the specified gradient
  13458. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13459. * @returns the current particle system
  13460. */
  13461. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13462. /**
  13463. * Remove a specific color gradient
  13464. * @param gradient defines the gradient to remove
  13465. * @returns the current particle system
  13466. */
  13467. removeColorGradient(gradient: number): IParticleSystem;
  13468. /**
  13469. * Adds a new size gradient
  13470. * @param gradient defines the gradient to use (between 0 and 1)
  13471. * @param factor defines the size factor to affect to the specified gradient
  13472. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13473. * @returns the current particle system
  13474. */
  13475. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13476. /**
  13477. * Remove a specific size gradient
  13478. * @param gradient defines the gradient to remove
  13479. * @returns the current particle system
  13480. */
  13481. removeSizeGradient(gradient: number): IParticleSystem;
  13482. /**
  13483. * Gets the current list of color gradients.
  13484. * You must use addColorGradient and removeColorGradient to udpate this list
  13485. * @returns the list of color gradients
  13486. */
  13487. getColorGradients(): Nullable<Array<ColorGradient>>;
  13488. /**
  13489. * Gets the current list of size gradients.
  13490. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13491. * @returns the list of size gradients
  13492. */
  13493. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13494. /**
  13495. * Gets the current list of angular speed gradients.
  13496. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13497. * @returns the list of angular speed gradients
  13498. */
  13499. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13500. /**
  13501. * Adds a new angular speed gradient
  13502. * @param gradient defines the gradient to use (between 0 and 1)
  13503. * @param factor defines the angular speed to affect to the specified gradient
  13504. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13505. * @returns the current particle system
  13506. */
  13507. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13508. /**
  13509. * Remove a specific angular speed gradient
  13510. * @param gradient defines the gradient to remove
  13511. * @returns the current particle system
  13512. */
  13513. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13514. /**
  13515. * Gets the current list of velocity gradients.
  13516. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13517. * @returns the list of velocity gradients
  13518. */
  13519. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13520. /**
  13521. * Adds a new velocity gradient
  13522. * @param gradient defines the gradient to use (between 0 and 1)
  13523. * @param factor defines the velocity to affect to the specified gradient
  13524. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13525. * @returns the current particle system
  13526. */
  13527. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13528. /**
  13529. * Remove a specific velocity gradient
  13530. * @param gradient defines the gradient to remove
  13531. * @returns the current particle system
  13532. */
  13533. removeVelocityGradient(gradient: number): IParticleSystem;
  13534. /**
  13535. * Gets the current list of limit velocity gradients.
  13536. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13537. * @returns the list of limit velocity gradients
  13538. */
  13539. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13540. /**
  13541. * Adds a new limit velocity gradient
  13542. * @param gradient defines the gradient to use (between 0 and 1)
  13543. * @param factor defines the limit velocity to affect to the specified gradient
  13544. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13545. * @returns the current particle system
  13546. */
  13547. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13548. /**
  13549. * Remove a specific limit velocity gradient
  13550. * @param gradient defines the gradient to remove
  13551. * @returns the current particle system
  13552. */
  13553. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13554. /**
  13555. * Adds a new drag gradient
  13556. * @param gradient defines the gradient to use (between 0 and 1)
  13557. * @param factor defines the drag to affect to the specified gradient
  13558. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13559. * @returns the current particle system
  13560. */
  13561. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13562. /**
  13563. * Remove a specific drag gradient
  13564. * @param gradient defines the gradient to remove
  13565. * @returns the current particle system
  13566. */
  13567. removeDragGradient(gradient: number): IParticleSystem;
  13568. /**
  13569. * Gets the current list of drag gradients.
  13570. * You must use addDragGradient and removeDragGradient to udpate this list
  13571. * @returns the list of drag gradients
  13572. */
  13573. getDragGradients(): Nullable<Array<FactorGradient>>;
  13574. /**
  13575. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13576. * @param gradient defines the gradient to use (between 0 and 1)
  13577. * @param factor defines the emit rate to affect to the specified gradient
  13578. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13579. * @returns the current particle system
  13580. */
  13581. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13582. /**
  13583. * Remove a specific emit rate gradient
  13584. * @param gradient defines the gradient to remove
  13585. * @returns the current particle system
  13586. */
  13587. removeEmitRateGradient(gradient: number): IParticleSystem;
  13588. /**
  13589. * Gets the current list of emit rate gradients.
  13590. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13591. * @returns the list of emit rate gradients
  13592. */
  13593. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13594. /**
  13595. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13596. * @param gradient defines the gradient to use (between 0 and 1)
  13597. * @param factor defines the start size to affect to the specified gradient
  13598. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13599. * @returns the current particle system
  13600. */
  13601. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13602. /**
  13603. * Remove a specific start size gradient
  13604. * @param gradient defines the gradient to remove
  13605. * @returns the current particle system
  13606. */
  13607. removeStartSizeGradient(gradient: number): IParticleSystem;
  13608. /**
  13609. * Gets the current list of start size gradients.
  13610. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13611. * @returns the list of start size gradients
  13612. */
  13613. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13614. /**
  13615. * Adds a new life time gradient
  13616. * @param gradient defines the gradient to use (between 0 and 1)
  13617. * @param factor defines the life time factor to affect to the specified gradient
  13618. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13619. * @returns the current particle system
  13620. */
  13621. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13622. /**
  13623. * Remove a specific life time gradient
  13624. * @param gradient defines the gradient to remove
  13625. * @returns the current particle system
  13626. */
  13627. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13628. /**
  13629. * Gets the current list of life time gradients.
  13630. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13631. * @returns the list of life time gradients
  13632. */
  13633. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13634. /**
  13635. * Gets the current list of color gradients.
  13636. * You must use addColorGradient and removeColorGradient to udpate this list
  13637. * @returns the list of color gradients
  13638. */
  13639. getColorGradients(): Nullable<Array<ColorGradient>>;
  13640. /**
  13641. * Adds a new ramp gradient used to remap particle colors
  13642. * @param gradient defines the gradient to use (between 0 and 1)
  13643. * @param color defines the color to affect to the specified gradient
  13644. * @returns the current particle system
  13645. */
  13646. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13647. /**
  13648. * Gets the current list of ramp gradients.
  13649. * You must use addRampGradient and removeRampGradient to udpate this list
  13650. * @returns the list of ramp gradients
  13651. */
  13652. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13653. /** Gets or sets a boolean indicating that ramp gradients must be used
  13654. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13655. */
  13656. useRampGradients: boolean;
  13657. /**
  13658. * Adds a new color remap gradient
  13659. * @param gradient defines the gradient to use (between 0 and 1)
  13660. * @param min defines the color remap minimal range
  13661. * @param max defines the color remap maximal range
  13662. * @returns the current particle system
  13663. */
  13664. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13665. /**
  13666. * Gets the current list of color remap gradients.
  13667. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13668. * @returns the list of color remap gradients
  13669. */
  13670. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13671. /**
  13672. * Adds a new alpha remap gradient
  13673. * @param gradient defines the gradient to use (between 0 and 1)
  13674. * @param min defines the alpha remap minimal range
  13675. * @param max defines the alpha remap maximal range
  13676. * @returns the current particle system
  13677. */
  13678. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13679. /**
  13680. * Gets the current list of alpha remap gradients.
  13681. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13682. * @returns the list of alpha remap gradients
  13683. */
  13684. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13685. /**
  13686. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13687. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13688. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13689. * @returns the emitter
  13690. */
  13691. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13692. /**
  13693. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13694. * @param radius The radius of the hemisphere to emit from
  13695. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13696. * @returns the emitter
  13697. */
  13698. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13699. /**
  13700. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13701. * @param radius The radius of the sphere to emit from
  13702. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13703. * @returns the emitter
  13704. */
  13705. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13706. /**
  13707. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13708. * @param radius The radius of the sphere to emit from
  13709. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13710. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13711. * @returns the emitter
  13712. */
  13713. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13714. /**
  13715. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13716. * @param radius The radius of the emission cylinder
  13717. * @param height The height of the emission cylinder
  13718. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13719. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13720. * @returns the emitter
  13721. */
  13722. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13723. /**
  13724. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13725. * @param radius The radius of the cylinder to emit from
  13726. * @param height The height of the emission cylinder
  13727. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13728. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13729. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13730. * @returns the emitter
  13731. */
  13732. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13733. /**
  13734. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13735. * @param radius The radius of the cone to emit from
  13736. * @param angle The base angle of the cone
  13737. * @returns the emitter
  13738. */
  13739. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13740. /**
  13741. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13742. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13743. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13744. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13745. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13746. * @returns the emitter
  13747. */
  13748. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13749. /**
  13750. * Get hosting scene
  13751. * @returns the scene
  13752. */
  13753. getScene(): Scene;
  13754. }
  13755. }
  13756. declare module "babylonjs/Meshes/transformNode" {
  13757. import { DeepImmutable } from "babylonjs/types";
  13758. import { Observable } from "babylonjs/Misc/observable";
  13759. import { Nullable } from "babylonjs/types";
  13760. import { Camera } from "babylonjs/Cameras/camera";
  13761. import { Scene } from "babylonjs/scene";
  13762. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13763. import { Node } from "babylonjs/node";
  13764. import { Bone } from "babylonjs/Bones/bone";
  13765. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13766. import { Space } from "babylonjs/Maths/math.axis";
  13767. /**
  13768. * 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.
  13769. * @see https://doc.babylonjs.com/how_to/transformnode
  13770. */
  13771. export class TransformNode extends Node {
  13772. /**
  13773. * Object will not rotate to face the camera
  13774. */
  13775. static BILLBOARDMODE_NONE: number;
  13776. /**
  13777. * Object will rotate to face the camera but only on the x axis
  13778. */
  13779. static BILLBOARDMODE_X: number;
  13780. /**
  13781. * Object will rotate to face the camera but only on the y axis
  13782. */
  13783. static BILLBOARDMODE_Y: number;
  13784. /**
  13785. * Object will rotate to face the camera but only on the z axis
  13786. */
  13787. static BILLBOARDMODE_Z: number;
  13788. /**
  13789. * Object will rotate to face the camera
  13790. */
  13791. static BILLBOARDMODE_ALL: number;
  13792. /**
  13793. * Object will rotate to face the camera's position instead of orientation
  13794. */
  13795. static BILLBOARDMODE_USE_POSITION: number;
  13796. private _forward;
  13797. private _forwardInverted;
  13798. private _up;
  13799. private _right;
  13800. private _rightInverted;
  13801. private _position;
  13802. private _rotation;
  13803. private _rotationQuaternion;
  13804. protected _scaling: Vector3;
  13805. protected _isDirty: boolean;
  13806. private _transformToBoneReferal;
  13807. private _isAbsoluteSynced;
  13808. private _billboardMode;
  13809. /**
  13810. * Gets or sets the billboard mode. Default is 0.
  13811. *
  13812. * | Value | Type | Description |
  13813. * | --- | --- | --- |
  13814. * | 0 | BILLBOARDMODE_NONE | |
  13815. * | 1 | BILLBOARDMODE_X | |
  13816. * | 2 | BILLBOARDMODE_Y | |
  13817. * | 4 | BILLBOARDMODE_Z | |
  13818. * | 7 | BILLBOARDMODE_ALL | |
  13819. *
  13820. */
  13821. get billboardMode(): number;
  13822. set billboardMode(value: number);
  13823. private _preserveParentRotationForBillboard;
  13824. /**
  13825. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13826. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13827. */
  13828. get preserveParentRotationForBillboard(): boolean;
  13829. set preserveParentRotationForBillboard(value: boolean);
  13830. /**
  13831. * 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
  13832. */
  13833. scalingDeterminant: number;
  13834. private _infiniteDistance;
  13835. /**
  13836. * Gets or sets the distance of the object to max, often used by skybox
  13837. */
  13838. get infiniteDistance(): boolean;
  13839. set infiniteDistance(value: boolean);
  13840. /**
  13841. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13842. * By default the system will update normals to compensate
  13843. */
  13844. ignoreNonUniformScaling: boolean;
  13845. /**
  13846. * 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
  13847. */
  13848. reIntegrateRotationIntoRotationQuaternion: boolean;
  13849. /** @hidden */
  13850. _poseMatrix: Nullable<Matrix>;
  13851. /** @hidden */
  13852. _localMatrix: Matrix;
  13853. private _usePivotMatrix;
  13854. private _absolutePosition;
  13855. private _absoluteScaling;
  13856. private _absoluteRotationQuaternion;
  13857. private _pivotMatrix;
  13858. private _pivotMatrixInverse;
  13859. protected _postMultiplyPivotMatrix: boolean;
  13860. protected _isWorldMatrixFrozen: boolean;
  13861. /** @hidden */
  13862. _indexInSceneTransformNodesArray: number;
  13863. /**
  13864. * An event triggered after the world matrix is updated
  13865. */
  13866. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13867. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13868. /**
  13869. * Gets a string identifying the name of the class
  13870. * @returns "TransformNode" string
  13871. */
  13872. getClassName(): string;
  13873. /**
  13874. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13875. */
  13876. get position(): Vector3;
  13877. set position(newPosition: Vector3);
  13878. /**
  13879. * 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)).
  13880. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13881. */
  13882. get rotation(): Vector3;
  13883. set rotation(newRotation: Vector3);
  13884. /**
  13885. * 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)).
  13886. */
  13887. get scaling(): Vector3;
  13888. set scaling(newScaling: Vector3);
  13889. /**
  13890. * 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).
  13891. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13892. */
  13893. get rotationQuaternion(): Nullable<Quaternion>;
  13894. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13895. /**
  13896. * The forward direction of that transform in world space.
  13897. */
  13898. get forward(): Vector3;
  13899. /**
  13900. * The up direction of that transform in world space.
  13901. */
  13902. get up(): Vector3;
  13903. /**
  13904. * The right direction of that transform in world space.
  13905. */
  13906. get right(): Vector3;
  13907. /**
  13908. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13909. * @param matrix the matrix to copy the pose from
  13910. * @returns this TransformNode.
  13911. */
  13912. updatePoseMatrix(matrix: Matrix): TransformNode;
  13913. /**
  13914. * Returns the mesh Pose matrix.
  13915. * @returns the pose matrix
  13916. */
  13917. getPoseMatrix(): Matrix;
  13918. /** @hidden */
  13919. _isSynchronized(): boolean;
  13920. /** @hidden */
  13921. _initCache(): void;
  13922. /**
  13923. * Flag the transform node as dirty (Forcing it to update everything)
  13924. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13925. * @returns this transform node
  13926. */
  13927. markAsDirty(property: string): TransformNode;
  13928. /**
  13929. * Returns the current mesh absolute position.
  13930. * Returns a Vector3.
  13931. */
  13932. get absolutePosition(): Vector3;
  13933. /**
  13934. * Returns the current mesh absolute scaling.
  13935. * Returns a Vector3.
  13936. */
  13937. get absoluteScaling(): Vector3;
  13938. /**
  13939. * Returns the current mesh absolute rotation.
  13940. * Returns a Quaternion.
  13941. */
  13942. get absoluteRotationQuaternion(): Quaternion;
  13943. /**
  13944. * Sets a new matrix to apply before all other transformation
  13945. * @param matrix defines the transform matrix
  13946. * @returns the current TransformNode
  13947. */
  13948. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13949. /**
  13950. * Sets a new pivot matrix to the current node
  13951. * @param matrix defines the new pivot matrix to use
  13952. * @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
  13953. * @returns the current TransformNode
  13954. */
  13955. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13956. /**
  13957. * Returns the mesh pivot matrix.
  13958. * Default : Identity.
  13959. * @returns the matrix
  13960. */
  13961. getPivotMatrix(): Matrix;
  13962. /**
  13963. * Instantiate (when possible) or clone that node with its hierarchy
  13964. * @param newParent defines the new parent to use for the instance (or clone)
  13965. * @param options defines options to configure how copy is done
  13966. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13967. * @returns an instance (or a clone) of the current node with its hiearchy
  13968. */
  13969. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13970. doNotInstantiate: boolean;
  13971. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13972. /**
  13973. * Prevents the World matrix to be computed any longer
  13974. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13975. * @returns the TransformNode.
  13976. */
  13977. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13978. /**
  13979. * Allows back the World matrix computation.
  13980. * @returns the TransformNode.
  13981. */
  13982. unfreezeWorldMatrix(): this;
  13983. /**
  13984. * True if the World matrix has been frozen.
  13985. */
  13986. get isWorldMatrixFrozen(): boolean;
  13987. /**
  13988. * Retuns the mesh absolute position in the World.
  13989. * @returns a Vector3.
  13990. */
  13991. getAbsolutePosition(): Vector3;
  13992. /**
  13993. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13994. * @param absolutePosition the absolute position to set
  13995. * @returns the TransformNode.
  13996. */
  13997. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13998. /**
  13999. * Sets the mesh position in its local space.
  14000. * @param vector3 the position to set in localspace
  14001. * @returns the TransformNode.
  14002. */
  14003. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14004. /**
  14005. * Returns the mesh position in the local space from the current World matrix values.
  14006. * @returns a new Vector3.
  14007. */
  14008. getPositionExpressedInLocalSpace(): Vector3;
  14009. /**
  14010. * Translates the mesh along the passed Vector3 in its local space.
  14011. * @param vector3 the distance to translate in localspace
  14012. * @returns the TransformNode.
  14013. */
  14014. locallyTranslate(vector3: Vector3): TransformNode;
  14015. private static _lookAtVectorCache;
  14016. /**
  14017. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14018. * @param targetPoint the position (must be in same space as current mesh) to look at
  14019. * @param yawCor optional yaw (y-axis) correction in radians
  14020. * @param pitchCor optional pitch (x-axis) correction in radians
  14021. * @param rollCor optional roll (z-axis) correction in radians
  14022. * @param space the choosen space of the target
  14023. * @returns the TransformNode.
  14024. */
  14025. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14026. /**
  14027. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14028. * This Vector3 is expressed in the World space.
  14029. * @param localAxis axis to rotate
  14030. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14031. */
  14032. getDirection(localAxis: Vector3): Vector3;
  14033. /**
  14034. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14035. * localAxis is expressed in the mesh local space.
  14036. * result is computed in the Wordl space from the mesh World matrix.
  14037. * @param localAxis axis to rotate
  14038. * @param result the resulting transformnode
  14039. * @returns this TransformNode.
  14040. */
  14041. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14042. /**
  14043. * Sets this transform node rotation to the given local axis.
  14044. * @param localAxis the axis in local space
  14045. * @param yawCor optional yaw (y-axis) correction in radians
  14046. * @param pitchCor optional pitch (x-axis) correction in radians
  14047. * @param rollCor optional roll (z-axis) correction in radians
  14048. * @returns this TransformNode
  14049. */
  14050. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14051. /**
  14052. * Sets a new pivot point to the current node
  14053. * @param point defines the new pivot point to use
  14054. * @param space defines if the point is in world or local space (local by default)
  14055. * @returns the current TransformNode
  14056. */
  14057. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14058. /**
  14059. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14060. * @returns the pivot point
  14061. */
  14062. getPivotPoint(): Vector3;
  14063. /**
  14064. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14065. * @param result the vector3 to store the result
  14066. * @returns this TransformNode.
  14067. */
  14068. getPivotPointToRef(result: Vector3): TransformNode;
  14069. /**
  14070. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14071. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14072. */
  14073. getAbsolutePivotPoint(): Vector3;
  14074. /**
  14075. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14076. * @param result vector3 to store the result
  14077. * @returns this TransformNode.
  14078. */
  14079. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14080. /**
  14081. * Defines the passed node as the parent of the current node.
  14082. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14083. * @see https://doc.babylonjs.com/how_to/parenting
  14084. * @param node the node ot set as the parent
  14085. * @returns this TransformNode.
  14086. */
  14087. setParent(node: Nullable<Node>): TransformNode;
  14088. private _nonUniformScaling;
  14089. /**
  14090. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14091. */
  14092. get nonUniformScaling(): boolean;
  14093. /** @hidden */
  14094. _updateNonUniformScalingState(value: boolean): boolean;
  14095. /**
  14096. * Attach the current TransformNode to another TransformNode associated with a bone
  14097. * @param bone Bone affecting the TransformNode
  14098. * @param affectedTransformNode TransformNode associated with the bone
  14099. * @returns this object
  14100. */
  14101. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14102. /**
  14103. * Detach the transform node if its associated with a bone
  14104. * @returns this object
  14105. */
  14106. detachFromBone(): TransformNode;
  14107. private static _rotationAxisCache;
  14108. /**
  14109. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14110. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14111. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14112. * The passed axis is also normalized.
  14113. * @param axis the axis to rotate around
  14114. * @param amount the amount to rotate in radians
  14115. * @param space Space to rotate in (Default: local)
  14116. * @returns the TransformNode.
  14117. */
  14118. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14119. /**
  14120. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14121. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14122. * The passed axis is also normalized. .
  14123. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14124. * @param point the point to rotate around
  14125. * @param axis the axis to rotate around
  14126. * @param amount the amount to rotate in radians
  14127. * @returns the TransformNode
  14128. */
  14129. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14130. /**
  14131. * Translates the mesh along the axis vector for the passed distance in the given space.
  14132. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14133. * @param axis the axis to translate in
  14134. * @param distance the distance to translate
  14135. * @param space Space to rotate in (Default: local)
  14136. * @returns the TransformNode.
  14137. */
  14138. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14139. /**
  14140. * Adds a rotation step to the mesh current rotation.
  14141. * x, y, z are Euler angles expressed in radians.
  14142. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14143. * This means this rotation is made in the mesh local space only.
  14144. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14145. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14146. * ```javascript
  14147. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14148. * ```
  14149. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14150. * 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.
  14151. * @param x Rotation to add
  14152. * @param y Rotation to add
  14153. * @param z Rotation to add
  14154. * @returns the TransformNode.
  14155. */
  14156. addRotation(x: number, y: number, z: number): TransformNode;
  14157. /**
  14158. * @hidden
  14159. */
  14160. protected _getEffectiveParent(): Nullable<Node>;
  14161. /**
  14162. * Computes the world matrix of the node
  14163. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14164. * @returns the world matrix
  14165. */
  14166. computeWorldMatrix(force?: boolean): Matrix;
  14167. /**
  14168. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14169. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14170. */
  14171. resetLocalMatrix(independentOfChildren?: boolean): void;
  14172. protected _afterComputeWorldMatrix(): void;
  14173. /**
  14174. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14175. * @param func callback function to add
  14176. *
  14177. * @returns the TransformNode.
  14178. */
  14179. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14180. /**
  14181. * Removes a registered callback function.
  14182. * @param func callback function to remove
  14183. * @returns the TransformNode.
  14184. */
  14185. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14186. /**
  14187. * Gets the position of the current mesh in camera space
  14188. * @param camera defines the camera to use
  14189. * @returns a position
  14190. */
  14191. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14192. /**
  14193. * Returns the distance from the mesh to the active camera
  14194. * @param camera defines the camera to use
  14195. * @returns the distance
  14196. */
  14197. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14198. /**
  14199. * Clone the current transform node
  14200. * @param name Name of the new clone
  14201. * @param newParent New parent for the clone
  14202. * @param doNotCloneChildren Do not clone children hierarchy
  14203. * @returns the new transform node
  14204. */
  14205. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14206. /**
  14207. * Serializes the objects information.
  14208. * @param currentSerializationObject defines the object to serialize in
  14209. * @returns the serialized object
  14210. */
  14211. serialize(currentSerializationObject?: any): any;
  14212. /**
  14213. * Returns a new TransformNode object parsed from the source provided.
  14214. * @param parsedTransformNode is the source.
  14215. * @param scene the scne the object belongs to
  14216. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14217. * @returns a new TransformNode object parsed from the source provided.
  14218. */
  14219. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14220. /**
  14221. * Get all child-transformNodes of this node
  14222. * @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
  14223. * @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
  14224. * @returns an array of TransformNode
  14225. */
  14226. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14227. /**
  14228. * Releases resources associated with this transform node.
  14229. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14230. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14231. */
  14232. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14233. /**
  14234. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14235. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14236. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14237. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14238. * @returns the current mesh
  14239. */
  14240. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14241. private _syncAbsoluteScalingAndRotation;
  14242. }
  14243. }
  14244. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14245. /**
  14246. * Class used to override all child animations of a given target
  14247. */
  14248. export class AnimationPropertiesOverride {
  14249. /**
  14250. * Gets or sets a value indicating if animation blending must be used
  14251. */
  14252. enableBlending: boolean;
  14253. /**
  14254. * Gets or sets the blending speed to use when enableBlending is true
  14255. */
  14256. blendingSpeed: number;
  14257. /**
  14258. * Gets or sets the default loop mode to use
  14259. */
  14260. loopMode: number;
  14261. }
  14262. }
  14263. declare module "babylonjs/Bones/bone" {
  14264. import { Skeleton } from "babylonjs/Bones/skeleton";
  14265. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14266. import { Nullable } from "babylonjs/types";
  14267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14268. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14269. import { Node } from "babylonjs/node";
  14270. import { Space } from "babylonjs/Maths/math.axis";
  14271. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14272. /**
  14273. * Class used to store bone information
  14274. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14275. */
  14276. export class Bone extends Node {
  14277. /**
  14278. * defines the bone name
  14279. */
  14280. name: string;
  14281. private static _tmpVecs;
  14282. private static _tmpQuat;
  14283. private static _tmpMats;
  14284. /**
  14285. * Gets the list of child bones
  14286. */
  14287. children: Bone[];
  14288. /** Gets the animations associated with this bone */
  14289. animations: import("babylonjs/Animations/animation").Animation[];
  14290. /**
  14291. * Gets or sets bone length
  14292. */
  14293. length: number;
  14294. /**
  14295. * @hidden Internal only
  14296. * Set this value to map this bone to a different index in the transform matrices
  14297. * Set this value to -1 to exclude the bone from the transform matrices
  14298. */
  14299. _index: Nullable<number>;
  14300. private _skeleton;
  14301. private _localMatrix;
  14302. private _restPose;
  14303. private _baseMatrix;
  14304. private _absoluteTransform;
  14305. private _invertedAbsoluteTransform;
  14306. private _parent;
  14307. private _scalingDeterminant;
  14308. private _worldTransform;
  14309. private _localScaling;
  14310. private _localRotation;
  14311. private _localPosition;
  14312. private _needToDecompose;
  14313. private _needToCompose;
  14314. /** @hidden */
  14315. _linkedTransformNode: Nullable<TransformNode>;
  14316. /** @hidden */
  14317. _waitingTransformNodeId: Nullable<string>;
  14318. /** @hidden */
  14319. get _matrix(): Matrix;
  14320. /** @hidden */
  14321. set _matrix(value: Matrix);
  14322. /**
  14323. * Create a new bone
  14324. * @param name defines the bone name
  14325. * @param skeleton defines the parent skeleton
  14326. * @param parentBone defines the parent (can be null if the bone is the root)
  14327. * @param localMatrix defines the local matrix
  14328. * @param restPose defines the rest pose matrix
  14329. * @param baseMatrix defines the base matrix
  14330. * @param index defines index of the bone in the hiearchy
  14331. */
  14332. constructor(
  14333. /**
  14334. * defines the bone name
  14335. */
  14336. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14337. /**
  14338. * Gets the current object class name.
  14339. * @return the class name
  14340. */
  14341. getClassName(): string;
  14342. /**
  14343. * Gets the parent skeleton
  14344. * @returns a skeleton
  14345. */
  14346. getSkeleton(): Skeleton;
  14347. /**
  14348. * Gets parent bone
  14349. * @returns a bone or null if the bone is the root of the bone hierarchy
  14350. */
  14351. getParent(): Nullable<Bone>;
  14352. /**
  14353. * Returns an array containing the root bones
  14354. * @returns an array containing the root bones
  14355. */
  14356. getChildren(): Array<Bone>;
  14357. /**
  14358. * Gets the node index in matrix array generated for rendering
  14359. * @returns the node index
  14360. */
  14361. getIndex(): number;
  14362. /**
  14363. * Sets the parent bone
  14364. * @param parent defines the parent (can be null if the bone is the root)
  14365. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14366. */
  14367. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14368. /**
  14369. * Gets the local matrix
  14370. * @returns a matrix
  14371. */
  14372. getLocalMatrix(): Matrix;
  14373. /**
  14374. * Gets the base matrix (initial matrix which remains unchanged)
  14375. * @returns a matrix
  14376. */
  14377. getBaseMatrix(): Matrix;
  14378. /**
  14379. * Gets the rest pose matrix
  14380. * @returns a matrix
  14381. */
  14382. getRestPose(): Matrix;
  14383. /**
  14384. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14385. */
  14386. getWorldMatrix(): Matrix;
  14387. /**
  14388. * Sets the local matrix to rest pose matrix
  14389. */
  14390. returnToRest(): void;
  14391. /**
  14392. * Gets the inverse of the absolute transform matrix.
  14393. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14394. * @returns a matrix
  14395. */
  14396. getInvertedAbsoluteTransform(): Matrix;
  14397. /**
  14398. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14399. * @returns a matrix
  14400. */
  14401. getAbsoluteTransform(): Matrix;
  14402. /**
  14403. * Links with the given transform node.
  14404. * The local matrix of this bone is copied from the transform node every frame.
  14405. * @param transformNode defines the transform node to link to
  14406. */
  14407. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14408. /**
  14409. * Gets the node used to drive the bone's transformation
  14410. * @returns a transform node or null
  14411. */
  14412. getTransformNode(): Nullable<TransformNode>;
  14413. /** Gets or sets current position (in local space) */
  14414. get position(): Vector3;
  14415. set position(newPosition: Vector3);
  14416. /** Gets or sets current rotation (in local space) */
  14417. get rotation(): Vector3;
  14418. set rotation(newRotation: Vector3);
  14419. /** Gets or sets current rotation quaternion (in local space) */
  14420. get rotationQuaternion(): Quaternion;
  14421. set rotationQuaternion(newRotation: Quaternion);
  14422. /** Gets or sets current scaling (in local space) */
  14423. get scaling(): Vector3;
  14424. set scaling(newScaling: Vector3);
  14425. /**
  14426. * Gets the animation properties override
  14427. */
  14428. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14429. private _decompose;
  14430. private _compose;
  14431. /**
  14432. * Update the base and local matrices
  14433. * @param matrix defines the new base or local matrix
  14434. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14435. * @param updateLocalMatrix defines if the local matrix should be updated
  14436. */
  14437. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14438. /** @hidden */
  14439. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14440. /**
  14441. * Flag the bone as dirty (Forcing it to update everything)
  14442. */
  14443. markAsDirty(): void;
  14444. /** @hidden */
  14445. _markAsDirtyAndCompose(): void;
  14446. private _markAsDirtyAndDecompose;
  14447. /**
  14448. * Translate the bone in local or world space
  14449. * @param vec The amount to translate the bone
  14450. * @param space The space that the translation is in
  14451. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14452. */
  14453. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14454. /**
  14455. * Set the postion of the bone in local or world space
  14456. * @param position The position to set the bone
  14457. * @param space The space that the position is in
  14458. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14459. */
  14460. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14461. /**
  14462. * Set the absolute position of the bone (world space)
  14463. * @param position The position to set the bone
  14464. * @param mesh The mesh that this bone is attached to
  14465. */
  14466. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14467. /**
  14468. * Scale the bone on the x, y and z axes (in local space)
  14469. * @param x The amount to scale the bone on the x axis
  14470. * @param y The amount to scale the bone on the y axis
  14471. * @param z The amount to scale the bone on the z axis
  14472. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14473. */
  14474. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14475. /**
  14476. * Set the bone scaling in local space
  14477. * @param scale defines the scaling vector
  14478. */
  14479. setScale(scale: Vector3): void;
  14480. /**
  14481. * Gets the current scaling in local space
  14482. * @returns the current scaling vector
  14483. */
  14484. getScale(): Vector3;
  14485. /**
  14486. * Gets the current scaling in local space and stores it in a target vector
  14487. * @param result defines the target vector
  14488. */
  14489. getScaleToRef(result: Vector3): void;
  14490. /**
  14491. * Set the yaw, pitch, and roll of the bone in local or world space
  14492. * @param yaw The rotation of the bone on the y axis
  14493. * @param pitch The rotation of the bone on the x axis
  14494. * @param roll The rotation of the bone on the z axis
  14495. * @param space The space that the axes of rotation are in
  14496. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14497. */
  14498. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14499. /**
  14500. * Add a rotation to the bone on an axis in local or world space
  14501. * @param axis The axis to rotate the bone on
  14502. * @param amount The amount to rotate the bone
  14503. * @param space The space that the axis is in
  14504. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14505. */
  14506. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14507. /**
  14508. * Set the rotation of the bone to a particular axis angle in local or world space
  14509. * @param axis The axis to rotate the bone on
  14510. * @param angle The angle that the bone should be rotated to
  14511. * @param space The space that the axis is in
  14512. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14513. */
  14514. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14515. /**
  14516. * Set the euler rotation of the bone in local of world space
  14517. * @param rotation The euler rotation that the bone should be set to
  14518. * @param space The space that the rotation is in
  14519. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14520. */
  14521. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14522. /**
  14523. * Set the quaternion rotation of the bone in local of world space
  14524. * @param quat The quaternion rotation that the bone should be set to
  14525. * @param space The space that the rotation is in
  14526. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14527. */
  14528. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14529. /**
  14530. * Set the rotation matrix of the bone in local of world space
  14531. * @param rotMat The rotation matrix that the bone should be set to
  14532. * @param space The space that the rotation is in
  14533. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14534. */
  14535. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14536. private _rotateWithMatrix;
  14537. private _getNegativeRotationToRef;
  14538. /**
  14539. * Get the position of the bone in local or world space
  14540. * @param space The space that the returned position is in
  14541. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14542. * @returns The position of the bone
  14543. */
  14544. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14545. /**
  14546. * Copy the position of the bone to a vector3 in local or world space
  14547. * @param space The space that the returned position is in
  14548. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14549. * @param result The vector3 to copy the position to
  14550. */
  14551. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14552. /**
  14553. * Get the absolute position of the bone (world space)
  14554. * @param mesh The mesh that this bone is attached to
  14555. * @returns The absolute position of the bone
  14556. */
  14557. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14558. /**
  14559. * Copy the absolute position of the bone (world space) to the result param
  14560. * @param mesh The mesh that this bone is attached to
  14561. * @param result The vector3 to copy the absolute position to
  14562. */
  14563. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14564. /**
  14565. * Compute the absolute transforms of this bone and its children
  14566. */
  14567. computeAbsoluteTransforms(): void;
  14568. /**
  14569. * Get the world direction from an axis that is in the local space of the bone
  14570. * @param localAxis The local direction that is used to compute the world direction
  14571. * @param mesh The mesh that this bone is attached to
  14572. * @returns The world direction
  14573. */
  14574. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14575. /**
  14576. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14577. * @param localAxis The local direction that is used to compute the world direction
  14578. * @param mesh The mesh that this bone is attached to
  14579. * @param result The vector3 that the world direction will be copied to
  14580. */
  14581. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14582. /**
  14583. * Get the euler rotation of the bone in local or world space
  14584. * @param space The space that the rotation should be in
  14585. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14586. * @returns The euler rotation
  14587. */
  14588. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14589. /**
  14590. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14591. * @param space The space that the rotation should be in
  14592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14593. * @param result The vector3 that the rotation should be copied to
  14594. */
  14595. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14596. /**
  14597. * Get the quaternion rotation of the bone in either local or world space
  14598. * @param space The space that the rotation should be in
  14599. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14600. * @returns The quaternion rotation
  14601. */
  14602. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14603. /**
  14604. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14605. * @param space The space that the rotation should be in
  14606. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14607. * @param result The quaternion that the rotation should be copied to
  14608. */
  14609. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14610. /**
  14611. * Get the rotation matrix of the bone in local or world space
  14612. * @param space The space that the rotation should be in
  14613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14614. * @returns The rotation matrix
  14615. */
  14616. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14617. /**
  14618. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14619. * @param space The space that the rotation should be in
  14620. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14621. * @param result The quaternion that the rotation should be copied to
  14622. */
  14623. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14624. /**
  14625. * Get the world position of a point that is in the local space of the bone
  14626. * @param position The local position
  14627. * @param mesh The mesh that this bone is attached to
  14628. * @returns The world position
  14629. */
  14630. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14631. /**
  14632. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14633. * @param position The local position
  14634. * @param mesh The mesh that this bone is attached to
  14635. * @param result The vector3 that the world position should be copied to
  14636. */
  14637. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14638. /**
  14639. * Get the local position of a point that is in world space
  14640. * @param position The world position
  14641. * @param mesh The mesh that this bone is attached to
  14642. * @returns The local position
  14643. */
  14644. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14645. /**
  14646. * Get the local position of a point that is in world space and copy it to the result param
  14647. * @param position The world position
  14648. * @param mesh The mesh that this bone is attached to
  14649. * @param result The vector3 that the local position should be copied to
  14650. */
  14651. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14652. }
  14653. }
  14654. declare module "babylonjs/Animations/runtimeAnimation" {
  14655. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14656. import { Animatable } from "babylonjs/Animations/animatable";
  14657. import { Scene } from "babylonjs/scene";
  14658. /**
  14659. * Defines a runtime animation
  14660. */
  14661. export class RuntimeAnimation {
  14662. private _events;
  14663. /**
  14664. * The current frame of the runtime animation
  14665. */
  14666. private _currentFrame;
  14667. /**
  14668. * The animation used by the runtime animation
  14669. */
  14670. private _animation;
  14671. /**
  14672. * The target of the runtime animation
  14673. */
  14674. private _target;
  14675. /**
  14676. * The initiating animatable
  14677. */
  14678. private _host;
  14679. /**
  14680. * The original value of the runtime animation
  14681. */
  14682. private _originalValue;
  14683. /**
  14684. * The original blend value of the runtime animation
  14685. */
  14686. private _originalBlendValue;
  14687. /**
  14688. * The offsets cache of the runtime animation
  14689. */
  14690. private _offsetsCache;
  14691. /**
  14692. * The high limits cache of the runtime animation
  14693. */
  14694. private _highLimitsCache;
  14695. /**
  14696. * Specifies if the runtime animation has been stopped
  14697. */
  14698. private _stopped;
  14699. /**
  14700. * The blending factor of the runtime animation
  14701. */
  14702. private _blendingFactor;
  14703. /**
  14704. * The BabylonJS scene
  14705. */
  14706. private _scene;
  14707. /**
  14708. * The current value of the runtime animation
  14709. */
  14710. private _currentValue;
  14711. /** @hidden */
  14712. _animationState: _IAnimationState;
  14713. /**
  14714. * The active target of the runtime animation
  14715. */
  14716. private _activeTargets;
  14717. private _currentActiveTarget;
  14718. private _directTarget;
  14719. /**
  14720. * The target path of the runtime animation
  14721. */
  14722. private _targetPath;
  14723. /**
  14724. * The weight of the runtime animation
  14725. */
  14726. private _weight;
  14727. /**
  14728. * The ratio offset of the runtime animation
  14729. */
  14730. private _ratioOffset;
  14731. /**
  14732. * The previous delay of the runtime animation
  14733. */
  14734. private _previousDelay;
  14735. /**
  14736. * The previous ratio of the runtime animation
  14737. */
  14738. private _previousRatio;
  14739. private _enableBlending;
  14740. private _keys;
  14741. private _minFrame;
  14742. private _maxFrame;
  14743. private _minValue;
  14744. private _maxValue;
  14745. private _targetIsArray;
  14746. /**
  14747. * Gets the current frame of the runtime animation
  14748. */
  14749. get currentFrame(): number;
  14750. /**
  14751. * Gets the weight of the runtime animation
  14752. */
  14753. get weight(): number;
  14754. /**
  14755. * Gets the current value of the runtime animation
  14756. */
  14757. get currentValue(): any;
  14758. /**
  14759. * Gets the target path of the runtime animation
  14760. */
  14761. get targetPath(): string;
  14762. /**
  14763. * Gets the actual target of the runtime animation
  14764. */
  14765. get target(): any;
  14766. /** @hidden */
  14767. _onLoop: () => void;
  14768. /**
  14769. * Create a new RuntimeAnimation object
  14770. * @param target defines the target of the animation
  14771. * @param animation defines the source animation object
  14772. * @param scene defines the hosting scene
  14773. * @param host defines the initiating Animatable
  14774. */
  14775. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14776. private _preparePath;
  14777. /**
  14778. * Gets the animation from the runtime animation
  14779. */
  14780. get animation(): Animation;
  14781. /**
  14782. * Resets the runtime animation to the beginning
  14783. * @param restoreOriginal defines whether to restore the target property to the original value
  14784. */
  14785. reset(restoreOriginal?: boolean): void;
  14786. /**
  14787. * Specifies if the runtime animation is stopped
  14788. * @returns Boolean specifying if the runtime animation is stopped
  14789. */
  14790. isStopped(): boolean;
  14791. /**
  14792. * Disposes of the runtime animation
  14793. */
  14794. dispose(): void;
  14795. /**
  14796. * Apply the interpolated value to the target
  14797. * @param currentValue defines the value computed by the animation
  14798. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14799. */
  14800. setValue(currentValue: any, weight: number): void;
  14801. private _getOriginalValues;
  14802. private _setValue;
  14803. /**
  14804. * Gets the loop pmode of the runtime animation
  14805. * @returns Loop Mode
  14806. */
  14807. private _getCorrectLoopMode;
  14808. /**
  14809. * Move the current animation to a given frame
  14810. * @param frame defines the frame to move to
  14811. */
  14812. goToFrame(frame: number): void;
  14813. /**
  14814. * @hidden Internal use only
  14815. */
  14816. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14817. /**
  14818. * Execute the current animation
  14819. * @param delay defines the delay to add to the current frame
  14820. * @param from defines the lower bound of the animation range
  14821. * @param to defines the upper bound of the animation range
  14822. * @param loop defines if the current animation must loop
  14823. * @param speedRatio defines the current speed ratio
  14824. * @param weight defines the weight of the animation (default is -1 so no weight)
  14825. * @param onLoop optional callback called when animation loops
  14826. * @returns a boolean indicating if the animation is running
  14827. */
  14828. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14829. }
  14830. }
  14831. declare module "babylonjs/Animations/animatable" {
  14832. import { Animation } from "babylonjs/Animations/animation";
  14833. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  14834. import { Nullable } from "babylonjs/types";
  14835. import { Observable } from "babylonjs/Misc/observable";
  14836. import { Scene } from "babylonjs/scene";
  14837. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  14838. import { Node } from "babylonjs/node";
  14839. /**
  14840. * Class used to store an actual running animation
  14841. */
  14842. export class Animatable {
  14843. /** defines the target object */
  14844. target: any;
  14845. /** defines the starting frame number (default is 0) */
  14846. fromFrame: number;
  14847. /** defines the ending frame number (default is 100) */
  14848. toFrame: number;
  14849. /** defines if the animation must loop (default is false) */
  14850. loopAnimation: boolean;
  14851. /** defines a callback to call when animation ends if it is not looping */
  14852. onAnimationEnd?: (() => void) | null | undefined;
  14853. /** defines a callback to call when animation loops */
  14854. onAnimationLoop?: (() => void) | null | undefined;
  14855. private _localDelayOffset;
  14856. private _pausedDelay;
  14857. private _runtimeAnimations;
  14858. private _paused;
  14859. private _scene;
  14860. private _speedRatio;
  14861. private _weight;
  14862. private _syncRoot;
  14863. /**
  14864. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14865. * This will only apply for non looping animation (default is true)
  14866. */
  14867. disposeOnEnd: boolean;
  14868. /**
  14869. * Gets a boolean indicating if the animation has started
  14870. */
  14871. animationStarted: boolean;
  14872. /**
  14873. * Observer raised when the animation ends
  14874. */
  14875. onAnimationEndObservable: Observable<Animatable>;
  14876. /**
  14877. * Observer raised when the animation loops
  14878. */
  14879. onAnimationLoopObservable: Observable<Animatable>;
  14880. /**
  14881. * Gets the root Animatable used to synchronize and normalize animations
  14882. */
  14883. get syncRoot(): Nullable<Animatable>;
  14884. /**
  14885. * Gets the current frame of the first RuntimeAnimation
  14886. * Used to synchronize Animatables
  14887. */
  14888. get masterFrame(): number;
  14889. /**
  14890. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14891. */
  14892. get weight(): number;
  14893. set weight(value: number);
  14894. /**
  14895. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14896. */
  14897. get speedRatio(): number;
  14898. set speedRatio(value: number);
  14899. /**
  14900. * Creates a new Animatable
  14901. * @param scene defines the hosting scene
  14902. * @param target defines the target object
  14903. * @param fromFrame defines the starting frame number (default is 0)
  14904. * @param toFrame defines the ending frame number (default is 100)
  14905. * @param loopAnimation defines if the animation must loop (default is false)
  14906. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14907. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14908. * @param animations defines a group of animation to add to the new Animatable
  14909. * @param onAnimationLoop defines a callback to call when animation loops
  14910. */
  14911. constructor(scene: Scene,
  14912. /** defines the target object */
  14913. target: any,
  14914. /** defines the starting frame number (default is 0) */
  14915. fromFrame?: number,
  14916. /** defines the ending frame number (default is 100) */
  14917. toFrame?: number,
  14918. /** defines if the animation must loop (default is false) */
  14919. loopAnimation?: boolean, speedRatio?: number,
  14920. /** defines a callback to call when animation ends if it is not looping */
  14921. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14922. /** defines a callback to call when animation loops */
  14923. onAnimationLoop?: (() => void) | null | undefined);
  14924. /**
  14925. * Synchronize and normalize current Animatable with a source Animatable
  14926. * This is useful when using animation weights and when animations are not of the same length
  14927. * @param root defines the root Animatable to synchronize with
  14928. * @returns the current Animatable
  14929. */
  14930. syncWith(root: Animatable): Animatable;
  14931. /**
  14932. * Gets the list of runtime animations
  14933. * @returns an array of RuntimeAnimation
  14934. */
  14935. getAnimations(): RuntimeAnimation[];
  14936. /**
  14937. * Adds more animations to the current animatable
  14938. * @param target defines the target of the animations
  14939. * @param animations defines the new animations to add
  14940. */
  14941. appendAnimations(target: any, animations: Animation[]): void;
  14942. /**
  14943. * Gets the source animation for a specific property
  14944. * @param property defines the propertyu to look for
  14945. * @returns null or the source animation for the given property
  14946. */
  14947. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14948. /**
  14949. * Gets the runtime animation for a specific property
  14950. * @param property defines the propertyu to look for
  14951. * @returns null or the runtime animation for the given property
  14952. */
  14953. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14954. /**
  14955. * Resets the animatable to its original state
  14956. */
  14957. reset(): void;
  14958. /**
  14959. * Allows the animatable to blend with current running animations
  14960. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14961. * @param blendingSpeed defines the blending speed to use
  14962. */
  14963. enableBlending(blendingSpeed: number): void;
  14964. /**
  14965. * Disable animation blending
  14966. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14967. */
  14968. disableBlending(): void;
  14969. /**
  14970. * Jump directly to a given frame
  14971. * @param frame defines the frame to jump to
  14972. */
  14973. goToFrame(frame: number): void;
  14974. /**
  14975. * Pause the animation
  14976. */
  14977. pause(): void;
  14978. /**
  14979. * Restart the animation
  14980. */
  14981. restart(): void;
  14982. private _raiseOnAnimationEnd;
  14983. /**
  14984. * Stop and delete the current animation
  14985. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14986. * @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)
  14987. */
  14988. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14989. /**
  14990. * Wait asynchronously for the animation to end
  14991. * @returns a promise which will be fullfilled when the animation ends
  14992. */
  14993. waitAsync(): Promise<Animatable>;
  14994. /** @hidden */
  14995. _animate(delay: number): boolean;
  14996. }
  14997. module "babylonjs/scene" {
  14998. interface Scene {
  14999. /** @hidden */
  15000. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15001. /** @hidden */
  15002. _processLateAnimationBindingsForMatrices(holder: {
  15003. totalWeight: number;
  15004. animations: RuntimeAnimation[];
  15005. originalValue: Matrix;
  15006. }): any;
  15007. /** @hidden */
  15008. _processLateAnimationBindingsForQuaternions(holder: {
  15009. totalWeight: number;
  15010. animations: RuntimeAnimation[];
  15011. originalValue: Quaternion;
  15012. }, refQuaternion: Quaternion): Quaternion;
  15013. /** @hidden */
  15014. _processLateAnimationBindings(): void;
  15015. /**
  15016. * Will start the animation sequence of a given target
  15017. * @param target defines the target
  15018. * @param from defines from which frame should animation start
  15019. * @param to defines until which frame should animation run.
  15020. * @param weight defines the weight to apply to the animation (1.0 by default)
  15021. * @param loop defines if the animation loops
  15022. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15023. * @param onAnimationEnd defines the function to be executed when the animation ends
  15024. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15025. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15026. * @param onAnimationLoop defines the callback to call when an animation loops
  15027. * @returns the animatable object created for this animation
  15028. */
  15029. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15030. /**
  15031. * Will start the animation sequence of a given target
  15032. * @param target defines the target
  15033. * @param from defines from which frame should animation start
  15034. * @param to defines until which frame should animation run.
  15035. * @param loop defines if the animation loops
  15036. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15037. * @param onAnimationEnd defines the function to be executed when the animation ends
  15038. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15039. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15040. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15041. * @param onAnimationLoop defines the callback to call when an animation loops
  15042. * @returns the animatable object created for this animation
  15043. */
  15044. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15045. /**
  15046. * Will start the animation sequence of a given target and its hierarchy
  15047. * @param target defines the target
  15048. * @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.
  15049. * @param from defines from which frame should animation start
  15050. * @param to defines until which frame should animation run.
  15051. * @param loop defines if the animation loops
  15052. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15053. * @param onAnimationEnd defines the function to be executed when the animation ends
  15054. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15055. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15056. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15057. * @param onAnimationLoop defines the callback to call when an animation loops
  15058. * @returns the list of created animatables
  15059. */
  15060. 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[];
  15061. /**
  15062. * Begin a new animation on a given node
  15063. * @param target defines the target where the animation will take place
  15064. * @param animations defines the list of animations to start
  15065. * @param from defines the initial value
  15066. * @param to defines the final value
  15067. * @param loop defines if you want animation to loop (off by default)
  15068. * @param speedRatio defines the speed ratio to apply to all animations
  15069. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15070. * @param onAnimationLoop defines the callback to call when an animation loops
  15071. * @returns the list of created animatables
  15072. */
  15073. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  15074. /**
  15075. * Begin a new animation on a given node and its hierarchy
  15076. * @param target defines the root node where the animation will take place
  15077. * @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.
  15078. * @param animations defines the list of animations to start
  15079. * @param from defines the initial value
  15080. * @param to defines the final value
  15081. * @param loop defines if you want animation to loop (off by default)
  15082. * @param speedRatio defines the speed ratio to apply to all animations
  15083. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15084. * @param onAnimationLoop defines the callback to call when an animation loops
  15085. * @returns the list of animatables created for all nodes
  15086. */
  15087. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  15088. /**
  15089. * Gets the animatable associated with a specific target
  15090. * @param target defines the target of the animatable
  15091. * @returns the required animatable if found
  15092. */
  15093. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15094. /**
  15095. * Gets all animatables associated with a given target
  15096. * @param target defines the target to look animatables for
  15097. * @returns an array of Animatables
  15098. */
  15099. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15100. /**
  15101. * Stops and removes all animations that have been applied to the scene
  15102. */
  15103. stopAllAnimations(): void;
  15104. /**
  15105. * Gets the current delta time used by animation engine
  15106. */
  15107. deltaTime: number;
  15108. }
  15109. }
  15110. module "babylonjs/Bones/bone" {
  15111. interface Bone {
  15112. /**
  15113. * Copy an animation range from another bone
  15114. * @param source defines the source bone
  15115. * @param rangeName defines the range name to copy
  15116. * @param frameOffset defines the frame offset
  15117. * @param rescaleAsRequired defines if rescaling must be applied if required
  15118. * @param skelDimensionsRatio defines the scaling ratio
  15119. * @returns true if operation was successful
  15120. */
  15121. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15122. }
  15123. }
  15124. }
  15125. declare module "babylonjs/Bones/skeleton" {
  15126. import { Bone } from "babylonjs/Bones/bone";
  15127. import { Observable } from "babylonjs/Misc/observable";
  15128. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15129. import { Scene } from "babylonjs/scene";
  15130. import { Nullable } from "babylonjs/types";
  15131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15132. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15133. import { Animatable } from "babylonjs/Animations/animatable";
  15134. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15135. import { Animation } from "babylonjs/Animations/animation";
  15136. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15137. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15138. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15139. /**
  15140. * Class used to handle skinning animations
  15141. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15142. */
  15143. export class Skeleton implements IAnimatable {
  15144. /** defines the skeleton name */
  15145. name: string;
  15146. /** defines the skeleton Id */
  15147. id: string;
  15148. /**
  15149. * Defines the list of child bones
  15150. */
  15151. bones: Bone[];
  15152. /**
  15153. * Defines an estimate of the dimension of the skeleton at rest
  15154. */
  15155. dimensionsAtRest: Vector3;
  15156. /**
  15157. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15158. */
  15159. needInitialSkinMatrix: boolean;
  15160. /**
  15161. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15162. */
  15163. overrideMesh: Nullable<AbstractMesh>;
  15164. /**
  15165. * Gets the list of animations attached to this skeleton
  15166. */
  15167. animations: Array<Animation>;
  15168. private _scene;
  15169. private _isDirty;
  15170. private _transformMatrices;
  15171. private _transformMatrixTexture;
  15172. private _meshesWithPoseMatrix;
  15173. private _animatables;
  15174. private _identity;
  15175. private _synchronizedWithMesh;
  15176. private _ranges;
  15177. private _lastAbsoluteTransformsUpdateId;
  15178. private _canUseTextureForBones;
  15179. private _uniqueId;
  15180. /** @hidden */
  15181. _numBonesWithLinkedTransformNode: number;
  15182. /** @hidden */
  15183. _hasWaitingData: Nullable<boolean>;
  15184. /**
  15185. * Specifies if the skeleton should be serialized
  15186. */
  15187. doNotSerialize: boolean;
  15188. private _useTextureToStoreBoneMatrices;
  15189. /**
  15190. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15191. * Please note that this option is not available if the hardware does not support it
  15192. */
  15193. get useTextureToStoreBoneMatrices(): boolean;
  15194. set useTextureToStoreBoneMatrices(value: boolean);
  15195. private _animationPropertiesOverride;
  15196. /**
  15197. * Gets or sets the animation properties override
  15198. */
  15199. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15200. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15201. /**
  15202. * List of inspectable custom properties (used by the Inspector)
  15203. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15204. */
  15205. inspectableCustomProperties: IInspectable[];
  15206. /**
  15207. * An observable triggered before computing the skeleton's matrices
  15208. */
  15209. onBeforeComputeObservable: Observable<Skeleton>;
  15210. /**
  15211. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15212. */
  15213. get isUsingTextureForMatrices(): boolean;
  15214. /**
  15215. * Gets the unique ID of this skeleton
  15216. */
  15217. get uniqueId(): number;
  15218. /**
  15219. * Creates a new skeleton
  15220. * @param name defines the skeleton name
  15221. * @param id defines the skeleton Id
  15222. * @param scene defines the hosting scene
  15223. */
  15224. constructor(
  15225. /** defines the skeleton name */
  15226. name: string,
  15227. /** defines the skeleton Id */
  15228. id: string, scene: Scene);
  15229. /**
  15230. * Gets the current object class name.
  15231. * @return the class name
  15232. */
  15233. getClassName(): string;
  15234. /**
  15235. * Returns an array containing the root bones
  15236. * @returns an array containing the root bones
  15237. */
  15238. getChildren(): Array<Bone>;
  15239. /**
  15240. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15241. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15242. * @returns a Float32Array containing matrices data
  15243. */
  15244. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15245. /**
  15246. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15247. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15248. * @returns a raw texture containing the data
  15249. */
  15250. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15251. /**
  15252. * Gets the current hosting scene
  15253. * @returns a scene object
  15254. */
  15255. getScene(): Scene;
  15256. /**
  15257. * Gets a string representing the current skeleton data
  15258. * @param fullDetails defines a boolean indicating if we want a verbose version
  15259. * @returns a string representing the current skeleton data
  15260. */
  15261. toString(fullDetails?: boolean): string;
  15262. /**
  15263. * Get bone's index searching by name
  15264. * @param name defines bone's name to search for
  15265. * @return the indice of the bone. Returns -1 if not found
  15266. */
  15267. getBoneIndexByName(name: string): number;
  15268. /**
  15269. * Creater a new animation range
  15270. * @param name defines the name of the range
  15271. * @param from defines the start key
  15272. * @param to defines the end key
  15273. */
  15274. createAnimationRange(name: string, from: number, to: number): void;
  15275. /**
  15276. * Delete a specific animation range
  15277. * @param name defines the name of the range
  15278. * @param deleteFrames defines if frames must be removed as well
  15279. */
  15280. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15281. /**
  15282. * Gets a specific animation range
  15283. * @param name defines the name of the range to look for
  15284. * @returns the requested animation range or null if not found
  15285. */
  15286. getAnimationRange(name: string): Nullable<AnimationRange>;
  15287. /**
  15288. * Gets the list of all animation ranges defined on this skeleton
  15289. * @returns an array
  15290. */
  15291. getAnimationRanges(): Nullable<AnimationRange>[];
  15292. /**
  15293. * Copy animation range from a source skeleton.
  15294. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15295. * @param source defines the source skeleton
  15296. * @param name defines the name of the range to copy
  15297. * @param rescaleAsRequired defines if rescaling must be applied if required
  15298. * @returns true if operation was successful
  15299. */
  15300. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15301. /**
  15302. * Forces the skeleton to go to rest pose
  15303. */
  15304. returnToRest(): void;
  15305. private _getHighestAnimationFrame;
  15306. /**
  15307. * Begin a specific animation range
  15308. * @param name defines the name of the range to start
  15309. * @param loop defines if looping must be turned on (false by default)
  15310. * @param speedRatio defines the speed ratio to apply (1 by default)
  15311. * @param onAnimationEnd defines a callback which will be called when animation will end
  15312. * @returns a new animatable
  15313. */
  15314. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15315. /** @hidden */
  15316. _markAsDirty(): void;
  15317. /** @hidden */
  15318. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15319. /** @hidden */
  15320. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15321. private _computeTransformMatrices;
  15322. /**
  15323. * Build all resources required to render a skeleton
  15324. */
  15325. prepare(): void;
  15326. /**
  15327. * Gets the list of animatables currently running for this skeleton
  15328. * @returns an array of animatables
  15329. */
  15330. getAnimatables(): IAnimatable[];
  15331. /**
  15332. * Clone the current skeleton
  15333. * @param name defines the name of the new skeleton
  15334. * @param id defines the id of the new skeleton
  15335. * @returns the new skeleton
  15336. */
  15337. clone(name: string, id?: string): Skeleton;
  15338. /**
  15339. * Enable animation blending for this skeleton
  15340. * @param blendingSpeed defines the blending speed to apply
  15341. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15342. */
  15343. enableBlending(blendingSpeed?: number): void;
  15344. /**
  15345. * Releases all resources associated with the current skeleton
  15346. */
  15347. dispose(): void;
  15348. /**
  15349. * Serialize the skeleton in a JSON object
  15350. * @returns a JSON object
  15351. */
  15352. serialize(): any;
  15353. /**
  15354. * Creates a new skeleton from serialized data
  15355. * @param parsedSkeleton defines the serialized data
  15356. * @param scene defines the hosting scene
  15357. * @returns a new skeleton
  15358. */
  15359. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15360. /**
  15361. * Compute all node absolute transforms
  15362. * @param forceUpdate defines if computation must be done even if cache is up to date
  15363. */
  15364. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15365. /**
  15366. * Gets the root pose matrix
  15367. * @returns a matrix
  15368. */
  15369. getPoseMatrix(): Nullable<Matrix>;
  15370. /**
  15371. * Sorts bones per internal index
  15372. */
  15373. sortBones(): void;
  15374. private _sortBones;
  15375. }
  15376. }
  15377. declare module "babylonjs/Meshes/instancedMesh" {
  15378. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15379. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15380. import { Camera } from "babylonjs/Cameras/camera";
  15381. import { Node } from "babylonjs/node";
  15382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15383. import { Mesh } from "babylonjs/Meshes/mesh";
  15384. import { Material } from "babylonjs/Materials/material";
  15385. import { Skeleton } from "babylonjs/Bones/skeleton";
  15386. import { Light } from "babylonjs/Lights/light";
  15387. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15388. /**
  15389. * Creates an instance based on a source mesh.
  15390. */
  15391. export class InstancedMesh extends AbstractMesh {
  15392. private _sourceMesh;
  15393. private _currentLOD;
  15394. /** @hidden */
  15395. _indexInSourceMeshInstanceArray: number;
  15396. constructor(name: string, source: Mesh);
  15397. /**
  15398. * Returns the string "InstancedMesh".
  15399. */
  15400. getClassName(): string;
  15401. /** Gets the list of lights affecting that mesh */
  15402. get lightSources(): Light[];
  15403. _resyncLightSources(): void;
  15404. _resyncLightSource(light: Light): void;
  15405. _removeLightSource(light: Light, dispose: boolean): void;
  15406. /**
  15407. * If the source mesh receives shadows
  15408. */
  15409. get receiveShadows(): boolean;
  15410. /**
  15411. * The material of the source mesh
  15412. */
  15413. get material(): Nullable<Material>;
  15414. /**
  15415. * Visibility of the source mesh
  15416. */
  15417. get visibility(): number;
  15418. /**
  15419. * Skeleton of the source mesh
  15420. */
  15421. get skeleton(): Nullable<Skeleton>;
  15422. /**
  15423. * Rendering ground id of the source mesh
  15424. */
  15425. get renderingGroupId(): number;
  15426. set renderingGroupId(value: number);
  15427. /**
  15428. * Returns the total number of vertices (integer).
  15429. */
  15430. getTotalVertices(): number;
  15431. /**
  15432. * Returns a positive integer : the total number of indices in this mesh geometry.
  15433. * @returns the numner of indices or zero if the mesh has no geometry.
  15434. */
  15435. getTotalIndices(): number;
  15436. /**
  15437. * The source mesh of the instance
  15438. */
  15439. get sourceMesh(): Mesh;
  15440. /**
  15441. * Is this node ready to be used/rendered
  15442. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15443. * @return {boolean} is it ready
  15444. */
  15445. isReady(completeCheck?: boolean): boolean;
  15446. /**
  15447. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15448. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15449. * @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.
  15450. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15451. */
  15452. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15453. /**
  15454. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15455. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15456. * The `data` are either a numeric array either a Float32Array.
  15457. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15458. * 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).
  15459. * Note that a new underlying VertexBuffer object is created each call.
  15460. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15461. *
  15462. * Possible `kind` values :
  15463. * - VertexBuffer.PositionKind
  15464. * - VertexBuffer.UVKind
  15465. * - VertexBuffer.UV2Kind
  15466. * - VertexBuffer.UV3Kind
  15467. * - VertexBuffer.UV4Kind
  15468. * - VertexBuffer.UV5Kind
  15469. * - VertexBuffer.UV6Kind
  15470. * - VertexBuffer.ColorKind
  15471. * - VertexBuffer.MatricesIndicesKind
  15472. * - VertexBuffer.MatricesIndicesExtraKind
  15473. * - VertexBuffer.MatricesWeightsKind
  15474. * - VertexBuffer.MatricesWeightsExtraKind
  15475. *
  15476. * Returns the Mesh.
  15477. */
  15478. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15479. /**
  15480. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15481. * If the mesh has no geometry, it is simply returned as it is.
  15482. * The `data` are either a numeric array either a Float32Array.
  15483. * No new underlying VertexBuffer object is created.
  15484. * 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.
  15485. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15486. *
  15487. * Possible `kind` values :
  15488. * - VertexBuffer.PositionKind
  15489. * - VertexBuffer.UVKind
  15490. * - VertexBuffer.UV2Kind
  15491. * - VertexBuffer.UV3Kind
  15492. * - VertexBuffer.UV4Kind
  15493. * - VertexBuffer.UV5Kind
  15494. * - VertexBuffer.UV6Kind
  15495. * - VertexBuffer.ColorKind
  15496. * - VertexBuffer.MatricesIndicesKind
  15497. * - VertexBuffer.MatricesIndicesExtraKind
  15498. * - VertexBuffer.MatricesWeightsKind
  15499. * - VertexBuffer.MatricesWeightsExtraKind
  15500. *
  15501. * Returns the Mesh.
  15502. */
  15503. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15504. /**
  15505. * Sets the mesh indices.
  15506. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15507. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15508. * This method creates a new index buffer each call.
  15509. * Returns the Mesh.
  15510. */
  15511. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15512. /**
  15513. * Boolean : True if the mesh owns the requested kind of data.
  15514. */
  15515. isVerticesDataPresent(kind: string): boolean;
  15516. /**
  15517. * Returns an array of indices (IndicesArray).
  15518. */
  15519. getIndices(): Nullable<IndicesArray>;
  15520. get _positions(): Nullable<Vector3[]>;
  15521. /**
  15522. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15523. * This means the mesh underlying bounding box and sphere are recomputed.
  15524. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15525. * @returns the current mesh
  15526. */
  15527. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15528. /** @hidden */
  15529. _preActivate(): InstancedMesh;
  15530. /** @hidden */
  15531. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15532. /** @hidden */
  15533. _postActivate(): void;
  15534. getWorldMatrix(): Matrix;
  15535. get isAnInstance(): boolean;
  15536. /**
  15537. * Returns the current associated LOD AbstractMesh.
  15538. */
  15539. getLOD(camera: Camera): AbstractMesh;
  15540. /** @hidden */
  15541. _preActivateForIntermediateRendering(renderId: number): Mesh;
  15542. /** @hidden */
  15543. _syncSubMeshes(): InstancedMesh;
  15544. /** @hidden */
  15545. _generatePointsArray(): boolean;
  15546. /**
  15547. * Creates a new InstancedMesh from the current mesh.
  15548. * - name (string) : the cloned mesh name
  15549. * - newParent (optional Node) : the optional Node to parent the clone to.
  15550. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15551. *
  15552. * Returns the clone.
  15553. */
  15554. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15555. /**
  15556. * Disposes the InstancedMesh.
  15557. * Returns nothing.
  15558. */
  15559. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15560. }
  15561. module "babylonjs/Meshes/mesh" {
  15562. interface Mesh {
  15563. /**
  15564. * Register a custom buffer that will be instanced
  15565. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15566. * @param kind defines the buffer kind
  15567. * @param stride defines the stride in floats
  15568. */
  15569. registerInstancedBuffer(kind: string, stride: number): void;
  15570. /** @hidden */
  15571. _userInstancedBuffersStorage: {
  15572. data: {
  15573. [key: string]: Float32Array;
  15574. };
  15575. sizes: {
  15576. [key: string]: number;
  15577. };
  15578. vertexBuffers: {
  15579. [key: string]: Nullable<VertexBuffer>;
  15580. };
  15581. strides: {
  15582. [key: string]: number;
  15583. };
  15584. };
  15585. }
  15586. }
  15587. module "babylonjs/Meshes/abstractMesh" {
  15588. interface AbstractMesh {
  15589. /**
  15590. * Object used to store instanced buffers defined by user
  15591. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15592. */
  15593. instancedBuffers: {
  15594. [key: string]: any;
  15595. };
  15596. }
  15597. }
  15598. }
  15599. declare module "babylonjs/Materials/shaderMaterial" {
  15600. import { Scene } from "babylonjs/scene";
  15601. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15602. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15603. import { Mesh } from "babylonjs/Meshes/mesh";
  15604. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15605. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15606. import { Texture } from "babylonjs/Materials/Textures/texture";
  15607. import { Material } from "babylonjs/Materials/material";
  15608. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15609. /**
  15610. * Defines the options associated with the creation of a shader material.
  15611. */
  15612. export interface IShaderMaterialOptions {
  15613. /**
  15614. * Does the material work in alpha blend mode
  15615. */
  15616. needAlphaBlending: boolean;
  15617. /**
  15618. * Does the material work in alpha test mode
  15619. */
  15620. needAlphaTesting: boolean;
  15621. /**
  15622. * The list of attribute names used in the shader
  15623. */
  15624. attributes: string[];
  15625. /**
  15626. * The list of unifrom names used in the shader
  15627. */
  15628. uniforms: string[];
  15629. /**
  15630. * The list of UBO names used in the shader
  15631. */
  15632. uniformBuffers: string[];
  15633. /**
  15634. * The list of sampler names used in the shader
  15635. */
  15636. samplers: string[];
  15637. /**
  15638. * The list of defines used in the shader
  15639. */
  15640. defines: string[];
  15641. }
  15642. /**
  15643. * 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.
  15644. *
  15645. * This returned material effects how the mesh will look based on the code in the shaders.
  15646. *
  15647. * @see http://doc.babylonjs.com/how_to/shader_material
  15648. */
  15649. export class ShaderMaterial extends Material {
  15650. private _shaderPath;
  15651. private _options;
  15652. private _textures;
  15653. private _textureArrays;
  15654. private _floats;
  15655. private _ints;
  15656. private _floatsArrays;
  15657. private _colors3;
  15658. private _colors3Arrays;
  15659. private _colors4;
  15660. private _colors4Arrays;
  15661. private _vectors2;
  15662. private _vectors3;
  15663. private _vectors4;
  15664. private _matrices;
  15665. private _matrixArrays;
  15666. private _matrices3x3;
  15667. private _matrices2x2;
  15668. private _vectors2Arrays;
  15669. private _vectors3Arrays;
  15670. private _vectors4Arrays;
  15671. private _cachedWorldViewMatrix;
  15672. private _cachedWorldViewProjectionMatrix;
  15673. private _renderId;
  15674. private _multiview;
  15675. /**
  15676. * Instantiate a new shader material.
  15677. * 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.
  15678. * This returned material effects how the mesh will look based on the code in the shaders.
  15679. * @see http://doc.babylonjs.com/how_to/shader_material
  15680. * @param name Define the name of the material in the scene
  15681. * @param scene Define the scene the material belongs to
  15682. * @param shaderPath Defines the route to the shader code in one of three ways:
  15683. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15684. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15685. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15686. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15687. * @param options Define the options used to create the shader
  15688. */
  15689. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15690. /**
  15691. * Gets the shader path used to define the shader code
  15692. * It can be modified to trigger a new compilation
  15693. */
  15694. get shaderPath(): any;
  15695. /**
  15696. * Sets the shader path used to define the shader code
  15697. * It can be modified to trigger a new compilation
  15698. */
  15699. set shaderPath(shaderPath: any);
  15700. /**
  15701. * Gets the options used to compile the shader.
  15702. * They can be modified to trigger a new compilation
  15703. */
  15704. get options(): IShaderMaterialOptions;
  15705. /**
  15706. * Gets the current class name of the material e.g. "ShaderMaterial"
  15707. * Mainly use in serialization.
  15708. * @returns the class name
  15709. */
  15710. getClassName(): string;
  15711. /**
  15712. * Specifies if the material will require alpha blending
  15713. * @returns a boolean specifying if alpha blending is needed
  15714. */
  15715. needAlphaBlending(): boolean;
  15716. /**
  15717. * Specifies if this material should be rendered in alpha test mode
  15718. * @returns a boolean specifying if an alpha test is needed.
  15719. */
  15720. needAlphaTesting(): boolean;
  15721. private _checkUniform;
  15722. /**
  15723. * Set a texture in the shader.
  15724. * @param name Define the name of the uniform samplers as defined in the shader
  15725. * @param texture Define the texture to bind to this sampler
  15726. * @return the material itself allowing "fluent" like uniform updates
  15727. */
  15728. setTexture(name: string, texture: Texture): ShaderMaterial;
  15729. /**
  15730. * Set a texture array in the shader.
  15731. * @param name Define the name of the uniform sampler array as defined in the shader
  15732. * @param textures Define the list of textures to bind to this sampler
  15733. * @return the material itself allowing "fluent" like uniform updates
  15734. */
  15735. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15736. /**
  15737. * Set a float in the shader.
  15738. * @param name Define the name of the uniform as defined in the shader
  15739. * @param value Define the value to give to the uniform
  15740. * @return the material itself allowing "fluent" like uniform updates
  15741. */
  15742. setFloat(name: string, value: number): ShaderMaterial;
  15743. /**
  15744. * Set a int in the shader.
  15745. * @param name Define the name of the uniform as defined in the shader
  15746. * @param value Define the value to give to the uniform
  15747. * @return the material itself allowing "fluent" like uniform updates
  15748. */
  15749. setInt(name: string, value: number): ShaderMaterial;
  15750. /**
  15751. * Set an array of floats in the shader.
  15752. * @param name Define the name of the uniform as defined in the shader
  15753. * @param value Define the value to give to the uniform
  15754. * @return the material itself allowing "fluent" like uniform updates
  15755. */
  15756. setFloats(name: string, value: number[]): ShaderMaterial;
  15757. /**
  15758. * Set a vec3 in the shader from a Color3.
  15759. * @param name Define the name of the uniform as defined in the shader
  15760. * @param value Define the value to give to the uniform
  15761. * @return the material itself allowing "fluent" like uniform updates
  15762. */
  15763. setColor3(name: string, value: Color3): ShaderMaterial;
  15764. /**
  15765. * Set a vec3 array in the shader from a Color3 array.
  15766. * @param name Define the name of the uniform as defined in the shader
  15767. * @param value Define the value to give to the uniform
  15768. * @return the material itself allowing "fluent" like uniform updates
  15769. */
  15770. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15771. /**
  15772. * Set a vec4 in the shader from a Color4.
  15773. * @param name Define the name of the uniform as defined in the shader
  15774. * @param value Define the value to give to the uniform
  15775. * @return the material itself allowing "fluent" like uniform updates
  15776. */
  15777. setColor4(name: string, value: Color4): ShaderMaterial;
  15778. /**
  15779. * Set a vec4 array in the shader from a Color4 array.
  15780. * @param name Define the name of the uniform as defined in the shader
  15781. * @param value Define the value to give to the uniform
  15782. * @return the material itself allowing "fluent" like uniform updates
  15783. */
  15784. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15785. /**
  15786. * Set a vec2 in the shader from a Vector2.
  15787. * @param name Define the name of the uniform as defined in the shader
  15788. * @param value Define the value to give to the uniform
  15789. * @return the material itself allowing "fluent" like uniform updates
  15790. */
  15791. setVector2(name: string, value: Vector2): ShaderMaterial;
  15792. /**
  15793. * Set a vec3 in the shader from a Vector3.
  15794. * @param name Define the name of the uniform as defined in the shader
  15795. * @param value Define the value to give to the uniform
  15796. * @return the material itself allowing "fluent" like uniform updates
  15797. */
  15798. setVector3(name: string, value: Vector3): ShaderMaterial;
  15799. /**
  15800. * Set a vec4 in the shader from a Vector4.
  15801. * @param name Define the name of the uniform as defined in the shader
  15802. * @param value Define the value to give to the uniform
  15803. * @return the material itself allowing "fluent" like uniform updates
  15804. */
  15805. setVector4(name: string, value: Vector4): ShaderMaterial;
  15806. /**
  15807. * Set a mat4 in the shader from a Matrix.
  15808. * @param name Define the name of the uniform as defined in the shader
  15809. * @param value Define the value to give to the uniform
  15810. * @return the material itself allowing "fluent" like uniform updates
  15811. */
  15812. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15813. /**
  15814. * Set a float32Array in the shader from a matrix array.
  15815. * @param name Define the name of the uniform as defined in the shader
  15816. * @param value Define the value to give to the uniform
  15817. * @return the material itself allowing "fluent" like uniform updates
  15818. */
  15819. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15820. /**
  15821. * Set a mat3 in the shader from a Float32Array.
  15822. * @param name Define the name of the uniform as defined in the shader
  15823. * @param value Define the value to give to the uniform
  15824. * @return the material itself allowing "fluent" like uniform updates
  15825. */
  15826. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15827. /**
  15828. * Set a mat2 in the shader from a Float32Array.
  15829. * @param name Define the name of the uniform as defined in the shader
  15830. * @param value Define the value to give to the uniform
  15831. * @return the material itself allowing "fluent" like uniform updates
  15832. */
  15833. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15834. /**
  15835. * Set a vec2 array in the shader from a number array.
  15836. * @param name Define the name of the uniform as defined in the shader
  15837. * @param value Define the value to give to the uniform
  15838. * @return the material itself allowing "fluent" like uniform updates
  15839. */
  15840. setArray2(name: string, value: number[]): ShaderMaterial;
  15841. /**
  15842. * Set a vec3 array in the shader from a number array.
  15843. * @param name Define the name of the uniform as defined in the shader
  15844. * @param value Define the value to give to the uniform
  15845. * @return the material itself allowing "fluent" like uniform updates
  15846. */
  15847. setArray3(name: string, value: number[]): ShaderMaterial;
  15848. /**
  15849. * Set a vec4 array in the shader from a number array.
  15850. * @param name Define the name of the uniform as defined in the shader
  15851. * @param value Define the value to give to the uniform
  15852. * @return the material itself allowing "fluent" like uniform updates
  15853. */
  15854. setArray4(name: string, value: number[]): ShaderMaterial;
  15855. private _checkCache;
  15856. /**
  15857. * Specifies that the submesh is ready to be used
  15858. * @param mesh defines the mesh to check
  15859. * @param subMesh defines which submesh to check
  15860. * @param useInstances specifies that instances should be used
  15861. * @returns a boolean indicating that the submesh is ready or not
  15862. */
  15863. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15864. /**
  15865. * Checks if the material is ready to render the requested mesh
  15866. * @param mesh Define the mesh to render
  15867. * @param useInstances Define whether or not the material is used with instances
  15868. * @returns true if ready, otherwise false
  15869. */
  15870. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15871. /**
  15872. * Binds the world matrix to the material
  15873. * @param world defines the world transformation matrix
  15874. */
  15875. bindOnlyWorldMatrix(world: Matrix): void;
  15876. /**
  15877. * Binds the material to the mesh
  15878. * @param world defines the world transformation matrix
  15879. * @param mesh defines the mesh to bind the material to
  15880. */
  15881. bind(world: Matrix, mesh?: Mesh): void;
  15882. /**
  15883. * Gets the active textures from the material
  15884. * @returns an array of textures
  15885. */
  15886. getActiveTextures(): BaseTexture[];
  15887. /**
  15888. * Specifies if the material uses a texture
  15889. * @param texture defines the texture to check against the material
  15890. * @returns a boolean specifying if the material uses the texture
  15891. */
  15892. hasTexture(texture: BaseTexture): boolean;
  15893. /**
  15894. * Makes a duplicate of the material, and gives it a new name
  15895. * @param name defines the new name for the duplicated material
  15896. * @returns the cloned material
  15897. */
  15898. clone(name: string): ShaderMaterial;
  15899. /**
  15900. * Disposes the material
  15901. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15902. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15903. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15904. */
  15905. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15906. /**
  15907. * Serializes this material in a JSON representation
  15908. * @returns the serialized material object
  15909. */
  15910. serialize(): any;
  15911. /**
  15912. * Creates a shader material from parsed shader material data
  15913. * @param source defines the JSON represnetation of the material
  15914. * @param scene defines the hosting scene
  15915. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15916. * @returns a new material
  15917. */
  15918. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15919. }
  15920. }
  15921. declare module "babylonjs/Shaders/color.fragment" {
  15922. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15923. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15924. /** @hidden */
  15925. export var colorPixelShader: {
  15926. name: string;
  15927. shader: string;
  15928. };
  15929. }
  15930. declare module "babylonjs/Shaders/color.vertex" {
  15931. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  15932. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15933. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  15934. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  15935. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  15936. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15937. /** @hidden */
  15938. export var colorVertexShader: {
  15939. name: string;
  15940. shader: string;
  15941. };
  15942. }
  15943. declare module "babylonjs/Meshes/linesMesh" {
  15944. import { Nullable } from "babylonjs/types";
  15945. import { Scene } from "babylonjs/scene";
  15946. import { Color3 } from "babylonjs/Maths/math.color";
  15947. import { Node } from "babylonjs/node";
  15948. import { SubMesh } from "babylonjs/Meshes/subMesh";
  15949. import { Mesh } from "babylonjs/Meshes/mesh";
  15950. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  15951. import { Effect } from "babylonjs/Materials/effect";
  15952. import { Material } from "babylonjs/Materials/material";
  15953. import "babylonjs/Shaders/color.fragment";
  15954. import "babylonjs/Shaders/color.vertex";
  15955. /**
  15956. * Line mesh
  15957. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15958. */
  15959. export class LinesMesh extends Mesh {
  15960. /**
  15961. * If vertex color should be applied to the mesh
  15962. */
  15963. readonly useVertexColor?: boolean | undefined;
  15964. /**
  15965. * If vertex alpha should be applied to the mesh
  15966. */
  15967. readonly useVertexAlpha?: boolean | undefined;
  15968. /**
  15969. * Color of the line (Default: White)
  15970. */
  15971. color: Color3;
  15972. /**
  15973. * Alpha of the line (Default: 1)
  15974. */
  15975. alpha: number;
  15976. /**
  15977. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15978. * This margin is expressed in world space coordinates, so its value may vary.
  15979. * Default value is 0.1
  15980. */
  15981. intersectionThreshold: number;
  15982. private _colorShader;
  15983. private color4;
  15984. /**
  15985. * Creates a new LinesMesh
  15986. * @param name defines the name
  15987. * @param scene defines the hosting scene
  15988. * @param parent defines the parent mesh if any
  15989. * @param source defines the optional source LinesMesh used to clone data from
  15990. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15991. * When false, achieved by calling a clone(), also passing False.
  15992. * This will make creation of children, recursive.
  15993. * @param useVertexColor defines if this LinesMesh supports vertex color
  15994. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  15995. */
  15996. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  15997. /**
  15998. * If vertex color should be applied to the mesh
  15999. */
  16000. useVertexColor?: boolean | undefined,
  16001. /**
  16002. * If vertex alpha should be applied to the mesh
  16003. */
  16004. useVertexAlpha?: boolean | undefined);
  16005. private _addClipPlaneDefine;
  16006. private _removeClipPlaneDefine;
  16007. isReady(): boolean;
  16008. /**
  16009. * Returns the string "LineMesh"
  16010. */
  16011. getClassName(): string;
  16012. /**
  16013. * @hidden
  16014. */
  16015. get material(): Material;
  16016. /**
  16017. * @hidden
  16018. */
  16019. set material(value: Material);
  16020. /**
  16021. * @hidden
  16022. */
  16023. get checkCollisions(): boolean;
  16024. /** @hidden */
  16025. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16026. /** @hidden */
  16027. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16028. /**
  16029. * Disposes of the line mesh
  16030. * @param doNotRecurse If children should be disposed
  16031. */
  16032. dispose(doNotRecurse?: boolean): void;
  16033. /**
  16034. * Returns a new LineMesh object cloned from the current one.
  16035. */
  16036. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16037. /**
  16038. * Creates a new InstancedLinesMesh object from the mesh model.
  16039. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16040. * @param name defines the name of the new instance
  16041. * @returns a new InstancedLinesMesh
  16042. */
  16043. createInstance(name: string): InstancedLinesMesh;
  16044. }
  16045. /**
  16046. * Creates an instance based on a source LinesMesh
  16047. */
  16048. export class InstancedLinesMesh extends InstancedMesh {
  16049. /**
  16050. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16051. * This margin is expressed in world space coordinates, so its value may vary.
  16052. * Initilized with the intersectionThreshold value of the source LinesMesh
  16053. */
  16054. intersectionThreshold: number;
  16055. constructor(name: string, source: LinesMesh);
  16056. /**
  16057. * Returns the string "InstancedLinesMesh".
  16058. */
  16059. getClassName(): string;
  16060. }
  16061. }
  16062. declare module "babylonjs/Shaders/line.fragment" {
  16063. /** @hidden */
  16064. export var linePixelShader: {
  16065. name: string;
  16066. shader: string;
  16067. };
  16068. }
  16069. declare module "babylonjs/Shaders/line.vertex" {
  16070. /** @hidden */
  16071. export var lineVertexShader: {
  16072. name: string;
  16073. shader: string;
  16074. };
  16075. }
  16076. declare module "babylonjs/Rendering/edgesRenderer" {
  16077. import { Nullable } from "babylonjs/types";
  16078. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16079. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16080. import { Vector3 } from "babylonjs/Maths/math.vector";
  16081. import { IDisposable } from "babylonjs/scene";
  16082. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16083. import "babylonjs/Shaders/line.fragment";
  16084. import "babylonjs/Shaders/line.vertex";
  16085. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16086. module "babylonjs/Meshes/abstractMesh" {
  16087. interface AbstractMesh {
  16088. /**
  16089. * Gets the edgesRenderer associated with the mesh
  16090. */
  16091. edgesRenderer: Nullable<EdgesRenderer>;
  16092. }
  16093. }
  16094. module "babylonjs/Meshes/linesMesh" {
  16095. interface LinesMesh {
  16096. /**
  16097. * Enables the edge rendering mode on the mesh.
  16098. * This mode makes the mesh edges visible
  16099. * @param epsilon defines the maximal distance between two angles to detect a face
  16100. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16101. * @returns the currentAbstractMesh
  16102. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16103. */
  16104. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16105. }
  16106. }
  16107. module "babylonjs/Meshes/linesMesh" {
  16108. interface InstancedLinesMesh {
  16109. /**
  16110. * Enables the edge rendering mode on the mesh.
  16111. * This mode makes the mesh edges visible
  16112. * @param epsilon defines the maximal distance between two angles to detect a face
  16113. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16114. * @returns the current InstancedLinesMesh
  16115. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16116. */
  16117. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16118. }
  16119. }
  16120. /**
  16121. * Defines the minimum contract an Edges renderer should follow.
  16122. */
  16123. export interface IEdgesRenderer extends IDisposable {
  16124. /**
  16125. * Gets or sets a boolean indicating if the edgesRenderer is active
  16126. */
  16127. isEnabled: boolean;
  16128. /**
  16129. * Renders the edges of the attached mesh,
  16130. */
  16131. render(): void;
  16132. /**
  16133. * Checks wether or not the edges renderer is ready to render.
  16134. * @return true if ready, otherwise false.
  16135. */
  16136. isReady(): boolean;
  16137. }
  16138. /**
  16139. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16140. */
  16141. export class EdgesRenderer implements IEdgesRenderer {
  16142. /**
  16143. * Define the size of the edges with an orthographic camera
  16144. */
  16145. edgesWidthScalerForOrthographic: number;
  16146. /**
  16147. * Define the size of the edges with a perspective camera
  16148. */
  16149. edgesWidthScalerForPerspective: number;
  16150. protected _source: AbstractMesh;
  16151. protected _linesPositions: number[];
  16152. protected _linesNormals: number[];
  16153. protected _linesIndices: number[];
  16154. protected _epsilon: number;
  16155. protected _indicesCount: number;
  16156. protected _lineShader: ShaderMaterial;
  16157. protected _ib: DataBuffer;
  16158. protected _buffers: {
  16159. [key: string]: Nullable<VertexBuffer>;
  16160. };
  16161. protected _checkVerticesInsteadOfIndices: boolean;
  16162. private _meshRebuildObserver;
  16163. private _meshDisposeObserver;
  16164. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16165. isEnabled: boolean;
  16166. /**
  16167. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16168. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16169. * @param source Mesh used to create edges
  16170. * @param epsilon sum of angles in adjacency to check for edge
  16171. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16172. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16173. */
  16174. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16175. protected _prepareRessources(): void;
  16176. /** @hidden */
  16177. _rebuild(): void;
  16178. /**
  16179. * Releases the required resources for the edges renderer
  16180. */
  16181. dispose(): void;
  16182. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16183. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16184. /**
  16185. * Checks if the pair of p0 and p1 is en edge
  16186. * @param faceIndex
  16187. * @param edge
  16188. * @param faceNormals
  16189. * @param p0
  16190. * @param p1
  16191. * @private
  16192. */
  16193. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16194. /**
  16195. * push line into the position, normal and index buffer
  16196. * @protected
  16197. */
  16198. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16199. /**
  16200. * Generates lines edges from adjacencjes
  16201. * @private
  16202. */
  16203. _generateEdgesLines(): void;
  16204. /**
  16205. * Checks wether or not the edges renderer is ready to render.
  16206. * @return true if ready, otherwise false.
  16207. */
  16208. isReady(): boolean;
  16209. /**
  16210. * Renders the edges of the attached mesh,
  16211. */
  16212. render(): void;
  16213. }
  16214. /**
  16215. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16216. */
  16217. export class LineEdgesRenderer extends EdgesRenderer {
  16218. /**
  16219. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16220. * @param source LineMesh used to generate edges
  16221. * @param epsilon not important (specified angle for edge detection)
  16222. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16223. */
  16224. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16225. /**
  16226. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16227. */
  16228. _generateEdgesLines(): void;
  16229. }
  16230. }
  16231. declare module "babylonjs/Rendering/renderingGroup" {
  16232. import { SmartArray } from "babylonjs/Misc/smartArray";
  16233. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16235. import { Nullable } from "babylonjs/types";
  16236. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16237. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16238. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16239. import { Material } from "babylonjs/Materials/material";
  16240. import { Scene } from "babylonjs/scene";
  16241. /**
  16242. * This represents the object necessary to create a rendering group.
  16243. * This is exclusively used and created by the rendering manager.
  16244. * To modify the behavior, you use the available helpers in your scene or meshes.
  16245. * @hidden
  16246. */
  16247. export class RenderingGroup {
  16248. index: number;
  16249. private static _zeroVector;
  16250. private _scene;
  16251. private _opaqueSubMeshes;
  16252. private _transparentSubMeshes;
  16253. private _alphaTestSubMeshes;
  16254. private _depthOnlySubMeshes;
  16255. private _particleSystems;
  16256. private _spriteManagers;
  16257. private _opaqueSortCompareFn;
  16258. private _alphaTestSortCompareFn;
  16259. private _transparentSortCompareFn;
  16260. private _renderOpaque;
  16261. private _renderAlphaTest;
  16262. private _renderTransparent;
  16263. /** @hidden */
  16264. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16265. onBeforeTransparentRendering: () => void;
  16266. /**
  16267. * Set the opaque sort comparison function.
  16268. * If null the sub meshes will be render in the order they were created
  16269. */
  16270. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16271. /**
  16272. * Set the alpha test sort comparison function.
  16273. * If null the sub meshes will be render in the order they were created
  16274. */
  16275. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16276. /**
  16277. * Set the transparent sort comparison function.
  16278. * If null the sub meshes will be render in the order they were created
  16279. */
  16280. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16281. /**
  16282. * Creates a new rendering group.
  16283. * @param index The rendering group index
  16284. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16285. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16286. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16287. */
  16288. 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>);
  16289. /**
  16290. * Render all the sub meshes contained in the group.
  16291. * @param customRenderFunction Used to override the default render behaviour of the group.
  16292. * @returns true if rendered some submeshes.
  16293. */
  16294. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16295. /**
  16296. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16297. * @param subMeshes The submeshes to render
  16298. */
  16299. private renderOpaqueSorted;
  16300. /**
  16301. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16302. * @param subMeshes The submeshes to render
  16303. */
  16304. private renderAlphaTestSorted;
  16305. /**
  16306. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16307. * @param subMeshes The submeshes to render
  16308. */
  16309. private renderTransparentSorted;
  16310. /**
  16311. * Renders the submeshes in a specified order.
  16312. * @param subMeshes The submeshes to sort before render
  16313. * @param sortCompareFn The comparison function use to sort
  16314. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16315. * @param transparent Specifies to activate blending if true
  16316. */
  16317. private static renderSorted;
  16318. /**
  16319. * Renders the submeshes in the order they were dispatched (no sort applied).
  16320. * @param subMeshes The submeshes to render
  16321. */
  16322. private static renderUnsorted;
  16323. /**
  16324. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16325. * are rendered back to front if in the same alpha index.
  16326. *
  16327. * @param a The first submesh
  16328. * @param b The second submesh
  16329. * @returns The result of the comparison
  16330. */
  16331. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16332. /**
  16333. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16334. * are rendered back to front.
  16335. *
  16336. * @param a The first submesh
  16337. * @param b The second submesh
  16338. * @returns The result of the comparison
  16339. */
  16340. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16341. /**
  16342. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16343. * are rendered front to back (prevent overdraw).
  16344. *
  16345. * @param a The first submesh
  16346. * @param b The second submesh
  16347. * @returns The result of the comparison
  16348. */
  16349. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16350. /**
  16351. * Resets the different lists of submeshes to prepare a new frame.
  16352. */
  16353. prepare(): void;
  16354. dispose(): void;
  16355. /**
  16356. * Inserts the submesh in its correct queue depending on its material.
  16357. * @param subMesh The submesh to dispatch
  16358. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16359. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16360. */
  16361. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16362. dispatchSprites(spriteManager: ISpriteManager): void;
  16363. dispatchParticles(particleSystem: IParticleSystem): void;
  16364. private _renderParticles;
  16365. private _renderSprites;
  16366. }
  16367. }
  16368. declare module "babylonjs/Rendering/renderingManager" {
  16369. import { Nullable } from "babylonjs/types";
  16370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16371. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16372. import { SmartArray } from "babylonjs/Misc/smartArray";
  16373. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16374. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16375. import { Material } from "babylonjs/Materials/material";
  16376. import { Scene } from "babylonjs/scene";
  16377. import { Camera } from "babylonjs/Cameras/camera";
  16378. /**
  16379. * Interface describing the different options available in the rendering manager
  16380. * regarding Auto Clear between groups.
  16381. */
  16382. export interface IRenderingManagerAutoClearSetup {
  16383. /**
  16384. * Defines whether or not autoclear is enable.
  16385. */
  16386. autoClear: boolean;
  16387. /**
  16388. * Defines whether or not to autoclear the depth buffer.
  16389. */
  16390. depth: boolean;
  16391. /**
  16392. * Defines whether or not to autoclear the stencil buffer.
  16393. */
  16394. stencil: boolean;
  16395. }
  16396. /**
  16397. * This class is used by the onRenderingGroupObservable
  16398. */
  16399. export class RenderingGroupInfo {
  16400. /**
  16401. * The Scene that being rendered
  16402. */
  16403. scene: Scene;
  16404. /**
  16405. * The camera currently used for the rendering pass
  16406. */
  16407. camera: Nullable<Camera>;
  16408. /**
  16409. * The ID of the renderingGroup being processed
  16410. */
  16411. renderingGroupId: number;
  16412. }
  16413. /**
  16414. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16415. * It is enable to manage the different groups as well as the different necessary sort functions.
  16416. * This should not be used directly aside of the few static configurations
  16417. */
  16418. export class RenderingManager {
  16419. /**
  16420. * The max id used for rendering groups (not included)
  16421. */
  16422. static MAX_RENDERINGGROUPS: number;
  16423. /**
  16424. * The min id used for rendering groups (included)
  16425. */
  16426. static MIN_RENDERINGGROUPS: number;
  16427. /**
  16428. * Used to globally prevent autoclearing scenes.
  16429. */
  16430. static AUTOCLEAR: boolean;
  16431. /**
  16432. * @hidden
  16433. */
  16434. _useSceneAutoClearSetup: boolean;
  16435. private _scene;
  16436. private _renderingGroups;
  16437. private _depthStencilBufferAlreadyCleaned;
  16438. private _autoClearDepthStencil;
  16439. private _customOpaqueSortCompareFn;
  16440. private _customAlphaTestSortCompareFn;
  16441. private _customTransparentSortCompareFn;
  16442. private _renderingGroupInfo;
  16443. /**
  16444. * Instantiates a new rendering group for a particular scene
  16445. * @param scene Defines the scene the groups belongs to
  16446. */
  16447. constructor(scene: Scene);
  16448. private _clearDepthStencilBuffer;
  16449. /**
  16450. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16451. * @hidden
  16452. */
  16453. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16454. /**
  16455. * Resets the different information of the group to prepare a new frame
  16456. * @hidden
  16457. */
  16458. reset(): void;
  16459. /**
  16460. * Dispose and release the group and its associated resources.
  16461. * @hidden
  16462. */
  16463. dispose(): void;
  16464. /**
  16465. * Clear the info related to rendering groups preventing retention points during dispose.
  16466. */
  16467. freeRenderingGroups(): void;
  16468. private _prepareRenderingGroup;
  16469. /**
  16470. * Add a sprite manager to the rendering manager in order to render it this frame.
  16471. * @param spriteManager Define the sprite manager to render
  16472. */
  16473. dispatchSprites(spriteManager: ISpriteManager): void;
  16474. /**
  16475. * Add a particle system to the rendering manager in order to render it this frame.
  16476. * @param particleSystem Define the particle system to render
  16477. */
  16478. dispatchParticles(particleSystem: IParticleSystem): void;
  16479. /**
  16480. * Add a submesh to the manager in order to render it this frame
  16481. * @param subMesh The submesh to dispatch
  16482. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16483. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16484. */
  16485. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16486. /**
  16487. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16488. * This allowed control for front to back rendering or reversly depending of the special needs.
  16489. *
  16490. * @param renderingGroupId The rendering group id corresponding to its index
  16491. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16492. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16493. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16494. */
  16495. 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;
  16496. /**
  16497. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16498. *
  16499. * @param renderingGroupId The rendering group id corresponding to its index
  16500. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16501. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16502. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16503. */
  16504. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16505. /**
  16506. * Gets the current auto clear configuration for one rendering group of the rendering
  16507. * manager.
  16508. * @param index the rendering group index to get the information for
  16509. * @returns The auto clear setup for the requested rendering group
  16510. */
  16511. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16512. }
  16513. }
  16514. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16515. import { SmartArray } from "babylonjs/Misc/smartArray";
  16516. import { Nullable } from "babylonjs/types";
  16517. import { Scene } from "babylonjs/scene";
  16518. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16519. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16521. import { Mesh } from "babylonjs/Meshes/mesh";
  16522. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16523. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16524. import { Effect } from "babylonjs/Materials/effect";
  16525. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16526. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16527. import "babylonjs/Shaders/shadowMap.fragment";
  16528. import "babylonjs/Shaders/shadowMap.vertex";
  16529. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16530. import { Observable } from "babylonjs/Misc/observable";
  16531. /**
  16532. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16533. */
  16534. export interface ICustomShaderOptions {
  16535. /**
  16536. * Gets or sets the custom shader name to use
  16537. */
  16538. shaderName: string;
  16539. /**
  16540. * The list of attribute names used in the shader
  16541. */
  16542. attributes?: string[];
  16543. /**
  16544. * The list of unifrom names used in the shader
  16545. */
  16546. uniforms?: string[];
  16547. /**
  16548. * The list of sampler names used in the shader
  16549. */
  16550. samplers?: string[];
  16551. /**
  16552. * The list of defines used in the shader
  16553. */
  16554. defines?: string[];
  16555. }
  16556. /**
  16557. * Interface to implement to create a shadow generator compatible with BJS.
  16558. */
  16559. export interface IShadowGenerator {
  16560. /**
  16561. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16562. * @returns The render target texture if present otherwise, null
  16563. */
  16564. getShadowMap(): Nullable<RenderTargetTexture>;
  16565. /**
  16566. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16567. * @param subMesh The submesh we want to render in the shadow map
  16568. * @param useInstances Defines wether will draw in the map using instances
  16569. * @returns true if ready otherwise, false
  16570. */
  16571. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16572. /**
  16573. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16574. * @param defines Defines of the material we want to update
  16575. * @param lightIndex Index of the light in the enabled light list of the material
  16576. */
  16577. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16578. /**
  16579. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16580. * defined in the generator but impacting the effect).
  16581. * It implies the unifroms available on the materials are the standard BJS ones.
  16582. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16583. * @param effect The effect we are binfing the information for
  16584. */
  16585. bindShadowLight(lightIndex: string, effect: Effect): void;
  16586. /**
  16587. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16588. * (eq to shadow prjection matrix * light transform matrix)
  16589. * @returns The transform matrix used to create the shadow map
  16590. */
  16591. getTransformMatrix(): Matrix;
  16592. /**
  16593. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16594. * Cube and 2D textures for instance.
  16595. */
  16596. recreateShadowMap(): void;
  16597. /**
  16598. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16599. * @param onCompiled Callback triggered at the and of the effects compilation
  16600. * @param options Sets of optional options forcing the compilation with different modes
  16601. */
  16602. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16603. useInstances: boolean;
  16604. }>): void;
  16605. /**
  16606. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16607. * @param options Sets of optional options forcing the compilation with different modes
  16608. * @returns A promise that resolves when the compilation completes
  16609. */
  16610. forceCompilationAsync(options?: Partial<{
  16611. useInstances: boolean;
  16612. }>): Promise<void>;
  16613. /**
  16614. * Serializes the shadow generator setup to a json object.
  16615. * @returns The serialized JSON object
  16616. */
  16617. serialize(): any;
  16618. /**
  16619. * Disposes the Shadow map and related Textures and effects.
  16620. */
  16621. dispose(): void;
  16622. }
  16623. /**
  16624. * Default implementation IShadowGenerator.
  16625. * This is the main object responsible of generating shadows in the framework.
  16626. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16627. */
  16628. export class ShadowGenerator implements IShadowGenerator {
  16629. /**
  16630. * Name of the shadow generator class
  16631. */
  16632. static CLASSNAME: string;
  16633. /**
  16634. * Shadow generator mode None: no filtering applied.
  16635. */
  16636. static readonly FILTER_NONE: number;
  16637. /**
  16638. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16639. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16640. */
  16641. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16642. /**
  16643. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16644. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16645. */
  16646. static readonly FILTER_POISSONSAMPLING: number;
  16647. /**
  16648. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16649. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16650. */
  16651. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16652. /**
  16653. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16654. * edge artifacts on steep falloff.
  16655. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16656. */
  16657. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16658. /**
  16659. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16660. * edge artifacts on steep falloff.
  16661. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16662. */
  16663. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16664. /**
  16665. * Shadow generator mode PCF: Percentage Closer Filtering
  16666. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16667. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16668. */
  16669. static readonly FILTER_PCF: number;
  16670. /**
  16671. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16672. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16673. * Contact Hardening
  16674. */
  16675. static readonly FILTER_PCSS: number;
  16676. /**
  16677. * Reserved for PCF and PCSS
  16678. * Highest Quality.
  16679. *
  16680. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16681. *
  16682. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16683. */
  16684. static readonly QUALITY_HIGH: number;
  16685. /**
  16686. * Reserved for PCF and PCSS
  16687. * Good tradeoff for quality/perf cross devices
  16688. *
  16689. * Execute PCF on a 3*3 kernel.
  16690. *
  16691. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16692. */
  16693. static readonly QUALITY_MEDIUM: number;
  16694. /**
  16695. * Reserved for PCF and PCSS
  16696. * The lowest quality but the fastest.
  16697. *
  16698. * Execute PCF on a 1*1 kernel.
  16699. *
  16700. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16701. */
  16702. static readonly QUALITY_LOW: number;
  16703. /** Gets or sets the custom shader name to use */
  16704. customShaderOptions: ICustomShaderOptions;
  16705. /**
  16706. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16707. */
  16708. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16709. /**
  16710. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16711. */
  16712. onAfterShadowMapRenderObservable: Observable<Effect>;
  16713. /**
  16714. * Observable triggered before a mesh is rendered in the shadow map.
  16715. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16716. */
  16717. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16718. /**
  16719. * Observable triggered after a mesh is rendered in the shadow map.
  16720. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16721. */
  16722. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16723. protected _bias: number;
  16724. /**
  16725. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16726. */
  16727. get bias(): number;
  16728. /**
  16729. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16730. */
  16731. set bias(bias: number);
  16732. protected _normalBias: number;
  16733. /**
  16734. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16735. */
  16736. get normalBias(): number;
  16737. /**
  16738. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16739. */
  16740. set normalBias(normalBias: number);
  16741. protected _blurBoxOffset: number;
  16742. /**
  16743. * Gets the blur box offset: offset applied during the blur pass.
  16744. * Only useful if useKernelBlur = false
  16745. */
  16746. get blurBoxOffset(): number;
  16747. /**
  16748. * Sets the blur box offset: offset applied during the blur pass.
  16749. * Only useful if useKernelBlur = false
  16750. */
  16751. set blurBoxOffset(value: number);
  16752. protected _blurScale: number;
  16753. /**
  16754. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16755. * 2 means half of the size.
  16756. */
  16757. get blurScale(): number;
  16758. /**
  16759. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16760. * 2 means half of the size.
  16761. */
  16762. set blurScale(value: number);
  16763. protected _blurKernel: number;
  16764. /**
  16765. * Gets the blur kernel: kernel size of the blur pass.
  16766. * Only useful if useKernelBlur = true
  16767. */
  16768. get blurKernel(): number;
  16769. /**
  16770. * Sets the blur kernel: kernel size of the blur pass.
  16771. * Only useful if useKernelBlur = true
  16772. */
  16773. set blurKernel(value: number);
  16774. protected _useKernelBlur: boolean;
  16775. /**
  16776. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16777. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16778. */
  16779. get useKernelBlur(): boolean;
  16780. /**
  16781. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16782. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16783. */
  16784. set useKernelBlur(value: boolean);
  16785. protected _depthScale: number;
  16786. /**
  16787. * Gets the depth scale used in ESM mode.
  16788. */
  16789. get depthScale(): number;
  16790. /**
  16791. * Sets the depth scale used in ESM mode.
  16792. * This can override the scale stored on the light.
  16793. */
  16794. set depthScale(value: number);
  16795. protected _validateFilter(filter: number): number;
  16796. protected _filter: number;
  16797. /**
  16798. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16799. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16800. */
  16801. get filter(): number;
  16802. /**
  16803. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16804. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16805. */
  16806. set filter(value: number);
  16807. /**
  16808. * Gets if the current filter is set to Poisson Sampling.
  16809. */
  16810. get usePoissonSampling(): boolean;
  16811. /**
  16812. * Sets the current filter to Poisson Sampling.
  16813. */
  16814. set usePoissonSampling(value: boolean);
  16815. /**
  16816. * Gets if the current filter is set to ESM.
  16817. */
  16818. get useExponentialShadowMap(): boolean;
  16819. /**
  16820. * Sets the current filter is to ESM.
  16821. */
  16822. set useExponentialShadowMap(value: boolean);
  16823. /**
  16824. * Gets if the current filter is set to filtered ESM.
  16825. */
  16826. get useBlurExponentialShadowMap(): boolean;
  16827. /**
  16828. * Gets if the current filter is set to filtered ESM.
  16829. */
  16830. set useBlurExponentialShadowMap(value: boolean);
  16831. /**
  16832. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16833. * exponential to prevent steep falloff artifacts).
  16834. */
  16835. get useCloseExponentialShadowMap(): boolean;
  16836. /**
  16837. * Sets the current filter to "close ESM" (using the inverse of the
  16838. * exponential to prevent steep falloff artifacts).
  16839. */
  16840. set useCloseExponentialShadowMap(value: boolean);
  16841. /**
  16842. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16843. * exponential to prevent steep falloff artifacts).
  16844. */
  16845. get useBlurCloseExponentialShadowMap(): boolean;
  16846. /**
  16847. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16848. * exponential to prevent steep falloff artifacts).
  16849. */
  16850. set useBlurCloseExponentialShadowMap(value: boolean);
  16851. /**
  16852. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16853. */
  16854. get usePercentageCloserFiltering(): boolean;
  16855. /**
  16856. * Sets the current filter to "PCF" (percentage closer filtering).
  16857. */
  16858. set usePercentageCloserFiltering(value: boolean);
  16859. protected _filteringQuality: number;
  16860. /**
  16861. * Gets the PCF or PCSS Quality.
  16862. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16863. */
  16864. get filteringQuality(): number;
  16865. /**
  16866. * Sets the PCF or PCSS Quality.
  16867. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16868. */
  16869. set filteringQuality(filteringQuality: number);
  16870. /**
  16871. * Gets if the current filter is set to "PCSS" (contact hardening).
  16872. */
  16873. get useContactHardeningShadow(): boolean;
  16874. /**
  16875. * Sets the current filter to "PCSS" (contact hardening).
  16876. */
  16877. set useContactHardeningShadow(value: boolean);
  16878. protected _contactHardeningLightSizeUVRatio: number;
  16879. /**
  16880. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16881. * Using a ratio helps keeping shape stability independently of the map size.
  16882. *
  16883. * It does not account for the light projection as it was having too much
  16884. * instability during the light setup or during light position changes.
  16885. *
  16886. * Only valid if useContactHardeningShadow is true.
  16887. */
  16888. get contactHardeningLightSizeUVRatio(): number;
  16889. /**
  16890. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16891. * Using a ratio helps keeping shape stability independently of the map size.
  16892. *
  16893. * It does not account for the light projection as it was having too much
  16894. * instability during the light setup or during light position changes.
  16895. *
  16896. * Only valid if useContactHardeningShadow is true.
  16897. */
  16898. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16899. protected _darkness: number;
  16900. /** Gets or sets the actual darkness of a shadow */
  16901. get darkness(): number;
  16902. set darkness(value: number);
  16903. /**
  16904. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16905. * 0 means strongest and 1 would means no shadow.
  16906. * @returns the darkness.
  16907. */
  16908. getDarkness(): number;
  16909. /**
  16910. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16911. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16912. * @returns the shadow generator allowing fluent coding.
  16913. */
  16914. setDarkness(darkness: number): ShadowGenerator;
  16915. protected _transparencyShadow: boolean;
  16916. /** Gets or sets the ability to have transparent shadow */
  16917. get transparencyShadow(): boolean;
  16918. set transparencyShadow(value: boolean);
  16919. /**
  16920. * Sets the ability to have transparent shadow (boolean).
  16921. * @param transparent True if transparent else False
  16922. * @returns the shadow generator allowing fluent coding
  16923. */
  16924. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16925. protected _shadowMap: Nullable<RenderTargetTexture>;
  16926. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16927. /**
  16928. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16929. * @returns The render target texture if present otherwise, null
  16930. */
  16931. getShadowMap(): Nullable<RenderTargetTexture>;
  16932. /**
  16933. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16934. * @returns The render target texture if the shadow map is present otherwise, null
  16935. */
  16936. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16937. /**
  16938. * Gets the class name of that object
  16939. * @returns "ShadowGenerator"
  16940. */
  16941. getClassName(): string;
  16942. /**
  16943. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16944. * @param mesh Mesh to add
  16945. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16946. * @returns the Shadow Generator itself
  16947. */
  16948. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16949. /**
  16950. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16951. * @param mesh Mesh to remove
  16952. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16953. * @returns the Shadow Generator itself
  16954. */
  16955. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16956. /**
  16957. * Controls the extent to which the shadows fade out at the edge of the frustum
  16958. */
  16959. frustumEdgeFalloff: number;
  16960. protected _light: IShadowLight;
  16961. /**
  16962. * Returns the associated light object.
  16963. * @returns the light generating the shadow
  16964. */
  16965. getLight(): IShadowLight;
  16966. /**
  16967. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16968. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16969. * It might on the other hand introduce peter panning.
  16970. */
  16971. forceBackFacesOnly: boolean;
  16972. protected _scene: Scene;
  16973. protected _lightDirection: Vector3;
  16974. protected _effect: Effect;
  16975. protected _viewMatrix: Matrix;
  16976. protected _projectionMatrix: Matrix;
  16977. protected _transformMatrix: Matrix;
  16978. protected _cachedPosition: Vector3;
  16979. protected _cachedDirection: Vector3;
  16980. protected _cachedDefines: string;
  16981. protected _currentRenderID: number;
  16982. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16983. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16984. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16985. protected _blurPostProcesses: PostProcess[];
  16986. protected _mapSize: number;
  16987. protected _currentFaceIndex: number;
  16988. protected _currentFaceIndexCache: number;
  16989. protected _textureType: number;
  16990. protected _defaultTextureMatrix: Matrix;
  16991. protected _storedUniqueId: Nullable<number>;
  16992. /** @hidden */
  16993. static _SceneComponentInitialization: (scene: Scene) => void;
  16994. /**
  16995. * Creates a ShadowGenerator object.
  16996. * A ShadowGenerator is the required tool to use the shadows.
  16997. * Each light casting shadows needs to use its own ShadowGenerator.
  16998. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  16999. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17000. * @param light The light object generating the shadows.
  17001. * @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.
  17002. */
  17003. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17004. protected _initializeGenerator(): void;
  17005. protected _createTargetRenderTexture(): void;
  17006. protected _initializeShadowMap(): void;
  17007. protected _initializeBlurRTTAndPostProcesses(): void;
  17008. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17009. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  17010. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17011. protected _applyFilterValues(): void;
  17012. /**
  17013. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17014. * @param onCompiled Callback triggered at the and of the effects compilation
  17015. * @param options Sets of optional options forcing the compilation with different modes
  17016. */
  17017. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17018. useInstances: boolean;
  17019. }>): void;
  17020. /**
  17021. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17022. * @param options Sets of optional options forcing the compilation with different modes
  17023. * @returns A promise that resolves when the compilation completes
  17024. */
  17025. forceCompilationAsync(options?: Partial<{
  17026. useInstances: boolean;
  17027. }>): Promise<void>;
  17028. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17029. /**
  17030. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17031. * @param subMesh The submesh we want to render in the shadow map
  17032. * @param useInstances Defines wether will draw in the map using instances
  17033. * @returns true if ready otherwise, false
  17034. */
  17035. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17036. /**
  17037. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17038. * @param defines Defines of the material we want to update
  17039. * @param lightIndex Index of the light in the enabled light list of the material
  17040. */
  17041. prepareDefines(defines: any, lightIndex: number): void;
  17042. /**
  17043. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17044. * defined in the generator but impacting the effect).
  17045. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17046. * @param effect The effect we are binfing the information for
  17047. */
  17048. bindShadowLight(lightIndex: string, effect: Effect): void;
  17049. /**
  17050. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17051. * (eq to shadow prjection matrix * light transform matrix)
  17052. * @returns The transform matrix used to create the shadow map
  17053. */
  17054. getTransformMatrix(): Matrix;
  17055. /**
  17056. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17057. * Cube and 2D textures for instance.
  17058. */
  17059. recreateShadowMap(): void;
  17060. protected _disposeBlurPostProcesses(): void;
  17061. protected _disposeRTTandPostProcesses(): void;
  17062. /**
  17063. * Disposes the ShadowGenerator.
  17064. * Returns nothing.
  17065. */
  17066. dispose(): void;
  17067. /**
  17068. * Serializes the shadow generator setup to a json object.
  17069. * @returns The serialized JSON object
  17070. */
  17071. serialize(): any;
  17072. /**
  17073. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17074. * @param parsedShadowGenerator The JSON object to parse
  17075. * @param scene The scene to create the shadow map for
  17076. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17077. * @returns The parsed shadow generator
  17078. */
  17079. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17080. }
  17081. }
  17082. declare module "babylonjs/Lights/light" {
  17083. import { Nullable } from "babylonjs/types";
  17084. import { Scene } from "babylonjs/scene";
  17085. import { Vector3 } from "babylonjs/Maths/math.vector";
  17086. import { Color3 } from "babylonjs/Maths/math.color";
  17087. import { Node } from "babylonjs/node";
  17088. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17089. import { Effect } from "babylonjs/Materials/effect";
  17090. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17091. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17092. /**
  17093. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17094. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17095. * 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.
  17096. */
  17097. export abstract class Light extends Node {
  17098. /**
  17099. * Falloff Default: light is falling off following the material specification:
  17100. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17101. */
  17102. static readonly FALLOFF_DEFAULT: number;
  17103. /**
  17104. * Falloff Physical: light is falling off following the inverse squared distance law.
  17105. */
  17106. static readonly FALLOFF_PHYSICAL: number;
  17107. /**
  17108. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17109. * to enhance interoperability with other engines.
  17110. */
  17111. static readonly FALLOFF_GLTF: number;
  17112. /**
  17113. * Falloff Standard: light is falling off like in the standard material
  17114. * to enhance interoperability with other materials.
  17115. */
  17116. static readonly FALLOFF_STANDARD: number;
  17117. /**
  17118. * If every light affecting the material is in this lightmapMode,
  17119. * material.lightmapTexture adds or multiplies
  17120. * (depends on material.useLightmapAsShadowmap)
  17121. * after every other light calculations.
  17122. */
  17123. static readonly LIGHTMAP_DEFAULT: number;
  17124. /**
  17125. * material.lightmapTexture as only diffuse lighting from this light
  17126. * adds only specular lighting from this light
  17127. * adds dynamic shadows
  17128. */
  17129. static readonly LIGHTMAP_SPECULAR: number;
  17130. /**
  17131. * material.lightmapTexture as only lighting
  17132. * no light calculation from this light
  17133. * only adds dynamic shadows from this light
  17134. */
  17135. static readonly LIGHTMAP_SHADOWSONLY: number;
  17136. /**
  17137. * Each light type uses the default quantity according to its type:
  17138. * point/spot lights use luminous intensity
  17139. * directional lights use illuminance
  17140. */
  17141. static readonly INTENSITYMODE_AUTOMATIC: number;
  17142. /**
  17143. * lumen (lm)
  17144. */
  17145. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17146. /**
  17147. * candela (lm/sr)
  17148. */
  17149. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17150. /**
  17151. * lux (lm/m^2)
  17152. */
  17153. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17154. /**
  17155. * nit (cd/m^2)
  17156. */
  17157. static readonly INTENSITYMODE_LUMINANCE: number;
  17158. /**
  17159. * Light type const id of the point light.
  17160. */
  17161. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17162. /**
  17163. * Light type const id of the directional light.
  17164. */
  17165. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17166. /**
  17167. * Light type const id of the spot light.
  17168. */
  17169. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17170. /**
  17171. * Light type const id of the hemispheric light.
  17172. */
  17173. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17174. /**
  17175. * Diffuse gives the basic color to an object.
  17176. */
  17177. diffuse: Color3;
  17178. /**
  17179. * Specular produces a highlight color on an object.
  17180. * Note: This is note affecting PBR materials.
  17181. */
  17182. specular: Color3;
  17183. /**
  17184. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17185. * falling off base on range or angle.
  17186. * This can be set to any values in Light.FALLOFF_x.
  17187. *
  17188. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17189. * other types of materials.
  17190. */
  17191. falloffType: number;
  17192. /**
  17193. * Strength of the light.
  17194. * Note: By default it is define in the framework own unit.
  17195. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17196. */
  17197. intensity: number;
  17198. private _range;
  17199. protected _inverseSquaredRange: number;
  17200. /**
  17201. * Defines how far from the source the light is impacting in scene units.
  17202. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17203. */
  17204. get range(): number;
  17205. /**
  17206. * Defines how far from the source the light is impacting in scene units.
  17207. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17208. */
  17209. set range(value: number);
  17210. /**
  17211. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17212. * of light.
  17213. */
  17214. private _photometricScale;
  17215. private _intensityMode;
  17216. /**
  17217. * Gets the photometric scale used to interpret the intensity.
  17218. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17219. */
  17220. get intensityMode(): number;
  17221. /**
  17222. * Sets the photometric scale used to interpret the intensity.
  17223. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17224. */
  17225. set intensityMode(value: number);
  17226. private _radius;
  17227. /**
  17228. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17229. */
  17230. get radius(): number;
  17231. /**
  17232. * sets the light radius used by PBR Materials to simulate soft area lights.
  17233. */
  17234. set radius(value: number);
  17235. private _renderPriority;
  17236. /**
  17237. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17238. * exceeding the number allowed of the materials.
  17239. */
  17240. renderPriority: number;
  17241. private _shadowEnabled;
  17242. /**
  17243. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17244. * the current shadow generator.
  17245. */
  17246. get shadowEnabled(): boolean;
  17247. /**
  17248. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17249. * the current shadow generator.
  17250. */
  17251. set shadowEnabled(value: boolean);
  17252. private _includedOnlyMeshes;
  17253. /**
  17254. * Gets the only meshes impacted by this light.
  17255. */
  17256. get includedOnlyMeshes(): AbstractMesh[];
  17257. /**
  17258. * Sets the only meshes impacted by this light.
  17259. */
  17260. set includedOnlyMeshes(value: AbstractMesh[]);
  17261. private _excludedMeshes;
  17262. /**
  17263. * Gets the meshes not impacted by this light.
  17264. */
  17265. get excludedMeshes(): AbstractMesh[];
  17266. /**
  17267. * Sets the meshes not impacted by this light.
  17268. */
  17269. set excludedMeshes(value: AbstractMesh[]);
  17270. private _excludeWithLayerMask;
  17271. /**
  17272. * Gets the layer id use to find what meshes are not impacted by the light.
  17273. * Inactive if 0
  17274. */
  17275. get excludeWithLayerMask(): number;
  17276. /**
  17277. * Sets the layer id use to find what meshes are not impacted by the light.
  17278. * Inactive if 0
  17279. */
  17280. set excludeWithLayerMask(value: number);
  17281. private _includeOnlyWithLayerMask;
  17282. /**
  17283. * Gets the layer id use to find what meshes are impacted by the light.
  17284. * Inactive if 0
  17285. */
  17286. get includeOnlyWithLayerMask(): number;
  17287. /**
  17288. * Sets the layer id use to find what meshes are impacted by the light.
  17289. * Inactive if 0
  17290. */
  17291. set includeOnlyWithLayerMask(value: number);
  17292. private _lightmapMode;
  17293. /**
  17294. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17295. */
  17296. get lightmapMode(): number;
  17297. /**
  17298. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17299. */
  17300. set lightmapMode(value: number);
  17301. /**
  17302. * Shadow generator associted to the light.
  17303. * @hidden Internal use only.
  17304. */
  17305. _shadowGenerator: Nullable<IShadowGenerator>;
  17306. /**
  17307. * @hidden Internal use only.
  17308. */
  17309. _excludedMeshesIds: string[];
  17310. /**
  17311. * @hidden Internal use only.
  17312. */
  17313. _includedOnlyMeshesIds: string[];
  17314. /**
  17315. * The current light unifom buffer.
  17316. * @hidden Internal use only.
  17317. */
  17318. _uniformBuffer: UniformBuffer;
  17319. /** @hidden */
  17320. _renderId: number;
  17321. /**
  17322. * Creates a Light object in the scene.
  17323. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17324. * @param name The firendly name of the light
  17325. * @param scene The scene the light belongs too
  17326. */
  17327. constructor(name: string, scene: Scene);
  17328. protected abstract _buildUniformLayout(): void;
  17329. /**
  17330. * Sets the passed Effect "effect" with the Light information.
  17331. * @param effect The effect to update
  17332. * @param lightIndex The index of the light in the effect to update
  17333. * @returns The light
  17334. */
  17335. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17336. /**
  17337. * Sets the passed Effect "effect" with the Light textures.
  17338. * @param effect The effect to update
  17339. * @param lightIndex The index of the light in the effect to update
  17340. * @returns The light
  17341. */
  17342. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17343. /**
  17344. * Binds the lights information from the scene to the effect for the given mesh.
  17345. * @param lightIndex Light index
  17346. * @param scene The scene where the light belongs to
  17347. * @param effect The effect we are binding the data to
  17348. * @param useSpecular Defines if specular is supported
  17349. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17350. */
  17351. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17352. /**
  17353. * Sets the passed Effect "effect" with the Light information.
  17354. * @param effect The effect to update
  17355. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17356. * @returns The light
  17357. */
  17358. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17359. /**
  17360. * Returns the string "Light".
  17361. * @returns the class name
  17362. */
  17363. getClassName(): string;
  17364. /** @hidden */
  17365. readonly _isLight: boolean;
  17366. /**
  17367. * Converts the light information to a readable string for debug purpose.
  17368. * @param fullDetails Supports for multiple levels of logging within scene loading
  17369. * @returns the human readable light info
  17370. */
  17371. toString(fullDetails?: boolean): string;
  17372. /** @hidden */
  17373. protected _syncParentEnabledState(): void;
  17374. /**
  17375. * Set the enabled state of this node.
  17376. * @param value - the new enabled state
  17377. */
  17378. setEnabled(value: boolean): void;
  17379. /**
  17380. * Returns the Light associated shadow generator if any.
  17381. * @return the associated shadow generator.
  17382. */
  17383. getShadowGenerator(): Nullable<IShadowGenerator>;
  17384. /**
  17385. * Returns a Vector3, the absolute light position in the World.
  17386. * @returns the world space position of the light
  17387. */
  17388. getAbsolutePosition(): Vector3;
  17389. /**
  17390. * Specifies if the light will affect the passed mesh.
  17391. * @param mesh The mesh to test against the light
  17392. * @return true the mesh is affected otherwise, false.
  17393. */
  17394. canAffectMesh(mesh: AbstractMesh): boolean;
  17395. /**
  17396. * Sort function to order lights for rendering.
  17397. * @param a First Light object to compare to second.
  17398. * @param b Second Light object to compare first.
  17399. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17400. */
  17401. static CompareLightsPriority(a: Light, b: Light): number;
  17402. /**
  17403. * Releases resources associated with this node.
  17404. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17405. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17406. */
  17407. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17408. /**
  17409. * Returns the light type ID (integer).
  17410. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17411. */
  17412. getTypeID(): number;
  17413. /**
  17414. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17415. * @returns the scaled intensity in intensity mode unit
  17416. */
  17417. getScaledIntensity(): number;
  17418. /**
  17419. * Returns a new Light object, named "name", from the current one.
  17420. * @param name The name of the cloned light
  17421. * @returns the new created light
  17422. */
  17423. clone(name: string): Nullable<Light>;
  17424. /**
  17425. * Serializes the current light into a Serialization object.
  17426. * @returns the serialized object.
  17427. */
  17428. serialize(): any;
  17429. /**
  17430. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17431. * This new light is named "name" and added to the passed scene.
  17432. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17433. * @param name The friendly name of the light
  17434. * @param scene The scene the new light will belong to
  17435. * @returns the constructor function
  17436. */
  17437. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17438. /**
  17439. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17440. * @param parsedLight The JSON representation of the light
  17441. * @param scene The scene to create the parsed light in
  17442. * @returns the created light after parsing
  17443. */
  17444. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17445. private _hookArrayForExcluded;
  17446. private _hookArrayForIncludedOnly;
  17447. private _resyncMeshes;
  17448. /**
  17449. * Forces the meshes to update their light related information in their rendering used effects
  17450. * @hidden Internal Use Only
  17451. */
  17452. _markMeshesAsLightDirty(): void;
  17453. /**
  17454. * Recomputes the cached photometric scale if needed.
  17455. */
  17456. private _computePhotometricScale;
  17457. /**
  17458. * Returns the Photometric Scale according to the light type and intensity mode.
  17459. */
  17460. private _getPhotometricScale;
  17461. /**
  17462. * Reorder the light in the scene according to their defined priority.
  17463. * @hidden Internal Use Only
  17464. */
  17465. _reorderLightsInScene(): void;
  17466. /**
  17467. * Prepares the list of defines specific to the light type.
  17468. * @param defines the list of defines
  17469. * @param lightIndex defines the index of the light for the effect
  17470. */
  17471. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17472. }
  17473. }
  17474. declare module "babylonjs/Actions/action" {
  17475. import { Observable } from "babylonjs/Misc/observable";
  17476. import { Condition } from "babylonjs/Actions/condition";
  17477. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17478. import { ActionManager } from "babylonjs/Actions/actionManager";
  17479. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17480. /**
  17481. * Interface used to define Action
  17482. */
  17483. export interface IAction {
  17484. /**
  17485. * Trigger for the action
  17486. */
  17487. trigger: number;
  17488. /** Options of the trigger */
  17489. triggerOptions: any;
  17490. /**
  17491. * Gets the trigger parameters
  17492. * @returns the trigger parameters
  17493. */
  17494. getTriggerParameter(): any;
  17495. /**
  17496. * Internal only - executes current action event
  17497. * @hidden
  17498. */
  17499. _executeCurrent(evt?: ActionEvent): void;
  17500. /**
  17501. * Serialize placeholder for child classes
  17502. * @param parent of child
  17503. * @returns the serialized object
  17504. */
  17505. serialize(parent: any): any;
  17506. /**
  17507. * Internal only
  17508. * @hidden
  17509. */
  17510. _prepare(): void;
  17511. /**
  17512. * Internal only - manager for action
  17513. * @hidden
  17514. */
  17515. _actionManager: AbstractActionManager;
  17516. /**
  17517. * Adds action to chain of actions, may be a DoNothingAction
  17518. * @param action defines the next action to execute
  17519. * @returns The action passed in
  17520. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17521. */
  17522. then(action: IAction): IAction;
  17523. }
  17524. /**
  17525. * The action to be carried out following a trigger
  17526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17527. */
  17528. export class Action implements IAction {
  17529. /** the trigger, with or without parameters, for the action */
  17530. triggerOptions: any;
  17531. /**
  17532. * Trigger for the action
  17533. */
  17534. trigger: number;
  17535. /**
  17536. * Internal only - manager for action
  17537. * @hidden
  17538. */
  17539. _actionManager: ActionManager;
  17540. private _nextActiveAction;
  17541. private _child;
  17542. private _condition?;
  17543. private _triggerParameter;
  17544. /**
  17545. * An event triggered prior to action being executed.
  17546. */
  17547. onBeforeExecuteObservable: Observable<Action>;
  17548. /**
  17549. * Creates a new Action
  17550. * @param triggerOptions the trigger, with or without parameters, for the action
  17551. * @param condition an optional determinant of action
  17552. */
  17553. constructor(
  17554. /** the trigger, with or without parameters, for the action */
  17555. triggerOptions: any, condition?: Condition);
  17556. /**
  17557. * Internal only
  17558. * @hidden
  17559. */
  17560. _prepare(): void;
  17561. /**
  17562. * Gets the trigger parameters
  17563. * @returns the trigger parameters
  17564. */
  17565. getTriggerParameter(): any;
  17566. /**
  17567. * Internal only - executes current action event
  17568. * @hidden
  17569. */
  17570. _executeCurrent(evt?: ActionEvent): void;
  17571. /**
  17572. * Execute placeholder for child classes
  17573. * @param evt optional action event
  17574. */
  17575. execute(evt?: ActionEvent): void;
  17576. /**
  17577. * Skips to next active action
  17578. */
  17579. skipToNextActiveAction(): void;
  17580. /**
  17581. * Adds action to chain of actions, may be a DoNothingAction
  17582. * @param action defines the next action to execute
  17583. * @returns The action passed in
  17584. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17585. */
  17586. then(action: Action): Action;
  17587. /**
  17588. * Internal only
  17589. * @hidden
  17590. */
  17591. _getProperty(propertyPath: string): string;
  17592. /**
  17593. * Internal only
  17594. * @hidden
  17595. */
  17596. _getEffectiveTarget(target: any, propertyPath: string): any;
  17597. /**
  17598. * Serialize placeholder for child classes
  17599. * @param parent of child
  17600. * @returns the serialized object
  17601. */
  17602. serialize(parent: any): any;
  17603. /**
  17604. * Internal only called by serialize
  17605. * @hidden
  17606. */
  17607. protected _serialize(serializedAction: any, parent?: any): any;
  17608. /**
  17609. * Internal only
  17610. * @hidden
  17611. */
  17612. static _SerializeValueAsString: (value: any) => string;
  17613. /**
  17614. * Internal only
  17615. * @hidden
  17616. */
  17617. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17618. name: string;
  17619. targetType: string;
  17620. value: string;
  17621. };
  17622. }
  17623. }
  17624. declare module "babylonjs/Actions/condition" {
  17625. import { ActionManager } from "babylonjs/Actions/actionManager";
  17626. /**
  17627. * A Condition applied to an Action
  17628. */
  17629. export class Condition {
  17630. /**
  17631. * Internal only - manager for action
  17632. * @hidden
  17633. */
  17634. _actionManager: ActionManager;
  17635. /**
  17636. * Internal only
  17637. * @hidden
  17638. */
  17639. _evaluationId: number;
  17640. /**
  17641. * Internal only
  17642. * @hidden
  17643. */
  17644. _currentResult: boolean;
  17645. /**
  17646. * Creates a new Condition
  17647. * @param actionManager the manager of the action the condition is applied to
  17648. */
  17649. constructor(actionManager: ActionManager);
  17650. /**
  17651. * Check if the current condition is valid
  17652. * @returns a boolean
  17653. */
  17654. isValid(): boolean;
  17655. /**
  17656. * Internal only
  17657. * @hidden
  17658. */
  17659. _getProperty(propertyPath: string): string;
  17660. /**
  17661. * Internal only
  17662. * @hidden
  17663. */
  17664. _getEffectiveTarget(target: any, propertyPath: string): any;
  17665. /**
  17666. * Serialize placeholder for child classes
  17667. * @returns the serialized object
  17668. */
  17669. serialize(): any;
  17670. /**
  17671. * Internal only
  17672. * @hidden
  17673. */
  17674. protected _serialize(serializedCondition: any): any;
  17675. }
  17676. /**
  17677. * Defines specific conditional operators as extensions of Condition
  17678. */
  17679. export class ValueCondition extends Condition {
  17680. /** path to specify the property of the target the conditional operator uses */
  17681. propertyPath: string;
  17682. /** the value compared by the conditional operator against the current value of the property */
  17683. value: any;
  17684. /** the conditional operator, default ValueCondition.IsEqual */
  17685. operator: number;
  17686. /**
  17687. * Internal only
  17688. * @hidden
  17689. */
  17690. private static _IsEqual;
  17691. /**
  17692. * Internal only
  17693. * @hidden
  17694. */
  17695. private static _IsDifferent;
  17696. /**
  17697. * Internal only
  17698. * @hidden
  17699. */
  17700. private static _IsGreater;
  17701. /**
  17702. * Internal only
  17703. * @hidden
  17704. */
  17705. private static _IsLesser;
  17706. /**
  17707. * returns the number for IsEqual
  17708. */
  17709. static get IsEqual(): number;
  17710. /**
  17711. * Returns the number for IsDifferent
  17712. */
  17713. static get IsDifferent(): number;
  17714. /**
  17715. * Returns the number for IsGreater
  17716. */
  17717. static get IsGreater(): number;
  17718. /**
  17719. * Returns the number for IsLesser
  17720. */
  17721. static get IsLesser(): number;
  17722. /**
  17723. * Internal only The action manager for the condition
  17724. * @hidden
  17725. */
  17726. _actionManager: ActionManager;
  17727. /**
  17728. * Internal only
  17729. * @hidden
  17730. */
  17731. private _target;
  17732. /**
  17733. * Internal only
  17734. * @hidden
  17735. */
  17736. private _effectiveTarget;
  17737. /**
  17738. * Internal only
  17739. * @hidden
  17740. */
  17741. private _property;
  17742. /**
  17743. * Creates a new ValueCondition
  17744. * @param actionManager manager for the action the condition applies to
  17745. * @param target for the action
  17746. * @param propertyPath path to specify the property of the target the conditional operator uses
  17747. * @param value the value compared by the conditional operator against the current value of the property
  17748. * @param operator the conditional operator, default ValueCondition.IsEqual
  17749. */
  17750. constructor(actionManager: ActionManager, target: any,
  17751. /** path to specify the property of the target the conditional operator uses */
  17752. propertyPath: string,
  17753. /** the value compared by the conditional operator against the current value of the property */
  17754. value: any,
  17755. /** the conditional operator, default ValueCondition.IsEqual */
  17756. operator?: number);
  17757. /**
  17758. * Compares the given value with the property value for the specified conditional operator
  17759. * @returns the result of the comparison
  17760. */
  17761. isValid(): boolean;
  17762. /**
  17763. * Serialize the ValueCondition into a JSON compatible object
  17764. * @returns serialization object
  17765. */
  17766. serialize(): any;
  17767. /**
  17768. * Gets the name of the conditional operator for the ValueCondition
  17769. * @param operator the conditional operator
  17770. * @returns the name
  17771. */
  17772. static GetOperatorName(operator: number): string;
  17773. }
  17774. /**
  17775. * Defines a predicate condition as an extension of Condition
  17776. */
  17777. export class PredicateCondition extends Condition {
  17778. /** defines the predicate function used to validate the condition */
  17779. predicate: () => boolean;
  17780. /**
  17781. * Internal only - manager for action
  17782. * @hidden
  17783. */
  17784. _actionManager: ActionManager;
  17785. /**
  17786. * Creates a new PredicateCondition
  17787. * @param actionManager manager for the action the condition applies to
  17788. * @param predicate defines the predicate function used to validate the condition
  17789. */
  17790. constructor(actionManager: ActionManager,
  17791. /** defines the predicate function used to validate the condition */
  17792. predicate: () => boolean);
  17793. /**
  17794. * @returns the validity of the predicate condition
  17795. */
  17796. isValid(): boolean;
  17797. }
  17798. /**
  17799. * Defines a state condition as an extension of Condition
  17800. */
  17801. export class StateCondition extends Condition {
  17802. /** Value to compare with target state */
  17803. value: string;
  17804. /**
  17805. * Internal only - manager for action
  17806. * @hidden
  17807. */
  17808. _actionManager: ActionManager;
  17809. /**
  17810. * Internal only
  17811. * @hidden
  17812. */
  17813. private _target;
  17814. /**
  17815. * Creates a new StateCondition
  17816. * @param actionManager manager for the action the condition applies to
  17817. * @param target of the condition
  17818. * @param value to compare with target state
  17819. */
  17820. constructor(actionManager: ActionManager, target: any,
  17821. /** Value to compare with target state */
  17822. value: string);
  17823. /**
  17824. * Gets a boolean indicating if the current condition is met
  17825. * @returns the validity of the state
  17826. */
  17827. isValid(): boolean;
  17828. /**
  17829. * Serialize the StateCondition into a JSON compatible object
  17830. * @returns serialization object
  17831. */
  17832. serialize(): any;
  17833. }
  17834. }
  17835. declare module "babylonjs/Actions/directActions" {
  17836. import { Action } from "babylonjs/Actions/action";
  17837. import { Condition } from "babylonjs/Actions/condition";
  17838. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17839. /**
  17840. * This defines an action responsible to toggle a boolean once triggered.
  17841. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17842. */
  17843. export class SwitchBooleanAction extends Action {
  17844. /**
  17845. * The path to the boolean property in the target object
  17846. */
  17847. propertyPath: string;
  17848. private _target;
  17849. private _effectiveTarget;
  17850. private _property;
  17851. /**
  17852. * Instantiate the action
  17853. * @param triggerOptions defines the trigger options
  17854. * @param target defines the object containing the boolean
  17855. * @param propertyPath defines the path to the boolean property in the target object
  17856. * @param condition defines the trigger related conditions
  17857. */
  17858. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17859. /** @hidden */
  17860. _prepare(): void;
  17861. /**
  17862. * Execute the action toggle the boolean value.
  17863. */
  17864. execute(): void;
  17865. /**
  17866. * Serializes the actions and its related information.
  17867. * @param parent defines the object to serialize in
  17868. * @returns the serialized object
  17869. */
  17870. serialize(parent: any): any;
  17871. }
  17872. /**
  17873. * This defines an action responsible to set a the state field of the target
  17874. * to a desired value once triggered.
  17875. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17876. */
  17877. export class SetStateAction extends Action {
  17878. /**
  17879. * The value to store in the state field.
  17880. */
  17881. value: string;
  17882. private _target;
  17883. /**
  17884. * Instantiate the action
  17885. * @param triggerOptions defines the trigger options
  17886. * @param target defines the object containing the state property
  17887. * @param value defines the value to store in the state field
  17888. * @param condition defines the trigger related conditions
  17889. */
  17890. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17891. /**
  17892. * Execute the action and store the value on the target state property.
  17893. */
  17894. execute(): void;
  17895. /**
  17896. * Serializes the actions and its related information.
  17897. * @param parent defines the object to serialize in
  17898. * @returns the serialized object
  17899. */
  17900. serialize(parent: any): any;
  17901. }
  17902. /**
  17903. * This defines an action responsible to set a property of the target
  17904. * to a desired value once triggered.
  17905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17906. */
  17907. export class SetValueAction extends Action {
  17908. /**
  17909. * The path of the property to set in the target.
  17910. */
  17911. propertyPath: string;
  17912. /**
  17913. * The value to set in the property
  17914. */
  17915. value: any;
  17916. private _target;
  17917. private _effectiveTarget;
  17918. private _property;
  17919. /**
  17920. * Instantiate the action
  17921. * @param triggerOptions defines the trigger options
  17922. * @param target defines the object containing the property
  17923. * @param propertyPath defines the path of the property to set in the target
  17924. * @param value defines the value to set in the property
  17925. * @param condition defines the trigger related conditions
  17926. */
  17927. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17928. /** @hidden */
  17929. _prepare(): void;
  17930. /**
  17931. * Execute the action and set the targetted property to the desired value.
  17932. */
  17933. execute(): void;
  17934. /**
  17935. * Serializes the actions and its related information.
  17936. * @param parent defines the object to serialize in
  17937. * @returns the serialized object
  17938. */
  17939. serialize(parent: any): any;
  17940. }
  17941. /**
  17942. * This defines an action responsible to increment the target value
  17943. * to a desired value once triggered.
  17944. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17945. */
  17946. export class IncrementValueAction extends Action {
  17947. /**
  17948. * The path of the property to increment in the target.
  17949. */
  17950. propertyPath: string;
  17951. /**
  17952. * The value we should increment the property by.
  17953. */
  17954. value: any;
  17955. private _target;
  17956. private _effectiveTarget;
  17957. private _property;
  17958. /**
  17959. * Instantiate the action
  17960. * @param triggerOptions defines the trigger options
  17961. * @param target defines the object containing the property
  17962. * @param propertyPath defines the path of the property to increment in the target
  17963. * @param value defines the value value we should increment the property by
  17964. * @param condition defines the trigger related conditions
  17965. */
  17966. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17967. /** @hidden */
  17968. _prepare(): void;
  17969. /**
  17970. * Execute the action and increment the target of the value amount.
  17971. */
  17972. execute(): void;
  17973. /**
  17974. * Serializes the actions and its related information.
  17975. * @param parent defines the object to serialize in
  17976. * @returns the serialized object
  17977. */
  17978. serialize(parent: any): any;
  17979. }
  17980. /**
  17981. * This defines an action responsible to start an animation once triggered.
  17982. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17983. */
  17984. export class PlayAnimationAction extends Action {
  17985. /**
  17986. * Where the animation should start (animation frame)
  17987. */
  17988. from: number;
  17989. /**
  17990. * Where the animation should stop (animation frame)
  17991. */
  17992. to: number;
  17993. /**
  17994. * Define if the animation should loop or stop after the first play.
  17995. */
  17996. loop?: boolean;
  17997. private _target;
  17998. /**
  17999. * Instantiate the action
  18000. * @param triggerOptions defines the trigger options
  18001. * @param target defines the target animation or animation name
  18002. * @param from defines from where the animation should start (animation frame)
  18003. * @param end defines where the animation should stop (animation frame)
  18004. * @param loop defines if the animation should loop or stop after the first play
  18005. * @param condition defines the trigger related conditions
  18006. */
  18007. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18008. /** @hidden */
  18009. _prepare(): void;
  18010. /**
  18011. * Execute the action and play the animation.
  18012. */
  18013. execute(): void;
  18014. /**
  18015. * Serializes the actions and its related information.
  18016. * @param parent defines the object to serialize in
  18017. * @returns the serialized object
  18018. */
  18019. serialize(parent: any): any;
  18020. }
  18021. /**
  18022. * This defines an action responsible to stop an animation once triggered.
  18023. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18024. */
  18025. export class StopAnimationAction extends Action {
  18026. private _target;
  18027. /**
  18028. * Instantiate the action
  18029. * @param triggerOptions defines the trigger options
  18030. * @param target defines the target animation or animation name
  18031. * @param condition defines the trigger related conditions
  18032. */
  18033. constructor(triggerOptions: any, target: any, condition?: Condition);
  18034. /** @hidden */
  18035. _prepare(): void;
  18036. /**
  18037. * Execute the action and stop the animation.
  18038. */
  18039. execute(): void;
  18040. /**
  18041. * Serializes the actions and its related information.
  18042. * @param parent defines the object to serialize in
  18043. * @returns the serialized object
  18044. */
  18045. serialize(parent: any): any;
  18046. }
  18047. /**
  18048. * This defines an action responsible that does nothing once triggered.
  18049. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18050. */
  18051. export class DoNothingAction extends Action {
  18052. /**
  18053. * Instantiate the action
  18054. * @param triggerOptions defines the trigger options
  18055. * @param condition defines the trigger related conditions
  18056. */
  18057. constructor(triggerOptions?: any, condition?: Condition);
  18058. /**
  18059. * Execute the action and do nothing.
  18060. */
  18061. execute(): void;
  18062. /**
  18063. * Serializes the actions and its related information.
  18064. * @param parent defines the object to serialize in
  18065. * @returns the serialized object
  18066. */
  18067. serialize(parent: any): any;
  18068. }
  18069. /**
  18070. * This defines an action responsible to trigger several actions once triggered.
  18071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18072. */
  18073. export class CombineAction extends Action {
  18074. /**
  18075. * The list of aggregated animations to run.
  18076. */
  18077. children: Action[];
  18078. /**
  18079. * Instantiate the action
  18080. * @param triggerOptions defines the trigger options
  18081. * @param children defines the list of aggregated animations to run
  18082. * @param condition defines the trigger related conditions
  18083. */
  18084. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18085. /** @hidden */
  18086. _prepare(): void;
  18087. /**
  18088. * Execute the action and executes all the aggregated actions.
  18089. */
  18090. execute(evt: ActionEvent): void;
  18091. /**
  18092. * Serializes the actions and its related information.
  18093. * @param parent defines the object to serialize in
  18094. * @returns the serialized object
  18095. */
  18096. serialize(parent: any): any;
  18097. }
  18098. /**
  18099. * This defines an action responsible to run code (external event) once triggered.
  18100. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18101. */
  18102. export class ExecuteCodeAction extends Action {
  18103. /**
  18104. * The callback function to run.
  18105. */
  18106. func: (evt: ActionEvent) => void;
  18107. /**
  18108. * Instantiate the action
  18109. * @param triggerOptions defines the trigger options
  18110. * @param func defines the callback function to run
  18111. * @param condition defines the trigger related conditions
  18112. */
  18113. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18114. /**
  18115. * Execute the action and run the attached code.
  18116. */
  18117. execute(evt: ActionEvent): void;
  18118. }
  18119. /**
  18120. * This defines an action responsible to set the parent property of the target once triggered.
  18121. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18122. */
  18123. export class SetParentAction extends Action {
  18124. private _parent;
  18125. private _target;
  18126. /**
  18127. * Instantiate the action
  18128. * @param triggerOptions defines the trigger options
  18129. * @param target defines the target containing the parent property
  18130. * @param parent defines from where the animation should start (animation frame)
  18131. * @param condition defines the trigger related conditions
  18132. */
  18133. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18134. /** @hidden */
  18135. _prepare(): void;
  18136. /**
  18137. * Execute the action and set the parent property.
  18138. */
  18139. execute(): void;
  18140. /**
  18141. * Serializes the actions and its related information.
  18142. * @param parent defines the object to serialize in
  18143. * @returns the serialized object
  18144. */
  18145. serialize(parent: any): any;
  18146. }
  18147. }
  18148. declare module "babylonjs/Actions/actionManager" {
  18149. import { Nullable } from "babylonjs/types";
  18150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18151. import { Scene } from "babylonjs/scene";
  18152. import { IAction } from "babylonjs/Actions/action";
  18153. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18154. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18155. /**
  18156. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18157. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18159. */
  18160. export class ActionManager extends AbstractActionManager {
  18161. /**
  18162. * Nothing
  18163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18164. */
  18165. static readonly NothingTrigger: number;
  18166. /**
  18167. * On pick
  18168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18169. */
  18170. static readonly OnPickTrigger: number;
  18171. /**
  18172. * On left pick
  18173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18174. */
  18175. static readonly OnLeftPickTrigger: number;
  18176. /**
  18177. * On right pick
  18178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18179. */
  18180. static readonly OnRightPickTrigger: number;
  18181. /**
  18182. * On center pick
  18183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18184. */
  18185. static readonly OnCenterPickTrigger: number;
  18186. /**
  18187. * On pick down
  18188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18189. */
  18190. static readonly OnPickDownTrigger: number;
  18191. /**
  18192. * On double pick
  18193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18194. */
  18195. static readonly OnDoublePickTrigger: number;
  18196. /**
  18197. * On pick up
  18198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18199. */
  18200. static readonly OnPickUpTrigger: number;
  18201. /**
  18202. * On pick out.
  18203. * This trigger will only be raised if you also declared a OnPickDown
  18204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18205. */
  18206. static readonly OnPickOutTrigger: number;
  18207. /**
  18208. * On long press
  18209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18210. */
  18211. static readonly OnLongPressTrigger: number;
  18212. /**
  18213. * On pointer over
  18214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18215. */
  18216. static readonly OnPointerOverTrigger: number;
  18217. /**
  18218. * On pointer out
  18219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18220. */
  18221. static readonly OnPointerOutTrigger: number;
  18222. /**
  18223. * On every frame
  18224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18225. */
  18226. static readonly OnEveryFrameTrigger: number;
  18227. /**
  18228. * On intersection enter
  18229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18230. */
  18231. static readonly OnIntersectionEnterTrigger: number;
  18232. /**
  18233. * On intersection exit
  18234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18235. */
  18236. static readonly OnIntersectionExitTrigger: number;
  18237. /**
  18238. * On key down
  18239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18240. */
  18241. static readonly OnKeyDownTrigger: number;
  18242. /**
  18243. * On key up
  18244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18245. */
  18246. static readonly OnKeyUpTrigger: number;
  18247. private _scene;
  18248. /**
  18249. * Creates a new action manager
  18250. * @param scene defines the hosting scene
  18251. */
  18252. constructor(scene: Scene);
  18253. /**
  18254. * Releases all associated resources
  18255. */
  18256. dispose(): void;
  18257. /**
  18258. * Gets hosting scene
  18259. * @returns the hosting scene
  18260. */
  18261. getScene(): Scene;
  18262. /**
  18263. * Does this action manager handles actions of any of the given triggers
  18264. * @param triggers defines the triggers to be tested
  18265. * @return a boolean indicating whether one (or more) of the triggers is handled
  18266. */
  18267. hasSpecificTriggers(triggers: number[]): boolean;
  18268. /**
  18269. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18270. * speed.
  18271. * @param triggerA defines the trigger to be tested
  18272. * @param triggerB defines the trigger to be tested
  18273. * @return a boolean indicating whether one (or more) of the triggers is handled
  18274. */
  18275. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18276. /**
  18277. * Does this action manager handles actions of a given trigger
  18278. * @param trigger defines the trigger to be tested
  18279. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18280. * @return whether the trigger is handled
  18281. */
  18282. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18283. /**
  18284. * Does this action manager has pointer triggers
  18285. */
  18286. get hasPointerTriggers(): boolean;
  18287. /**
  18288. * Does this action manager has pick triggers
  18289. */
  18290. get hasPickTriggers(): boolean;
  18291. /**
  18292. * Registers an action to this action manager
  18293. * @param action defines the action to be registered
  18294. * @return the action amended (prepared) after registration
  18295. */
  18296. registerAction(action: IAction): Nullable<IAction>;
  18297. /**
  18298. * Unregisters an action to this action manager
  18299. * @param action defines the action to be unregistered
  18300. * @return a boolean indicating whether the action has been unregistered
  18301. */
  18302. unregisterAction(action: IAction): Boolean;
  18303. /**
  18304. * Process a specific trigger
  18305. * @param trigger defines the trigger to process
  18306. * @param evt defines the event details to be processed
  18307. */
  18308. processTrigger(trigger: number, evt?: IActionEvent): void;
  18309. /** @hidden */
  18310. _getEffectiveTarget(target: any, propertyPath: string): any;
  18311. /** @hidden */
  18312. _getProperty(propertyPath: string): string;
  18313. /**
  18314. * Serialize this manager to a JSON object
  18315. * @param name defines the property name to store this manager
  18316. * @returns a JSON representation of this manager
  18317. */
  18318. serialize(name: string): any;
  18319. /**
  18320. * Creates a new ActionManager from a JSON data
  18321. * @param parsedActions defines the JSON data to read from
  18322. * @param object defines the hosting mesh
  18323. * @param scene defines the hosting scene
  18324. */
  18325. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18326. /**
  18327. * Get a trigger name by index
  18328. * @param trigger defines the trigger index
  18329. * @returns a trigger name
  18330. */
  18331. static GetTriggerName(trigger: number): string;
  18332. }
  18333. }
  18334. declare module "babylonjs/Sprites/sprite" {
  18335. import { Vector3 } from "babylonjs/Maths/math.vector";
  18336. import { Nullable } from "babylonjs/types";
  18337. import { ActionManager } from "babylonjs/Actions/actionManager";
  18338. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18339. import { Color4 } from "babylonjs/Maths/math.color";
  18340. /**
  18341. * Class used to represent a sprite
  18342. * @see http://doc.babylonjs.com/babylon101/sprites
  18343. */
  18344. export class Sprite {
  18345. /** defines the name */
  18346. name: string;
  18347. /** Gets or sets the current world position */
  18348. position: Vector3;
  18349. /** Gets or sets the main color */
  18350. color: Color4;
  18351. /** Gets or sets the width */
  18352. width: number;
  18353. /** Gets or sets the height */
  18354. height: number;
  18355. /** Gets or sets rotation angle */
  18356. angle: number;
  18357. /** Gets or sets the cell index in the sprite sheet */
  18358. cellIndex: number;
  18359. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18360. cellRef: string;
  18361. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18362. invertU: number;
  18363. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18364. invertV: number;
  18365. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18366. disposeWhenFinishedAnimating: boolean;
  18367. /** Gets the list of attached animations */
  18368. animations: Animation[];
  18369. /** Gets or sets a boolean indicating if the sprite can be picked */
  18370. isPickable: boolean;
  18371. /**
  18372. * Gets or sets the associated action manager
  18373. */
  18374. actionManager: Nullable<ActionManager>;
  18375. private _animationStarted;
  18376. private _loopAnimation;
  18377. private _fromIndex;
  18378. private _toIndex;
  18379. private _delay;
  18380. private _direction;
  18381. private _manager;
  18382. private _time;
  18383. private _onAnimationEnd;
  18384. /**
  18385. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18386. */
  18387. isVisible: boolean;
  18388. /**
  18389. * Gets or sets the sprite size
  18390. */
  18391. get size(): number;
  18392. set size(value: number);
  18393. /**
  18394. * Creates a new Sprite
  18395. * @param name defines the name
  18396. * @param manager defines the manager
  18397. */
  18398. constructor(
  18399. /** defines the name */
  18400. name: string, manager: ISpriteManager);
  18401. /**
  18402. * Starts an animation
  18403. * @param from defines the initial key
  18404. * @param to defines the end key
  18405. * @param loop defines if the animation must loop
  18406. * @param delay defines the start delay (in ms)
  18407. * @param onAnimationEnd defines a callback to call when animation ends
  18408. */
  18409. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18410. /** Stops current animation (if any) */
  18411. stopAnimation(): void;
  18412. /** @hidden */
  18413. _animate(deltaTime: number): void;
  18414. /** Release associated resources */
  18415. dispose(): void;
  18416. }
  18417. }
  18418. declare module "babylonjs/Collisions/pickingInfo" {
  18419. import { Nullable } from "babylonjs/types";
  18420. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18422. import { Sprite } from "babylonjs/Sprites/sprite";
  18423. import { Ray } from "babylonjs/Culling/ray";
  18424. /**
  18425. * Information about the result of picking within a scene
  18426. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18427. */
  18428. export class PickingInfo {
  18429. /** @hidden */
  18430. _pickingUnavailable: boolean;
  18431. /**
  18432. * If the pick collided with an object
  18433. */
  18434. hit: boolean;
  18435. /**
  18436. * Distance away where the pick collided
  18437. */
  18438. distance: number;
  18439. /**
  18440. * The location of pick collision
  18441. */
  18442. pickedPoint: Nullable<Vector3>;
  18443. /**
  18444. * The mesh corresponding the the pick collision
  18445. */
  18446. pickedMesh: Nullable<AbstractMesh>;
  18447. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18448. bu: number;
  18449. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18450. bv: number;
  18451. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18452. faceId: number;
  18453. /** Id of the the submesh that was picked */
  18454. subMeshId: number;
  18455. /** If a sprite was picked, this will be the sprite the pick collided with */
  18456. pickedSprite: Nullable<Sprite>;
  18457. /**
  18458. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18459. */
  18460. originMesh: Nullable<AbstractMesh>;
  18461. /**
  18462. * The ray that was used to perform the picking.
  18463. */
  18464. ray: Nullable<Ray>;
  18465. /**
  18466. * Gets the normal correspodning to the face the pick collided with
  18467. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18468. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18469. * @returns The normal correspodning to the face the pick collided with
  18470. */
  18471. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18472. /**
  18473. * Gets the texture coordinates of where the pick occured
  18474. * @returns the vector containing the coordnates of the texture
  18475. */
  18476. getTextureCoordinates(): Nullable<Vector2>;
  18477. }
  18478. }
  18479. declare module "babylonjs/Events/pointerEvents" {
  18480. import { Nullable } from "babylonjs/types";
  18481. import { Vector2 } from "babylonjs/Maths/math.vector";
  18482. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18483. import { Ray } from "babylonjs/Culling/ray";
  18484. /**
  18485. * Gather the list of pointer event types as constants.
  18486. */
  18487. export class PointerEventTypes {
  18488. /**
  18489. * 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.
  18490. */
  18491. static readonly POINTERDOWN: number;
  18492. /**
  18493. * The pointerup event is fired when a pointer is no longer active.
  18494. */
  18495. static readonly POINTERUP: number;
  18496. /**
  18497. * The pointermove event is fired when a pointer changes coordinates.
  18498. */
  18499. static readonly POINTERMOVE: number;
  18500. /**
  18501. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18502. */
  18503. static readonly POINTERWHEEL: number;
  18504. /**
  18505. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18506. */
  18507. static readonly POINTERPICK: number;
  18508. /**
  18509. * The pointertap event is fired when a the object has been touched and released without drag.
  18510. */
  18511. static readonly POINTERTAP: number;
  18512. /**
  18513. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18514. */
  18515. static readonly POINTERDOUBLETAP: number;
  18516. }
  18517. /**
  18518. * Base class of pointer info types.
  18519. */
  18520. export class PointerInfoBase {
  18521. /**
  18522. * Defines the type of event (PointerEventTypes)
  18523. */
  18524. type: number;
  18525. /**
  18526. * Defines the related dom event
  18527. */
  18528. event: PointerEvent | MouseWheelEvent;
  18529. /**
  18530. * Instantiates the base class of pointers info.
  18531. * @param type Defines the type of event (PointerEventTypes)
  18532. * @param event Defines the related dom event
  18533. */
  18534. constructor(
  18535. /**
  18536. * Defines the type of event (PointerEventTypes)
  18537. */
  18538. type: number,
  18539. /**
  18540. * Defines the related dom event
  18541. */
  18542. event: PointerEvent | MouseWheelEvent);
  18543. }
  18544. /**
  18545. * This class is used to store pointer related info for the onPrePointerObservable event.
  18546. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18547. */
  18548. export class PointerInfoPre extends PointerInfoBase {
  18549. /**
  18550. * Ray from a pointer if availible (eg. 6dof controller)
  18551. */
  18552. ray: Nullable<Ray>;
  18553. /**
  18554. * Defines the local position of the pointer on the canvas.
  18555. */
  18556. localPosition: Vector2;
  18557. /**
  18558. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18559. */
  18560. skipOnPointerObservable: boolean;
  18561. /**
  18562. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18563. * @param type Defines the type of event (PointerEventTypes)
  18564. * @param event Defines the related dom event
  18565. * @param localX Defines the local x coordinates of the pointer when the event occured
  18566. * @param localY Defines the local y coordinates of the pointer when the event occured
  18567. */
  18568. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18569. }
  18570. /**
  18571. * This type contains all the data related to a pointer event in Babylon.js.
  18572. * 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.
  18573. */
  18574. export class PointerInfo extends PointerInfoBase {
  18575. /**
  18576. * Defines the picking info associated to the info (if any)\
  18577. */
  18578. pickInfo: Nullable<PickingInfo>;
  18579. /**
  18580. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18581. * @param type Defines the type of event (PointerEventTypes)
  18582. * @param event Defines the related dom event
  18583. * @param pickInfo Defines the picking info associated to the info (if any)\
  18584. */
  18585. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18586. /**
  18587. * Defines the picking info associated to the info (if any)\
  18588. */
  18589. pickInfo: Nullable<PickingInfo>);
  18590. }
  18591. /**
  18592. * Data relating to a touch event on the screen.
  18593. */
  18594. export interface PointerTouch {
  18595. /**
  18596. * X coordinate of touch.
  18597. */
  18598. x: number;
  18599. /**
  18600. * Y coordinate of touch.
  18601. */
  18602. y: number;
  18603. /**
  18604. * Id of touch. Unique for each finger.
  18605. */
  18606. pointerId: number;
  18607. /**
  18608. * Event type passed from DOM.
  18609. */
  18610. type: any;
  18611. }
  18612. }
  18613. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18614. import { Observable } from "babylonjs/Misc/observable";
  18615. import { Nullable } from "babylonjs/types";
  18616. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18617. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18618. /**
  18619. * Manage the mouse inputs to control the movement of a free camera.
  18620. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18621. */
  18622. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18623. /**
  18624. * Define if touch is enabled in the mouse input
  18625. */
  18626. touchEnabled: boolean;
  18627. /**
  18628. * Defines the camera the input is attached to.
  18629. */
  18630. camera: FreeCamera;
  18631. /**
  18632. * Defines the buttons associated with the input to handle camera move.
  18633. */
  18634. buttons: number[];
  18635. /**
  18636. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18637. */
  18638. angularSensibility: number;
  18639. private _pointerInput;
  18640. private _onMouseMove;
  18641. private _observer;
  18642. private previousPosition;
  18643. /**
  18644. * Observable for when a pointer move event occurs containing the move offset
  18645. */
  18646. onPointerMovedObservable: Observable<{
  18647. offsetX: number;
  18648. offsetY: number;
  18649. }>;
  18650. /**
  18651. * @hidden
  18652. * If the camera should be rotated automatically based on pointer movement
  18653. */
  18654. _allowCameraRotation: boolean;
  18655. /**
  18656. * Manage the mouse inputs to control the movement of a free camera.
  18657. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18658. * @param touchEnabled Defines if touch is enabled or not
  18659. */
  18660. constructor(
  18661. /**
  18662. * Define if touch is enabled in the mouse input
  18663. */
  18664. touchEnabled?: boolean);
  18665. /**
  18666. * Attach the input controls to a specific dom element to get the input from.
  18667. * @param element Defines the element the controls should be listened from
  18668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18669. */
  18670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18671. /**
  18672. * Called on JS contextmenu event.
  18673. * Override this method to provide functionality.
  18674. */
  18675. protected onContextMenu(evt: PointerEvent): void;
  18676. /**
  18677. * Detach the current controls from the specified dom element.
  18678. * @param element Defines the element to stop listening the inputs from
  18679. */
  18680. detachControl(element: Nullable<HTMLElement>): void;
  18681. /**
  18682. * Gets the class name of the current intput.
  18683. * @returns the class name
  18684. */
  18685. getClassName(): string;
  18686. /**
  18687. * Get the friendly name associated with the input class.
  18688. * @returns the input friendly name
  18689. */
  18690. getSimpleName(): string;
  18691. }
  18692. }
  18693. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  18694. import { Nullable } from "babylonjs/types";
  18695. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18696. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18697. /**
  18698. * Manage the touch inputs to control the movement of a free camera.
  18699. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18700. */
  18701. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18702. /**
  18703. * Defines the camera the input is attached to.
  18704. */
  18705. camera: FreeCamera;
  18706. /**
  18707. * Defines the touch sensibility for rotation.
  18708. * The higher the faster.
  18709. */
  18710. touchAngularSensibility: number;
  18711. /**
  18712. * Defines the touch sensibility for move.
  18713. * The higher the faster.
  18714. */
  18715. touchMoveSensibility: number;
  18716. private _offsetX;
  18717. private _offsetY;
  18718. private _pointerPressed;
  18719. private _pointerInput;
  18720. private _observer;
  18721. private _onLostFocus;
  18722. /**
  18723. * Attach the input controls to a specific dom element to get the input from.
  18724. * @param element Defines the element the controls should be listened from
  18725. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18726. */
  18727. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18728. /**
  18729. * Detach the current controls from the specified dom element.
  18730. * @param element Defines the element to stop listening the inputs from
  18731. */
  18732. detachControl(element: Nullable<HTMLElement>): void;
  18733. /**
  18734. * Update the current camera state depending on the inputs that have been used this frame.
  18735. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18736. */
  18737. checkInputs(): void;
  18738. /**
  18739. * Gets the class name of the current intput.
  18740. * @returns the class name
  18741. */
  18742. getClassName(): string;
  18743. /**
  18744. * Get the friendly name associated with the input class.
  18745. * @returns the input friendly name
  18746. */
  18747. getSimpleName(): string;
  18748. }
  18749. }
  18750. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  18751. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18752. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  18753. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  18754. import { Nullable } from "babylonjs/types";
  18755. /**
  18756. * Default Inputs manager for the FreeCamera.
  18757. * It groups all the default supported inputs for ease of use.
  18758. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18759. */
  18760. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18761. /**
  18762. * @hidden
  18763. */
  18764. _mouseInput: Nullable<FreeCameraMouseInput>;
  18765. /**
  18766. * Instantiates a new FreeCameraInputsManager.
  18767. * @param camera Defines the camera the inputs belong to
  18768. */
  18769. constructor(camera: FreeCamera);
  18770. /**
  18771. * Add keyboard input support to the input manager.
  18772. * @returns the current input manager
  18773. */
  18774. addKeyboard(): FreeCameraInputsManager;
  18775. /**
  18776. * Add mouse input support to the input manager.
  18777. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18778. * @returns the current input manager
  18779. */
  18780. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18781. /**
  18782. * Removes the mouse input support from the manager
  18783. * @returns the current input manager
  18784. */
  18785. removeMouse(): FreeCameraInputsManager;
  18786. /**
  18787. * Add touch input support to the input manager.
  18788. * @returns the current input manager
  18789. */
  18790. addTouch(): FreeCameraInputsManager;
  18791. /**
  18792. * Remove all attached input methods from a camera
  18793. */
  18794. clear(): void;
  18795. }
  18796. }
  18797. declare module "babylonjs/Cameras/freeCamera" {
  18798. import { Vector3 } from "babylonjs/Maths/math.vector";
  18799. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18800. import { Scene } from "babylonjs/scene";
  18801. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  18802. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  18803. /**
  18804. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18805. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18806. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18807. */
  18808. export class FreeCamera extends TargetCamera {
  18809. /**
  18810. * Define the collision ellipsoid of the camera.
  18811. * This is helpful to simulate a camera body like the player body around the camera
  18812. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18813. */
  18814. ellipsoid: Vector3;
  18815. /**
  18816. * Define an offset for the position of the ellipsoid around the camera.
  18817. * This can be helpful to determine the center of the body near the gravity center of the body
  18818. * instead of its head.
  18819. */
  18820. ellipsoidOffset: Vector3;
  18821. /**
  18822. * Enable or disable collisions of the camera with the rest of the scene objects.
  18823. */
  18824. checkCollisions: boolean;
  18825. /**
  18826. * Enable or disable gravity on the camera.
  18827. */
  18828. applyGravity: boolean;
  18829. /**
  18830. * Define the input manager associated to the camera.
  18831. */
  18832. inputs: FreeCameraInputsManager;
  18833. /**
  18834. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18835. * Higher values reduce sensitivity.
  18836. */
  18837. get angularSensibility(): number;
  18838. /**
  18839. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18840. * Higher values reduce sensitivity.
  18841. */
  18842. set angularSensibility(value: number);
  18843. /**
  18844. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18845. */
  18846. get keysUp(): number[];
  18847. set keysUp(value: number[]);
  18848. /**
  18849. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18850. */
  18851. get keysDown(): number[];
  18852. set keysDown(value: number[]);
  18853. /**
  18854. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18855. */
  18856. get keysLeft(): number[];
  18857. set keysLeft(value: number[]);
  18858. /**
  18859. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18860. */
  18861. get keysRight(): number[];
  18862. set keysRight(value: number[]);
  18863. /**
  18864. * Event raised when the camera collide with a mesh in the scene.
  18865. */
  18866. onCollide: (collidedMesh: AbstractMesh) => void;
  18867. private _collider;
  18868. private _needMoveForGravity;
  18869. private _oldPosition;
  18870. private _diffPosition;
  18871. private _newPosition;
  18872. /** @hidden */
  18873. _localDirection: Vector3;
  18874. /** @hidden */
  18875. _transformedDirection: Vector3;
  18876. /**
  18877. * Instantiates a Free Camera.
  18878. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18879. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18880. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18881. * @param name Define the name of the camera in the scene
  18882. * @param position Define the start position of the camera in the scene
  18883. * @param scene Define the scene the camera belongs to
  18884. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18885. */
  18886. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18887. /**
  18888. * Attached controls to the current camera.
  18889. * @param element Defines the element the controls should be listened from
  18890. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18891. */
  18892. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18893. /**
  18894. * Detach the current controls from the camera.
  18895. * The camera will stop reacting to inputs.
  18896. * @param element Defines the element to stop listening the inputs from
  18897. */
  18898. detachControl(element: HTMLElement): void;
  18899. private _collisionMask;
  18900. /**
  18901. * Define a collision mask to limit the list of object the camera can collide with
  18902. */
  18903. get collisionMask(): number;
  18904. set collisionMask(mask: number);
  18905. /** @hidden */
  18906. _collideWithWorld(displacement: Vector3): void;
  18907. private _onCollisionPositionChange;
  18908. /** @hidden */
  18909. _checkInputs(): void;
  18910. /** @hidden */
  18911. _decideIfNeedsToMove(): boolean;
  18912. /** @hidden */
  18913. _updatePosition(): void;
  18914. /**
  18915. * Destroy the camera and release the current resources hold by it.
  18916. */
  18917. dispose(): void;
  18918. /**
  18919. * Gets the current object class name.
  18920. * @return the class name
  18921. */
  18922. getClassName(): string;
  18923. }
  18924. }
  18925. declare module "babylonjs/Gamepads/gamepad" {
  18926. import { Observable } from "babylonjs/Misc/observable";
  18927. /**
  18928. * Represents a gamepad control stick position
  18929. */
  18930. export class StickValues {
  18931. /**
  18932. * The x component of the control stick
  18933. */
  18934. x: number;
  18935. /**
  18936. * The y component of the control stick
  18937. */
  18938. y: number;
  18939. /**
  18940. * Initializes the gamepad x and y control stick values
  18941. * @param x The x component of the gamepad control stick value
  18942. * @param y The y component of the gamepad control stick value
  18943. */
  18944. constructor(
  18945. /**
  18946. * The x component of the control stick
  18947. */
  18948. x: number,
  18949. /**
  18950. * The y component of the control stick
  18951. */
  18952. y: number);
  18953. }
  18954. /**
  18955. * An interface which manages callbacks for gamepad button changes
  18956. */
  18957. export interface GamepadButtonChanges {
  18958. /**
  18959. * Called when a gamepad has been changed
  18960. */
  18961. changed: boolean;
  18962. /**
  18963. * Called when a gamepad press event has been triggered
  18964. */
  18965. pressChanged: boolean;
  18966. /**
  18967. * Called when a touch event has been triggered
  18968. */
  18969. touchChanged: boolean;
  18970. /**
  18971. * Called when a value has changed
  18972. */
  18973. valueChanged: boolean;
  18974. }
  18975. /**
  18976. * Represents a gamepad
  18977. */
  18978. export class Gamepad {
  18979. /**
  18980. * The id of the gamepad
  18981. */
  18982. id: string;
  18983. /**
  18984. * The index of the gamepad
  18985. */
  18986. index: number;
  18987. /**
  18988. * The browser gamepad
  18989. */
  18990. browserGamepad: any;
  18991. /**
  18992. * Specifies what type of gamepad this represents
  18993. */
  18994. type: number;
  18995. private _leftStick;
  18996. private _rightStick;
  18997. /** @hidden */
  18998. _isConnected: boolean;
  18999. private _leftStickAxisX;
  19000. private _leftStickAxisY;
  19001. private _rightStickAxisX;
  19002. private _rightStickAxisY;
  19003. /**
  19004. * Triggered when the left control stick has been changed
  19005. */
  19006. private _onleftstickchanged;
  19007. /**
  19008. * Triggered when the right control stick has been changed
  19009. */
  19010. private _onrightstickchanged;
  19011. /**
  19012. * Represents a gamepad controller
  19013. */
  19014. static GAMEPAD: number;
  19015. /**
  19016. * Represents a generic controller
  19017. */
  19018. static GENERIC: number;
  19019. /**
  19020. * Represents an XBox controller
  19021. */
  19022. static XBOX: number;
  19023. /**
  19024. * Represents a pose-enabled controller
  19025. */
  19026. static POSE_ENABLED: number;
  19027. /**
  19028. * Represents an Dual Shock controller
  19029. */
  19030. static DUALSHOCK: number;
  19031. /**
  19032. * Specifies whether the left control stick should be Y-inverted
  19033. */
  19034. protected _invertLeftStickY: boolean;
  19035. /**
  19036. * Specifies if the gamepad has been connected
  19037. */
  19038. get isConnected(): boolean;
  19039. /**
  19040. * Initializes the gamepad
  19041. * @param id The id of the gamepad
  19042. * @param index The index of the gamepad
  19043. * @param browserGamepad The browser gamepad
  19044. * @param leftStickX The x component of the left joystick
  19045. * @param leftStickY The y component of the left joystick
  19046. * @param rightStickX The x component of the right joystick
  19047. * @param rightStickY The y component of the right joystick
  19048. */
  19049. constructor(
  19050. /**
  19051. * The id of the gamepad
  19052. */
  19053. id: string,
  19054. /**
  19055. * The index of the gamepad
  19056. */
  19057. index: number,
  19058. /**
  19059. * The browser gamepad
  19060. */
  19061. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19062. /**
  19063. * Callback triggered when the left joystick has changed
  19064. * @param callback
  19065. */
  19066. onleftstickchanged(callback: (values: StickValues) => void): void;
  19067. /**
  19068. * Callback triggered when the right joystick has changed
  19069. * @param callback
  19070. */
  19071. onrightstickchanged(callback: (values: StickValues) => void): void;
  19072. /**
  19073. * Gets the left joystick
  19074. */
  19075. get leftStick(): StickValues;
  19076. /**
  19077. * Sets the left joystick values
  19078. */
  19079. set leftStick(newValues: StickValues);
  19080. /**
  19081. * Gets the right joystick
  19082. */
  19083. get rightStick(): StickValues;
  19084. /**
  19085. * Sets the right joystick value
  19086. */
  19087. set rightStick(newValues: StickValues);
  19088. /**
  19089. * Updates the gamepad joystick positions
  19090. */
  19091. update(): void;
  19092. /**
  19093. * Disposes the gamepad
  19094. */
  19095. dispose(): void;
  19096. }
  19097. /**
  19098. * Represents a generic gamepad
  19099. */
  19100. export class GenericPad extends Gamepad {
  19101. private _buttons;
  19102. private _onbuttondown;
  19103. private _onbuttonup;
  19104. /**
  19105. * Observable triggered when a button has been pressed
  19106. */
  19107. onButtonDownObservable: Observable<number>;
  19108. /**
  19109. * Observable triggered when a button has been released
  19110. */
  19111. onButtonUpObservable: Observable<number>;
  19112. /**
  19113. * Callback triggered when a button has been pressed
  19114. * @param callback Called when a button has been pressed
  19115. */
  19116. onbuttondown(callback: (buttonPressed: number) => void): void;
  19117. /**
  19118. * Callback triggered when a button has been released
  19119. * @param callback Called when a button has been released
  19120. */
  19121. onbuttonup(callback: (buttonReleased: number) => void): void;
  19122. /**
  19123. * Initializes the generic gamepad
  19124. * @param id The id of the generic gamepad
  19125. * @param index The index of the generic gamepad
  19126. * @param browserGamepad The browser gamepad
  19127. */
  19128. constructor(id: string, index: number, browserGamepad: any);
  19129. private _setButtonValue;
  19130. /**
  19131. * Updates the generic gamepad
  19132. */
  19133. update(): void;
  19134. /**
  19135. * Disposes the generic gamepad
  19136. */
  19137. dispose(): void;
  19138. }
  19139. }
  19140. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19141. import { Observable } from "babylonjs/Misc/observable";
  19142. import { Nullable } from "babylonjs/types";
  19143. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19144. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19146. import { Ray } from "babylonjs/Culling/ray";
  19147. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19148. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19149. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19150. /**
  19151. * Defines the types of pose enabled controllers that are supported
  19152. */
  19153. export enum PoseEnabledControllerType {
  19154. /**
  19155. * HTC Vive
  19156. */
  19157. VIVE = 0,
  19158. /**
  19159. * Oculus Rift
  19160. */
  19161. OCULUS = 1,
  19162. /**
  19163. * Windows mixed reality
  19164. */
  19165. WINDOWS = 2,
  19166. /**
  19167. * Samsung gear VR
  19168. */
  19169. GEAR_VR = 3,
  19170. /**
  19171. * Google Daydream
  19172. */
  19173. DAYDREAM = 4,
  19174. /**
  19175. * Generic
  19176. */
  19177. GENERIC = 5
  19178. }
  19179. /**
  19180. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19181. */
  19182. export interface MutableGamepadButton {
  19183. /**
  19184. * Value of the button/trigger
  19185. */
  19186. value: number;
  19187. /**
  19188. * If the button/trigger is currently touched
  19189. */
  19190. touched: boolean;
  19191. /**
  19192. * If the button/trigger is currently pressed
  19193. */
  19194. pressed: boolean;
  19195. }
  19196. /**
  19197. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19198. * @hidden
  19199. */
  19200. export interface ExtendedGamepadButton extends GamepadButton {
  19201. /**
  19202. * If the button/trigger is currently pressed
  19203. */
  19204. readonly pressed: boolean;
  19205. /**
  19206. * If the button/trigger is currently touched
  19207. */
  19208. readonly touched: boolean;
  19209. /**
  19210. * Value of the button/trigger
  19211. */
  19212. readonly value: number;
  19213. }
  19214. /** @hidden */
  19215. export interface _GamePadFactory {
  19216. /**
  19217. * Returns whether or not the current gamepad can be created for this type of controller.
  19218. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19219. * @returns true if it can be created, otherwise false
  19220. */
  19221. canCreate(gamepadInfo: any): boolean;
  19222. /**
  19223. * Creates a new instance of the Gamepad.
  19224. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19225. * @returns the new gamepad instance
  19226. */
  19227. create(gamepadInfo: any): Gamepad;
  19228. }
  19229. /**
  19230. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19231. */
  19232. export class PoseEnabledControllerHelper {
  19233. /** @hidden */
  19234. static _ControllerFactories: _GamePadFactory[];
  19235. /** @hidden */
  19236. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19237. /**
  19238. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19239. * @param vrGamepad the gamepad to initialized
  19240. * @returns a vr controller of the type the gamepad identified as
  19241. */
  19242. static InitiateController(vrGamepad: any): Gamepad;
  19243. }
  19244. /**
  19245. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19246. */
  19247. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19248. /**
  19249. * If the controller is used in a webXR session
  19250. */
  19251. isXR: boolean;
  19252. private _deviceRoomPosition;
  19253. private _deviceRoomRotationQuaternion;
  19254. /**
  19255. * The device position in babylon space
  19256. */
  19257. devicePosition: Vector3;
  19258. /**
  19259. * The device rotation in babylon space
  19260. */
  19261. deviceRotationQuaternion: Quaternion;
  19262. /**
  19263. * The scale factor of the device in babylon space
  19264. */
  19265. deviceScaleFactor: number;
  19266. /**
  19267. * (Likely devicePosition should be used instead) The device position in its room space
  19268. */
  19269. position: Vector3;
  19270. /**
  19271. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19272. */
  19273. rotationQuaternion: Quaternion;
  19274. /**
  19275. * The type of controller (Eg. Windows mixed reality)
  19276. */
  19277. controllerType: PoseEnabledControllerType;
  19278. protected _calculatedPosition: Vector3;
  19279. private _calculatedRotation;
  19280. /**
  19281. * The raw pose from the device
  19282. */
  19283. rawPose: DevicePose;
  19284. private _trackPosition;
  19285. private _maxRotationDistFromHeadset;
  19286. private _draggedRoomRotation;
  19287. /**
  19288. * @hidden
  19289. */
  19290. _disableTrackPosition(fixedPosition: Vector3): void;
  19291. /**
  19292. * Internal, the mesh attached to the controller
  19293. * @hidden
  19294. */
  19295. _mesh: Nullable<AbstractMesh>;
  19296. private _poseControlledCamera;
  19297. private _leftHandSystemQuaternion;
  19298. /**
  19299. * Internal, matrix used to convert room space to babylon space
  19300. * @hidden
  19301. */
  19302. _deviceToWorld: Matrix;
  19303. /**
  19304. * Node to be used when casting a ray from the controller
  19305. * @hidden
  19306. */
  19307. _pointingPoseNode: Nullable<TransformNode>;
  19308. /**
  19309. * Name of the child mesh that can be used to cast a ray from the controller
  19310. */
  19311. static readonly POINTING_POSE: string;
  19312. /**
  19313. * Creates a new PoseEnabledController from a gamepad
  19314. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19315. */
  19316. constructor(browserGamepad: any);
  19317. private _workingMatrix;
  19318. /**
  19319. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19320. */
  19321. update(): void;
  19322. /**
  19323. * Updates only the pose device and mesh without doing any button event checking
  19324. */
  19325. protected _updatePoseAndMesh(): void;
  19326. /**
  19327. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19328. * @param poseData raw pose fromthe device
  19329. */
  19330. updateFromDevice(poseData: DevicePose): void;
  19331. /**
  19332. * @hidden
  19333. */
  19334. _meshAttachedObservable: Observable<AbstractMesh>;
  19335. /**
  19336. * Attaches a mesh to the controller
  19337. * @param mesh the mesh to be attached
  19338. */
  19339. attachToMesh(mesh: AbstractMesh): void;
  19340. /**
  19341. * Attaches the controllers mesh to a camera
  19342. * @param camera the camera the mesh should be attached to
  19343. */
  19344. attachToPoseControlledCamera(camera: TargetCamera): void;
  19345. /**
  19346. * Disposes of the controller
  19347. */
  19348. dispose(): void;
  19349. /**
  19350. * The mesh that is attached to the controller
  19351. */
  19352. get mesh(): Nullable<AbstractMesh>;
  19353. /**
  19354. * Gets the ray of the controller in the direction the controller is pointing
  19355. * @param length the length the resulting ray should be
  19356. * @returns a ray in the direction the controller is pointing
  19357. */
  19358. getForwardRay(length?: number): Ray;
  19359. }
  19360. }
  19361. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19362. import { Observable } from "babylonjs/Misc/observable";
  19363. import { Scene } from "babylonjs/scene";
  19364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19365. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19366. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19367. import { Nullable } from "babylonjs/types";
  19368. /**
  19369. * Defines the WebVRController object that represents controllers tracked in 3D space
  19370. */
  19371. export abstract class WebVRController extends PoseEnabledController {
  19372. /**
  19373. * Internal, the default controller model for the controller
  19374. */
  19375. protected _defaultModel: Nullable<AbstractMesh>;
  19376. /**
  19377. * Fired when the trigger state has changed
  19378. */
  19379. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19380. /**
  19381. * Fired when the main button state has changed
  19382. */
  19383. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19384. /**
  19385. * Fired when the secondary button state has changed
  19386. */
  19387. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19388. /**
  19389. * Fired when the pad state has changed
  19390. */
  19391. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19392. /**
  19393. * Fired when controllers stick values have changed
  19394. */
  19395. onPadValuesChangedObservable: Observable<StickValues>;
  19396. /**
  19397. * Array of button availible on the controller
  19398. */
  19399. protected _buttons: Array<MutableGamepadButton>;
  19400. private _onButtonStateChange;
  19401. /**
  19402. * Fired when a controller button's state has changed
  19403. * @param callback the callback containing the button that was modified
  19404. */
  19405. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19406. /**
  19407. * X and Y axis corresponding to the controllers joystick
  19408. */
  19409. pad: StickValues;
  19410. /**
  19411. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19412. */
  19413. hand: string;
  19414. /**
  19415. * The default controller model for the controller
  19416. */
  19417. get defaultModel(): Nullable<AbstractMesh>;
  19418. /**
  19419. * Creates a new WebVRController from a gamepad
  19420. * @param vrGamepad the gamepad that the WebVRController should be created from
  19421. */
  19422. constructor(vrGamepad: any);
  19423. /**
  19424. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19425. */
  19426. update(): void;
  19427. /**
  19428. * Function to be called when a button is modified
  19429. */
  19430. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19431. /**
  19432. * Loads a mesh and attaches it to the controller
  19433. * @param scene the scene the mesh should be added to
  19434. * @param meshLoaded callback for when the mesh has been loaded
  19435. */
  19436. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19437. private _setButtonValue;
  19438. private _changes;
  19439. private _checkChanges;
  19440. /**
  19441. * Disposes of th webVRCOntroller
  19442. */
  19443. dispose(): void;
  19444. }
  19445. }
  19446. declare module "babylonjs/Lights/hemisphericLight" {
  19447. import { Nullable } from "babylonjs/types";
  19448. import { Scene } from "babylonjs/scene";
  19449. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19450. import { Color3 } from "babylonjs/Maths/math.color";
  19451. import { Effect } from "babylonjs/Materials/effect";
  19452. import { Light } from "babylonjs/Lights/light";
  19453. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19454. /**
  19455. * The HemisphericLight simulates the ambient environment light,
  19456. * so the passed direction is the light reflection direction, not the incoming direction.
  19457. */
  19458. export class HemisphericLight extends Light {
  19459. /**
  19460. * The groundColor is the light in the opposite direction to the one specified during creation.
  19461. * 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.
  19462. */
  19463. groundColor: Color3;
  19464. /**
  19465. * The light reflection direction, not the incoming direction.
  19466. */
  19467. direction: Vector3;
  19468. /**
  19469. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19470. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19471. * The HemisphericLight can't cast shadows.
  19472. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19473. * @param name The friendly name of the light
  19474. * @param direction The direction of the light reflection
  19475. * @param scene The scene the light belongs to
  19476. */
  19477. constructor(name: string, direction: Vector3, scene: Scene);
  19478. protected _buildUniformLayout(): void;
  19479. /**
  19480. * Returns the string "HemisphericLight".
  19481. * @return The class name
  19482. */
  19483. getClassName(): string;
  19484. /**
  19485. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19486. * Returns the updated direction.
  19487. * @param target The target the direction should point to
  19488. * @return The computed direction
  19489. */
  19490. setDirectionToTarget(target: Vector3): Vector3;
  19491. /**
  19492. * Returns the shadow generator associated to the light.
  19493. * @returns Always null for hemispheric lights because it does not support shadows.
  19494. */
  19495. getShadowGenerator(): Nullable<IShadowGenerator>;
  19496. /**
  19497. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19498. * @param effect The effect to update
  19499. * @param lightIndex The index of the light in the effect to update
  19500. * @returns The hemispheric light
  19501. */
  19502. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19503. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19504. /**
  19505. * Computes the world matrix of the node
  19506. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19507. * @param useWasUpdatedFlag defines a reserved property
  19508. * @returns the world matrix
  19509. */
  19510. computeWorldMatrix(): Matrix;
  19511. /**
  19512. * Returns the integer 3.
  19513. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19514. */
  19515. getTypeID(): number;
  19516. /**
  19517. * Prepares the list of defines specific to the light type.
  19518. * @param defines the list of defines
  19519. * @param lightIndex defines the index of the light for the effect
  19520. */
  19521. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19522. }
  19523. }
  19524. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19525. /** @hidden */
  19526. export var vrMultiviewToSingleviewPixelShader: {
  19527. name: string;
  19528. shader: string;
  19529. };
  19530. }
  19531. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19532. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19533. import { Scene } from "babylonjs/scene";
  19534. /**
  19535. * Renders to multiple views with a single draw call
  19536. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19537. */
  19538. export class MultiviewRenderTarget extends RenderTargetTexture {
  19539. /**
  19540. * Creates a multiview render target
  19541. * @param scene scene used with the render target
  19542. * @param size the size of the render target (used for each view)
  19543. */
  19544. constructor(scene: Scene, size?: number | {
  19545. width: number;
  19546. height: number;
  19547. } | {
  19548. ratio: number;
  19549. });
  19550. /**
  19551. * @hidden
  19552. * @param faceIndex the face index, if its a cube texture
  19553. */
  19554. _bindFrameBuffer(faceIndex?: number): void;
  19555. /**
  19556. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19557. * @returns the view count
  19558. */
  19559. getViewCount(): number;
  19560. }
  19561. }
  19562. declare module "babylonjs/Maths/math.frustum" {
  19563. import { Matrix } from "babylonjs/Maths/math.vector";
  19564. import { DeepImmutable } from "babylonjs/types";
  19565. import { Plane } from "babylonjs/Maths/math.plane";
  19566. /**
  19567. * Represents a camera frustum
  19568. */
  19569. export class Frustum {
  19570. /**
  19571. * Gets the planes representing the frustum
  19572. * @param transform matrix to be applied to the returned planes
  19573. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19574. */
  19575. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19576. /**
  19577. * Gets the near frustum plane transformed by the transform matrix
  19578. * @param transform transformation matrix to be applied to the resulting frustum plane
  19579. * @param frustumPlane the resuling frustum plane
  19580. */
  19581. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19582. /**
  19583. * Gets the far frustum plane transformed by the transform matrix
  19584. * @param transform transformation matrix to be applied to the resulting frustum plane
  19585. * @param frustumPlane the resuling frustum plane
  19586. */
  19587. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19588. /**
  19589. * Gets the left frustum plane transformed by the transform matrix
  19590. * @param transform transformation matrix to be applied to the resulting frustum plane
  19591. * @param frustumPlane the resuling frustum plane
  19592. */
  19593. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19594. /**
  19595. * Gets the right frustum plane transformed by the transform matrix
  19596. * @param transform transformation matrix to be applied to the resulting frustum plane
  19597. * @param frustumPlane the resuling frustum plane
  19598. */
  19599. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19600. /**
  19601. * Gets the top frustum plane transformed by the transform matrix
  19602. * @param transform transformation matrix to be applied to the resulting frustum plane
  19603. * @param frustumPlane the resuling frustum plane
  19604. */
  19605. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19606. /**
  19607. * Gets the bottom frustum plane transformed by the transform matrix
  19608. * @param transform transformation matrix to be applied to the resulting frustum plane
  19609. * @param frustumPlane the resuling frustum plane
  19610. */
  19611. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19612. /**
  19613. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19614. * @param transform transformation matrix to be applied to the resulting frustum planes
  19615. * @param frustumPlanes the resuling frustum planes
  19616. */
  19617. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19618. }
  19619. }
  19620. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19621. import { Camera } from "babylonjs/Cameras/camera";
  19622. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19623. import { Nullable } from "babylonjs/types";
  19624. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19625. import { Matrix } from "babylonjs/Maths/math.vector";
  19626. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19627. module "babylonjs/Engines/engine" {
  19628. interface Engine {
  19629. /**
  19630. * Creates a new multiview render target
  19631. * @param width defines the width of the texture
  19632. * @param height defines the height of the texture
  19633. * @returns the created multiview texture
  19634. */
  19635. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19636. /**
  19637. * Binds a multiview framebuffer to be drawn to
  19638. * @param multiviewTexture texture to bind
  19639. */
  19640. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19641. }
  19642. }
  19643. module "babylonjs/Cameras/camera" {
  19644. interface Camera {
  19645. /**
  19646. * @hidden
  19647. * 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)
  19648. */
  19649. _useMultiviewToSingleView: boolean;
  19650. /**
  19651. * @hidden
  19652. * 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)
  19653. */
  19654. _multiviewTexture: Nullable<RenderTargetTexture>;
  19655. /**
  19656. * @hidden
  19657. * ensures the multiview texture of the camera exists and has the specified width/height
  19658. * @param width height to set on the multiview texture
  19659. * @param height width to set on the multiview texture
  19660. */
  19661. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19662. }
  19663. }
  19664. module "babylonjs/scene" {
  19665. interface Scene {
  19666. /** @hidden */
  19667. _transformMatrixR: Matrix;
  19668. /** @hidden */
  19669. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19670. /** @hidden */
  19671. _createMultiviewUbo(): void;
  19672. /** @hidden */
  19673. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19674. /** @hidden */
  19675. _renderMultiviewToSingleView(camera: Camera): void;
  19676. }
  19677. }
  19678. }
  19679. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19680. import { Camera } from "babylonjs/Cameras/camera";
  19681. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19682. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19683. import "babylonjs/Engines/Extensions/engine.multiview";
  19684. /**
  19685. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19686. * This will not be used for webXR as it supports displaying texture arrays directly
  19687. */
  19688. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19689. /**
  19690. * Initializes a VRMultiviewToSingleview
  19691. * @param name name of the post process
  19692. * @param camera camera to be applied to
  19693. * @param scaleFactor scaling factor to the size of the output texture
  19694. */
  19695. constructor(name: string, camera: Camera, scaleFactor: number);
  19696. }
  19697. }
  19698. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19699. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19700. import { Nullable } from "babylonjs/types";
  19701. import { Size } from "babylonjs/Maths/math.size";
  19702. import { Observable } from "babylonjs/Misc/observable";
  19703. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  19704. /**
  19705. * Interface used to define additional presentation attributes
  19706. */
  19707. export interface IVRPresentationAttributes {
  19708. /**
  19709. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19710. */
  19711. highRefreshRate: boolean;
  19712. /**
  19713. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19714. */
  19715. foveationLevel: number;
  19716. }
  19717. module "babylonjs/Engines/engine" {
  19718. interface Engine {
  19719. /** @hidden */
  19720. _vrDisplay: any;
  19721. /** @hidden */
  19722. _vrSupported: boolean;
  19723. /** @hidden */
  19724. _oldSize: Size;
  19725. /** @hidden */
  19726. _oldHardwareScaleFactor: number;
  19727. /** @hidden */
  19728. _vrExclusivePointerMode: boolean;
  19729. /** @hidden */
  19730. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19731. /** @hidden */
  19732. _onVRDisplayPointerRestricted: () => void;
  19733. /** @hidden */
  19734. _onVRDisplayPointerUnrestricted: () => void;
  19735. /** @hidden */
  19736. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19737. /** @hidden */
  19738. _onVrDisplayDisconnect: Nullable<() => void>;
  19739. /** @hidden */
  19740. _onVrDisplayPresentChange: Nullable<() => void>;
  19741. /**
  19742. * Observable signaled when VR display mode changes
  19743. */
  19744. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19745. /**
  19746. * Observable signaled when VR request present is complete
  19747. */
  19748. onVRRequestPresentComplete: Observable<boolean>;
  19749. /**
  19750. * Observable signaled when VR request present starts
  19751. */
  19752. onVRRequestPresentStart: Observable<Engine>;
  19753. /**
  19754. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19755. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19756. */
  19757. isInVRExclusivePointerMode: boolean;
  19758. /**
  19759. * Gets a boolean indicating if a webVR device was detected
  19760. * @returns true if a webVR device was detected
  19761. */
  19762. isVRDevicePresent(): boolean;
  19763. /**
  19764. * Gets the current webVR device
  19765. * @returns the current webVR device (or null)
  19766. */
  19767. getVRDevice(): any;
  19768. /**
  19769. * Initializes a webVR display and starts listening to display change events
  19770. * The onVRDisplayChangedObservable will be notified upon these changes
  19771. * @returns A promise containing a VRDisplay and if vr is supported
  19772. */
  19773. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19774. /** @hidden */
  19775. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19776. /**
  19777. * Gets or sets the presentation attributes used to configure VR rendering
  19778. */
  19779. vrPresentationAttributes?: IVRPresentationAttributes;
  19780. /**
  19781. * Call this function to switch to webVR mode
  19782. * Will do nothing if webVR is not supported or if there is no webVR device
  19783. * @param options the webvr options provided to the camera. mainly used for multiview
  19784. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19785. */
  19786. enableVR(options: WebVROptions): void;
  19787. /** @hidden */
  19788. _onVRFullScreenTriggered(): void;
  19789. }
  19790. }
  19791. }
  19792. declare module "babylonjs/Cameras/VR/webVRCamera" {
  19793. import { Nullable } from "babylonjs/types";
  19794. import { Observable } from "babylonjs/Misc/observable";
  19795. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19796. import { Scene } from "babylonjs/scene";
  19797. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19798. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  19799. import { Node } from "babylonjs/node";
  19800. import { Ray } from "babylonjs/Culling/ray";
  19801. import "babylonjs/Cameras/RigModes/webVRRigMode";
  19802. import "babylonjs/Engines/Extensions/engine.webVR";
  19803. /**
  19804. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19805. * IMPORTANT!! The data is right-hand data.
  19806. * @export
  19807. * @interface DevicePose
  19808. */
  19809. export interface DevicePose {
  19810. /**
  19811. * The position of the device, values in array are [x,y,z].
  19812. */
  19813. readonly position: Nullable<Float32Array>;
  19814. /**
  19815. * The linearVelocity of the device, values in array are [x,y,z].
  19816. */
  19817. readonly linearVelocity: Nullable<Float32Array>;
  19818. /**
  19819. * The linearAcceleration of the device, values in array are [x,y,z].
  19820. */
  19821. readonly linearAcceleration: Nullable<Float32Array>;
  19822. /**
  19823. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19824. */
  19825. readonly orientation: Nullable<Float32Array>;
  19826. /**
  19827. * The angularVelocity of the device, values in array are [x,y,z].
  19828. */
  19829. readonly angularVelocity: Nullable<Float32Array>;
  19830. /**
  19831. * The angularAcceleration of the device, values in array are [x,y,z].
  19832. */
  19833. readonly angularAcceleration: Nullable<Float32Array>;
  19834. }
  19835. /**
  19836. * Interface representing a pose controlled object in Babylon.
  19837. * A pose controlled object has both regular pose values as well as pose values
  19838. * from an external device such as a VR head mounted display
  19839. */
  19840. export interface PoseControlled {
  19841. /**
  19842. * The position of the object in babylon space.
  19843. */
  19844. position: Vector3;
  19845. /**
  19846. * The rotation quaternion of the object in babylon space.
  19847. */
  19848. rotationQuaternion: Quaternion;
  19849. /**
  19850. * The position of the device in babylon space.
  19851. */
  19852. devicePosition?: Vector3;
  19853. /**
  19854. * The rotation quaternion of the device in babylon space.
  19855. */
  19856. deviceRotationQuaternion: Quaternion;
  19857. /**
  19858. * The raw pose coming from the device.
  19859. */
  19860. rawPose: Nullable<DevicePose>;
  19861. /**
  19862. * The scale of the device to be used when translating from device space to babylon space.
  19863. */
  19864. deviceScaleFactor: number;
  19865. /**
  19866. * Updates the poseControlled values based on the input device pose.
  19867. * @param poseData the pose data to update the object with
  19868. */
  19869. updateFromDevice(poseData: DevicePose): void;
  19870. }
  19871. /**
  19872. * Set of options to customize the webVRCamera
  19873. */
  19874. export interface WebVROptions {
  19875. /**
  19876. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19877. */
  19878. trackPosition?: boolean;
  19879. /**
  19880. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19881. */
  19882. positionScale?: number;
  19883. /**
  19884. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19885. */
  19886. displayName?: string;
  19887. /**
  19888. * Should the native controller meshes be initialized. (default: true)
  19889. */
  19890. controllerMeshes?: boolean;
  19891. /**
  19892. * Creating a default HemiLight only on controllers. (default: true)
  19893. */
  19894. defaultLightingOnControllers?: boolean;
  19895. /**
  19896. * If you don't want to use the default VR button of the helper. (default: false)
  19897. */
  19898. useCustomVRButton?: boolean;
  19899. /**
  19900. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19901. */
  19902. customVRButton?: HTMLButtonElement;
  19903. /**
  19904. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19905. */
  19906. rayLength?: number;
  19907. /**
  19908. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19909. */
  19910. defaultHeight?: number;
  19911. /**
  19912. * If multiview should be used if availible (default: false)
  19913. */
  19914. useMultiview?: boolean;
  19915. }
  19916. /**
  19917. * This represents a WebVR camera.
  19918. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19919. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19920. */
  19921. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19922. private webVROptions;
  19923. /**
  19924. * @hidden
  19925. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19926. */
  19927. _vrDevice: any;
  19928. /**
  19929. * The rawPose of the vrDevice.
  19930. */
  19931. rawPose: Nullable<DevicePose>;
  19932. private _onVREnabled;
  19933. private _specsVersion;
  19934. private _attached;
  19935. private _frameData;
  19936. protected _descendants: Array<Node>;
  19937. private _deviceRoomPosition;
  19938. /** @hidden */
  19939. _deviceRoomRotationQuaternion: Quaternion;
  19940. private _standingMatrix;
  19941. /**
  19942. * Represents device position in babylon space.
  19943. */
  19944. devicePosition: Vector3;
  19945. /**
  19946. * Represents device rotation in babylon space.
  19947. */
  19948. deviceRotationQuaternion: Quaternion;
  19949. /**
  19950. * The scale of the device to be used when translating from device space to babylon space.
  19951. */
  19952. deviceScaleFactor: number;
  19953. private _deviceToWorld;
  19954. private _worldToDevice;
  19955. /**
  19956. * References to the webVR controllers for the vrDevice.
  19957. */
  19958. controllers: Array<WebVRController>;
  19959. /**
  19960. * Emits an event when a controller is attached.
  19961. */
  19962. onControllersAttachedObservable: Observable<WebVRController[]>;
  19963. /**
  19964. * Emits an event when a controller's mesh has been loaded;
  19965. */
  19966. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19967. /**
  19968. * Emits an event when the HMD's pose has been updated.
  19969. */
  19970. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19971. private _poseSet;
  19972. /**
  19973. * If the rig cameras be used as parent instead of this camera.
  19974. */
  19975. rigParenting: boolean;
  19976. private _lightOnControllers;
  19977. private _defaultHeight?;
  19978. /**
  19979. * Instantiates a WebVRFreeCamera.
  19980. * @param name The name of the WebVRFreeCamera
  19981. * @param position The starting anchor position for the camera
  19982. * @param scene The scene the camera belongs to
  19983. * @param webVROptions a set of customizable options for the webVRCamera
  19984. */
  19985. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19986. /**
  19987. * Gets the device distance from the ground in meters.
  19988. * @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.
  19989. */
  19990. deviceDistanceToRoomGround(): number;
  19991. /**
  19992. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19993. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19994. */
  19995. useStandingMatrix(callback?: (bool: boolean) => void): void;
  19996. /**
  19997. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19998. * @returns A promise with a boolean set to if the standing matrix is supported.
  19999. */
  20000. useStandingMatrixAsync(): Promise<boolean>;
  20001. /**
  20002. * Disposes the camera
  20003. */
  20004. dispose(): void;
  20005. /**
  20006. * Gets a vrController by name.
  20007. * @param name The name of the controller to retreive
  20008. * @returns the controller matching the name specified or null if not found
  20009. */
  20010. getControllerByName(name: string): Nullable<WebVRController>;
  20011. private _leftController;
  20012. /**
  20013. * The controller corresponding to the users left hand.
  20014. */
  20015. get leftController(): Nullable<WebVRController>;
  20016. private _rightController;
  20017. /**
  20018. * The controller corresponding to the users right hand.
  20019. */
  20020. get rightController(): Nullable<WebVRController>;
  20021. /**
  20022. * Casts a ray forward from the vrCamera's gaze.
  20023. * @param length Length of the ray (default: 100)
  20024. * @returns the ray corresponding to the gaze
  20025. */
  20026. getForwardRay(length?: number): Ray;
  20027. /**
  20028. * @hidden
  20029. * Updates the camera based on device's frame data
  20030. */
  20031. _checkInputs(): void;
  20032. /**
  20033. * Updates the poseControlled values based on the input device pose.
  20034. * @param poseData Pose coming from the device
  20035. */
  20036. updateFromDevice(poseData: DevicePose): void;
  20037. private _htmlElementAttached;
  20038. private _detachIfAttached;
  20039. /**
  20040. * WebVR's attach control will start broadcasting frames to the device.
  20041. * Note that in certain browsers (chrome for example) this function must be called
  20042. * within a user-interaction callback. Example:
  20043. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20044. *
  20045. * @param element html element to attach the vrDevice to
  20046. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20047. */
  20048. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20049. /**
  20050. * Detaches the camera from the html element and disables VR
  20051. *
  20052. * @param element html element to detach from
  20053. */
  20054. detachControl(element: HTMLElement): void;
  20055. /**
  20056. * @returns the name of this class
  20057. */
  20058. getClassName(): string;
  20059. /**
  20060. * Calls resetPose on the vrDisplay
  20061. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20062. */
  20063. resetToCurrentRotation(): void;
  20064. /**
  20065. * @hidden
  20066. * Updates the rig cameras (left and right eye)
  20067. */
  20068. _updateRigCameras(): void;
  20069. private _workingVector;
  20070. private _oneVector;
  20071. private _workingMatrix;
  20072. private updateCacheCalled;
  20073. private _correctPositionIfNotTrackPosition;
  20074. /**
  20075. * @hidden
  20076. * Updates the cached values of the camera
  20077. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20078. */
  20079. _updateCache(ignoreParentClass?: boolean): void;
  20080. /**
  20081. * @hidden
  20082. * Get current device position in babylon world
  20083. */
  20084. _computeDevicePosition(): void;
  20085. /**
  20086. * Updates the current device position and rotation in the babylon world
  20087. */
  20088. update(): void;
  20089. /**
  20090. * @hidden
  20091. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20092. * @returns an identity matrix
  20093. */
  20094. _getViewMatrix(): Matrix;
  20095. private _tmpMatrix;
  20096. /**
  20097. * This function is called by the two RIG cameras.
  20098. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20099. * @hidden
  20100. */
  20101. _getWebVRViewMatrix(): Matrix;
  20102. /** @hidden */
  20103. _getWebVRProjectionMatrix(): Matrix;
  20104. private _onGamepadConnectedObserver;
  20105. private _onGamepadDisconnectedObserver;
  20106. private _updateCacheWhenTrackingDisabledObserver;
  20107. /**
  20108. * Initializes the controllers and their meshes
  20109. */
  20110. initControllers(): void;
  20111. }
  20112. }
  20113. declare module "babylonjs/PostProcesses/postProcess" {
  20114. import { Nullable } from "babylonjs/types";
  20115. import { SmartArray } from "babylonjs/Misc/smartArray";
  20116. import { Observable } from "babylonjs/Misc/observable";
  20117. import { Vector2 } from "babylonjs/Maths/math.vector";
  20118. import { Camera } from "babylonjs/Cameras/camera";
  20119. import { Effect } from "babylonjs/Materials/effect";
  20120. import "babylonjs/Shaders/postprocess.vertex";
  20121. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20122. import { Engine } from "babylonjs/Engines/engine";
  20123. import { Color4 } from "babylonjs/Maths/math.color";
  20124. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20125. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20126. /**
  20127. * Size options for a post process
  20128. */
  20129. export type PostProcessOptions = {
  20130. width: number;
  20131. height: number;
  20132. };
  20133. /**
  20134. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20135. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20136. */
  20137. export class PostProcess {
  20138. /** Name of the PostProcess. */
  20139. name: string;
  20140. /**
  20141. * Gets or sets the unique id of the post process
  20142. */
  20143. uniqueId: number;
  20144. /**
  20145. * Width of the texture to apply the post process on
  20146. */
  20147. width: number;
  20148. /**
  20149. * Height of the texture to apply the post process on
  20150. */
  20151. height: number;
  20152. /**
  20153. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20154. * @hidden
  20155. */
  20156. _outputTexture: Nullable<InternalTexture>;
  20157. /**
  20158. * Sampling mode used by the shader
  20159. * See https://doc.babylonjs.com/classes/3.1/texture
  20160. */
  20161. renderTargetSamplingMode: number;
  20162. /**
  20163. * Clear color to use when screen clearing
  20164. */
  20165. clearColor: Color4;
  20166. /**
  20167. * If the buffer needs to be cleared before applying the post process. (default: true)
  20168. * Should be set to false if shader will overwrite all previous pixels.
  20169. */
  20170. autoClear: boolean;
  20171. /**
  20172. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20173. */
  20174. alphaMode: number;
  20175. /**
  20176. * Sets the setAlphaBlendConstants of the babylon engine
  20177. */
  20178. alphaConstants: Color4;
  20179. /**
  20180. * Animations to be used for the post processing
  20181. */
  20182. animations: import("babylonjs/Animations/animation").Animation[];
  20183. /**
  20184. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20185. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20186. */
  20187. enablePixelPerfectMode: boolean;
  20188. /**
  20189. * Force the postprocess to be applied without taking in account viewport
  20190. */
  20191. forceFullscreenViewport: boolean;
  20192. /**
  20193. * List of inspectable custom properties (used by the Inspector)
  20194. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20195. */
  20196. inspectableCustomProperties: IInspectable[];
  20197. /**
  20198. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20199. *
  20200. * | Value | Type | Description |
  20201. * | ----- | ----------------------------------- | ----------- |
  20202. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20203. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20204. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20205. *
  20206. */
  20207. scaleMode: number;
  20208. /**
  20209. * Force textures to be a power of two (default: false)
  20210. */
  20211. alwaysForcePOT: boolean;
  20212. private _samples;
  20213. /**
  20214. * Number of sample textures (default: 1)
  20215. */
  20216. get samples(): number;
  20217. set samples(n: number);
  20218. /**
  20219. * Modify the scale of the post process to be the same as the viewport (default: false)
  20220. */
  20221. adaptScaleToCurrentViewport: boolean;
  20222. private _camera;
  20223. private _scene;
  20224. private _engine;
  20225. private _options;
  20226. private _reusable;
  20227. private _textureType;
  20228. private _textureFormat;
  20229. /**
  20230. * Smart array of input and output textures for the post process.
  20231. * @hidden
  20232. */
  20233. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20234. /**
  20235. * The index in _textures that corresponds to the output texture.
  20236. * @hidden
  20237. */
  20238. _currentRenderTextureInd: number;
  20239. private _effect;
  20240. private _samplers;
  20241. private _fragmentUrl;
  20242. private _vertexUrl;
  20243. private _parameters;
  20244. private _scaleRatio;
  20245. protected _indexParameters: any;
  20246. private _shareOutputWithPostProcess;
  20247. private _texelSize;
  20248. private _forcedOutputTexture;
  20249. /**
  20250. * Returns the fragment url or shader name used in the post process.
  20251. * @returns the fragment url or name in the shader store.
  20252. */
  20253. getEffectName(): string;
  20254. /**
  20255. * An event triggered when the postprocess is activated.
  20256. */
  20257. onActivateObservable: Observable<Camera>;
  20258. private _onActivateObserver;
  20259. /**
  20260. * A function that is added to the onActivateObservable
  20261. */
  20262. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20263. /**
  20264. * An event triggered when the postprocess changes its size.
  20265. */
  20266. onSizeChangedObservable: Observable<PostProcess>;
  20267. private _onSizeChangedObserver;
  20268. /**
  20269. * A function that is added to the onSizeChangedObservable
  20270. */
  20271. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20272. /**
  20273. * An event triggered when the postprocess applies its effect.
  20274. */
  20275. onApplyObservable: Observable<Effect>;
  20276. private _onApplyObserver;
  20277. /**
  20278. * A function that is added to the onApplyObservable
  20279. */
  20280. set onApply(callback: (effect: Effect) => void);
  20281. /**
  20282. * An event triggered before rendering the postprocess
  20283. */
  20284. onBeforeRenderObservable: Observable<Effect>;
  20285. private _onBeforeRenderObserver;
  20286. /**
  20287. * A function that is added to the onBeforeRenderObservable
  20288. */
  20289. set onBeforeRender(callback: (effect: Effect) => void);
  20290. /**
  20291. * An event triggered after rendering the postprocess
  20292. */
  20293. onAfterRenderObservable: Observable<Effect>;
  20294. private _onAfterRenderObserver;
  20295. /**
  20296. * A function that is added to the onAfterRenderObservable
  20297. */
  20298. set onAfterRender(callback: (efect: Effect) => void);
  20299. /**
  20300. * 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
  20301. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20302. */
  20303. get inputTexture(): InternalTexture;
  20304. set inputTexture(value: InternalTexture);
  20305. /**
  20306. * Gets the camera which post process is applied to.
  20307. * @returns The camera the post process is applied to.
  20308. */
  20309. getCamera(): Camera;
  20310. /**
  20311. * Gets the texel size of the postprocess.
  20312. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20313. */
  20314. get texelSize(): Vector2;
  20315. /**
  20316. * Creates a new instance PostProcess
  20317. * @param name The name of the PostProcess.
  20318. * @param fragmentUrl The url of the fragment shader to be used.
  20319. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20320. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20321. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20322. * @param camera The camera to apply the render pass to.
  20323. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20324. * @param engine The engine which the post process will be applied. (default: current engine)
  20325. * @param reusable If the post process can be reused on the same frame. (default: false)
  20326. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20327. * @param textureType Type of textures used when performing the post process. (default: 0)
  20328. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20329. * @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
  20330. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20331. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20332. */
  20333. constructor(
  20334. /** Name of the PostProcess. */
  20335. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  20336. /**
  20337. * Gets a string idenfifying the name of the class
  20338. * @returns "PostProcess" string
  20339. */
  20340. getClassName(): string;
  20341. /**
  20342. * Gets the engine which this post process belongs to.
  20343. * @returns The engine the post process was enabled with.
  20344. */
  20345. getEngine(): Engine;
  20346. /**
  20347. * The effect that is created when initializing the post process.
  20348. * @returns The created effect corresponding the the postprocess.
  20349. */
  20350. getEffect(): Effect;
  20351. /**
  20352. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20353. * @param postProcess The post process to share the output with.
  20354. * @returns This post process.
  20355. */
  20356. shareOutputWith(postProcess: PostProcess): PostProcess;
  20357. /**
  20358. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20359. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20360. */
  20361. useOwnOutput(): void;
  20362. /**
  20363. * Updates the effect with the current post process compile time values and recompiles the shader.
  20364. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20365. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20366. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20367. * @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
  20368. * @param onCompiled Called when the shader has been compiled.
  20369. * @param onError Called if there is an error when compiling a shader.
  20370. */
  20371. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20372. /**
  20373. * The post process is reusable if it can be used multiple times within one frame.
  20374. * @returns If the post process is reusable
  20375. */
  20376. isReusable(): boolean;
  20377. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20378. markTextureDirty(): void;
  20379. /**
  20380. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20381. * 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.
  20382. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20383. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20384. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20385. * @returns The target texture that was bound to be written to.
  20386. */
  20387. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20388. /**
  20389. * If the post process is supported.
  20390. */
  20391. get isSupported(): boolean;
  20392. /**
  20393. * The aspect ratio of the output texture.
  20394. */
  20395. get aspectRatio(): number;
  20396. /**
  20397. * Get a value indicating if the post-process is ready to be used
  20398. * @returns true if the post-process is ready (shader is compiled)
  20399. */
  20400. isReady(): boolean;
  20401. /**
  20402. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20403. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20404. */
  20405. apply(): Nullable<Effect>;
  20406. private _disposeTextures;
  20407. /**
  20408. * Disposes the post process.
  20409. * @param camera The camera to dispose the post process on.
  20410. */
  20411. dispose(camera?: Camera): void;
  20412. }
  20413. }
  20414. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20415. /** @hidden */
  20416. export var kernelBlurVaryingDeclaration: {
  20417. name: string;
  20418. shader: string;
  20419. };
  20420. }
  20421. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20422. /** @hidden */
  20423. export var kernelBlurFragment: {
  20424. name: string;
  20425. shader: string;
  20426. };
  20427. }
  20428. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20429. /** @hidden */
  20430. export var kernelBlurFragment2: {
  20431. name: string;
  20432. shader: string;
  20433. };
  20434. }
  20435. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20436. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20437. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20438. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20439. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20440. /** @hidden */
  20441. export var kernelBlurPixelShader: {
  20442. name: string;
  20443. shader: string;
  20444. };
  20445. }
  20446. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20447. /** @hidden */
  20448. export var kernelBlurVertex: {
  20449. name: string;
  20450. shader: string;
  20451. };
  20452. }
  20453. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20454. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20455. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20456. /** @hidden */
  20457. export var kernelBlurVertexShader: {
  20458. name: string;
  20459. shader: string;
  20460. };
  20461. }
  20462. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20463. import { Vector2 } from "babylonjs/Maths/math.vector";
  20464. import { Nullable } from "babylonjs/types";
  20465. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20466. import { Camera } from "babylonjs/Cameras/camera";
  20467. import { Effect } from "babylonjs/Materials/effect";
  20468. import { Engine } from "babylonjs/Engines/engine";
  20469. import "babylonjs/Shaders/kernelBlur.fragment";
  20470. import "babylonjs/Shaders/kernelBlur.vertex";
  20471. /**
  20472. * The Blur Post Process which blurs an image based on a kernel and direction.
  20473. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20474. */
  20475. export class BlurPostProcess extends PostProcess {
  20476. /** The direction in which to blur the image. */
  20477. direction: Vector2;
  20478. private blockCompilation;
  20479. protected _kernel: number;
  20480. protected _idealKernel: number;
  20481. protected _packedFloat: boolean;
  20482. private _staticDefines;
  20483. /**
  20484. * Sets the length in pixels of the blur sample region
  20485. */
  20486. set kernel(v: number);
  20487. /**
  20488. * Gets the length in pixels of the blur sample region
  20489. */
  20490. get kernel(): number;
  20491. /**
  20492. * Sets wether or not the blur needs to unpack/repack floats
  20493. */
  20494. set packedFloat(v: boolean);
  20495. /**
  20496. * Gets wether or not the blur is unpacking/repacking floats
  20497. */
  20498. get packedFloat(): boolean;
  20499. /**
  20500. * Creates a new instance BlurPostProcess
  20501. * @param name The name of the effect.
  20502. * @param direction The direction in which to blur the image.
  20503. * @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.
  20504. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20505. * @param camera The camera to apply the render pass to.
  20506. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20507. * @param engine The engine which the post process will be applied. (default: current engine)
  20508. * @param reusable If the post process can be reused on the same frame. (default: false)
  20509. * @param textureType Type of textures used when performing the post process. (default: 0)
  20510. * @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)
  20511. */
  20512. constructor(name: string,
  20513. /** The direction in which to blur the image. */
  20514. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20515. /**
  20516. * Updates the effect with the current post process compile time values and recompiles the shader.
  20517. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20518. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20519. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20520. * @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
  20521. * @param onCompiled Called when the shader has been compiled.
  20522. * @param onError Called if there is an error when compiling a shader.
  20523. */
  20524. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20525. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20526. /**
  20527. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20528. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20529. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20530. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20531. * The gaps between physical kernels are compensated for in the weighting of the samples
  20532. * @param idealKernel Ideal blur kernel.
  20533. * @return Nearest best kernel.
  20534. */
  20535. protected _nearestBestKernel(idealKernel: number): number;
  20536. /**
  20537. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20538. * @param x The point on the Gaussian distribution to sample.
  20539. * @return the value of the Gaussian function at x.
  20540. */
  20541. protected _gaussianWeight(x: number): number;
  20542. /**
  20543. * Generates a string that can be used as a floating point number in GLSL.
  20544. * @param x Value to print.
  20545. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20546. * @return GLSL float string.
  20547. */
  20548. protected _glslFloat(x: number, decimalFigures?: number): string;
  20549. }
  20550. }
  20551. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20552. import { Scene } from "babylonjs/scene";
  20553. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20554. import { Plane } from "babylonjs/Maths/math.plane";
  20555. /**
  20556. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20557. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20558. * You can then easily use it as a reflectionTexture on a flat surface.
  20559. * In case the surface is not a plane, please consider relying on reflection probes.
  20560. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20561. */
  20562. export class MirrorTexture extends RenderTargetTexture {
  20563. private scene;
  20564. /**
  20565. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20566. * 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.
  20567. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20568. */
  20569. mirrorPlane: Plane;
  20570. /**
  20571. * Define the blur ratio used to blur the reflection if needed.
  20572. */
  20573. set blurRatio(value: number);
  20574. get blurRatio(): number;
  20575. /**
  20576. * Define the adaptive blur kernel used to blur the reflection if needed.
  20577. * This will autocompute the closest best match for the `blurKernel`
  20578. */
  20579. set adaptiveBlurKernel(value: number);
  20580. /**
  20581. * Define the blur kernel used to blur the reflection if needed.
  20582. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20583. */
  20584. set blurKernel(value: number);
  20585. /**
  20586. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20587. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20588. */
  20589. set blurKernelX(value: number);
  20590. get blurKernelX(): number;
  20591. /**
  20592. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20593. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20594. */
  20595. set blurKernelY(value: number);
  20596. get blurKernelY(): number;
  20597. private _autoComputeBlurKernel;
  20598. protected _onRatioRescale(): void;
  20599. private _updateGammaSpace;
  20600. private _imageProcessingConfigChangeObserver;
  20601. private _transformMatrix;
  20602. private _mirrorMatrix;
  20603. private _savedViewMatrix;
  20604. private _blurX;
  20605. private _blurY;
  20606. private _adaptiveBlurKernel;
  20607. private _blurKernelX;
  20608. private _blurKernelY;
  20609. private _blurRatio;
  20610. /**
  20611. * Instantiates a Mirror Texture.
  20612. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20613. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20614. * You can then easily use it as a reflectionTexture on a flat surface.
  20615. * In case the surface is not a plane, please consider relying on reflection probes.
  20616. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20617. * @param name
  20618. * @param size
  20619. * @param scene
  20620. * @param generateMipMaps
  20621. * @param type
  20622. * @param samplingMode
  20623. * @param generateDepthBuffer
  20624. */
  20625. constructor(name: string, size: number | {
  20626. width: number;
  20627. height: number;
  20628. } | {
  20629. ratio: number;
  20630. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20631. private _preparePostProcesses;
  20632. /**
  20633. * Clone the mirror texture.
  20634. * @returns the cloned texture
  20635. */
  20636. clone(): MirrorTexture;
  20637. /**
  20638. * Serialize the texture to a JSON representation you could use in Parse later on
  20639. * @returns the serialized JSON representation
  20640. */
  20641. serialize(): any;
  20642. /**
  20643. * Dispose the texture and release its associated resources.
  20644. */
  20645. dispose(): void;
  20646. }
  20647. }
  20648. declare module "babylonjs/Materials/Textures/texture" {
  20649. import { Observable } from "babylonjs/Misc/observable";
  20650. import { Nullable } from "babylonjs/types";
  20651. import { Matrix } from "babylonjs/Maths/math.vector";
  20652. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20653. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20654. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20655. import { Scene } from "babylonjs/scene";
  20656. /**
  20657. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20658. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20659. */
  20660. export class Texture extends BaseTexture {
  20661. /**
  20662. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20663. */
  20664. static SerializeBuffers: boolean;
  20665. /** @hidden */
  20666. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20667. /** @hidden */
  20668. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20669. /** @hidden */
  20670. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20671. /** nearest is mag = nearest and min = nearest and mip = linear */
  20672. static readonly NEAREST_SAMPLINGMODE: number;
  20673. /** nearest is mag = nearest and min = nearest and mip = linear */
  20674. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20675. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20676. static readonly BILINEAR_SAMPLINGMODE: number;
  20677. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20678. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20679. /** Trilinear is mag = linear and min = linear and mip = linear */
  20680. static readonly TRILINEAR_SAMPLINGMODE: number;
  20681. /** Trilinear is mag = linear and min = linear and mip = linear */
  20682. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20683. /** mag = nearest and min = nearest and mip = nearest */
  20684. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20685. /** mag = nearest and min = linear and mip = nearest */
  20686. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20687. /** mag = nearest and min = linear and mip = linear */
  20688. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20689. /** mag = nearest and min = linear and mip = none */
  20690. static readonly NEAREST_LINEAR: number;
  20691. /** mag = nearest and min = nearest and mip = none */
  20692. static readonly NEAREST_NEAREST: number;
  20693. /** mag = linear and min = nearest and mip = nearest */
  20694. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20695. /** mag = linear and min = nearest and mip = linear */
  20696. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20697. /** mag = linear and min = linear and mip = none */
  20698. static readonly LINEAR_LINEAR: number;
  20699. /** mag = linear and min = nearest and mip = none */
  20700. static readonly LINEAR_NEAREST: number;
  20701. /** Explicit coordinates mode */
  20702. static readonly EXPLICIT_MODE: number;
  20703. /** Spherical coordinates mode */
  20704. static readonly SPHERICAL_MODE: number;
  20705. /** Planar coordinates mode */
  20706. static readonly PLANAR_MODE: number;
  20707. /** Cubic coordinates mode */
  20708. static readonly CUBIC_MODE: number;
  20709. /** Projection coordinates mode */
  20710. static readonly PROJECTION_MODE: number;
  20711. /** Inverse Cubic coordinates mode */
  20712. static readonly SKYBOX_MODE: number;
  20713. /** Inverse Cubic coordinates mode */
  20714. static readonly INVCUBIC_MODE: number;
  20715. /** Equirectangular coordinates mode */
  20716. static readonly EQUIRECTANGULAR_MODE: number;
  20717. /** Equirectangular Fixed coordinates mode */
  20718. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20719. /** Equirectangular Fixed Mirrored coordinates mode */
  20720. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20721. /** Texture is not repeating outside of 0..1 UVs */
  20722. static readonly CLAMP_ADDRESSMODE: number;
  20723. /** Texture is repeating outside of 0..1 UVs */
  20724. static readonly WRAP_ADDRESSMODE: number;
  20725. /** Texture is repeating and mirrored */
  20726. static readonly MIRROR_ADDRESSMODE: number;
  20727. /**
  20728. * 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
  20729. */
  20730. static UseSerializedUrlIfAny: boolean;
  20731. /**
  20732. * Define the url of the texture.
  20733. */
  20734. url: Nullable<string>;
  20735. /**
  20736. * Define an offset on the texture to offset the u coordinates of the UVs
  20737. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20738. */
  20739. uOffset: number;
  20740. /**
  20741. * Define an offset on the texture to offset the v coordinates of the UVs
  20742. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20743. */
  20744. vOffset: number;
  20745. /**
  20746. * Define an offset on the texture to scale the u coordinates of the UVs
  20747. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20748. */
  20749. uScale: number;
  20750. /**
  20751. * Define an offset on the texture to scale the v coordinates of the UVs
  20752. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20753. */
  20754. vScale: number;
  20755. /**
  20756. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20757. * @see http://doc.babylonjs.com/how_to/more_materials
  20758. */
  20759. uAng: number;
  20760. /**
  20761. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20762. * @see http://doc.babylonjs.com/how_to/more_materials
  20763. */
  20764. vAng: number;
  20765. /**
  20766. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20767. * @see http://doc.babylonjs.com/how_to/more_materials
  20768. */
  20769. wAng: number;
  20770. /**
  20771. * Defines the center of rotation (U)
  20772. */
  20773. uRotationCenter: number;
  20774. /**
  20775. * Defines the center of rotation (V)
  20776. */
  20777. vRotationCenter: number;
  20778. /**
  20779. * Defines the center of rotation (W)
  20780. */
  20781. wRotationCenter: number;
  20782. /**
  20783. * Are mip maps generated for this texture or not.
  20784. */
  20785. get noMipmap(): boolean;
  20786. /**
  20787. * List of inspectable custom properties (used by the Inspector)
  20788. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20789. */
  20790. inspectableCustomProperties: Nullable<IInspectable[]>;
  20791. private _noMipmap;
  20792. /** @hidden */
  20793. _invertY: boolean;
  20794. private _rowGenerationMatrix;
  20795. private _cachedTextureMatrix;
  20796. private _projectionModeMatrix;
  20797. private _t0;
  20798. private _t1;
  20799. private _t2;
  20800. private _cachedUOffset;
  20801. private _cachedVOffset;
  20802. private _cachedUScale;
  20803. private _cachedVScale;
  20804. private _cachedUAng;
  20805. private _cachedVAng;
  20806. private _cachedWAng;
  20807. private _cachedProjectionMatrixId;
  20808. private _cachedCoordinatesMode;
  20809. /** @hidden */
  20810. protected _initialSamplingMode: number;
  20811. /** @hidden */
  20812. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20813. private _deleteBuffer;
  20814. protected _format: Nullable<number>;
  20815. private _delayedOnLoad;
  20816. private _delayedOnError;
  20817. private _mimeType?;
  20818. /**
  20819. * Observable triggered once the texture has been loaded.
  20820. */
  20821. onLoadObservable: Observable<Texture>;
  20822. protected _isBlocking: boolean;
  20823. /**
  20824. * Is the texture preventing material to render while loading.
  20825. * If false, a default texture will be used instead of the loading one during the preparation step.
  20826. */
  20827. set isBlocking(value: boolean);
  20828. get isBlocking(): boolean;
  20829. /**
  20830. * Get the current sampling mode associated with the texture.
  20831. */
  20832. get samplingMode(): number;
  20833. /**
  20834. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20835. */
  20836. get invertY(): boolean;
  20837. /**
  20838. * Instantiates a new texture.
  20839. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20840. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20841. * @param url defines the url of the picture to load as a texture
  20842. * @param scene defines the scene or engine the texture will belong to
  20843. * @param noMipmap defines if the texture will require mip maps or not
  20844. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20845. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20846. * @param onLoad defines a callback triggered when the texture has been loaded
  20847. * @param onError defines a callback triggered when an error occurred during the loading session
  20848. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20849. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20850. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20851. * @param mimeType defines an optional mime type information
  20852. */
  20853. 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);
  20854. /**
  20855. * Update the url (and optional buffer) of this texture if url was null during construction.
  20856. * @param url the url of the texture
  20857. * @param buffer the buffer of the texture (defaults to null)
  20858. * @param onLoad callback called when the texture is loaded (defaults to null)
  20859. */
  20860. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20861. /**
  20862. * Finish the loading sequence of a texture flagged as delayed load.
  20863. * @hidden
  20864. */
  20865. delayLoad(): void;
  20866. private _prepareRowForTextureGeneration;
  20867. /**
  20868. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20869. * @returns the transform matrix of the texture.
  20870. */
  20871. getTextureMatrix(uBase?: number): Matrix;
  20872. /**
  20873. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20874. * @returns The reflection texture transform
  20875. */
  20876. getReflectionTextureMatrix(): Matrix;
  20877. /**
  20878. * Clones the texture.
  20879. * @returns the cloned texture
  20880. */
  20881. clone(): Texture;
  20882. /**
  20883. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20884. * @returns The JSON representation of the texture
  20885. */
  20886. serialize(): any;
  20887. /**
  20888. * Get the current class name of the texture useful for serialization or dynamic coding.
  20889. * @returns "Texture"
  20890. */
  20891. getClassName(): string;
  20892. /**
  20893. * Dispose the texture and release its associated resources.
  20894. */
  20895. dispose(): void;
  20896. /**
  20897. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20898. * @param parsedTexture Define the JSON representation of the texture
  20899. * @param scene Define the scene the parsed texture should be instantiated in
  20900. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20901. * @returns The parsed texture if successful
  20902. */
  20903. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20904. /**
  20905. * Creates a texture from its base 64 representation.
  20906. * @param data Define the base64 payload without the data: prefix
  20907. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20908. * @param scene Define the scene the texture should belong to
  20909. * @param noMipmap Forces the texture to not create mip map information if true
  20910. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20911. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20912. * @param onLoad define a callback triggered when the texture has been loaded
  20913. * @param onError define a callback triggered when an error occurred during the loading session
  20914. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20915. * @returns the created texture
  20916. */
  20917. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20918. /**
  20919. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20920. * @param data Define the base64 payload without the data: prefix
  20921. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20922. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20923. * @param scene Define the scene the texture should belong to
  20924. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20925. * @param noMipmap Forces the texture to not create mip map information if true
  20926. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20927. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20928. * @param onLoad define a callback triggered when the texture has been loaded
  20929. * @param onError define a callback triggered when an error occurred during the loading session
  20930. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20931. * @returns the created texture
  20932. */
  20933. 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;
  20934. }
  20935. }
  20936. declare module "babylonjs/PostProcesses/postProcessManager" {
  20937. import { Nullable } from "babylonjs/types";
  20938. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20939. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20940. import { Scene } from "babylonjs/scene";
  20941. /**
  20942. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20943. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20944. */
  20945. export class PostProcessManager {
  20946. private _scene;
  20947. private _indexBuffer;
  20948. private _vertexBuffers;
  20949. /**
  20950. * Creates a new instance PostProcess
  20951. * @param scene The scene that the post process is associated with.
  20952. */
  20953. constructor(scene: Scene);
  20954. private _prepareBuffers;
  20955. private _buildIndexBuffer;
  20956. /**
  20957. * Rebuilds the vertex buffers of the manager.
  20958. * @hidden
  20959. */
  20960. _rebuild(): void;
  20961. /**
  20962. * Prepares a frame to be run through a post process.
  20963. * @param sourceTexture The input texture to the post procesess. (default: null)
  20964. * @param postProcesses An array of post processes to be run. (default: null)
  20965. * @returns True if the post processes were able to be run.
  20966. * @hidden
  20967. */
  20968. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20969. /**
  20970. * Manually render a set of post processes to a texture.
  20971. * @param postProcesses An array of post processes to be run.
  20972. * @param targetTexture The target texture to render to.
  20973. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20974. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20975. * @param lodLevel defines which lod of the texture to render to
  20976. */
  20977. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20978. /**
  20979. * Finalize the result of the output of the postprocesses.
  20980. * @param doNotPresent If true the result will not be displayed to the screen.
  20981. * @param targetTexture The target texture to render to.
  20982. * @param faceIndex The index of the face to bind the target texture to.
  20983. * @param postProcesses The array of post processes to render.
  20984. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20985. * @hidden
  20986. */
  20987. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20988. /**
  20989. * Disposes of the post process manager.
  20990. */
  20991. dispose(): void;
  20992. }
  20993. }
  20994. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20995. import { Observable } from "babylonjs/Misc/observable";
  20996. import { SmartArray } from "babylonjs/Misc/smartArray";
  20997. import { Nullable, Immutable } from "babylonjs/types";
  20998. import { Camera } from "babylonjs/Cameras/camera";
  20999. import { Scene } from "babylonjs/scene";
  21000. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21001. import { Color4 } from "babylonjs/Maths/math.color";
  21002. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21003. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21004. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21005. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21006. import { Texture } from "babylonjs/Materials/Textures/texture";
  21007. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21008. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21009. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21010. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21011. import { Engine } from "babylonjs/Engines/engine";
  21012. /**
  21013. * This Helps creating a texture that will be created from a camera in your scene.
  21014. * It is basically a dynamic texture that could be used to create special effects for instance.
  21015. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21016. */
  21017. export class RenderTargetTexture extends Texture {
  21018. isCube: boolean;
  21019. /**
  21020. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21021. */
  21022. static readonly REFRESHRATE_RENDER_ONCE: number;
  21023. /**
  21024. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21025. */
  21026. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21027. /**
  21028. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21029. * the central point of your effect and can save a lot of performances.
  21030. */
  21031. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21032. /**
  21033. * Use this predicate to dynamically define the list of mesh you want to render.
  21034. * If set, the renderList property will be overwritten.
  21035. */
  21036. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21037. private _renderList;
  21038. /**
  21039. * Use this list to define the list of mesh you want to render.
  21040. */
  21041. get renderList(): Nullable<Array<AbstractMesh>>;
  21042. set renderList(value: Nullable<Array<AbstractMesh>>);
  21043. /**
  21044. * Use this function to overload the renderList array at rendering time.
  21045. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21046. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21047. * the cube (if the RTT is a cube, else layerOrFace=0).
  21048. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  21049. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  21050. * hold dummy elements!
  21051. */
  21052. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  21053. private _hookArray;
  21054. /**
  21055. * Define if particles should be rendered in your texture.
  21056. */
  21057. renderParticles: boolean;
  21058. /**
  21059. * Define if sprites should be rendered in your texture.
  21060. */
  21061. renderSprites: boolean;
  21062. /**
  21063. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21064. */
  21065. coordinatesMode: number;
  21066. /**
  21067. * Define the camera used to render the texture.
  21068. */
  21069. activeCamera: Nullable<Camera>;
  21070. /**
  21071. * Override the render function of the texture with your own one.
  21072. */
  21073. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21074. /**
  21075. * Define if camera post processes should be use while rendering the texture.
  21076. */
  21077. useCameraPostProcesses: boolean;
  21078. /**
  21079. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21080. */
  21081. ignoreCameraViewport: boolean;
  21082. private _postProcessManager;
  21083. private _postProcesses;
  21084. private _resizeObserver;
  21085. /**
  21086. * An event triggered when the texture is unbind.
  21087. */
  21088. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21089. /**
  21090. * An event triggered when the texture is unbind.
  21091. */
  21092. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21093. private _onAfterUnbindObserver;
  21094. /**
  21095. * Set a after unbind callback in the texture.
  21096. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21097. */
  21098. set onAfterUnbind(callback: () => void);
  21099. /**
  21100. * An event triggered before rendering the texture
  21101. */
  21102. onBeforeRenderObservable: Observable<number>;
  21103. private _onBeforeRenderObserver;
  21104. /**
  21105. * Set a before render callback in the texture.
  21106. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21107. */
  21108. set onBeforeRender(callback: (faceIndex: number) => void);
  21109. /**
  21110. * An event triggered after rendering the texture
  21111. */
  21112. onAfterRenderObservable: Observable<number>;
  21113. private _onAfterRenderObserver;
  21114. /**
  21115. * Set a after render callback in the texture.
  21116. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21117. */
  21118. set onAfterRender(callback: (faceIndex: number) => void);
  21119. /**
  21120. * An event triggered after the texture clear
  21121. */
  21122. onClearObservable: Observable<Engine>;
  21123. private _onClearObserver;
  21124. /**
  21125. * Set a clear callback in the texture.
  21126. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21127. */
  21128. set onClear(callback: (Engine: Engine) => void);
  21129. /**
  21130. * An event triggered when the texture is resized.
  21131. */
  21132. onResizeObservable: Observable<RenderTargetTexture>;
  21133. /**
  21134. * Define the clear color of the Render Target if it should be different from the scene.
  21135. */
  21136. clearColor: Color4;
  21137. protected _size: number | {
  21138. width: number;
  21139. height: number;
  21140. layers?: number;
  21141. };
  21142. protected _initialSizeParameter: number | {
  21143. width: number;
  21144. height: number;
  21145. } | {
  21146. ratio: number;
  21147. };
  21148. protected _sizeRatio: Nullable<number>;
  21149. /** @hidden */
  21150. _generateMipMaps: boolean;
  21151. protected _renderingManager: RenderingManager;
  21152. /** @hidden */
  21153. _waitingRenderList: string[];
  21154. protected _doNotChangeAspectRatio: boolean;
  21155. protected _currentRefreshId: number;
  21156. protected _refreshRate: number;
  21157. protected _textureMatrix: Matrix;
  21158. protected _samples: number;
  21159. protected _renderTargetOptions: RenderTargetCreationOptions;
  21160. /**
  21161. * Gets render target creation options that were used.
  21162. */
  21163. get renderTargetOptions(): RenderTargetCreationOptions;
  21164. protected _engine: Engine;
  21165. protected _onRatioRescale(): void;
  21166. /**
  21167. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21168. * It must define where the camera used to render the texture is set
  21169. */
  21170. boundingBoxPosition: Vector3;
  21171. private _boundingBoxSize;
  21172. /**
  21173. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21174. * When defined, the cubemap will switch to local mode
  21175. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21176. * @example https://www.babylonjs-playground.com/#RNASML
  21177. */
  21178. set boundingBoxSize(value: Vector3);
  21179. get boundingBoxSize(): Vector3;
  21180. /**
  21181. * In case the RTT has been created with a depth texture, get the associated
  21182. * depth texture.
  21183. * Otherwise, return null.
  21184. */
  21185. get depthStencilTexture(): Nullable<InternalTexture>;
  21186. /**
  21187. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21188. * or used a shadow, depth texture...
  21189. * @param name The friendly name of the texture
  21190. * @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)
  21191. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21192. * @param generateMipMaps True if mip maps need to be generated after render.
  21193. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21194. * @param type The type of the buffer in the RTT (int, half float, float...)
  21195. * @param isCube True if a cube texture needs to be created
  21196. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21197. * @param generateDepthBuffer True to generate a depth buffer
  21198. * @param generateStencilBuffer True to generate a stencil buffer
  21199. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21200. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21201. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21202. */
  21203. constructor(name: string, size: number | {
  21204. width: number;
  21205. height: number;
  21206. layers?: number;
  21207. } | {
  21208. ratio: number;
  21209. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21210. /**
  21211. * Creates a depth stencil texture.
  21212. * This is only available in WebGL 2 or with the depth texture extension available.
  21213. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21214. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21215. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21216. */
  21217. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21218. private _processSizeParameter;
  21219. /**
  21220. * Define the number of samples to use in case of MSAA.
  21221. * It defaults to one meaning no MSAA has been enabled.
  21222. */
  21223. get samples(): number;
  21224. set samples(value: number);
  21225. /**
  21226. * Resets the refresh counter of the texture and start bak from scratch.
  21227. * Could be useful to regenerate the texture if it is setup to render only once.
  21228. */
  21229. resetRefreshCounter(): void;
  21230. /**
  21231. * Define the refresh rate of the texture or the rendering frequency.
  21232. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21233. */
  21234. get refreshRate(): number;
  21235. set refreshRate(value: number);
  21236. /**
  21237. * Adds a post process to the render target rendering passes.
  21238. * @param postProcess define the post process to add
  21239. */
  21240. addPostProcess(postProcess: PostProcess): void;
  21241. /**
  21242. * Clear all the post processes attached to the render target
  21243. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21244. */
  21245. clearPostProcesses(dispose?: boolean): void;
  21246. /**
  21247. * Remove one of the post process from the list of attached post processes to the texture
  21248. * @param postProcess define the post process to remove from the list
  21249. */
  21250. removePostProcess(postProcess: PostProcess): void;
  21251. /** @hidden */
  21252. _shouldRender(): boolean;
  21253. /**
  21254. * Gets the actual render size of the texture.
  21255. * @returns the width of the render size
  21256. */
  21257. getRenderSize(): number;
  21258. /**
  21259. * Gets the actual render width of the texture.
  21260. * @returns the width of the render size
  21261. */
  21262. getRenderWidth(): number;
  21263. /**
  21264. * Gets the actual render height of the texture.
  21265. * @returns the height of the render size
  21266. */
  21267. getRenderHeight(): number;
  21268. /**
  21269. * Gets the actual number of layers of the texture.
  21270. * @returns the number of layers
  21271. */
  21272. getRenderLayers(): number;
  21273. /**
  21274. * Get if the texture can be rescaled or not.
  21275. */
  21276. get canRescale(): boolean;
  21277. /**
  21278. * Resize the texture using a ratio.
  21279. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21280. */
  21281. scale(ratio: number): void;
  21282. /**
  21283. * Get the texture reflection matrix used to rotate/transform the reflection.
  21284. * @returns the reflection matrix
  21285. */
  21286. getReflectionTextureMatrix(): Matrix;
  21287. /**
  21288. * Resize the texture to a new desired size.
  21289. * Be carrefull as it will recreate all the data in the new texture.
  21290. * @param size Define the new size. It can be:
  21291. * - a number for squared texture,
  21292. * - an object containing { width: number, height: number }
  21293. * - or an object containing a ratio { ratio: number }
  21294. */
  21295. resize(size: number | {
  21296. width: number;
  21297. height: number;
  21298. } | {
  21299. ratio: number;
  21300. }): void;
  21301. private _defaultRenderListPrepared;
  21302. /**
  21303. * Renders all the objects from the render list into the texture.
  21304. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21305. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21306. */
  21307. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21308. private _bestReflectionRenderTargetDimension;
  21309. private _prepareRenderingManager;
  21310. /**
  21311. * @hidden
  21312. * @param faceIndex face index to bind to if this is a cubetexture
  21313. * @param layer defines the index of the texture to bind in the array
  21314. */
  21315. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21316. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21317. private renderToTarget;
  21318. /**
  21319. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21320. * This allowed control for front to back rendering or reversly depending of the special needs.
  21321. *
  21322. * @param renderingGroupId The rendering group id corresponding to its index
  21323. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21324. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21325. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21326. */
  21327. 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;
  21328. /**
  21329. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21330. *
  21331. * @param renderingGroupId The rendering group id corresponding to its index
  21332. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21333. */
  21334. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21335. /**
  21336. * Clones the texture.
  21337. * @returns the cloned texture
  21338. */
  21339. clone(): RenderTargetTexture;
  21340. /**
  21341. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21342. * @returns The JSON representation of the texture
  21343. */
  21344. serialize(): any;
  21345. /**
  21346. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21347. */
  21348. disposeFramebufferObjects(): void;
  21349. /**
  21350. * Dispose the texture and release its associated resources.
  21351. */
  21352. dispose(): void;
  21353. /** @hidden */
  21354. _rebuild(): void;
  21355. /**
  21356. * Clear the info related to rendering groups preventing retention point in material dispose.
  21357. */
  21358. freeRenderingGroups(): void;
  21359. /**
  21360. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21361. * @returns the view count
  21362. */
  21363. getViewCount(): number;
  21364. }
  21365. }
  21366. declare module "babylonjs/Materials/material" {
  21367. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21368. import { SmartArray } from "babylonjs/Misc/smartArray";
  21369. import { Observable } from "babylonjs/Misc/observable";
  21370. import { Nullable } from "babylonjs/types";
  21371. import { Scene } from "babylonjs/scene";
  21372. import { Matrix } from "babylonjs/Maths/math.vector";
  21373. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21375. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21376. import { Effect } from "babylonjs/Materials/effect";
  21377. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21378. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21379. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21380. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21381. import { Mesh } from "babylonjs/Meshes/mesh";
  21382. import { Animation } from "babylonjs/Animations/animation";
  21383. /**
  21384. * Options for compiling materials.
  21385. */
  21386. export interface IMaterialCompilationOptions {
  21387. /**
  21388. * Defines whether clip planes are enabled.
  21389. */
  21390. clipPlane: boolean;
  21391. /**
  21392. * Defines whether instances are enabled.
  21393. */
  21394. useInstances: boolean;
  21395. }
  21396. /**
  21397. * Base class for the main features of a material in Babylon.js
  21398. */
  21399. export class Material implements IAnimatable {
  21400. /**
  21401. * Returns the triangle fill mode
  21402. */
  21403. static readonly TriangleFillMode: number;
  21404. /**
  21405. * Returns the wireframe mode
  21406. */
  21407. static readonly WireFrameFillMode: number;
  21408. /**
  21409. * Returns the point fill mode
  21410. */
  21411. static readonly PointFillMode: number;
  21412. /**
  21413. * Returns the point list draw mode
  21414. */
  21415. static readonly PointListDrawMode: number;
  21416. /**
  21417. * Returns the line list draw mode
  21418. */
  21419. static readonly LineListDrawMode: number;
  21420. /**
  21421. * Returns the line loop draw mode
  21422. */
  21423. static readonly LineLoopDrawMode: number;
  21424. /**
  21425. * Returns the line strip draw mode
  21426. */
  21427. static readonly LineStripDrawMode: number;
  21428. /**
  21429. * Returns the triangle strip draw mode
  21430. */
  21431. static readonly TriangleStripDrawMode: number;
  21432. /**
  21433. * Returns the triangle fan draw mode
  21434. */
  21435. static readonly TriangleFanDrawMode: number;
  21436. /**
  21437. * Stores the clock-wise side orientation
  21438. */
  21439. static readonly ClockWiseSideOrientation: number;
  21440. /**
  21441. * Stores the counter clock-wise side orientation
  21442. */
  21443. static readonly CounterClockWiseSideOrientation: number;
  21444. /**
  21445. * The dirty texture flag value
  21446. */
  21447. static readonly TextureDirtyFlag: number;
  21448. /**
  21449. * The dirty light flag value
  21450. */
  21451. static readonly LightDirtyFlag: number;
  21452. /**
  21453. * The dirty fresnel flag value
  21454. */
  21455. static readonly FresnelDirtyFlag: number;
  21456. /**
  21457. * The dirty attribute flag value
  21458. */
  21459. static readonly AttributesDirtyFlag: number;
  21460. /**
  21461. * The dirty misc flag value
  21462. */
  21463. static readonly MiscDirtyFlag: number;
  21464. /**
  21465. * The all dirty flag value
  21466. */
  21467. static readonly AllDirtyFlag: number;
  21468. /**
  21469. * The ID of the material
  21470. */
  21471. id: string;
  21472. /**
  21473. * Gets or sets the unique id of the material
  21474. */
  21475. uniqueId: number;
  21476. /**
  21477. * The name of the material
  21478. */
  21479. name: string;
  21480. /**
  21481. * Gets or sets user defined metadata
  21482. */
  21483. metadata: any;
  21484. /**
  21485. * For internal use only. Please do not use.
  21486. */
  21487. reservedDataStore: any;
  21488. /**
  21489. * Specifies if the ready state should be checked on each call
  21490. */
  21491. checkReadyOnEveryCall: boolean;
  21492. /**
  21493. * Specifies if the ready state should be checked once
  21494. */
  21495. checkReadyOnlyOnce: boolean;
  21496. /**
  21497. * The state of the material
  21498. */
  21499. state: string;
  21500. /**
  21501. * The alpha value of the material
  21502. */
  21503. protected _alpha: number;
  21504. /**
  21505. * List of inspectable custom properties (used by the Inspector)
  21506. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21507. */
  21508. inspectableCustomProperties: IInspectable[];
  21509. /**
  21510. * Sets the alpha value of the material
  21511. */
  21512. set alpha(value: number);
  21513. /**
  21514. * Gets the alpha value of the material
  21515. */
  21516. get alpha(): number;
  21517. /**
  21518. * Specifies if back face culling is enabled
  21519. */
  21520. protected _backFaceCulling: boolean;
  21521. /**
  21522. * Sets the back-face culling state
  21523. */
  21524. set backFaceCulling(value: boolean);
  21525. /**
  21526. * Gets the back-face culling state
  21527. */
  21528. get backFaceCulling(): boolean;
  21529. /**
  21530. * Stores the value for side orientation
  21531. */
  21532. sideOrientation: number;
  21533. /**
  21534. * Callback triggered when the material is compiled
  21535. */
  21536. onCompiled: Nullable<(effect: Effect) => void>;
  21537. /**
  21538. * Callback triggered when an error occurs
  21539. */
  21540. onError: Nullable<(effect: Effect, errors: string) => void>;
  21541. /**
  21542. * Callback triggered to get the render target textures
  21543. */
  21544. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21545. /**
  21546. * Gets a boolean indicating that current material needs to register RTT
  21547. */
  21548. get hasRenderTargetTextures(): boolean;
  21549. /**
  21550. * Specifies if the material should be serialized
  21551. */
  21552. doNotSerialize: boolean;
  21553. /**
  21554. * @hidden
  21555. */
  21556. _storeEffectOnSubMeshes: boolean;
  21557. /**
  21558. * Stores the animations for the material
  21559. */
  21560. animations: Nullable<Array<Animation>>;
  21561. /**
  21562. * An event triggered when the material is disposed
  21563. */
  21564. onDisposeObservable: Observable<Material>;
  21565. /**
  21566. * An observer which watches for dispose events
  21567. */
  21568. private _onDisposeObserver;
  21569. private _onUnBindObservable;
  21570. /**
  21571. * Called during a dispose event
  21572. */
  21573. set onDispose(callback: () => void);
  21574. private _onBindObservable;
  21575. /**
  21576. * An event triggered when the material is bound
  21577. */
  21578. get onBindObservable(): Observable<AbstractMesh>;
  21579. /**
  21580. * An observer which watches for bind events
  21581. */
  21582. private _onBindObserver;
  21583. /**
  21584. * Called during a bind event
  21585. */
  21586. set onBind(callback: (Mesh: AbstractMesh) => void);
  21587. /**
  21588. * An event triggered when the material is unbound
  21589. */
  21590. get onUnBindObservable(): Observable<Material>;
  21591. /**
  21592. * Stores the value of the alpha mode
  21593. */
  21594. private _alphaMode;
  21595. /**
  21596. * Sets the value of the alpha mode.
  21597. *
  21598. * | Value | Type | Description |
  21599. * | --- | --- | --- |
  21600. * | 0 | ALPHA_DISABLE | |
  21601. * | 1 | ALPHA_ADD | |
  21602. * | 2 | ALPHA_COMBINE | |
  21603. * | 3 | ALPHA_SUBTRACT | |
  21604. * | 4 | ALPHA_MULTIPLY | |
  21605. * | 5 | ALPHA_MAXIMIZED | |
  21606. * | 6 | ALPHA_ONEONE | |
  21607. * | 7 | ALPHA_PREMULTIPLIED | |
  21608. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21609. * | 9 | ALPHA_INTERPOLATE | |
  21610. * | 10 | ALPHA_SCREENMODE | |
  21611. *
  21612. */
  21613. set alphaMode(value: number);
  21614. /**
  21615. * Gets the value of the alpha mode
  21616. */
  21617. get alphaMode(): number;
  21618. /**
  21619. * Stores the state of the need depth pre-pass value
  21620. */
  21621. private _needDepthPrePass;
  21622. /**
  21623. * Sets the need depth pre-pass value
  21624. */
  21625. set needDepthPrePass(value: boolean);
  21626. /**
  21627. * Gets the depth pre-pass value
  21628. */
  21629. get needDepthPrePass(): boolean;
  21630. /**
  21631. * Specifies if depth writing should be disabled
  21632. */
  21633. disableDepthWrite: boolean;
  21634. /**
  21635. * Specifies if depth writing should be forced
  21636. */
  21637. forceDepthWrite: boolean;
  21638. /**
  21639. * Specifies the depth function that should be used. 0 means the default engine function
  21640. */
  21641. depthFunction: number;
  21642. /**
  21643. * Specifies if there should be a separate pass for culling
  21644. */
  21645. separateCullingPass: boolean;
  21646. /**
  21647. * Stores the state specifing if fog should be enabled
  21648. */
  21649. private _fogEnabled;
  21650. /**
  21651. * Sets the state for enabling fog
  21652. */
  21653. set fogEnabled(value: boolean);
  21654. /**
  21655. * Gets the value of the fog enabled state
  21656. */
  21657. get fogEnabled(): boolean;
  21658. /**
  21659. * Stores the size of points
  21660. */
  21661. pointSize: number;
  21662. /**
  21663. * Stores the z offset value
  21664. */
  21665. zOffset: number;
  21666. /**
  21667. * Gets a value specifying if wireframe mode is enabled
  21668. */
  21669. get wireframe(): boolean;
  21670. /**
  21671. * Sets the state of wireframe mode
  21672. */
  21673. set wireframe(value: boolean);
  21674. /**
  21675. * Gets the value specifying if point clouds are enabled
  21676. */
  21677. get pointsCloud(): boolean;
  21678. /**
  21679. * Sets the state of point cloud mode
  21680. */
  21681. set pointsCloud(value: boolean);
  21682. /**
  21683. * Gets the material fill mode
  21684. */
  21685. get fillMode(): number;
  21686. /**
  21687. * Sets the material fill mode
  21688. */
  21689. set fillMode(value: number);
  21690. /**
  21691. * @hidden
  21692. * Stores the effects for the material
  21693. */
  21694. _effect: Nullable<Effect>;
  21695. /**
  21696. * Specifies if uniform buffers should be used
  21697. */
  21698. private _useUBO;
  21699. /**
  21700. * Stores a reference to the scene
  21701. */
  21702. private _scene;
  21703. /**
  21704. * Stores the fill mode state
  21705. */
  21706. private _fillMode;
  21707. /**
  21708. * Specifies if the depth write state should be cached
  21709. */
  21710. private _cachedDepthWriteState;
  21711. /**
  21712. * Specifies if the depth function state should be cached
  21713. */
  21714. private _cachedDepthFunctionState;
  21715. /**
  21716. * Stores the uniform buffer
  21717. */
  21718. protected _uniformBuffer: UniformBuffer;
  21719. /** @hidden */
  21720. _indexInSceneMaterialArray: number;
  21721. /** @hidden */
  21722. meshMap: Nullable<{
  21723. [id: string]: AbstractMesh | undefined;
  21724. }>;
  21725. /**
  21726. * Creates a material instance
  21727. * @param name defines the name of the material
  21728. * @param scene defines the scene to reference
  21729. * @param doNotAdd specifies if the material should be added to the scene
  21730. */
  21731. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21732. /**
  21733. * Returns a string representation of the current material
  21734. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21735. * @returns a string with material information
  21736. */
  21737. toString(fullDetails?: boolean): string;
  21738. /**
  21739. * Gets the class name of the material
  21740. * @returns a string with the class name of the material
  21741. */
  21742. getClassName(): string;
  21743. /**
  21744. * Specifies if updates for the material been locked
  21745. */
  21746. get isFrozen(): boolean;
  21747. /**
  21748. * Locks updates for the material
  21749. */
  21750. freeze(): void;
  21751. /**
  21752. * Unlocks updates for the material
  21753. */
  21754. unfreeze(): void;
  21755. /**
  21756. * Specifies if the material is ready to be used
  21757. * @param mesh defines the mesh to check
  21758. * @param useInstances specifies if instances should be used
  21759. * @returns a boolean indicating if the material is ready to be used
  21760. */
  21761. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21762. /**
  21763. * Specifies that the submesh is ready to be used
  21764. * @param mesh defines the mesh to check
  21765. * @param subMesh defines which submesh to check
  21766. * @param useInstances specifies that instances should be used
  21767. * @returns a boolean indicating that the submesh is ready or not
  21768. */
  21769. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21770. /**
  21771. * Returns the material effect
  21772. * @returns the effect associated with the material
  21773. */
  21774. getEffect(): Nullable<Effect>;
  21775. /**
  21776. * Returns the current scene
  21777. * @returns a Scene
  21778. */
  21779. getScene(): Scene;
  21780. /**
  21781. * Specifies if the material will require alpha blending
  21782. * @returns a boolean specifying if alpha blending is needed
  21783. */
  21784. needAlphaBlending(): boolean;
  21785. /**
  21786. * Specifies if the mesh will require alpha blending
  21787. * @param mesh defines the mesh to check
  21788. * @returns a boolean specifying if alpha blending is needed for the mesh
  21789. */
  21790. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21791. /**
  21792. * Specifies if this material should be rendered in alpha test mode
  21793. * @returns a boolean specifying if an alpha test is needed.
  21794. */
  21795. needAlphaTesting(): boolean;
  21796. /**
  21797. * Gets the texture used for the alpha test
  21798. * @returns the texture to use for alpha testing
  21799. */
  21800. getAlphaTestTexture(): Nullable<BaseTexture>;
  21801. /**
  21802. * Marks the material to indicate that it needs to be re-calculated
  21803. */
  21804. markDirty(): void;
  21805. /** @hidden */
  21806. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21807. /**
  21808. * Binds the material to the mesh
  21809. * @param world defines the world transformation matrix
  21810. * @param mesh defines the mesh to bind the material to
  21811. */
  21812. bind(world: Matrix, mesh?: Mesh): void;
  21813. /**
  21814. * Binds the submesh to the material
  21815. * @param world defines the world transformation matrix
  21816. * @param mesh defines the mesh containing the submesh
  21817. * @param subMesh defines the submesh to bind the material to
  21818. */
  21819. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21820. /**
  21821. * Binds the world matrix to the material
  21822. * @param world defines the world transformation matrix
  21823. */
  21824. bindOnlyWorldMatrix(world: Matrix): void;
  21825. /**
  21826. * Binds the scene's uniform buffer to the effect.
  21827. * @param effect defines the effect to bind to the scene uniform buffer
  21828. * @param sceneUbo defines the uniform buffer storing scene data
  21829. */
  21830. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21831. /**
  21832. * Binds the view matrix to the effect
  21833. * @param effect defines the effect to bind the view matrix to
  21834. */
  21835. bindView(effect: Effect): void;
  21836. /**
  21837. * Binds the view projection matrix to the effect
  21838. * @param effect defines the effect to bind the view projection matrix to
  21839. */
  21840. bindViewProjection(effect: Effect): void;
  21841. /**
  21842. * Specifies if material alpha testing should be turned on for the mesh
  21843. * @param mesh defines the mesh to check
  21844. */
  21845. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21846. /**
  21847. * Processes to execute after binding the material to a mesh
  21848. * @param mesh defines the rendered mesh
  21849. */
  21850. protected _afterBind(mesh?: Mesh): void;
  21851. /**
  21852. * Unbinds the material from the mesh
  21853. */
  21854. unbind(): void;
  21855. /**
  21856. * Gets the active textures from the material
  21857. * @returns an array of textures
  21858. */
  21859. getActiveTextures(): BaseTexture[];
  21860. /**
  21861. * Specifies if the material uses a texture
  21862. * @param texture defines the texture to check against the material
  21863. * @returns a boolean specifying if the material uses the texture
  21864. */
  21865. hasTexture(texture: BaseTexture): boolean;
  21866. /**
  21867. * Makes a duplicate of the material, and gives it a new name
  21868. * @param name defines the new name for the duplicated material
  21869. * @returns the cloned material
  21870. */
  21871. clone(name: string): Nullable<Material>;
  21872. /**
  21873. * Gets the meshes bound to the material
  21874. * @returns an array of meshes bound to the material
  21875. */
  21876. getBindedMeshes(): AbstractMesh[];
  21877. /**
  21878. * Force shader compilation
  21879. * @param mesh defines the mesh associated with this material
  21880. * @param onCompiled defines a function to execute once the material is compiled
  21881. * @param options defines the options to configure the compilation
  21882. * @param onError defines a function to execute if the material fails compiling
  21883. */
  21884. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21885. /**
  21886. * Force shader compilation
  21887. * @param mesh defines the mesh that will use this material
  21888. * @param options defines additional options for compiling the shaders
  21889. * @returns a promise that resolves when the compilation completes
  21890. */
  21891. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21892. private static readonly _AllDirtyCallBack;
  21893. private static readonly _ImageProcessingDirtyCallBack;
  21894. private static readonly _TextureDirtyCallBack;
  21895. private static readonly _FresnelDirtyCallBack;
  21896. private static readonly _MiscDirtyCallBack;
  21897. private static readonly _LightsDirtyCallBack;
  21898. private static readonly _AttributeDirtyCallBack;
  21899. private static _FresnelAndMiscDirtyCallBack;
  21900. private static _TextureAndMiscDirtyCallBack;
  21901. private static readonly _DirtyCallbackArray;
  21902. private static readonly _RunDirtyCallBacks;
  21903. /**
  21904. * Marks a define in the material to indicate that it needs to be re-computed
  21905. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21906. */
  21907. markAsDirty(flag: number): void;
  21908. /**
  21909. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21910. * @param func defines a function which checks material defines against the submeshes
  21911. */
  21912. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21913. /**
  21914. * Indicates that we need to re-calculated for all submeshes
  21915. */
  21916. protected _markAllSubMeshesAsAllDirty(): void;
  21917. /**
  21918. * Indicates that image processing needs to be re-calculated for all submeshes
  21919. */
  21920. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21921. /**
  21922. * Indicates that textures need to be re-calculated for all submeshes
  21923. */
  21924. protected _markAllSubMeshesAsTexturesDirty(): void;
  21925. /**
  21926. * Indicates that fresnel needs to be re-calculated for all submeshes
  21927. */
  21928. protected _markAllSubMeshesAsFresnelDirty(): void;
  21929. /**
  21930. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21931. */
  21932. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21933. /**
  21934. * Indicates that lights need to be re-calculated for all submeshes
  21935. */
  21936. protected _markAllSubMeshesAsLightsDirty(): void;
  21937. /**
  21938. * Indicates that attributes need to be re-calculated for all submeshes
  21939. */
  21940. protected _markAllSubMeshesAsAttributesDirty(): void;
  21941. /**
  21942. * Indicates that misc needs to be re-calculated for all submeshes
  21943. */
  21944. protected _markAllSubMeshesAsMiscDirty(): void;
  21945. /**
  21946. * Indicates that textures and misc need to be re-calculated for all submeshes
  21947. */
  21948. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21949. /**
  21950. * Disposes the material
  21951. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21952. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21953. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21954. */
  21955. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21956. /** @hidden */
  21957. private releaseVertexArrayObject;
  21958. /**
  21959. * Serializes this material
  21960. * @returns the serialized material object
  21961. */
  21962. serialize(): any;
  21963. /**
  21964. * Creates a material from parsed material data
  21965. * @param parsedMaterial defines parsed material data
  21966. * @param scene defines the hosting scene
  21967. * @param rootUrl defines the root URL to use to load textures
  21968. * @returns a new material
  21969. */
  21970. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21971. }
  21972. }
  21973. declare module "babylonjs/Materials/multiMaterial" {
  21974. import { Nullable } from "babylonjs/types";
  21975. import { Scene } from "babylonjs/scene";
  21976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21977. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21978. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21979. import { Material } from "babylonjs/Materials/material";
  21980. /**
  21981. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21982. * separate meshes. This can be use to improve performances.
  21983. * @see http://doc.babylonjs.com/how_to/multi_materials
  21984. */
  21985. export class MultiMaterial extends Material {
  21986. private _subMaterials;
  21987. /**
  21988. * Gets or Sets the list of Materials used within the multi material.
  21989. * They need to be ordered according to the submeshes order in the associated mesh
  21990. */
  21991. get subMaterials(): Nullable<Material>[];
  21992. set subMaterials(value: Nullable<Material>[]);
  21993. /**
  21994. * Function used to align with Node.getChildren()
  21995. * @returns the list of Materials used within the multi material
  21996. */
  21997. getChildren(): Nullable<Material>[];
  21998. /**
  21999. * Instantiates a new Multi Material
  22000. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22001. * separate meshes. This can be use to improve performances.
  22002. * @see http://doc.babylonjs.com/how_to/multi_materials
  22003. * @param name Define the name in the scene
  22004. * @param scene Define the scene the material belongs to
  22005. */
  22006. constructor(name: string, scene: Scene);
  22007. private _hookArray;
  22008. /**
  22009. * Get one of the submaterial by its index in the submaterials array
  22010. * @param index The index to look the sub material at
  22011. * @returns The Material if the index has been defined
  22012. */
  22013. getSubMaterial(index: number): Nullable<Material>;
  22014. /**
  22015. * Get the list of active textures for the whole sub materials list.
  22016. * @returns All the textures that will be used during the rendering
  22017. */
  22018. getActiveTextures(): BaseTexture[];
  22019. /**
  22020. * Gets the current class name of the material e.g. "MultiMaterial"
  22021. * Mainly use in serialization.
  22022. * @returns the class name
  22023. */
  22024. getClassName(): string;
  22025. /**
  22026. * Checks if the material is ready to render the requested sub mesh
  22027. * @param mesh Define the mesh the submesh belongs to
  22028. * @param subMesh Define the sub mesh to look readyness for
  22029. * @param useInstances Define whether or not the material is used with instances
  22030. * @returns true if ready, otherwise false
  22031. */
  22032. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22033. /**
  22034. * Clones the current material and its related sub materials
  22035. * @param name Define the name of the newly cloned material
  22036. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22037. * @returns the cloned material
  22038. */
  22039. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22040. /**
  22041. * Serializes the materials into a JSON representation.
  22042. * @returns the JSON representation
  22043. */
  22044. serialize(): any;
  22045. /**
  22046. * Dispose the material and release its associated resources
  22047. * @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)
  22048. * @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)
  22049. * @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)
  22050. */
  22051. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22052. /**
  22053. * Creates a MultiMaterial from parsed MultiMaterial data.
  22054. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22055. * @param scene defines the hosting scene
  22056. * @returns a new MultiMaterial
  22057. */
  22058. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22059. }
  22060. }
  22061. declare module "babylonjs/Meshes/subMesh" {
  22062. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22063. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22064. import { Engine } from "babylonjs/Engines/engine";
  22065. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22066. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22067. import { Effect } from "babylonjs/Materials/effect";
  22068. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22069. import { Plane } from "babylonjs/Maths/math.plane";
  22070. import { Collider } from "babylonjs/Collisions/collider";
  22071. import { Material } from "babylonjs/Materials/material";
  22072. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22073. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22074. import { Mesh } from "babylonjs/Meshes/mesh";
  22075. import { Ray } from "babylonjs/Culling/ray";
  22076. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22077. /**
  22078. * Base class for submeshes
  22079. */
  22080. export class BaseSubMesh {
  22081. /** @hidden */
  22082. _materialDefines: Nullable<MaterialDefines>;
  22083. /** @hidden */
  22084. _materialEffect: Nullable<Effect>;
  22085. /**
  22086. * Gets material defines used by the effect associated to the sub mesh
  22087. */
  22088. get materialDefines(): Nullable<MaterialDefines>;
  22089. /**
  22090. * Sets material defines used by the effect associated to the sub mesh
  22091. */
  22092. set materialDefines(defines: Nullable<MaterialDefines>);
  22093. /**
  22094. * Gets associated effect
  22095. */
  22096. get effect(): Nullable<Effect>;
  22097. /**
  22098. * Sets associated effect (effect used to render this submesh)
  22099. * @param effect defines the effect to associate with
  22100. * @param defines defines the set of defines used to compile this effect
  22101. */
  22102. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22103. }
  22104. /**
  22105. * Defines a subdivision inside a mesh
  22106. */
  22107. export class SubMesh extends BaseSubMesh implements ICullable {
  22108. /** the material index to use */
  22109. materialIndex: number;
  22110. /** vertex index start */
  22111. verticesStart: number;
  22112. /** vertices count */
  22113. verticesCount: number;
  22114. /** index start */
  22115. indexStart: number;
  22116. /** indices count */
  22117. indexCount: number;
  22118. /** @hidden */
  22119. _linesIndexCount: number;
  22120. private _mesh;
  22121. private _renderingMesh;
  22122. private _boundingInfo;
  22123. private _linesIndexBuffer;
  22124. /** @hidden */
  22125. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22126. /** @hidden */
  22127. _trianglePlanes: Plane[];
  22128. /** @hidden */
  22129. _lastColliderTransformMatrix: Nullable<Matrix>;
  22130. /** @hidden */
  22131. _renderId: number;
  22132. /** @hidden */
  22133. _alphaIndex: number;
  22134. /** @hidden */
  22135. _distanceToCamera: number;
  22136. /** @hidden */
  22137. _id: number;
  22138. private _currentMaterial;
  22139. /**
  22140. * Add a new submesh to a mesh
  22141. * @param materialIndex defines the material index to use
  22142. * @param verticesStart defines vertex index start
  22143. * @param verticesCount defines vertices count
  22144. * @param indexStart defines index start
  22145. * @param indexCount defines indices count
  22146. * @param mesh defines the parent mesh
  22147. * @param renderingMesh defines an optional rendering mesh
  22148. * @param createBoundingBox defines if bounding box should be created for this submesh
  22149. * @returns the new submesh
  22150. */
  22151. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22152. /**
  22153. * Creates a new submesh
  22154. * @param materialIndex defines the material index to use
  22155. * @param verticesStart defines vertex index start
  22156. * @param verticesCount defines vertices count
  22157. * @param indexStart defines index start
  22158. * @param indexCount defines indices count
  22159. * @param mesh defines the parent mesh
  22160. * @param renderingMesh defines an optional rendering mesh
  22161. * @param createBoundingBox defines if bounding box should be created for this submesh
  22162. */
  22163. constructor(
  22164. /** the material index to use */
  22165. materialIndex: number,
  22166. /** vertex index start */
  22167. verticesStart: number,
  22168. /** vertices count */
  22169. verticesCount: number,
  22170. /** index start */
  22171. indexStart: number,
  22172. /** indices count */
  22173. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22174. /**
  22175. * Returns true if this submesh covers the entire parent mesh
  22176. * @ignorenaming
  22177. */
  22178. get IsGlobal(): boolean;
  22179. /**
  22180. * Returns the submesh BoudingInfo object
  22181. * @returns current bounding info (or mesh's one if the submesh is global)
  22182. */
  22183. getBoundingInfo(): BoundingInfo;
  22184. /**
  22185. * Sets the submesh BoundingInfo
  22186. * @param boundingInfo defines the new bounding info to use
  22187. * @returns the SubMesh
  22188. */
  22189. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22190. /**
  22191. * Returns the mesh of the current submesh
  22192. * @return the parent mesh
  22193. */
  22194. getMesh(): AbstractMesh;
  22195. /**
  22196. * Returns the rendering mesh of the submesh
  22197. * @returns the rendering mesh (could be different from parent mesh)
  22198. */
  22199. getRenderingMesh(): Mesh;
  22200. /**
  22201. * Returns the submesh material
  22202. * @returns null or the current material
  22203. */
  22204. getMaterial(): Nullable<Material>;
  22205. /**
  22206. * Sets a new updated BoundingInfo object to the submesh
  22207. * @param data defines an optional position array to use to determine the bounding info
  22208. * @returns the SubMesh
  22209. */
  22210. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22211. /** @hidden */
  22212. _checkCollision(collider: Collider): boolean;
  22213. /**
  22214. * Updates the submesh BoundingInfo
  22215. * @param world defines the world matrix to use to update the bounding info
  22216. * @returns the submesh
  22217. */
  22218. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22219. /**
  22220. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22221. * @param frustumPlanes defines the frustum planes
  22222. * @returns true if the submesh is intersecting with the frustum
  22223. */
  22224. isInFrustum(frustumPlanes: Plane[]): boolean;
  22225. /**
  22226. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22227. * @param frustumPlanes defines the frustum planes
  22228. * @returns true if the submesh is inside the frustum
  22229. */
  22230. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22231. /**
  22232. * Renders the submesh
  22233. * @param enableAlphaMode defines if alpha needs to be used
  22234. * @returns the submesh
  22235. */
  22236. render(enableAlphaMode: boolean): SubMesh;
  22237. /**
  22238. * @hidden
  22239. */
  22240. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22241. /**
  22242. * Checks if the submesh intersects with a ray
  22243. * @param ray defines the ray to test
  22244. * @returns true is the passed ray intersects the submesh bounding box
  22245. */
  22246. canIntersects(ray: Ray): boolean;
  22247. /**
  22248. * Intersects current submesh with a ray
  22249. * @param ray defines the ray to test
  22250. * @param positions defines mesh's positions array
  22251. * @param indices defines mesh's indices array
  22252. * @param fastCheck defines if only bounding info should be used
  22253. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22254. * @returns intersection info or null if no intersection
  22255. */
  22256. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22257. /** @hidden */
  22258. private _intersectLines;
  22259. /** @hidden */
  22260. private _intersectUnIndexedLines;
  22261. /** @hidden */
  22262. private _intersectTriangles;
  22263. /** @hidden */
  22264. private _intersectUnIndexedTriangles;
  22265. /** @hidden */
  22266. _rebuild(): void;
  22267. /**
  22268. * Creates a new submesh from the passed mesh
  22269. * @param newMesh defines the new hosting mesh
  22270. * @param newRenderingMesh defines an optional rendering mesh
  22271. * @returns the new submesh
  22272. */
  22273. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22274. /**
  22275. * Release associated resources
  22276. */
  22277. dispose(): void;
  22278. /**
  22279. * Gets the class name
  22280. * @returns the string "SubMesh".
  22281. */
  22282. getClassName(): string;
  22283. /**
  22284. * Creates a new submesh from indices data
  22285. * @param materialIndex the index of the main mesh material
  22286. * @param startIndex the index where to start the copy in the mesh indices array
  22287. * @param indexCount the number of indices to copy then from the startIndex
  22288. * @param mesh the main mesh to create the submesh from
  22289. * @param renderingMesh the optional rendering mesh
  22290. * @returns a new submesh
  22291. */
  22292. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22293. }
  22294. }
  22295. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22296. /**
  22297. * Class used to represent data loading progression
  22298. */
  22299. export class SceneLoaderFlags {
  22300. private static _ForceFullSceneLoadingForIncremental;
  22301. private static _ShowLoadingScreen;
  22302. private static _CleanBoneMatrixWeights;
  22303. private static _loggingLevel;
  22304. /**
  22305. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22306. */
  22307. static get ForceFullSceneLoadingForIncremental(): boolean;
  22308. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22309. /**
  22310. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22311. */
  22312. static get ShowLoadingScreen(): boolean;
  22313. static set ShowLoadingScreen(value: boolean);
  22314. /**
  22315. * Defines the current logging level (while loading the scene)
  22316. * @ignorenaming
  22317. */
  22318. static get loggingLevel(): number;
  22319. static set loggingLevel(value: number);
  22320. /**
  22321. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22322. */
  22323. static get CleanBoneMatrixWeights(): boolean;
  22324. static set CleanBoneMatrixWeights(value: boolean);
  22325. }
  22326. }
  22327. declare module "babylonjs/Meshes/geometry" {
  22328. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22329. import { Scene } from "babylonjs/scene";
  22330. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22331. import { Engine } from "babylonjs/Engines/engine";
  22332. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22333. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22334. import { Effect } from "babylonjs/Materials/effect";
  22335. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22336. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22337. import { Mesh } from "babylonjs/Meshes/mesh";
  22338. /**
  22339. * Class used to store geometry data (vertex buffers + index buffer)
  22340. */
  22341. export class Geometry implements IGetSetVerticesData {
  22342. /**
  22343. * Gets or sets the ID of the geometry
  22344. */
  22345. id: string;
  22346. /**
  22347. * Gets or sets the unique ID of the geometry
  22348. */
  22349. uniqueId: number;
  22350. /**
  22351. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22352. */
  22353. delayLoadState: number;
  22354. /**
  22355. * Gets the file containing the data to load when running in delay load state
  22356. */
  22357. delayLoadingFile: Nullable<string>;
  22358. /**
  22359. * Callback called when the geometry is updated
  22360. */
  22361. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22362. private _scene;
  22363. private _engine;
  22364. private _meshes;
  22365. private _totalVertices;
  22366. /** @hidden */
  22367. _indices: IndicesArray;
  22368. /** @hidden */
  22369. _vertexBuffers: {
  22370. [key: string]: VertexBuffer;
  22371. };
  22372. private _isDisposed;
  22373. private _extend;
  22374. private _boundingBias;
  22375. /** @hidden */
  22376. _delayInfo: Array<string>;
  22377. private _indexBuffer;
  22378. private _indexBufferIsUpdatable;
  22379. /** @hidden */
  22380. _boundingInfo: Nullable<BoundingInfo>;
  22381. /** @hidden */
  22382. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22383. /** @hidden */
  22384. _softwareSkinningFrameId: number;
  22385. private _vertexArrayObjects;
  22386. private _updatable;
  22387. /** @hidden */
  22388. _positions: Nullable<Vector3[]>;
  22389. /**
  22390. * 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
  22391. */
  22392. get boundingBias(): Vector2;
  22393. /**
  22394. * 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
  22395. */
  22396. set boundingBias(value: Vector2);
  22397. /**
  22398. * Static function used to attach a new empty geometry to a mesh
  22399. * @param mesh defines the mesh to attach the geometry to
  22400. * @returns the new Geometry
  22401. */
  22402. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22403. /**
  22404. * Creates a new geometry
  22405. * @param id defines the unique ID
  22406. * @param scene defines the hosting scene
  22407. * @param vertexData defines the VertexData used to get geometry data
  22408. * @param updatable defines if geometry must be updatable (false by default)
  22409. * @param mesh defines the mesh that will be associated with the geometry
  22410. */
  22411. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22412. /**
  22413. * Gets the current extend of the geometry
  22414. */
  22415. get extend(): {
  22416. minimum: Vector3;
  22417. maximum: Vector3;
  22418. };
  22419. /**
  22420. * Gets the hosting scene
  22421. * @returns the hosting Scene
  22422. */
  22423. getScene(): Scene;
  22424. /**
  22425. * Gets the hosting engine
  22426. * @returns the hosting Engine
  22427. */
  22428. getEngine(): Engine;
  22429. /**
  22430. * Defines if the geometry is ready to use
  22431. * @returns true if the geometry is ready to be used
  22432. */
  22433. isReady(): boolean;
  22434. /**
  22435. * Gets a value indicating that the geometry should not be serialized
  22436. */
  22437. get doNotSerialize(): boolean;
  22438. /** @hidden */
  22439. _rebuild(): void;
  22440. /**
  22441. * Affects all geometry data in one call
  22442. * @param vertexData defines the geometry data
  22443. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22444. */
  22445. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22446. /**
  22447. * Set specific vertex data
  22448. * @param kind defines the data kind (Position, normal, etc...)
  22449. * @param data defines the vertex data to use
  22450. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22451. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22452. */
  22453. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22454. /**
  22455. * Removes a specific vertex data
  22456. * @param kind defines the data kind (Position, normal, etc...)
  22457. */
  22458. removeVerticesData(kind: string): void;
  22459. /**
  22460. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22461. * @param buffer defines the vertex buffer to use
  22462. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22463. */
  22464. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22465. /**
  22466. * Update a specific vertex buffer
  22467. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22468. * It will do nothing if the buffer is not updatable
  22469. * @param kind defines the data kind (Position, normal, etc...)
  22470. * @param data defines the data to use
  22471. * @param offset defines the offset in the target buffer where to store the data
  22472. * @param useBytes set to true if the offset is in bytes
  22473. */
  22474. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22475. /**
  22476. * Update a specific vertex buffer
  22477. * This function will create a new buffer if the current one is not updatable
  22478. * @param kind defines the data kind (Position, normal, etc...)
  22479. * @param data defines the data to use
  22480. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22481. */
  22482. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22483. private _updateBoundingInfo;
  22484. /** @hidden */
  22485. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22486. /**
  22487. * Gets total number of vertices
  22488. * @returns the total number of vertices
  22489. */
  22490. getTotalVertices(): number;
  22491. /**
  22492. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22493. * @param kind defines the data kind (Position, normal, etc...)
  22494. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22495. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22496. * @returns a float array containing vertex data
  22497. */
  22498. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22499. /**
  22500. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22501. * @param kind defines the data kind (Position, normal, etc...)
  22502. * @returns true if the vertex buffer with the specified kind is updatable
  22503. */
  22504. isVertexBufferUpdatable(kind: string): boolean;
  22505. /**
  22506. * Gets a specific vertex buffer
  22507. * @param kind defines the data kind (Position, normal, etc...)
  22508. * @returns a VertexBuffer
  22509. */
  22510. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22511. /**
  22512. * Returns all vertex buffers
  22513. * @return an object holding all vertex buffers indexed by kind
  22514. */
  22515. getVertexBuffers(): Nullable<{
  22516. [key: string]: VertexBuffer;
  22517. }>;
  22518. /**
  22519. * Gets a boolean indicating if specific vertex buffer is present
  22520. * @param kind defines the data kind (Position, normal, etc...)
  22521. * @returns true if data is present
  22522. */
  22523. isVerticesDataPresent(kind: string): boolean;
  22524. /**
  22525. * Gets a list of all attached data kinds (Position, normal, etc...)
  22526. * @returns a list of string containing all kinds
  22527. */
  22528. getVerticesDataKinds(): string[];
  22529. /**
  22530. * Update index buffer
  22531. * @param indices defines the indices to store in the index buffer
  22532. * @param offset defines the offset in the target buffer where to store the data
  22533. * @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)
  22534. */
  22535. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22536. /**
  22537. * Creates a new index buffer
  22538. * @param indices defines the indices to store in the index buffer
  22539. * @param totalVertices defines the total number of vertices (could be null)
  22540. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22541. */
  22542. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22543. /**
  22544. * Return the total number of indices
  22545. * @returns the total number of indices
  22546. */
  22547. getTotalIndices(): number;
  22548. /**
  22549. * Gets the index buffer array
  22550. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22551. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22552. * @returns the index buffer array
  22553. */
  22554. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22555. /**
  22556. * Gets the index buffer
  22557. * @return the index buffer
  22558. */
  22559. getIndexBuffer(): Nullable<DataBuffer>;
  22560. /** @hidden */
  22561. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22562. /**
  22563. * Release the associated resources for a specific mesh
  22564. * @param mesh defines the source mesh
  22565. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22566. */
  22567. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22568. /**
  22569. * Apply current geometry to a given mesh
  22570. * @param mesh defines the mesh to apply geometry to
  22571. */
  22572. applyToMesh(mesh: Mesh): void;
  22573. private _updateExtend;
  22574. private _applyToMesh;
  22575. private notifyUpdate;
  22576. /**
  22577. * Load the geometry if it was flagged as delay loaded
  22578. * @param scene defines the hosting scene
  22579. * @param onLoaded defines a callback called when the geometry is loaded
  22580. */
  22581. load(scene: Scene, onLoaded?: () => void): void;
  22582. private _queueLoad;
  22583. /**
  22584. * Invert the geometry to move from a right handed system to a left handed one.
  22585. */
  22586. toLeftHanded(): void;
  22587. /** @hidden */
  22588. _resetPointsArrayCache(): void;
  22589. /** @hidden */
  22590. _generatePointsArray(): boolean;
  22591. /**
  22592. * Gets a value indicating if the geometry is disposed
  22593. * @returns true if the geometry was disposed
  22594. */
  22595. isDisposed(): boolean;
  22596. private _disposeVertexArrayObjects;
  22597. /**
  22598. * Free all associated resources
  22599. */
  22600. dispose(): void;
  22601. /**
  22602. * Clone the current geometry into a new geometry
  22603. * @param id defines the unique ID of the new geometry
  22604. * @returns a new geometry object
  22605. */
  22606. copy(id: string): Geometry;
  22607. /**
  22608. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22609. * @return a JSON representation of the current geometry data (without the vertices data)
  22610. */
  22611. serialize(): any;
  22612. private toNumberArray;
  22613. /**
  22614. * Serialize all vertices data into a JSON oject
  22615. * @returns a JSON representation of the current geometry data
  22616. */
  22617. serializeVerticeData(): any;
  22618. /**
  22619. * Extracts a clone of a mesh geometry
  22620. * @param mesh defines the source mesh
  22621. * @param id defines the unique ID of the new geometry object
  22622. * @returns the new geometry object
  22623. */
  22624. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22625. /**
  22626. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22627. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22628. * Be aware Math.random() could cause collisions, but:
  22629. * "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"
  22630. * @returns a string containing a new GUID
  22631. */
  22632. static RandomId(): string;
  22633. /** @hidden */
  22634. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22635. private static _CleanMatricesWeights;
  22636. /**
  22637. * Create a new geometry from persisted data (Using .babylon file format)
  22638. * @param parsedVertexData defines the persisted data
  22639. * @param scene defines the hosting scene
  22640. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22641. * @returns the new geometry object
  22642. */
  22643. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22644. }
  22645. }
  22646. declare module "babylonjs/Meshes/mesh.vertexData" {
  22647. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22648. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22649. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22650. import { Geometry } from "babylonjs/Meshes/geometry";
  22651. import { Mesh } from "babylonjs/Meshes/mesh";
  22652. /**
  22653. * Define an interface for all classes that will get and set the data on vertices
  22654. */
  22655. export interface IGetSetVerticesData {
  22656. /**
  22657. * Gets a boolean indicating if specific vertex data is present
  22658. * @param kind defines the vertex data kind to use
  22659. * @returns true is data kind is present
  22660. */
  22661. isVerticesDataPresent(kind: string): boolean;
  22662. /**
  22663. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22664. * @param kind defines the data kind (Position, normal, etc...)
  22665. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22666. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22667. * @returns a float array containing vertex data
  22668. */
  22669. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22670. /**
  22671. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22672. * @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.
  22673. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22674. * @returns the indices array or an empty array if the mesh has no geometry
  22675. */
  22676. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22677. /**
  22678. * Set specific vertex data
  22679. * @param kind defines the data kind (Position, normal, etc...)
  22680. * @param data defines the vertex data to use
  22681. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22682. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22683. */
  22684. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22685. /**
  22686. * Update a specific associated vertex buffer
  22687. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22688. * - VertexBuffer.PositionKind
  22689. * - VertexBuffer.UVKind
  22690. * - VertexBuffer.UV2Kind
  22691. * - VertexBuffer.UV3Kind
  22692. * - VertexBuffer.UV4Kind
  22693. * - VertexBuffer.UV5Kind
  22694. * - VertexBuffer.UV6Kind
  22695. * - VertexBuffer.ColorKind
  22696. * - VertexBuffer.MatricesIndicesKind
  22697. * - VertexBuffer.MatricesIndicesExtraKind
  22698. * - VertexBuffer.MatricesWeightsKind
  22699. * - VertexBuffer.MatricesWeightsExtraKind
  22700. * @param data defines the data source
  22701. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22702. * @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)
  22703. */
  22704. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22705. /**
  22706. * Creates a new index buffer
  22707. * @param indices defines the indices to store in the index buffer
  22708. * @param totalVertices defines the total number of vertices (could be null)
  22709. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22710. */
  22711. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22712. }
  22713. /**
  22714. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22715. */
  22716. export class VertexData {
  22717. /**
  22718. * Mesh side orientation : usually the external or front surface
  22719. */
  22720. static readonly FRONTSIDE: number;
  22721. /**
  22722. * Mesh side orientation : usually the internal or back surface
  22723. */
  22724. static readonly BACKSIDE: number;
  22725. /**
  22726. * Mesh side orientation : both internal and external or front and back surfaces
  22727. */
  22728. static readonly DOUBLESIDE: number;
  22729. /**
  22730. * Mesh side orientation : by default, `FRONTSIDE`
  22731. */
  22732. static readonly DEFAULTSIDE: number;
  22733. /**
  22734. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22735. */
  22736. positions: Nullable<FloatArray>;
  22737. /**
  22738. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22739. */
  22740. normals: Nullable<FloatArray>;
  22741. /**
  22742. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22743. */
  22744. tangents: Nullable<FloatArray>;
  22745. /**
  22746. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22747. */
  22748. uvs: Nullable<FloatArray>;
  22749. /**
  22750. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22751. */
  22752. uvs2: Nullable<FloatArray>;
  22753. /**
  22754. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22755. */
  22756. uvs3: Nullable<FloatArray>;
  22757. /**
  22758. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22759. */
  22760. uvs4: Nullable<FloatArray>;
  22761. /**
  22762. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22763. */
  22764. uvs5: Nullable<FloatArray>;
  22765. /**
  22766. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22767. */
  22768. uvs6: Nullable<FloatArray>;
  22769. /**
  22770. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22771. */
  22772. colors: Nullable<FloatArray>;
  22773. /**
  22774. * 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).
  22775. */
  22776. matricesIndices: Nullable<FloatArray>;
  22777. /**
  22778. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22779. */
  22780. matricesWeights: Nullable<FloatArray>;
  22781. /**
  22782. * An array extending the number of possible indices
  22783. */
  22784. matricesIndicesExtra: Nullable<FloatArray>;
  22785. /**
  22786. * An array extending the number of possible weights when the number of indices is extended
  22787. */
  22788. matricesWeightsExtra: Nullable<FloatArray>;
  22789. /**
  22790. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22791. */
  22792. indices: Nullable<IndicesArray>;
  22793. /**
  22794. * Uses the passed data array to set the set the values for the specified kind of data
  22795. * @param data a linear array of floating numbers
  22796. * @param kind the type of data that is being set, eg positions, colors etc
  22797. */
  22798. set(data: FloatArray, kind: string): void;
  22799. /**
  22800. * Associates the vertexData to the passed Mesh.
  22801. * Sets it as updatable or not (default `false`)
  22802. * @param mesh the mesh the vertexData is applied to
  22803. * @param updatable when used and having the value true allows new data to update the vertexData
  22804. * @returns the VertexData
  22805. */
  22806. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22807. /**
  22808. * Associates the vertexData to the passed Geometry.
  22809. * Sets it as updatable or not (default `false`)
  22810. * @param geometry the geometry the vertexData is applied to
  22811. * @param updatable when used and having the value true allows new data to update the vertexData
  22812. * @returns VertexData
  22813. */
  22814. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22815. /**
  22816. * Updates the associated mesh
  22817. * @param mesh the mesh to be updated
  22818. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22819. * @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
  22820. * @returns VertexData
  22821. */
  22822. updateMesh(mesh: Mesh): VertexData;
  22823. /**
  22824. * Updates the associated geometry
  22825. * @param geometry the geometry to be updated
  22826. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22827. * @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
  22828. * @returns VertexData.
  22829. */
  22830. updateGeometry(geometry: Geometry): VertexData;
  22831. private _applyTo;
  22832. private _update;
  22833. /**
  22834. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22835. * @param matrix the transforming matrix
  22836. * @returns the VertexData
  22837. */
  22838. transform(matrix: Matrix): VertexData;
  22839. /**
  22840. * Merges the passed VertexData into the current one
  22841. * @param other the VertexData to be merged into the current one
  22842. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22843. * @returns the modified VertexData
  22844. */
  22845. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22846. private _mergeElement;
  22847. private _validate;
  22848. /**
  22849. * Serializes the VertexData
  22850. * @returns a serialized object
  22851. */
  22852. serialize(): any;
  22853. /**
  22854. * Extracts the vertexData from a mesh
  22855. * @param mesh the mesh from which to extract the VertexData
  22856. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22857. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22858. * @returns the object VertexData associated to the passed mesh
  22859. */
  22860. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22861. /**
  22862. * Extracts the vertexData from the geometry
  22863. * @param geometry the geometry from which to extract the VertexData
  22864. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22865. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22866. * @returns the object VertexData associated to the passed mesh
  22867. */
  22868. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22869. private static _ExtractFrom;
  22870. /**
  22871. * Creates the VertexData for a Ribbon
  22872. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22873. * * pathArray array of paths, each of which an array of successive Vector3
  22874. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22875. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22876. * * 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
  22877. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22878. * * 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)
  22879. * * 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)
  22880. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22881. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22882. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22883. * @returns the VertexData of the ribbon
  22884. */
  22885. static CreateRibbon(options: {
  22886. pathArray: Vector3[][];
  22887. closeArray?: boolean;
  22888. closePath?: boolean;
  22889. offset?: number;
  22890. sideOrientation?: number;
  22891. frontUVs?: Vector4;
  22892. backUVs?: Vector4;
  22893. invertUV?: boolean;
  22894. uvs?: Vector2[];
  22895. colors?: Color4[];
  22896. }): VertexData;
  22897. /**
  22898. * Creates the VertexData for a box
  22899. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22900. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22901. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22902. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22903. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22904. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22905. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22906. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22907. * * 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)
  22908. * * 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)
  22909. * @returns the VertexData of the box
  22910. */
  22911. static CreateBox(options: {
  22912. size?: number;
  22913. width?: number;
  22914. height?: number;
  22915. depth?: number;
  22916. faceUV?: Vector4[];
  22917. faceColors?: Color4[];
  22918. sideOrientation?: number;
  22919. frontUVs?: Vector4;
  22920. backUVs?: Vector4;
  22921. }): VertexData;
  22922. /**
  22923. * Creates the VertexData for a tiled box
  22924. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22925. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22926. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22927. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22928. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22929. * @returns the VertexData of the box
  22930. */
  22931. static CreateTiledBox(options: {
  22932. pattern?: number;
  22933. width?: number;
  22934. height?: number;
  22935. depth?: number;
  22936. tileSize?: number;
  22937. tileWidth?: number;
  22938. tileHeight?: number;
  22939. alignHorizontal?: number;
  22940. alignVertical?: number;
  22941. faceUV?: Vector4[];
  22942. faceColors?: Color4[];
  22943. sideOrientation?: number;
  22944. }): VertexData;
  22945. /**
  22946. * Creates the VertexData for a tiled plane
  22947. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22948. * * pattern a limited pattern arrangement depending on the number
  22949. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22950. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22951. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22952. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22953. * * 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)
  22954. * * 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)
  22955. * @returns the VertexData of the tiled plane
  22956. */
  22957. static CreateTiledPlane(options: {
  22958. pattern?: number;
  22959. tileSize?: number;
  22960. tileWidth?: number;
  22961. tileHeight?: number;
  22962. size?: number;
  22963. width?: number;
  22964. height?: number;
  22965. alignHorizontal?: number;
  22966. alignVertical?: number;
  22967. sideOrientation?: number;
  22968. frontUVs?: Vector4;
  22969. backUVs?: Vector4;
  22970. }): VertexData;
  22971. /**
  22972. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22973. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22974. * * segments sets the number of horizontal strips optional, default 32
  22975. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22976. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22977. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22978. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22979. * * 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
  22980. * * 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
  22981. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22982. * * 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)
  22983. * * 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)
  22984. * @returns the VertexData of the ellipsoid
  22985. */
  22986. static CreateSphere(options: {
  22987. segments?: number;
  22988. diameter?: number;
  22989. diameterX?: number;
  22990. diameterY?: number;
  22991. diameterZ?: number;
  22992. arc?: number;
  22993. slice?: number;
  22994. sideOrientation?: number;
  22995. frontUVs?: Vector4;
  22996. backUVs?: Vector4;
  22997. }): VertexData;
  22998. /**
  22999. * Creates the VertexData for a cylinder, cone or prism
  23000. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23001. * * height sets the height (y direction) of the cylinder, optional, default 2
  23002. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23003. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23004. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23005. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23006. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23007. * * 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
  23008. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23009. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23010. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23011. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23012. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23013. * * 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)
  23014. * * 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)
  23015. * @returns the VertexData of the cylinder, cone or prism
  23016. */
  23017. static CreateCylinder(options: {
  23018. height?: number;
  23019. diameterTop?: number;
  23020. diameterBottom?: number;
  23021. diameter?: number;
  23022. tessellation?: number;
  23023. subdivisions?: number;
  23024. arc?: number;
  23025. faceColors?: Color4[];
  23026. faceUV?: Vector4[];
  23027. hasRings?: boolean;
  23028. enclose?: boolean;
  23029. sideOrientation?: number;
  23030. frontUVs?: Vector4;
  23031. backUVs?: Vector4;
  23032. }): VertexData;
  23033. /**
  23034. * Creates the VertexData for a torus
  23035. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23036. * * diameter the diameter of the torus, optional default 1
  23037. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23038. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23039. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23040. * * 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)
  23041. * * 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)
  23042. * @returns the VertexData of the torus
  23043. */
  23044. static CreateTorus(options: {
  23045. diameter?: number;
  23046. thickness?: number;
  23047. tessellation?: number;
  23048. sideOrientation?: number;
  23049. frontUVs?: Vector4;
  23050. backUVs?: Vector4;
  23051. }): VertexData;
  23052. /**
  23053. * Creates the VertexData of the LineSystem
  23054. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23055. * - lines an array of lines, each line being an array of successive Vector3
  23056. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23057. * @returns the VertexData of the LineSystem
  23058. */
  23059. static CreateLineSystem(options: {
  23060. lines: Vector3[][];
  23061. colors?: Nullable<Color4[][]>;
  23062. }): VertexData;
  23063. /**
  23064. * Create the VertexData for a DashedLines
  23065. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23066. * - points an array successive Vector3
  23067. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23068. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23069. * - dashNb the intended total number of dashes, optional, default 200
  23070. * @returns the VertexData for the DashedLines
  23071. */
  23072. static CreateDashedLines(options: {
  23073. points: Vector3[];
  23074. dashSize?: number;
  23075. gapSize?: number;
  23076. dashNb?: number;
  23077. }): VertexData;
  23078. /**
  23079. * Creates the VertexData for a Ground
  23080. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23081. * - width the width (x direction) of the ground, optional, default 1
  23082. * - height the height (z direction) of the ground, optional, default 1
  23083. * - subdivisions the number of subdivisions per side, optional, default 1
  23084. * @returns the VertexData of the Ground
  23085. */
  23086. static CreateGround(options: {
  23087. width?: number;
  23088. height?: number;
  23089. subdivisions?: number;
  23090. subdivisionsX?: number;
  23091. subdivisionsY?: number;
  23092. }): VertexData;
  23093. /**
  23094. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23095. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23096. * * xmin the ground minimum X coordinate, optional, default -1
  23097. * * zmin the ground minimum Z coordinate, optional, default -1
  23098. * * xmax the ground maximum X coordinate, optional, default 1
  23099. * * zmax the ground maximum Z coordinate, optional, default 1
  23100. * * 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}
  23101. * * 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}
  23102. * @returns the VertexData of the TiledGround
  23103. */
  23104. static CreateTiledGround(options: {
  23105. xmin: number;
  23106. zmin: number;
  23107. xmax: number;
  23108. zmax: number;
  23109. subdivisions?: {
  23110. w: number;
  23111. h: number;
  23112. };
  23113. precision?: {
  23114. w: number;
  23115. h: number;
  23116. };
  23117. }): VertexData;
  23118. /**
  23119. * Creates the VertexData of the Ground designed from a heightmap
  23120. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23121. * * width the width (x direction) of the ground
  23122. * * height the height (z direction) of the ground
  23123. * * subdivisions the number of subdivisions per side
  23124. * * minHeight the minimum altitude on the ground, optional, default 0
  23125. * * maxHeight the maximum altitude on the ground, optional default 1
  23126. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23127. * * buffer the array holding the image color data
  23128. * * bufferWidth the width of image
  23129. * * bufferHeight the height of image
  23130. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23131. * @returns the VertexData of the Ground designed from a heightmap
  23132. */
  23133. static CreateGroundFromHeightMap(options: {
  23134. width: number;
  23135. height: number;
  23136. subdivisions: number;
  23137. minHeight: number;
  23138. maxHeight: number;
  23139. colorFilter: Color3;
  23140. buffer: Uint8Array;
  23141. bufferWidth: number;
  23142. bufferHeight: number;
  23143. alphaFilter: number;
  23144. }): VertexData;
  23145. /**
  23146. * Creates the VertexData for a Plane
  23147. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23148. * * size sets the width and height of the plane to the value of size, optional default 1
  23149. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23150. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23151. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23152. * * 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)
  23153. * * 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)
  23154. * @returns the VertexData of the box
  23155. */
  23156. static CreatePlane(options: {
  23157. size?: number;
  23158. width?: number;
  23159. height?: number;
  23160. sideOrientation?: number;
  23161. frontUVs?: Vector4;
  23162. backUVs?: Vector4;
  23163. }): VertexData;
  23164. /**
  23165. * Creates the VertexData of the Disc or regular Polygon
  23166. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23167. * * radius the radius of the disc, optional default 0.5
  23168. * * tessellation the number of polygon sides, optional, default 64
  23169. * * 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
  23170. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23171. * * 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)
  23172. * * 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)
  23173. * @returns the VertexData of the box
  23174. */
  23175. static CreateDisc(options: {
  23176. radius?: number;
  23177. tessellation?: number;
  23178. arc?: number;
  23179. sideOrientation?: number;
  23180. frontUVs?: Vector4;
  23181. backUVs?: Vector4;
  23182. }): VertexData;
  23183. /**
  23184. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23185. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23186. * @param polygon a mesh built from polygonTriangulation.build()
  23187. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23188. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23189. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23190. * @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)
  23191. * @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)
  23192. * @returns the VertexData of the Polygon
  23193. */
  23194. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23195. /**
  23196. * Creates the VertexData of the IcoSphere
  23197. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23198. * * radius the radius of the IcoSphere, optional default 1
  23199. * * radiusX allows stretching in the x direction, optional, default radius
  23200. * * radiusY allows stretching in the y direction, optional, default radius
  23201. * * radiusZ allows stretching in the z direction, optional, default radius
  23202. * * flat when true creates a flat shaded mesh, optional, default true
  23203. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23204. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23205. * * 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)
  23206. * * 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)
  23207. * @returns the VertexData of the IcoSphere
  23208. */
  23209. static CreateIcoSphere(options: {
  23210. radius?: number;
  23211. radiusX?: number;
  23212. radiusY?: number;
  23213. radiusZ?: number;
  23214. flat?: boolean;
  23215. subdivisions?: number;
  23216. sideOrientation?: number;
  23217. frontUVs?: Vector4;
  23218. backUVs?: Vector4;
  23219. }): VertexData;
  23220. /**
  23221. * Creates the VertexData for a Polyhedron
  23222. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23223. * * type provided types are:
  23224. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23225. * * 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)
  23226. * * size the size of the IcoSphere, optional default 1
  23227. * * sizeX allows stretching in the x direction, optional, default size
  23228. * * sizeY allows stretching in the y direction, optional, default size
  23229. * * sizeZ allows stretching in the z direction, optional, default size
  23230. * * 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
  23231. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23232. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23233. * * flat when true creates a flat shaded mesh, optional, default true
  23234. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23235. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23236. * * 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)
  23237. * * 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)
  23238. * @returns the VertexData of the Polyhedron
  23239. */
  23240. static CreatePolyhedron(options: {
  23241. type?: number;
  23242. size?: number;
  23243. sizeX?: number;
  23244. sizeY?: number;
  23245. sizeZ?: number;
  23246. custom?: any;
  23247. faceUV?: Vector4[];
  23248. faceColors?: Color4[];
  23249. flat?: boolean;
  23250. sideOrientation?: number;
  23251. frontUVs?: Vector4;
  23252. backUVs?: Vector4;
  23253. }): VertexData;
  23254. /**
  23255. * Creates the VertexData for a TorusKnot
  23256. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23257. * * radius the radius of the torus knot, optional, default 2
  23258. * * tube the thickness of the tube, optional, default 0.5
  23259. * * radialSegments the number of sides on each tube segments, optional, default 32
  23260. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23261. * * p the number of windings around the z axis, optional, default 2
  23262. * * q the number of windings around the x axis, optional, default 3
  23263. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23264. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23265. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23266. * @returns the VertexData of the Torus Knot
  23267. */
  23268. static CreateTorusKnot(options: {
  23269. radius?: number;
  23270. tube?: number;
  23271. radialSegments?: number;
  23272. tubularSegments?: number;
  23273. p?: number;
  23274. q?: number;
  23275. sideOrientation?: number;
  23276. frontUVs?: Vector4;
  23277. backUVs?: Vector4;
  23278. }): VertexData;
  23279. /**
  23280. * Compute normals for given positions and indices
  23281. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23282. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23283. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23284. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23285. * * facetNormals : optional array of facet normals (vector3)
  23286. * * facetPositions : optional array of facet positions (vector3)
  23287. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23288. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23289. * * bInfo : optional bounding info, required for facetPartitioning computation
  23290. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23291. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23292. * * useRightHandedSystem: optional boolean to for right handed system computation
  23293. * * depthSort : optional boolean to enable the facet depth sort computation
  23294. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23295. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23296. */
  23297. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23298. facetNormals?: any;
  23299. facetPositions?: any;
  23300. facetPartitioning?: any;
  23301. ratio?: number;
  23302. bInfo?: any;
  23303. bbSize?: Vector3;
  23304. subDiv?: any;
  23305. useRightHandedSystem?: boolean;
  23306. depthSort?: boolean;
  23307. distanceTo?: Vector3;
  23308. depthSortedFacets?: any;
  23309. }): void;
  23310. /** @hidden */
  23311. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23312. /**
  23313. * Applies VertexData created from the imported parameters to the geometry
  23314. * @param parsedVertexData the parsed data from an imported file
  23315. * @param geometry the geometry to apply the VertexData to
  23316. */
  23317. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23318. }
  23319. }
  23320. declare module "babylonjs/Morph/morphTarget" {
  23321. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23322. import { Observable } from "babylonjs/Misc/observable";
  23323. import { Nullable, FloatArray } from "babylonjs/types";
  23324. import { Scene } from "babylonjs/scene";
  23325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23326. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23327. /**
  23328. * Defines a target to use with MorphTargetManager
  23329. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23330. */
  23331. export class MorphTarget implements IAnimatable {
  23332. /** defines the name of the target */
  23333. name: string;
  23334. /**
  23335. * Gets or sets the list of animations
  23336. */
  23337. animations: import("babylonjs/Animations/animation").Animation[];
  23338. private _scene;
  23339. private _positions;
  23340. private _normals;
  23341. private _tangents;
  23342. private _uvs;
  23343. private _influence;
  23344. private _uniqueId;
  23345. /**
  23346. * Observable raised when the influence changes
  23347. */
  23348. onInfluenceChanged: Observable<boolean>;
  23349. /** @hidden */
  23350. _onDataLayoutChanged: Observable<void>;
  23351. /**
  23352. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23353. */
  23354. get influence(): number;
  23355. set influence(influence: number);
  23356. /**
  23357. * Gets or sets the id of the morph Target
  23358. */
  23359. id: string;
  23360. private _animationPropertiesOverride;
  23361. /**
  23362. * Gets or sets the animation properties override
  23363. */
  23364. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23365. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23366. /**
  23367. * Creates a new MorphTarget
  23368. * @param name defines the name of the target
  23369. * @param influence defines the influence to use
  23370. * @param scene defines the scene the morphtarget belongs to
  23371. */
  23372. constructor(
  23373. /** defines the name of the target */
  23374. name: string, influence?: number, scene?: Nullable<Scene>);
  23375. /**
  23376. * Gets the unique ID of this manager
  23377. */
  23378. get uniqueId(): number;
  23379. /**
  23380. * Gets a boolean defining if the target contains position data
  23381. */
  23382. get hasPositions(): boolean;
  23383. /**
  23384. * Gets a boolean defining if the target contains normal data
  23385. */
  23386. get hasNormals(): boolean;
  23387. /**
  23388. * Gets a boolean defining if the target contains tangent data
  23389. */
  23390. get hasTangents(): boolean;
  23391. /**
  23392. * Gets a boolean defining if the target contains texture coordinates data
  23393. */
  23394. get hasUVs(): boolean;
  23395. /**
  23396. * Affects position data to this target
  23397. * @param data defines the position data to use
  23398. */
  23399. setPositions(data: Nullable<FloatArray>): void;
  23400. /**
  23401. * Gets the position data stored in this target
  23402. * @returns a FloatArray containing the position data (or null if not present)
  23403. */
  23404. getPositions(): Nullable<FloatArray>;
  23405. /**
  23406. * Affects normal data to this target
  23407. * @param data defines the normal data to use
  23408. */
  23409. setNormals(data: Nullable<FloatArray>): void;
  23410. /**
  23411. * Gets the normal data stored in this target
  23412. * @returns a FloatArray containing the normal data (or null if not present)
  23413. */
  23414. getNormals(): Nullable<FloatArray>;
  23415. /**
  23416. * Affects tangent data to this target
  23417. * @param data defines the tangent data to use
  23418. */
  23419. setTangents(data: Nullable<FloatArray>): void;
  23420. /**
  23421. * Gets the tangent data stored in this target
  23422. * @returns a FloatArray containing the tangent data (or null if not present)
  23423. */
  23424. getTangents(): Nullable<FloatArray>;
  23425. /**
  23426. * Affects texture coordinates data to this target
  23427. * @param data defines the texture coordinates data to use
  23428. */
  23429. setUVs(data: Nullable<FloatArray>): void;
  23430. /**
  23431. * Gets the texture coordinates data stored in this target
  23432. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23433. */
  23434. getUVs(): Nullable<FloatArray>;
  23435. /**
  23436. * Clone the current target
  23437. * @returns a new MorphTarget
  23438. */
  23439. clone(): MorphTarget;
  23440. /**
  23441. * Serializes the current target into a Serialization object
  23442. * @returns the serialized object
  23443. */
  23444. serialize(): any;
  23445. /**
  23446. * Returns the string "MorphTarget"
  23447. * @returns "MorphTarget"
  23448. */
  23449. getClassName(): string;
  23450. /**
  23451. * Creates a new target from serialized data
  23452. * @param serializationObject defines the serialized data to use
  23453. * @returns a new MorphTarget
  23454. */
  23455. static Parse(serializationObject: any): MorphTarget;
  23456. /**
  23457. * Creates a MorphTarget from mesh data
  23458. * @param mesh defines the source mesh
  23459. * @param name defines the name to use for the new target
  23460. * @param influence defines the influence to attach to the target
  23461. * @returns a new MorphTarget
  23462. */
  23463. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23464. }
  23465. }
  23466. declare module "babylonjs/Morph/morphTargetManager" {
  23467. import { Nullable } from "babylonjs/types";
  23468. import { Scene } from "babylonjs/scene";
  23469. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23470. /**
  23471. * This class is used to deform meshes using morphing between different targets
  23472. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23473. */
  23474. export class MorphTargetManager {
  23475. private _targets;
  23476. private _targetInfluenceChangedObservers;
  23477. private _targetDataLayoutChangedObservers;
  23478. private _activeTargets;
  23479. private _scene;
  23480. private _influences;
  23481. private _supportsNormals;
  23482. private _supportsTangents;
  23483. private _supportsUVs;
  23484. private _vertexCount;
  23485. private _uniqueId;
  23486. private _tempInfluences;
  23487. /**
  23488. * Gets or sets a boolean indicating if normals must be morphed
  23489. */
  23490. enableNormalMorphing: boolean;
  23491. /**
  23492. * Gets or sets a boolean indicating if tangents must be morphed
  23493. */
  23494. enableTangentMorphing: boolean;
  23495. /**
  23496. * Gets or sets a boolean indicating if UV must be morphed
  23497. */
  23498. enableUVMorphing: boolean;
  23499. /**
  23500. * Creates a new MorphTargetManager
  23501. * @param scene defines the current scene
  23502. */
  23503. constructor(scene?: Nullable<Scene>);
  23504. /**
  23505. * Gets the unique ID of this manager
  23506. */
  23507. get uniqueId(): number;
  23508. /**
  23509. * Gets the number of vertices handled by this manager
  23510. */
  23511. get vertexCount(): number;
  23512. /**
  23513. * Gets a boolean indicating if this manager supports morphing of normals
  23514. */
  23515. get supportsNormals(): boolean;
  23516. /**
  23517. * Gets a boolean indicating if this manager supports morphing of tangents
  23518. */
  23519. get supportsTangents(): boolean;
  23520. /**
  23521. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23522. */
  23523. get supportsUVs(): boolean;
  23524. /**
  23525. * Gets the number of targets stored in this manager
  23526. */
  23527. get numTargets(): number;
  23528. /**
  23529. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23530. */
  23531. get numInfluencers(): number;
  23532. /**
  23533. * Gets the list of influences (one per target)
  23534. */
  23535. get influences(): Float32Array;
  23536. /**
  23537. * Gets the active target at specified index. An active target is a target with an influence > 0
  23538. * @param index defines the index to check
  23539. * @returns the requested target
  23540. */
  23541. getActiveTarget(index: number): MorphTarget;
  23542. /**
  23543. * Gets the target at specified index
  23544. * @param index defines the index to check
  23545. * @returns the requested target
  23546. */
  23547. getTarget(index: number): MorphTarget;
  23548. /**
  23549. * Add a new target to this manager
  23550. * @param target defines the target to add
  23551. */
  23552. addTarget(target: MorphTarget): void;
  23553. /**
  23554. * Removes a target from the manager
  23555. * @param target defines the target to remove
  23556. */
  23557. removeTarget(target: MorphTarget): void;
  23558. /**
  23559. * Clone the current manager
  23560. * @returns a new MorphTargetManager
  23561. */
  23562. clone(): MorphTargetManager;
  23563. /**
  23564. * Serializes the current manager into a Serialization object
  23565. * @returns the serialized object
  23566. */
  23567. serialize(): any;
  23568. private _syncActiveTargets;
  23569. /**
  23570. * Syncrhonize the targets with all the meshes using this morph target manager
  23571. */
  23572. synchronize(): void;
  23573. /**
  23574. * Creates a new MorphTargetManager from serialized data
  23575. * @param serializationObject defines the serialized data
  23576. * @param scene defines the hosting scene
  23577. * @returns the new MorphTargetManager
  23578. */
  23579. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23580. }
  23581. }
  23582. declare module "babylonjs/Meshes/meshLODLevel" {
  23583. import { Mesh } from "babylonjs/Meshes/mesh";
  23584. import { Nullable } from "babylonjs/types";
  23585. /**
  23586. * Class used to represent a specific level of detail of a mesh
  23587. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23588. */
  23589. export class MeshLODLevel {
  23590. /** Defines the distance where this level should start being displayed */
  23591. distance: number;
  23592. /** Defines the mesh to use to render this level */
  23593. mesh: Nullable<Mesh>;
  23594. /**
  23595. * Creates a new LOD level
  23596. * @param distance defines the distance where this level should star being displayed
  23597. * @param mesh defines the mesh to use to render this level
  23598. */
  23599. constructor(
  23600. /** Defines the distance where this level should start being displayed */
  23601. distance: number,
  23602. /** Defines the mesh to use to render this level */
  23603. mesh: Nullable<Mesh>);
  23604. }
  23605. }
  23606. declare module "babylonjs/Meshes/groundMesh" {
  23607. import { Scene } from "babylonjs/scene";
  23608. import { Vector3 } from "babylonjs/Maths/math.vector";
  23609. import { Mesh } from "babylonjs/Meshes/mesh";
  23610. /**
  23611. * Mesh representing the gorund
  23612. */
  23613. export class GroundMesh extends Mesh {
  23614. /** If octree should be generated */
  23615. generateOctree: boolean;
  23616. private _heightQuads;
  23617. /** @hidden */
  23618. _subdivisionsX: number;
  23619. /** @hidden */
  23620. _subdivisionsY: number;
  23621. /** @hidden */
  23622. _width: number;
  23623. /** @hidden */
  23624. _height: number;
  23625. /** @hidden */
  23626. _minX: number;
  23627. /** @hidden */
  23628. _maxX: number;
  23629. /** @hidden */
  23630. _minZ: number;
  23631. /** @hidden */
  23632. _maxZ: number;
  23633. constructor(name: string, scene: Scene);
  23634. /**
  23635. * "GroundMesh"
  23636. * @returns "GroundMesh"
  23637. */
  23638. getClassName(): string;
  23639. /**
  23640. * The minimum of x and y subdivisions
  23641. */
  23642. get subdivisions(): number;
  23643. /**
  23644. * X subdivisions
  23645. */
  23646. get subdivisionsX(): number;
  23647. /**
  23648. * Y subdivisions
  23649. */
  23650. get subdivisionsY(): number;
  23651. /**
  23652. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23653. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23654. * @param chunksCount the number of subdivisions for x and y
  23655. * @param octreeBlocksSize (Default: 32)
  23656. */
  23657. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23658. /**
  23659. * Returns a height (y) value in the Worl system :
  23660. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23661. * @param x x coordinate
  23662. * @param z z coordinate
  23663. * @returns the ground y position if (x, z) are outside the ground surface.
  23664. */
  23665. getHeightAtCoordinates(x: number, z: number): number;
  23666. /**
  23667. * Returns a normalized vector (Vector3) orthogonal to the ground
  23668. * at the ground coordinates (x, z) expressed in the World system.
  23669. * @param x x coordinate
  23670. * @param z z coordinate
  23671. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23672. */
  23673. getNormalAtCoordinates(x: number, z: number): Vector3;
  23674. /**
  23675. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23676. * at the ground coordinates (x, z) expressed in the World system.
  23677. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23678. * @param x x coordinate
  23679. * @param z z coordinate
  23680. * @param ref vector to store the result
  23681. * @returns the GroundMesh.
  23682. */
  23683. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23684. /**
  23685. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23686. * if the ground has been updated.
  23687. * This can be used in the render loop.
  23688. * @returns the GroundMesh.
  23689. */
  23690. updateCoordinateHeights(): GroundMesh;
  23691. private _getFacetAt;
  23692. private _initHeightQuads;
  23693. private _computeHeightQuads;
  23694. /**
  23695. * Serializes this ground mesh
  23696. * @param serializationObject object to write serialization to
  23697. */
  23698. serialize(serializationObject: any): void;
  23699. /**
  23700. * Parses a serialized ground mesh
  23701. * @param parsedMesh the serialized mesh
  23702. * @param scene the scene to create the ground mesh in
  23703. * @returns the created ground mesh
  23704. */
  23705. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23706. }
  23707. }
  23708. declare module "babylonjs/Physics/physicsJoint" {
  23709. import { Vector3 } from "babylonjs/Maths/math.vector";
  23710. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23711. /**
  23712. * Interface for Physics-Joint data
  23713. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23714. */
  23715. export interface PhysicsJointData {
  23716. /**
  23717. * The main pivot of the joint
  23718. */
  23719. mainPivot?: Vector3;
  23720. /**
  23721. * The connected pivot of the joint
  23722. */
  23723. connectedPivot?: Vector3;
  23724. /**
  23725. * The main axis of the joint
  23726. */
  23727. mainAxis?: Vector3;
  23728. /**
  23729. * The connected axis of the joint
  23730. */
  23731. connectedAxis?: Vector3;
  23732. /**
  23733. * The collision of the joint
  23734. */
  23735. collision?: boolean;
  23736. /**
  23737. * Native Oimo/Cannon/Energy data
  23738. */
  23739. nativeParams?: any;
  23740. }
  23741. /**
  23742. * This is a holder class for the physics joint created by the physics plugin
  23743. * It holds a set of functions to control the underlying joint
  23744. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23745. */
  23746. export class PhysicsJoint {
  23747. /**
  23748. * The type of the physics joint
  23749. */
  23750. type: number;
  23751. /**
  23752. * The data for the physics joint
  23753. */
  23754. jointData: PhysicsJointData;
  23755. private _physicsJoint;
  23756. protected _physicsPlugin: IPhysicsEnginePlugin;
  23757. /**
  23758. * Initializes the physics joint
  23759. * @param type The type of the physics joint
  23760. * @param jointData The data for the physics joint
  23761. */
  23762. constructor(
  23763. /**
  23764. * The type of the physics joint
  23765. */
  23766. type: number,
  23767. /**
  23768. * The data for the physics joint
  23769. */
  23770. jointData: PhysicsJointData);
  23771. /**
  23772. * Gets the physics joint
  23773. */
  23774. get physicsJoint(): any;
  23775. /**
  23776. * Sets the physics joint
  23777. */
  23778. set physicsJoint(newJoint: any);
  23779. /**
  23780. * Sets the physics plugin
  23781. */
  23782. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23783. /**
  23784. * Execute a function that is physics-plugin specific.
  23785. * @param {Function} func the function that will be executed.
  23786. * It accepts two parameters: the physics world and the physics joint
  23787. */
  23788. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23789. /**
  23790. * Distance-Joint type
  23791. */
  23792. static DistanceJoint: number;
  23793. /**
  23794. * Hinge-Joint type
  23795. */
  23796. static HingeJoint: number;
  23797. /**
  23798. * Ball-and-Socket joint type
  23799. */
  23800. static BallAndSocketJoint: number;
  23801. /**
  23802. * Wheel-Joint type
  23803. */
  23804. static WheelJoint: number;
  23805. /**
  23806. * Slider-Joint type
  23807. */
  23808. static SliderJoint: number;
  23809. /**
  23810. * Prismatic-Joint type
  23811. */
  23812. static PrismaticJoint: number;
  23813. /**
  23814. * Universal-Joint type
  23815. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23816. */
  23817. static UniversalJoint: number;
  23818. /**
  23819. * Hinge-Joint 2 type
  23820. */
  23821. static Hinge2Joint: number;
  23822. /**
  23823. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23824. */
  23825. static PointToPointJoint: number;
  23826. /**
  23827. * Spring-Joint type
  23828. */
  23829. static SpringJoint: number;
  23830. /**
  23831. * Lock-Joint type
  23832. */
  23833. static LockJoint: number;
  23834. }
  23835. /**
  23836. * A class representing a physics distance joint
  23837. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23838. */
  23839. export class DistanceJoint extends PhysicsJoint {
  23840. /**
  23841. *
  23842. * @param jointData The data for the Distance-Joint
  23843. */
  23844. constructor(jointData: DistanceJointData);
  23845. /**
  23846. * Update the predefined distance.
  23847. * @param maxDistance The maximum preferred distance
  23848. * @param minDistance The minimum preferred distance
  23849. */
  23850. updateDistance(maxDistance: number, minDistance?: number): void;
  23851. }
  23852. /**
  23853. * Represents a Motor-Enabled Joint
  23854. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23855. */
  23856. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23857. /**
  23858. * Initializes the Motor-Enabled Joint
  23859. * @param type The type of the joint
  23860. * @param jointData The physica joint data for the joint
  23861. */
  23862. constructor(type: number, jointData: PhysicsJointData);
  23863. /**
  23864. * Set the motor values.
  23865. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23866. * @param force the force to apply
  23867. * @param maxForce max force for this motor.
  23868. */
  23869. setMotor(force?: number, maxForce?: number): void;
  23870. /**
  23871. * Set the motor's limits.
  23872. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23873. * @param upperLimit The upper limit of the motor
  23874. * @param lowerLimit The lower limit of the motor
  23875. */
  23876. setLimit(upperLimit: number, lowerLimit?: number): void;
  23877. }
  23878. /**
  23879. * This class represents a single physics Hinge-Joint
  23880. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23881. */
  23882. export class HingeJoint extends MotorEnabledJoint {
  23883. /**
  23884. * Initializes the Hinge-Joint
  23885. * @param jointData The joint data for the Hinge-Joint
  23886. */
  23887. constructor(jointData: PhysicsJointData);
  23888. /**
  23889. * Set the motor values.
  23890. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23891. * @param {number} force the force to apply
  23892. * @param {number} maxForce max force for this motor.
  23893. */
  23894. setMotor(force?: number, maxForce?: number): void;
  23895. /**
  23896. * Set the motor's limits.
  23897. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23898. * @param upperLimit The upper limit of the motor
  23899. * @param lowerLimit The lower limit of the motor
  23900. */
  23901. setLimit(upperLimit: number, lowerLimit?: number): void;
  23902. }
  23903. /**
  23904. * This class represents a dual hinge physics joint (same as wheel joint)
  23905. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23906. */
  23907. export class Hinge2Joint extends MotorEnabledJoint {
  23908. /**
  23909. * Initializes the Hinge2-Joint
  23910. * @param jointData The joint data for the Hinge2-Joint
  23911. */
  23912. constructor(jointData: PhysicsJointData);
  23913. /**
  23914. * Set the motor values.
  23915. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23916. * @param {number} targetSpeed the speed the motor is to reach
  23917. * @param {number} maxForce max force for this motor.
  23918. * @param {motorIndex} the motor's index, 0 or 1.
  23919. */
  23920. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23921. /**
  23922. * Set the motor limits.
  23923. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23924. * @param {number} upperLimit the upper limit
  23925. * @param {number} lowerLimit lower limit
  23926. * @param {motorIndex} the motor's index, 0 or 1.
  23927. */
  23928. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23929. }
  23930. /**
  23931. * Interface for a motor enabled joint
  23932. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23933. */
  23934. export interface IMotorEnabledJoint {
  23935. /**
  23936. * Physics joint
  23937. */
  23938. physicsJoint: any;
  23939. /**
  23940. * Sets the motor of the motor-enabled joint
  23941. * @param force The force of the motor
  23942. * @param maxForce The maximum force of the motor
  23943. * @param motorIndex The index of the motor
  23944. */
  23945. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23946. /**
  23947. * Sets the limit of the motor
  23948. * @param upperLimit The upper limit of the motor
  23949. * @param lowerLimit The lower limit of the motor
  23950. * @param motorIndex The index of the motor
  23951. */
  23952. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23953. }
  23954. /**
  23955. * Joint data for a Distance-Joint
  23956. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23957. */
  23958. export interface DistanceJointData extends PhysicsJointData {
  23959. /**
  23960. * Max distance the 2 joint objects can be apart
  23961. */
  23962. maxDistance: number;
  23963. }
  23964. /**
  23965. * Joint data from a spring joint
  23966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23967. */
  23968. export interface SpringJointData extends PhysicsJointData {
  23969. /**
  23970. * Length of the spring
  23971. */
  23972. length: number;
  23973. /**
  23974. * Stiffness of the spring
  23975. */
  23976. stiffness: number;
  23977. /**
  23978. * Damping of the spring
  23979. */
  23980. damping: number;
  23981. /** this callback will be called when applying the force to the impostors. */
  23982. forceApplicationCallback: () => void;
  23983. }
  23984. }
  23985. declare module "babylonjs/Physics/physicsRaycastResult" {
  23986. import { Vector3 } from "babylonjs/Maths/math.vector";
  23987. /**
  23988. * Holds the data for the raycast result
  23989. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23990. */
  23991. export class PhysicsRaycastResult {
  23992. private _hasHit;
  23993. private _hitDistance;
  23994. private _hitNormalWorld;
  23995. private _hitPointWorld;
  23996. private _rayFromWorld;
  23997. private _rayToWorld;
  23998. /**
  23999. * Gets if there was a hit
  24000. */
  24001. get hasHit(): boolean;
  24002. /**
  24003. * Gets the distance from the hit
  24004. */
  24005. get hitDistance(): number;
  24006. /**
  24007. * Gets the hit normal/direction in the world
  24008. */
  24009. get hitNormalWorld(): Vector3;
  24010. /**
  24011. * Gets the hit point in the world
  24012. */
  24013. get hitPointWorld(): Vector3;
  24014. /**
  24015. * Gets the ray "start point" of the ray in the world
  24016. */
  24017. get rayFromWorld(): Vector3;
  24018. /**
  24019. * Gets the ray "end point" of the ray in the world
  24020. */
  24021. get rayToWorld(): Vector3;
  24022. /**
  24023. * Sets the hit data (normal & point in world space)
  24024. * @param hitNormalWorld defines the normal in world space
  24025. * @param hitPointWorld defines the point in world space
  24026. */
  24027. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24028. /**
  24029. * Sets the distance from the start point to the hit point
  24030. * @param distance
  24031. */
  24032. setHitDistance(distance: number): void;
  24033. /**
  24034. * Calculates the distance manually
  24035. */
  24036. calculateHitDistance(): void;
  24037. /**
  24038. * Resets all the values to default
  24039. * @param from The from point on world space
  24040. * @param to The to point on world space
  24041. */
  24042. reset(from?: Vector3, to?: Vector3): void;
  24043. }
  24044. /**
  24045. * Interface for the size containing width and height
  24046. */
  24047. interface IXYZ {
  24048. /**
  24049. * X
  24050. */
  24051. x: number;
  24052. /**
  24053. * Y
  24054. */
  24055. y: number;
  24056. /**
  24057. * Z
  24058. */
  24059. z: number;
  24060. }
  24061. }
  24062. declare module "babylonjs/Physics/IPhysicsEngine" {
  24063. import { Nullable } from "babylonjs/types";
  24064. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24066. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24067. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24068. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24069. /**
  24070. * Interface used to describe a physics joint
  24071. */
  24072. export interface PhysicsImpostorJoint {
  24073. /** Defines the main impostor to which the joint is linked */
  24074. mainImpostor: PhysicsImpostor;
  24075. /** Defines the impostor that is connected to the main impostor using this joint */
  24076. connectedImpostor: PhysicsImpostor;
  24077. /** Defines the joint itself */
  24078. joint: PhysicsJoint;
  24079. }
  24080. /** @hidden */
  24081. export interface IPhysicsEnginePlugin {
  24082. world: any;
  24083. name: string;
  24084. setGravity(gravity: Vector3): void;
  24085. setTimeStep(timeStep: number): void;
  24086. getTimeStep(): number;
  24087. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24088. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24089. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24090. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24091. removePhysicsBody(impostor: PhysicsImpostor): void;
  24092. generateJoint(joint: PhysicsImpostorJoint): void;
  24093. removeJoint(joint: PhysicsImpostorJoint): void;
  24094. isSupported(): boolean;
  24095. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24096. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24097. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24098. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24099. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24100. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24101. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24102. getBodyMass(impostor: PhysicsImpostor): number;
  24103. getBodyFriction(impostor: PhysicsImpostor): number;
  24104. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24105. getBodyRestitution(impostor: PhysicsImpostor): number;
  24106. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24107. getBodyPressure?(impostor: PhysicsImpostor): number;
  24108. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24109. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24110. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24111. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24112. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24113. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24114. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24115. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24116. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24117. sleepBody(impostor: PhysicsImpostor): void;
  24118. wakeUpBody(impostor: PhysicsImpostor): void;
  24119. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24120. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24121. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24122. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24123. getRadius(impostor: PhysicsImpostor): number;
  24124. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24125. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24126. dispose(): void;
  24127. }
  24128. /**
  24129. * Interface used to define a physics engine
  24130. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24131. */
  24132. export interface IPhysicsEngine {
  24133. /**
  24134. * Gets the gravity vector used by the simulation
  24135. */
  24136. gravity: Vector3;
  24137. /**
  24138. * Sets the gravity vector used by the simulation
  24139. * @param gravity defines the gravity vector to use
  24140. */
  24141. setGravity(gravity: Vector3): void;
  24142. /**
  24143. * Set the time step of the physics engine.
  24144. * Default is 1/60.
  24145. * To slow it down, enter 1/600 for example.
  24146. * To speed it up, 1/30
  24147. * @param newTimeStep the new timestep to apply to this world.
  24148. */
  24149. setTimeStep(newTimeStep: number): void;
  24150. /**
  24151. * Get the time step of the physics engine.
  24152. * @returns the current time step
  24153. */
  24154. getTimeStep(): number;
  24155. /**
  24156. * Set the sub time step of the physics engine.
  24157. * Default is 0 meaning there is no sub steps
  24158. * To increase physics resolution precision, set a small value (like 1 ms)
  24159. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24160. */
  24161. setSubTimeStep(subTimeStep: number): void;
  24162. /**
  24163. * Get the sub time step of the physics engine.
  24164. * @returns the current sub time step
  24165. */
  24166. getSubTimeStep(): number;
  24167. /**
  24168. * Release all resources
  24169. */
  24170. dispose(): void;
  24171. /**
  24172. * Gets the name of the current physics plugin
  24173. * @returns the name of the plugin
  24174. */
  24175. getPhysicsPluginName(): string;
  24176. /**
  24177. * Adding a new impostor for the impostor tracking.
  24178. * This will be done by the impostor itself.
  24179. * @param impostor the impostor to add
  24180. */
  24181. addImpostor(impostor: PhysicsImpostor): void;
  24182. /**
  24183. * Remove an impostor from the engine.
  24184. * This impostor and its mesh will not longer be updated by the physics engine.
  24185. * @param impostor the impostor to remove
  24186. */
  24187. removeImpostor(impostor: PhysicsImpostor): void;
  24188. /**
  24189. * Add a joint to the physics engine
  24190. * @param mainImpostor defines the main impostor to which the joint is added.
  24191. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24192. * @param joint defines the joint that will connect both impostors.
  24193. */
  24194. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24195. /**
  24196. * Removes a joint from the simulation
  24197. * @param mainImpostor defines the impostor used with the joint
  24198. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24199. * @param joint defines the joint to remove
  24200. */
  24201. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24202. /**
  24203. * Gets the current plugin used to run the simulation
  24204. * @returns current plugin
  24205. */
  24206. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24207. /**
  24208. * Gets the list of physic impostors
  24209. * @returns an array of PhysicsImpostor
  24210. */
  24211. getImpostors(): Array<PhysicsImpostor>;
  24212. /**
  24213. * Gets the impostor for a physics enabled object
  24214. * @param object defines the object impersonated by the impostor
  24215. * @returns the PhysicsImpostor or null if not found
  24216. */
  24217. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24218. /**
  24219. * Gets the impostor for a physics body object
  24220. * @param body defines physics body used by the impostor
  24221. * @returns the PhysicsImpostor or null if not found
  24222. */
  24223. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24224. /**
  24225. * Does a raycast in the physics world
  24226. * @param from when should the ray start?
  24227. * @param to when should the ray end?
  24228. * @returns PhysicsRaycastResult
  24229. */
  24230. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24231. /**
  24232. * Called by the scene. No need to call it.
  24233. * @param delta defines the timespam between frames
  24234. */
  24235. _step(delta: number): void;
  24236. }
  24237. }
  24238. declare module "babylonjs/Physics/physicsImpostor" {
  24239. import { Nullable, IndicesArray } from "babylonjs/types";
  24240. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24241. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24243. import { Scene } from "babylonjs/scene";
  24244. import { Bone } from "babylonjs/Bones/bone";
  24245. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24246. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24247. import { Space } from "babylonjs/Maths/math.axis";
  24248. /**
  24249. * The interface for the physics imposter parameters
  24250. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24251. */
  24252. export interface PhysicsImpostorParameters {
  24253. /**
  24254. * The mass of the physics imposter
  24255. */
  24256. mass: number;
  24257. /**
  24258. * The friction of the physics imposter
  24259. */
  24260. friction?: number;
  24261. /**
  24262. * The coefficient of restitution of the physics imposter
  24263. */
  24264. restitution?: number;
  24265. /**
  24266. * The native options of the physics imposter
  24267. */
  24268. nativeOptions?: any;
  24269. /**
  24270. * Specifies if the parent should be ignored
  24271. */
  24272. ignoreParent?: boolean;
  24273. /**
  24274. * Specifies if bi-directional transformations should be disabled
  24275. */
  24276. disableBidirectionalTransformation?: boolean;
  24277. /**
  24278. * The pressure inside the physics imposter, soft object only
  24279. */
  24280. pressure?: number;
  24281. /**
  24282. * The stiffness the physics imposter, soft object only
  24283. */
  24284. stiffness?: number;
  24285. /**
  24286. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24287. */
  24288. velocityIterations?: number;
  24289. /**
  24290. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24291. */
  24292. positionIterations?: number;
  24293. /**
  24294. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24295. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24296. * Add to fix multiple points
  24297. */
  24298. fixedPoints?: number;
  24299. /**
  24300. * The collision margin around a soft object
  24301. */
  24302. margin?: number;
  24303. /**
  24304. * The collision margin around a soft object
  24305. */
  24306. damping?: number;
  24307. /**
  24308. * The path for a rope based on an extrusion
  24309. */
  24310. path?: any;
  24311. /**
  24312. * The shape of an extrusion used for a rope based on an extrusion
  24313. */
  24314. shape?: any;
  24315. }
  24316. /**
  24317. * Interface for a physics-enabled object
  24318. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24319. */
  24320. export interface IPhysicsEnabledObject {
  24321. /**
  24322. * The position of the physics-enabled object
  24323. */
  24324. position: Vector3;
  24325. /**
  24326. * The rotation of the physics-enabled object
  24327. */
  24328. rotationQuaternion: Nullable<Quaternion>;
  24329. /**
  24330. * The scale of the physics-enabled object
  24331. */
  24332. scaling: Vector3;
  24333. /**
  24334. * The rotation of the physics-enabled object
  24335. */
  24336. rotation?: Vector3;
  24337. /**
  24338. * The parent of the physics-enabled object
  24339. */
  24340. parent?: any;
  24341. /**
  24342. * The bounding info of the physics-enabled object
  24343. * @returns The bounding info of the physics-enabled object
  24344. */
  24345. getBoundingInfo(): BoundingInfo;
  24346. /**
  24347. * Computes the world matrix
  24348. * @param force Specifies if the world matrix should be computed by force
  24349. * @returns A world matrix
  24350. */
  24351. computeWorldMatrix(force: boolean): Matrix;
  24352. /**
  24353. * Gets the world matrix
  24354. * @returns A world matrix
  24355. */
  24356. getWorldMatrix?(): Matrix;
  24357. /**
  24358. * Gets the child meshes
  24359. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24360. * @returns An array of abstract meshes
  24361. */
  24362. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24363. /**
  24364. * Gets the vertex data
  24365. * @param kind The type of vertex data
  24366. * @returns A nullable array of numbers, or a float32 array
  24367. */
  24368. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24369. /**
  24370. * Gets the indices from the mesh
  24371. * @returns A nullable array of index arrays
  24372. */
  24373. getIndices?(): Nullable<IndicesArray>;
  24374. /**
  24375. * Gets the scene from the mesh
  24376. * @returns the indices array or null
  24377. */
  24378. getScene?(): Scene;
  24379. /**
  24380. * Gets the absolute position from the mesh
  24381. * @returns the absolute position
  24382. */
  24383. getAbsolutePosition(): Vector3;
  24384. /**
  24385. * Gets the absolute pivot point from the mesh
  24386. * @returns the absolute pivot point
  24387. */
  24388. getAbsolutePivotPoint(): Vector3;
  24389. /**
  24390. * Rotates the mesh
  24391. * @param axis The axis of rotation
  24392. * @param amount The amount of rotation
  24393. * @param space The space of the rotation
  24394. * @returns The rotation transform node
  24395. */
  24396. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24397. /**
  24398. * Translates the mesh
  24399. * @param axis The axis of translation
  24400. * @param distance The distance of translation
  24401. * @param space The space of the translation
  24402. * @returns The transform node
  24403. */
  24404. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24405. /**
  24406. * Sets the absolute position of the mesh
  24407. * @param absolutePosition The absolute position of the mesh
  24408. * @returns The transform node
  24409. */
  24410. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24411. /**
  24412. * Gets the class name of the mesh
  24413. * @returns The class name
  24414. */
  24415. getClassName(): string;
  24416. }
  24417. /**
  24418. * Represents a physics imposter
  24419. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24420. */
  24421. export class PhysicsImpostor {
  24422. /**
  24423. * The physics-enabled object used as the physics imposter
  24424. */
  24425. object: IPhysicsEnabledObject;
  24426. /**
  24427. * The type of the physics imposter
  24428. */
  24429. type: number;
  24430. private _options;
  24431. private _scene?;
  24432. /**
  24433. * The default object size of the imposter
  24434. */
  24435. static DEFAULT_OBJECT_SIZE: Vector3;
  24436. /**
  24437. * The identity quaternion of the imposter
  24438. */
  24439. static IDENTITY_QUATERNION: Quaternion;
  24440. /** @hidden */
  24441. _pluginData: any;
  24442. private _physicsEngine;
  24443. private _physicsBody;
  24444. private _bodyUpdateRequired;
  24445. private _onBeforePhysicsStepCallbacks;
  24446. private _onAfterPhysicsStepCallbacks;
  24447. /** @hidden */
  24448. _onPhysicsCollideCallbacks: Array<{
  24449. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24450. otherImpostors: Array<PhysicsImpostor>;
  24451. }>;
  24452. private _deltaPosition;
  24453. private _deltaRotation;
  24454. private _deltaRotationConjugated;
  24455. /** @hidden */
  24456. _isFromLine: boolean;
  24457. private _parent;
  24458. private _isDisposed;
  24459. private static _tmpVecs;
  24460. private static _tmpQuat;
  24461. /**
  24462. * Specifies if the physics imposter is disposed
  24463. */
  24464. get isDisposed(): boolean;
  24465. /**
  24466. * Gets the mass of the physics imposter
  24467. */
  24468. get mass(): number;
  24469. set mass(value: number);
  24470. /**
  24471. * Gets the coefficient of friction
  24472. */
  24473. get friction(): number;
  24474. /**
  24475. * Sets the coefficient of friction
  24476. */
  24477. set friction(value: number);
  24478. /**
  24479. * Gets the coefficient of restitution
  24480. */
  24481. get restitution(): number;
  24482. /**
  24483. * Sets the coefficient of restitution
  24484. */
  24485. set restitution(value: number);
  24486. /**
  24487. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24488. */
  24489. get pressure(): number;
  24490. /**
  24491. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24492. */
  24493. set pressure(value: number);
  24494. /**
  24495. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24496. */
  24497. get stiffness(): number;
  24498. /**
  24499. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24500. */
  24501. set stiffness(value: number);
  24502. /**
  24503. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24504. */
  24505. get velocityIterations(): number;
  24506. /**
  24507. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24508. */
  24509. set velocityIterations(value: number);
  24510. /**
  24511. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24512. */
  24513. get positionIterations(): number;
  24514. /**
  24515. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24516. */
  24517. set positionIterations(value: number);
  24518. /**
  24519. * The unique id of the physics imposter
  24520. * set by the physics engine when adding this impostor to the array
  24521. */
  24522. uniqueId: number;
  24523. /**
  24524. * @hidden
  24525. */
  24526. soft: boolean;
  24527. /**
  24528. * @hidden
  24529. */
  24530. segments: number;
  24531. private _joints;
  24532. /**
  24533. * Initializes the physics imposter
  24534. * @param object The physics-enabled object used as the physics imposter
  24535. * @param type The type of the physics imposter
  24536. * @param _options The options for the physics imposter
  24537. * @param _scene The Babylon scene
  24538. */
  24539. constructor(
  24540. /**
  24541. * The physics-enabled object used as the physics imposter
  24542. */
  24543. object: IPhysicsEnabledObject,
  24544. /**
  24545. * The type of the physics imposter
  24546. */
  24547. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24548. /**
  24549. * This function will completly initialize this impostor.
  24550. * It will create a new body - but only if this mesh has no parent.
  24551. * If it has, this impostor will not be used other than to define the impostor
  24552. * of the child mesh.
  24553. * @hidden
  24554. */
  24555. _init(): void;
  24556. private _getPhysicsParent;
  24557. /**
  24558. * Should a new body be generated.
  24559. * @returns boolean specifying if body initialization is required
  24560. */
  24561. isBodyInitRequired(): boolean;
  24562. /**
  24563. * Sets the updated scaling
  24564. * @param updated Specifies if the scaling is updated
  24565. */
  24566. setScalingUpdated(): void;
  24567. /**
  24568. * Force a regeneration of this or the parent's impostor's body.
  24569. * Use under cautious - This will remove all joints already implemented.
  24570. */
  24571. forceUpdate(): void;
  24572. /**
  24573. * Gets the body that holds this impostor. Either its own, or its parent.
  24574. */
  24575. get physicsBody(): any;
  24576. /**
  24577. * Get the parent of the physics imposter
  24578. * @returns Physics imposter or null
  24579. */
  24580. get parent(): Nullable<PhysicsImpostor>;
  24581. /**
  24582. * Sets the parent of the physics imposter
  24583. */
  24584. set parent(value: Nullable<PhysicsImpostor>);
  24585. /**
  24586. * Set the physics body. Used mainly by the physics engine/plugin
  24587. */
  24588. set physicsBody(physicsBody: any);
  24589. /**
  24590. * Resets the update flags
  24591. */
  24592. resetUpdateFlags(): void;
  24593. /**
  24594. * Gets the object extend size
  24595. * @returns the object extend size
  24596. */
  24597. getObjectExtendSize(): Vector3;
  24598. /**
  24599. * Gets the object center
  24600. * @returns The object center
  24601. */
  24602. getObjectCenter(): Vector3;
  24603. /**
  24604. * Get a specific parameter from the options parameters
  24605. * @param paramName The object parameter name
  24606. * @returns The object parameter
  24607. */
  24608. getParam(paramName: string): any;
  24609. /**
  24610. * Sets a specific parameter in the options given to the physics plugin
  24611. * @param paramName The parameter name
  24612. * @param value The value of the parameter
  24613. */
  24614. setParam(paramName: string, value: number): void;
  24615. /**
  24616. * Specifically change the body's mass option. Won't recreate the physics body object
  24617. * @param mass The mass of the physics imposter
  24618. */
  24619. setMass(mass: number): void;
  24620. /**
  24621. * Gets the linear velocity
  24622. * @returns linear velocity or null
  24623. */
  24624. getLinearVelocity(): Nullable<Vector3>;
  24625. /**
  24626. * Sets the linear velocity
  24627. * @param velocity linear velocity or null
  24628. */
  24629. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24630. /**
  24631. * Gets the angular velocity
  24632. * @returns angular velocity or null
  24633. */
  24634. getAngularVelocity(): Nullable<Vector3>;
  24635. /**
  24636. * Sets the angular velocity
  24637. * @param velocity The velocity or null
  24638. */
  24639. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24640. /**
  24641. * Execute a function with the physics plugin native code
  24642. * Provide a function the will have two variables - the world object and the physics body object
  24643. * @param func The function to execute with the physics plugin native code
  24644. */
  24645. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24646. /**
  24647. * Register a function that will be executed before the physics world is stepping forward
  24648. * @param func The function to execute before the physics world is stepped forward
  24649. */
  24650. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24651. /**
  24652. * Unregister a function that will be executed before the physics world is stepping forward
  24653. * @param func The function to execute before the physics world is stepped forward
  24654. */
  24655. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24656. /**
  24657. * Register a function that will be executed after the physics step
  24658. * @param func The function to execute after physics step
  24659. */
  24660. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24661. /**
  24662. * Unregisters a function that will be executed after the physics step
  24663. * @param func The function to execute after physics step
  24664. */
  24665. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24666. /**
  24667. * register a function that will be executed when this impostor collides against a different body
  24668. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24669. * @param func Callback that is executed on collision
  24670. */
  24671. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24672. /**
  24673. * Unregisters the physics imposter on contact
  24674. * @param collideAgainst The physics object to collide against
  24675. * @param func Callback to execute on collision
  24676. */
  24677. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24678. private _tmpQuat;
  24679. private _tmpQuat2;
  24680. /**
  24681. * Get the parent rotation
  24682. * @returns The parent rotation
  24683. */
  24684. getParentsRotation(): Quaternion;
  24685. /**
  24686. * this function is executed by the physics engine.
  24687. */
  24688. beforeStep: () => void;
  24689. /**
  24690. * this function is executed by the physics engine
  24691. */
  24692. afterStep: () => void;
  24693. /**
  24694. * Legacy collision detection event support
  24695. */
  24696. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24697. /**
  24698. * event and body object due to cannon's event-based architecture.
  24699. */
  24700. onCollide: (e: {
  24701. body: any;
  24702. }) => void;
  24703. /**
  24704. * Apply a force
  24705. * @param force The force to apply
  24706. * @param contactPoint The contact point for the force
  24707. * @returns The physics imposter
  24708. */
  24709. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24710. /**
  24711. * Apply an impulse
  24712. * @param force The impulse force
  24713. * @param contactPoint The contact point for the impulse force
  24714. * @returns The physics imposter
  24715. */
  24716. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24717. /**
  24718. * A help function to create a joint
  24719. * @param otherImpostor A physics imposter used to create a joint
  24720. * @param jointType The type of joint
  24721. * @param jointData The data for the joint
  24722. * @returns The physics imposter
  24723. */
  24724. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24725. /**
  24726. * Add a joint to this impostor with a different impostor
  24727. * @param otherImpostor A physics imposter used to add a joint
  24728. * @param joint The joint to add
  24729. * @returns The physics imposter
  24730. */
  24731. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24732. /**
  24733. * Add an anchor to a cloth impostor
  24734. * @param otherImpostor rigid impostor to anchor to
  24735. * @param width ratio across width from 0 to 1
  24736. * @param height ratio up height from 0 to 1
  24737. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24738. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24739. * @returns impostor the soft imposter
  24740. */
  24741. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24742. /**
  24743. * Add a hook to a rope impostor
  24744. * @param otherImpostor rigid impostor to anchor to
  24745. * @param length ratio across rope from 0 to 1
  24746. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24747. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24748. * @returns impostor the rope imposter
  24749. */
  24750. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24751. /**
  24752. * Will keep this body still, in a sleep mode.
  24753. * @returns the physics imposter
  24754. */
  24755. sleep(): PhysicsImpostor;
  24756. /**
  24757. * Wake the body up.
  24758. * @returns The physics imposter
  24759. */
  24760. wakeUp(): PhysicsImpostor;
  24761. /**
  24762. * Clones the physics imposter
  24763. * @param newObject The physics imposter clones to this physics-enabled object
  24764. * @returns A nullable physics imposter
  24765. */
  24766. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24767. /**
  24768. * Disposes the physics imposter
  24769. */
  24770. dispose(): void;
  24771. /**
  24772. * Sets the delta position
  24773. * @param position The delta position amount
  24774. */
  24775. setDeltaPosition(position: Vector3): void;
  24776. /**
  24777. * Sets the delta rotation
  24778. * @param rotation The delta rotation amount
  24779. */
  24780. setDeltaRotation(rotation: Quaternion): void;
  24781. /**
  24782. * Gets the box size of the physics imposter and stores the result in the input parameter
  24783. * @param result Stores the box size
  24784. * @returns The physics imposter
  24785. */
  24786. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24787. /**
  24788. * Gets the radius of the physics imposter
  24789. * @returns Radius of the physics imposter
  24790. */
  24791. getRadius(): number;
  24792. /**
  24793. * Sync a bone with this impostor
  24794. * @param bone The bone to sync to the impostor.
  24795. * @param boneMesh The mesh that the bone is influencing.
  24796. * @param jointPivot The pivot of the joint / bone in local space.
  24797. * @param distToJoint Optional distance from the impostor to the joint.
  24798. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24799. */
  24800. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24801. /**
  24802. * Sync impostor to a bone
  24803. * @param bone The bone that the impostor will be synced to.
  24804. * @param boneMesh The mesh that the bone is influencing.
  24805. * @param jointPivot The pivot of the joint / bone in local space.
  24806. * @param distToJoint Optional distance from the impostor to the joint.
  24807. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24808. * @param boneAxis Optional vector3 axis the bone is aligned with
  24809. */
  24810. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24811. /**
  24812. * No-Imposter type
  24813. */
  24814. static NoImpostor: number;
  24815. /**
  24816. * Sphere-Imposter type
  24817. */
  24818. static SphereImpostor: number;
  24819. /**
  24820. * Box-Imposter type
  24821. */
  24822. static BoxImpostor: number;
  24823. /**
  24824. * Plane-Imposter type
  24825. */
  24826. static PlaneImpostor: number;
  24827. /**
  24828. * Mesh-imposter type
  24829. */
  24830. static MeshImpostor: number;
  24831. /**
  24832. * Capsule-Impostor type (Ammo.js plugin only)
  24833. */
  24834. static CapsuleImpostor: number;
  24835. /**
  24836. * Cylinder-Imposter type
  24837. */
  24838. static CylinderImpostor: number;
  24839. /**
  24840. * Particle-Imposter type
  24841. */
  24842. static ParticleImpostor: number;
  24843. /**
  24844. * Heightmap-Imposter type
  24845. */
  24846. static HeightmapImpostor: number;
  24847. /**
  24848. * ConvexHull-Impostor type (Ammo.js plugin only)
  24849. */
  24850. static ConvexHullImpostor: number;
  24851. /**
  24852. * Custom-Imposter type (Ammo.js plugin only)
  24853. */
  24854. static CustomImpostor: number;
  24855. /**
  24856. * Rope-Imposter type
  24857. */
  24858. static RopeImpostor: number;
  24859. /**
  24860. * Cloth-Imposter type
  24861. */
  24862. static ClothImpostor: number;
  24863. /**
  24864. * Softbody-Imposter type
  24865. */
  24866. static SoftbodyImpostor: number;
  24867. }
  24868. }
  24869. declare module "babylonjs/Meshes/mesh" {
  24870. import { Observable } from "babylonjs/Misc/observable";
  24871. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24872. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24873. import { Camera } from "babylonjs/Cameras/camera";
  24874. import { Scene } from "babylonjs/scene";
  24875. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24876. import { Color4 } from "babylonjs/Maths/math.color";
  24877. import { Engine } from "babylonjs/Engines/engine";
  24878. import { Node } from "babylonjs/node";
  24879. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24880. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24881. import { Buffer } from "babylonjs/Meshes/buffer";
  24882. import { Geometry } from "babylonjs/Meshes/geometry";
  24883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24884. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24885. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24886. import { Effect } from "babylonjs/Materials/effect";
  24887. import { Material } from "babylonjs/Materials/material";
  24888. import { Skeleton } from "babylonjs/Bones/skeleton";
  24889. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24890. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24891. import { Path3D } from "babylonjs/Maths/math.path";
  24892. import { Plane } from "babylonjs/Maths/math.plane";
  24893. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24894. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24895. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24896. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24897. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24898. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24899. /**
  24900. * @hidden
  24901. **/
  24902. export class _CreationDataStorage {
  24903. closePath?: boolean;
  24904. closeArray?: boolean;
  24905. idx: number[];
  24906. dashSize: number;
  24907. gapSize: number;
  24908. path3D: Path3D;
  24909. pathArray: Vector3[][];
  24910. arc: number;
  24911. radius: number;
  24912. cap: number;
  24913. tessellation: number;
  24914. }
  24915. /**
  24916. * @hidden
  24917. **/
  24918. class _InstanceDataStorage {
  24919. visibleInstances: any;
  24920. batchCache: _InstancesBatch;
  24921. instancesBufferSize: number;
  24922. instancesBuffer: Nullable<Buffer>;
  24923. instancesData: Float32Array;
  24924. overridenInstanceCount: number;
  24925. isFrozen: boolean;
  24926. previousBatch: Nullable<_InstancesBatch>;
  24927. hardwareInstancedRendering: boolean;
  24928. sideOrientation: number;
  24929. manualUpdate: boolean;
  24930. }
  24931. /**
  24932. * @hidden
  24933. **/
  24934. export class _InstancesBatch {
  24935. mustReturn: boolean;
  24936. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24937. renderSelf: boolean[];
  24938. hardwareInstancedRendering: boolean[];
  24939. }
  24940. /**
  24941. * Class used to represent renderable models
  24942. */
  24943. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24944. /**
  24945. * Mesh side orientation : usually the external or front surface
  24946. */
  24947. static readonly FRONTSIDE: number;
  24948. /**
  24949. * Mesh side orientation : usually the internal or back surface
  24950. */
  24951. static readonly BACKSIDE: number;
  24952. /**
  24953. * Mesh side orientation : both internal and external or front and back surfaces
  24954. */
  24955. static readonly DOUBLESIDE: number;
  24956. /**
  24957. * Mesh side orientation : by default, `FRONTSIDE`
  24958. */
  24959. static readonly DEFAULTSIDE: number;
  24960. /**
  24961. * Mesh cap setting : no cap
  24962. */
  24963. static readonly NO_CAP: number;
  24964. /**
  24965. * Mesh cap setting : one cap at the beginning of the mesh
  24966. */
  24967. static readonly CAP_START: number;
  24968. /**
  24969. * Mesh cap setting : one cap at the end of the mesh
  24970. */
  24971. static readonly CAP_END: number;
  24972. /**
  24973. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24974. */
  24975. static readonly CAP_ALL: number;
  24976. /**
  24977. * Mesh pattern setting : no flip or rotate
  24978. */
  24979. static readonly NO_FLIP: number;
  24980. /**
  24981. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24982. */
  24983. static readonly FLIP_TILE: number;
  24984. /**
  24985. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24986. */
  24987. static readonly ROTATE_TILE: number;
  24988. /**
  24989. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24990. */
  24991. static readonly FLIP_ROW: number;
  24992. /**
  24993. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24994. */
  24995. static readonly ROTATE_ROW: number;
  24996. /**
  24997. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24998. */
  24999. static readonly FLIP_N_ROTATE_TILE: number;
  25000. /**
  25001. * Mesh pattern setting : rotate pattern and rotate
  25002. */
  25003. static readonly FLIP_N_ROTATE_ROW: number;
  25004. /**
  25005. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25006. */
  25007. static readonly CENTER: number;
  25008. /**
  25009. * Mesh tile positioning : part tiles on left
  25010. */
  25011. static readonly LEFT: number;
  25012. /**
  25013. * Mesh tile positioning : part tiles on right
  25014. */
  25015. static readonly RIGHT: number;
  25016. /**
  25017. * Mesh tile positioning : part tiles on top
  25018. */
  25019. static readonly TOP: number;
  25020. /**
  25021. * Mesh tile positioning : part tiles on bottom
  25022. */
  25023. static readonly BOTTOM: number;
  25024. /**
  25025. * Gets the default side orientation.
  25026. * @param orientation the orientation to value to attempt to get
  25027. * @returns the default orientation
  25028. * @hidden
  25029. */
  25030. static _GetDefaultSideOrientation(orientation?: number): number;
  25031. private _internalMeshDataInfo;
  25032. /**
  25033. * An event triggered before rendering the mesh
  25034. */
  25035. get onBeforeRenderObservable(): Observable<Mesh>;
  25036. /**
  25037. * An event triggered before binding the mesh
  25038. */
  25039. get onBeforeBindObservable(): Observable<Mesh>;
  25040. /**
  25041. * An event triggered after rendering the mesh
  25042. */
  25043. get onAfterRenderObservable(): Observable<Mesh>;
  25044. /**
  25045. * An event triggered before drawing the mesh
  25046. */
  25047. get onBeforeDrawObservable(): Observable<Mesh>;
  25048. private _onBeforeDrawObserver;
  25049. /**
  25050. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25051. */
  25052. set onBeforeDraw(callback: () => void);
  25053. get hasInstances(): boolean;
  25054. /**
  25055. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25056. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25057. */
  25058. delayLoadState: number;
  25059. /**
  25060. * Gets the list of instances created from this mesh
  25061. * it is not supposed to be modified manually.
  25062. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25063. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25064. */
  25065. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25066. /**
  25067. * Gets the file containing delay loading data for this mesh
  25068. */
  25069. delayLoadingFile: string;
  25070. /** @hidden */
  25071. _binaryInfo: any;
  25072. /**
  25073. * User defined function used to change how LOD level selection is done
  25074. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25075. */
  25076. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25077. /**
  25078. * Gets or sets the morph target manager
  25079. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25080. */
  25081. get morphTargetManager(): Nullable<MorphTargetManager>;
  25082. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25083. /** @hidden */
  25084. _creationDataStorage: Nullable<_CreationDataStorage>;
  25085. /** @hidden */
  25086. _geometry: Nullable<Geometry>;
  25087. /** @hidden */
  25088. _delayInfo: Array<string>;
  25089. /** @hidden */
  25090. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25091. /** @hidden */
  25092. _instanceDataStorage: _InstanceDataStorage;
  25093. private _effectiveMaterial;
  25094. /** @hidden */
  25095. _shouldGenerateFlatShading: boolean;
  25096. /** @hidden */
  25097. _originalBuilderSideOrientation: number;
  25098. /**
  25099. * Use this property to change the original side orientation defined at construction time
  25100. */
  25101. overrideMaterialSideOrientation: Nullable<number>;
  25102. /**
  25103. * Gets the source mesh (the one used to clone this one from)
  25104. */
  25105. get source(): Nullable<Mesh>;
  25106. /**
  25107. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25108. */
  25109. get isUnIndexed(): boolean;
  25110. set isUnIndexed(value: boolean);
  25111. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25112. get worldMatrixInstancedBuffer(): Float32Array;
  25113. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25114. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25115. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25116. /**
  25117. * @constructor
  25118. * @param name The value used by scene.getMeshByName() to do a lookup.
  25119. * @param scene The scene to add this mesh to.
  25120. * @param parent The parent of this mesh, if it has one
  25121. * @param source An optional Mesh from which geometry is shared, cloned.
  25122. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25123. * When false, achieved by calling a clone(), also passing False.
  25124. * This will make creation of children, recursive.
  25125. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25126. */
  25127. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25128. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25129. doNotInstantiate: boolean;
  25130. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25131. /**
  25132. * Gets the class name
  25133. * @returns the string "Mesh".
  25134. */
  25135. getClassName(): string;
  25136. /** @hidden */
  25137. get _isMesh(): boolean;
  25138. /**
  25139. * Returns a description of this mesh
  25140. * @param fullDetails define if full details about this mesh must be used
  25141. * @returns a descriptive string representing this mesh
  25142. */
  25143. toString(fullDetails?: boolean): string;
  25144. /** @hidden */
  25145. _unBindEffect(): void;
  25146. /**
  25147. * Gets a boolean indicating if this mesh has LOD
  25148. */
  25149. get hasLODLevels(): boolean;
  25150. /**
  25151. * Gets the list of MeshLODLevel associated with the current mesh
  25152. * @returns an array of MeshLODLevel
  25153. */
  25154. getLODLevels(): MeshLODLevel[];
  25155. private _sortLODLevels;
  25156. /**
  25157. * Add a mesh as LOD level triggered at the given distance.
  25158. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25159. * @param distance The distance from the center of the object to show this level
  25160. * @param mesh The mesh to be added as LOD level (can be null)
  25161. * @return This mesh (for chaining)
  25162. */
  25163. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25164. /**
  25165. * Returns the LOD level mesh at the passed distance or null if not found.
  25166. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25167. * @param distance The distance from the center of the object to show this level
  25168. * @returns a Mesh or `null`
  25169. */
  25170. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25171. /**
  25172. * Remove a mesh from the LOD array
  25173. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25174. * @param mesh defines the mesh to be removed
  25175. * @return This mesh (for chaining)
  25176. */
  25177. removeLODLevel(mesh: Mesh): Mesh;
  25178. /**
  25179. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25180. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25181. * @param camera defines the camera to use to compute distance
  25182. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25183. * @return This mesh (for chaining)
  25184. */
  25185. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25186. /**
  25187. * Gets the mesh internal Geometry object
  25188. */
  25189. get geometry(): Nullable<Geometry>;
  25190. /**
  25191. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25192. * @returns the total number of vertices
  25193. */
  25194. getTotalVertices(): number;
  25195. /**
  25196. * Returns the content of an associated vertex buffer
  25197. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25198. * - VertexBuffer.PositionKind
  25199. * - VertexBuffer.UVKind
  25200. * - VertexBuffer.UV2Kind
  25201. * - VertexBuffer.UV3Kind
  25202. * - VertexBuffer.UV4Kind
  25203. * - VertexBuffer.UV5Kind
  25204. * - VertexBuffer.UV6Kind
  25205. * - VertexBuffer.ColorKind
  25206. * - VertexBuffer.MatricesIndicesKind
  25207. * - VertexBuffer.MatricesIndicesExtraKind
  25208. * - VertexBuffer.MatricesWeightsKind
  25209. * - VertexBuffer.MatricesWeightsExtraKind
  25210. * @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
  25211. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25212. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25213. */
  25214. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25215. /**
  25216. * Returns the mesh VertexBuffer object from the requested `kind`
  25217. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25218. * - VertexBuffer.PositionKind
  25219. * - VertexBuffer.NormalKind
  25220. * - VertexBuffer.UVKind
  25221. * - VertexBuffer.UV2Kind
  25222. * - VertexBuffer.UV3Kind
  25223. * - VertexBuffer.UV4Kind
  25224. * - VertexBuffer.UV5Kind
  25225. * - VertexBuffer.UV6Kind
  25226. * - VertexBuffer.ColorKind
  25227. * - VertexBuffer.MatricesIndicesKind
  25228. * - VertexBuffer.MatricesIndicesExtraKind
  25229. * - VertexBuffer.MatricesWeightsKind
  25230. * - VertexBuffer.MatricesWeightsExtraKind
  25231. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25232. */
  25233. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25234. /**
  25235. * Tests if a specific vertex buffer is associated with this mesh
  25236. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25237. * - VertexBuffer.PositionKind
  25238. * - VertexBuffer.NormalKind
  25239. * - VertexBuffer.UVKind
  25240. * - VertexBuffer.UV2Kind
  25241. * - VertexBuffer.UV3Kind
  25242. * - VertexBuffer.UV4Kind
  25243. * - VertexBuffer.UV5Kind
  25244. * - VertexBuffer.UV6Kind
  25245. * - VertexBuffer.ColorKind
  25246. * - VertexBuffer.MatricesIndicesKind
  25247. * - VertexBuffer.MatricesIndicesExtraKind
  25248. * - VertexBuffer.MatricesWeightsKind
  25249. * - VertexBuffer.MatricesWeightsExtraKind
  25250. * @returns a boolean
  25251. */
  25252. isVerticesDataPresent(kind: string): boolean;
  25253. /**
  25254. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25255. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25256. * - VertexBuffer.PositionKind
  25257. * - VertexBuffer.UVKind
  25258. * - VertexBuffer.UV2Kind
  25259. * - VertexBuffer.UV3Kind
  25260. * - VertexBuffer.UV4Kind
  25261. * - VertexBuffer.UV5Kind
  25262. * - VertexBuffer.UV6Kind
  25263. * - VertexBuffer.ColorKind
  25264. * - VertexBuffer.MatricesIndicesKind
  25265. * - VertexBuffer.MatricesIndicesExtraKind
  25266. * - VertexBuffer.MatricesWeightsKind
  25267. * - VertexBuffer.MatricesWeightsExtraKind
  25268. * @returns a boolean
  25269. */
  25270. isVertexBufferUpdatable(kind: string): boolean;
  25271. /**
  25272. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25273. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25274. * - VertexBuffer.PositionKind
  25275. * - VertexBuffer.NormalKind
  25276. * - VertexBuffer.UVKind
  25277. * - VertexBuffer.UV2Kind
  25278. * - VertexBuffer.UV3Kind
  25279. * - VertexBuffer.UV4Kind
  25280. * - VertexBuffer.UV5Kind
  25281. * - VertexBuffer.UV6Kind
  25282. * - VertexBuffer.ColorKind
  25283. * - VertexBuffer.MatricesIndicesKind
  25284. * - VertexBuffer.MatricesIndicesExtraKind
  25285. * - VertexBuffer.MatricesWeightsKind
  25286. * - VertexBuffer.MatricesWeightsExtraKind
  25287. * @returns an array of strings
  25288. */
  25289. getVerticesDataKinds(): string[];
  25290. /**
  25291. * Returns a positive integer : the total number of indices in this mesh geometry.
  25292. * @returns the numner of indices or zero if the mesh has no geometry.
  25293. */
  25294. getTotalIndices(): number;
  25295. /**
  25296. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25297. * @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.
  25298. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25299. * @returns the indices array or an empty array if the mesh has no geometry
  25300. */
  25301. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25302. get isBlocked(): boolean;
  25303. /**
  25304. * Determine if the current mesh is ready to be rendered
  25305. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25306. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25307. * @returns true if all associated assets are ready (material, textures, shaders)
  25308. */
  25309. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25310. /**
  25311. * 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.
  25312. */
  25313. get areNormalsFrozen(): boolean;
  25314. /**
  25315. * 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.
  25316. * @returns the current mesh
  25317. */
  25318. freezeNormals(): Mesh;
  25319. /**
  25320. * 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
  25321. * @returns the current mesh
  25322. */
  25323. unfreezeNormals(): Mesh;
  25324. /**
  25325. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25326. */
  25327. set overridenInstanceCount(count: number);
  25328. /** @hidden */
  25329. _preActivate(): Mesh;
  25330. /** @hidden */
  25331. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25332. /** @hidden */
  25333. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25334. /**
  25335. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25336. * This means the mesh underlying bounding box and sphere are recomputed.
  25337. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25338. * @returns the current mesh
  25339. */
  25340. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25341. /** @hidden */
  25342. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25343. /**
  25344. * This function will subdivide the mesh into multiple submeshes
  25345. * @param count defines the expected number of submeshes
  25346. */
  25347. subdivide(count: number): void;
  25348. /**
  25349. * Copy a FloatArray into a specific associated vertex buffer
  25350. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25351. * - VertexBuffer.PositionKind
  25352. * - VertexBuffer.UVKind
  25353. * - VertexBuffer.UV2Kind
  25354. * - VertexBuffer.UV3Kind
  25355. * - VertexBuffer.UV4Kind
  25356. * - VertexBuffer.UV5Kind
  25357. * - VertexBuffer.UV6Kind
  25358. * - VertexBuffer.ColorKind
  25359. * - VertexBuffer.MatricesIndicesKind
  25360. * - VertexBuffer.MatricesIndicesExtraKind
  25361. * - VertexBuffer.MatricesWeightsKind
  25362. * - VertexBuffer.MatricesWeightsExtraKind
  25363. * @param data defines the data source
  25364. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25365. * @param stride defines the data stride size (can be null)
  25366. * @returns the current mesh
  25367. */
  25368. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25369. /**
  25370. * Delete a vertex buffer associated with this mesh
  25371. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25372. * - VertexBuffer.PositionKind
  25373. * - VertexBuffer.UVKind
  25374. * - VertexBuffer.UV2Kind
  25375. * - VertexBuffer.UV3Kind
  25376. * - VertexBuffer.UV4Kind
  25377. * - VertexBuffer.UV5Kind
  25378. * - VertexBuffer.UV6Kind
  25379. * - VertexBuffer.ColorKind
  25380. * - VertexBuffer.MatricesIndicesKind
  25381. * - VertexBuffer.MatricesIndicesExtraKind
  25382. * - VertexBuffer.MatricesWeightsKind
  25383. * - VertexBuffer.MatricesWeightsExtraKind
  25384. */
  25385. removeVerticesData(kind: string): void;
  25386. /**
  25387. * Flags an associated vertex buffer as updatable
  25388. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25389. * - VertexBuffer.PositionKind
  25390. * - VertexBuffer.UVKind
  25391. * - VertexBuffer.UV2Kind
  25392. * - VertexBuffer.UV3Kind
  25393. * - VertexBuffer.UV4Kind
  25394. * - VertexBuffer.UV5Kind
  25395. * - VertexBuffer.UV6Kind
  25396. * - VertexBuffer.ColorKind
  25397. * - VertexBuffer.MatricesIndicesKind
  25398. * - VertexBuffer.MatricesIndicesExtraKind
  25399. * - VertexBuffer.MatricesWeightsKind
  25400. * - VertexBuffer.MatricesWeightsExtraKind
  25401. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25402. */
  25403. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25404. /**
  25405. * Sets the mesh global Vertex Buffer
  25406. * @param buffer defines the buffer to use
  25407. * @returns the current mesh
  25408. */
  25409. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25410. /**
  25411. * Update a specific associated vertex buffer
  25412. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25413. * - VertexBuffer.PositionKind
  25414. * - VertexBuffer.UVKind
  25415. * - VertexBuffer.UV2Kind
  25416. * - VertexBuffer.UV3Kind
  25417. * - VertexBuffer.UV4Kind
  25418. * - VertexBuffer.UV5Kind
  25419. * - VertexBuffer.UV6Kind
  25420. * - VertexBuffer.ColorKind
  25421. * - VertexBuffer.MatricesIndicesKind
  25422. * - VertexBuffer.MatricesIndicesExtraKind
  25423. * - VertexBuffer.MatricesWeightsKind
  25424. * - VertexBuffer.MatricesWeightsExtraKind
  25425. * @param data defines the data source
  25426. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25427. * @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)
  25428. * @returns the current mesh
  25429. */
  25430. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25431. /**
  25432. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25433. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25434. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25435. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25436. * @returns the current mesh
  25437. */
  25438. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25439. /**
  25440. * Creates a un-shared specific occurence of the geometry for the mesh.
  25441. * @returns the current mesh
  25442. */
  25443. makeGeometryUnique(): Mesh;
  25444. /**
  25445. * Set the index buffer of this mesh
  25446. * @param indices defines the source data
  25447. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25448. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25449. * @returns the current mesh
  25450. */
  25451. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25452. /**
  25453. * Update the current index buffer
  25454. * @param indices defines the source data
  25455. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25456. * @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)
  25457. * @returns the current mesh
  25458. */
  25459. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25460. /**
  25461. * Invert the geometry to move from a right handed system to a left handed one.
  25462. * @returns the current mesh
  25463. */
  25464. toLeftHanded(): Mesh;
  25465. /** @hidden */
  25466. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25467. /** @hidden */
  25468. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25469. /**
  25470. * Registers for this mesh a javascript function called just before the rendering process
  25471. * @param func defines the function to call before rendering this mesh
  25472. * @returns the current mesh
  25473. */
  25474. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25475. /**
  25476. * Disposes a previously registered javascript function called before the rendering
  25477. * @param func defines the function to remove
  25478. * @returns the current mesh
  25479. */
  25480. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25481. /**
  25482. * Registers for this mesh a javascript function called just after the rendering is complete
  25483. * @param func defines the function to call after rendering this mesh
  25484. * @returns the current mesh
  25485. */
  25486. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25487. /**
  25488. * Disposes a previously registered javascript function called after the rendering.
  25489. * @param func defines the function to remove
  25490. * @returns the current mesh
  25491. */
  25492. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25493. /** @hidden */
  25494. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25495. /** @hidden */
  25496. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25497. /** @hidden */
  25498. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25499. /** @hidden */
  25500. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25501. /** @hidden */
  25502. _rebuild(): void;
  25503. /** @hidden */
  25504. _freeze(): void;
  25505. /** @hidden */
  25506. _unFreeze(): void;
  25507. /**
  25508. * 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
  25509. * @param subMesh defines the subMesh to render
  25510. * @param enableAlphaMode defines if alpha mode can be changed
  25511. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25512. * @returns the current mesh
  25513. */
  25514. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25515. private _onBeforeDraw;
  25516. /**
  25517. * Renormalize the mesh and patch it up if there are no weights
  25518. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25519. * However in the case of zero weights then we set just a single influence to 1.
  25520. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25521. */
  25522. cleanMatrixWeights(): void;
  25523. private normalizeSkinFourWeights;
  25524. private normalizeSkinWeightsAndExtra;
  25525. /**
  25526. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25527. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25528. * the user know there was an issue with importing the mesh
  25529. * @returns a validation object with skinned, valid and report string
  25530. */
  25531. validateSkinning(): {
  25532. skinned: boolean;
  25533. valid: boolean;
  25534. report: string;
  25535. };
  25536. /** @hidden */
  25537. _checkDelayState(): Mesh;
  25538. private _queueLoad;
  25539. /**
  25540. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25541. * A mesh is in the frustum if its bounding box intersects the frustum
  25542. * @param frustumPlanes defines the frustum to test
  25543. * @returns true if the mesh is in the frustum planes
  25544. */
  25545. isInFrustum(frustumPlanes: Plane[]): boolean;
  25546. /**
  25547. * Sets the mesh material by the material or multiMaterial `id` property
  25548. * @param id is a string identifying the material or the multiMaterial
  25549. * @returns the current mesh
  25550. */
  25551. setMaterialByID(id: string): Mesh;
  25552. /**
  25553. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25554. * @returns an array of IAnimatable
  25555. */
  25556. getAnimatables(): IAnimatable[];
  25557. /**
  25558. * Modifies the mesh geometry according to the passed transformation matrix.
  25559. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25560. * The mesh normals are modified using the same transformation.
  25561. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25562. * @param transform defines the transform matrix to use
  25563. * @see http://doc.babylonjs.com/resources/baking_transformations
  25564. * @returns the current mesh
  25565. */
  25566. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25567. /**
  25568. * Modifies the mesh geometry according to its own current World Matrix.
  25569. * The mesh World Matrix is then reset.
  25570. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25571. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25572. * @see http://doc.babylonjs.com/resources/baking_transformations
  25573. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25574. * @returns the current mesh
  25575. */
  25576. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25577. /** @hidden */
  25578. get _positions(): Nullable<Vector3[]>;
  25579. /** @hidden */
  25580. _resetPointsArrayCache(): Mesh;
  25581. /** @hidden */
  25582. _generatePointsArray(): boolean;
  25583. /**
  25584. * Returns a new Mesh object generated from the current mesh properties.
  25585. * This method must not get confused with createInstance()
  25586. * @param name is a string, the name given to the new mesh
  25587. * @param newParent can be any Node object (default `null`)
  25588. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25589. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25590. * @returns a new mesh
  25591. */
  25592. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25593. /**
  25594. * Releases resources associated with this mesh.
  25595. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25596. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25597. */
  25598. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25599. /** @hidden */
  25600. _disposeInstanceSpecificData(): void;
  25601. /**
  25602. * Modifies the mesh geometry according to a displacement map.
  25603. * 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.
  25604. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25605. * @param url is a string, the URL from the image file is to be downloaded.
  25606. * @param minHeight is the lower limit of the displacement.
  25607. * @param maxHeight is the upper limit of the displacement.
  25608. * @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.
  25609. * @param uvOffset is an optional vector2 used to offset UV.
  25610. * @param uvScale is an optional vector2 used to scale UV.
  25611. * @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.
  25612. * @returns the Mesh.
  25613. */
  25614. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25615. /**
  25616. * Modifies the mesh geometry according to a displacementMap buffer.
  25617. * 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.
  25618. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25619. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25620. * @param heightMapWidth is the width of the buffer image.
  25621. * @param heightMapHeight is the height of the buffer image.
  25622. * @param minHeight is the lower limit of the displacement.
  25623. * @param maxHeight is the upper limit of the displacement.
  25624. * @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.
  25625. * @param uvOffset is an optional vector2 used to offset UV.
  25626. * @param uvScale is an optional vector2 used to scale UV.
  25627. * @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.
  25628. * @returns the Mesh.
  25629. */
  25630. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25631. /**
  25632. * Modify the mesh to get a flat shading rendering.
  25633. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25634. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25635. * @returns current mesh
  25636. */
  25637. convertToFlatShadedMesh(): Mesh;
  25638. /**
  25639. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25640. * In other words, more vertices, no more indices and a single bigger VBO.
  25641. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25642. * @returns current mesh
  25643. */
  25644. convertToUnIndexedMesh(): Mesh;
  25645. /**
  25646. * Inverses facet orientations.
  25647. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25648. * @param flipNormals will also inverts the normals
  25649. * @returns current mesh
  25650. */
  25651. flipFaces(flipNormals?: boolean): Mesh;
  25652. /**
  25653. * Increase the number of facets and hence vertices in a mesh
  25654. * Vertex normals are interpolated from existing vertex normals
  25655. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25656. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25657. */
  25658. increaseVertices(numberPerEdge: number): void;
  25659. /**
  25660. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25661. * This will undo any application of covertToFlatShadedMesh
  25662. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25663. */
  25664. forceSharedVertices(): void;
  25665. /** @hidden */
  25666. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25667. /** @hidden */
  25668. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25669. /**
  25670. * Creates a new InstancedMesh object from the mesh model.
  25671. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25672. * @param name defines the name of the new instance
  25673. * @returns a new InstancedMesh
  25674. */
  25675. createInstance(name: string): InstancedMesh;
  25676. /**
  25677. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25678. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25679. * @returns the current mesh
  25680. */
  25681. synchronizeInstances(): Mesh;
  25682. /**
  25683. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25684. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25685. * This should be used together with the simplification to avoid disappearing triangles.
  25686. * @param successCallback an optional success callback to be called after the optimization finished.
  25687. * @returns the current mesh
  25688. */
  25689. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25690. /**
  25691. * Serialize current mesh
  25692. * @param serializationObject defines the object which will receive the serialization data
  25693. */
  25694. serialize(serializationObject: any): void;
  25695. /** @hidden */
  25696. _syncGeometryWithMorphTargetManager(): void;
  25697. /** @hidden */
  25698. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25699. /**
  25700. * Returns a new Mesh object parsed from the source provided.
  25701. * @param parsedMesh is the source
  25702. * @param scene defines the hosting scene
  25703. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25704. * @returns a new Mesh
  25705. */
  25706. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25707. /**
  25708. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25709. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25710. * @param name defines the name of the mesh to create
  25711. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25712. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25713. * @param closePath creates a seam between the first and the last points of each path of the path array
  25714. * @param offset is taken in account only if the `pathArray` is containing a single path
  25715. * @param scene defines the hosting scene
  25716. * @param updatable defines if the mesh must be flagged as updatable
  25717. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25718. * @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)
  25719. * @returns a new Mesh
  25720. */
  25721. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25722. /**
  25723. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25724. * @param name defines the name of the mesh to create
  25725. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25726. * @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
  25727. * @param scene defines the hosting scene
  25728. * @param updatable defines if the mesh must be flagged as updatable
  25729. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25730. * @returns a new Mesh
  25731. */
  25732. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25733. /**
  25734. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25735. * @param name defines the name of the mesh to create
  25736. * @param size sets the size (float) of each box side (default 1)
  25737. * @param scene defines the hosting scene
  25738. * @param updatable defines if the mesh must be flagged as updatable
  25739. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25740. * @returns a new Mesh
  25741. */
  25742. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25743. /**
  25744. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25745. * @param name defines the name of the mesh to create
  25746. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25747. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25748. * @param scene defines the hosting scene
  25749. * @param updatable defines if the mesh must be flagged as updatable
  25750. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25751. * @returns a new Mesh
  25752. */
  25753. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25754. /**
  25755. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25756. * @param name defines the name of the mesh to create
  25757. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25758. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25759. * @param scene defines the hosting scene
  25760. * @returns a new Mesh
  25761. */
  25762. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25763. /**
  25764. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25765. * @param name defines the name of the mesh to create
  25766. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25767. * @param diameterTop set the top cap diameter (floats, default 1)
  25768. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25769. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25770. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25771. * @param scene defines the hosting scene
  25772. * @param updatable defines if the mesh must be flagged as updatable
  25773. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25774. * @returns a new Mesh
  25775. */
  25776. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25777. /**
  25778. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25779. * @param name defines the name of the mesh to create
  25780. * @param diameter sets the diameter size (float) of the torus (default 1)
  25781. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25782. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25783. * @param scene defines the hosting scene
  25784. * @param updatable defines if the mesh must be flagged as updatable
  25785. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25786. * @returns a new Mesh
  25787. */
  25788. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25789. /**
  25790. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25791. * @param name defines the name of the mesh to create
  25792. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25793. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25794. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25795. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25796. * @param p the number of windings on X axis (positive integers, default 2)
  25797. * @param q the number of windings on Y axis (positive integers, default 3)
  25798. * @param scene defines the hosting scene
  25799. * @param updatable defines if the mesh must be flagged as updatable
  25800. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25801. * @returns a new Mesh
  25802. */
  25803. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25804. /**
  25805. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25806. * @param name defines the name of the mesh to create
  25807. * @param points is an array successive Vector3
  25808. * @param scene defines the hosting scene
  25809. * @param updatable defines if the mesh must be flagged as updatable
  25810. * @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).
  25811. * @returns a new Mesh
  25812. */
  25813. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25814. /**
  25815. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25816. * @param name defines the name of the mesh to create
  25817. * @param points is an array successive Vector3
  25818. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25819. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25820. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25821. * @param scene defines the hosting scene
  25822. * @param updatable defines if the mesh must be flagged as updatable
  25823. * @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)
  25824. * @returns a new Mesh
  25825. */
  25826. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25827. /**
  25828. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25829. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25830. * 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.
  25831. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25832. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25833. * Remember you can only change the shape positions, not their number when updating a polygon.
  25834. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25835. * @param name defines the name of the mesh to create
  25836. * @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
  25837. * @param scene defines the hosting scene
  25838. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25839. * @param updatable defines if the mesh must be flagged as updatable
  25840. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25841. * @param earcutInjection can be used to inject your own earcut reference
  25842. * @returns a new Mesh
  25843. */
  25844. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25845. /**
  25846. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25847. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25848. * @param name defines the name of the mesh to create
  25849. * @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
  25850. * @param depth defines the height of extrusion
  25851. * @param scene defines the hosting scene
  25852. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25853. * @param updatable defines if the mesh must be flagged as updatable
  25854. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25855. * @param earcutInjection can be used to inject your own earcut reference
  25856. * @returns a new Mesh
  25857. */
  25858. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25859. /**
  25860. * Creates an extruded shape mesh.
  25861. * 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
  25862. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25863. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25864. * @param name defines the name of the mesh to create
  25865. * @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
  25866. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25867. * @param scale is the value to scale the shape
  25868. * @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
  25869. * @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
  25870. * @param scene defines the hosting scene
  25871. * @param updatable defines if the mesh must be flagged as updatable
  25872. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25873. * @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)
  25874. * @returns a new Mesh
  25875. */
  25876. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25877. /**
  25878. * Creates an custom extruded shape mesh.
  25879. * The custom extrusion is a parametric shape.
  25880. * It has no predefined shape. Its final shape will depend on the input parameters.
  25881. * Please consider using the same method from the MeshBuilder class instead
  25882. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25883. * @param name defines the name of the mesh to create
  25884. * @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
  25885. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25886. * @param scaleFunction is a custom Javascript function called on each path point
  25887. * @param rotationFunction is a custom Javascript function called on each path point
  25888. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25889. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25890. * @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
  25891. * @param scene defines the hosting scene
  25892. * @param updatable defines if the mesh must be flagged as updatable
  25893. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25894. * @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)
  25895. * @returns a new Mesh
  25896. */
  25897. 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;
  25898. /**
  25899. * Creates lathe mesh.
  25900. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25901. * Please consider using the same method from the MeshBuilder class instead
  25902. * @param name defines the name of the mesh to create
  25903. * @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
  25904. * @param radius is the radius value of the lathe
  25905. * @param tessellation is the side number of the lathe.
  25906. * @param scene defines the hosting scene
  25907. * @param updatable defines if the mesh must be flagged as updatable
  25908. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25909. * @returns a new Mesh
  25910. */
  25911. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25912. /**
  25913. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25914. * @param name defines the name of the mesh to create
  25915. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25916. * @param scene defines the hosting scene
  25917. * @param updatable defines if the mesh must be flagged as updatable
  25918. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25919. * @returns a new Mesh
  25920. */
  25921. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25922. /**
  25923. * Creates a ground mesh.
  25924. * Please consider using the same method from the MeshBuilder class instead
  25925. * @param name defines the name of the mesh to create
  25926. * @param width set the width of the ground
  25927. * @param height set the height of the ground
  25928. * @param subdivisions sets the number of subdivisions per side
  25929. * @param scene defines the hosting scene
  25930. * @param updatable defines if the mesh must be flagged as updatable
  25931. * @returns a new Mesh
  25932. */
  25933. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25934. /**
  25935. * Creates a tiled ground mesh.
  25936. * Please consider using the same method from the MeshBuilder class instead
  25937. * @param name defines the name of the mesh to create
  25938. * @param xmin set the ground minimum X coordinate
  25939. * @param zmin set the ground minimum Y coordinate
  25940. * @param xmax set the ground maximum X coordinate
  25941. * @param zmax set the ground maximum Z coordinate
  25942. * @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
  25943. * @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
  25944. * @param scene defines the hosting scene
  25945. * @param updatable defines if the mesh must be flagged as updatable
  25946. * @returns a new Mesh
  25947. */
  25948. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25949. w: number;
  25950. h: number;
  25951. }, precision: {
  25952. w: number;
  25953. h: number;
  25954. }, scene: Scene, updatable?: boolean): Mesh;
  25955. /**
  25956. * Creates a ground mesh from a height map.
  25957. * Please consider using the same method from the MeshBuilder class instead
  25958. * @see http://doc.babylonjs.com/babylon101/height_map
  25959. * @param name defines the name of the mesh to create
  25960. * @param url sets the URL of the height map image resource
  25961. * @param width set the ground width size
  25962. * @param height set the ground height size
  25963. * @param subdivisions sets the number of subdivision per side
  25964. * @param minHeight is the minimum altitude on the ground
  25965. * @param maxHeight is the maximum altitude on the ground
  25966. * @param scene defines the hosting scene
  25967. * @param updatable defines if the mesh must be flagged as updatable
  25968. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25969. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25970. * @returns a new Mesh
  25971. */
  25972. 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;
  25973. /**
  25974. * Creates a tube mesh.
  25975. * The tube is a parametric shape.
  25976. * It has no predefined shape. Its final shape will depend on the input parameters.
  25977. * Please consider using the same method from the MeshBuilder class instead
  25978. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25979. * @param name defines the name of the mesh to create
  25980. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25981. * @param radius sets the tube radius size
  25982. * @param tessellation is the number of sides on the tubular surface
  25983. * @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
  25984. * @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
  25985. * @param scene defines the hosting scene
  25986. * @param updatable defines if the mesh must be flagged as updatable
  25987. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25988. * @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)
  25989. * @returns a new Mesh
  25990. */
  25991. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25992. (i: number, distance: number): number;
  25993. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25994. /**
  25995. * Creates a polyhedron mesh.
  25996. * Please consider using the same method from the MeshBuilder class instead.
  25997. * * 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
  25998. * * The parameter `size` (positive float, default 1) sets the polygon size
  25999. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26000. * * 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`
  26001. * * 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
  26002. * * 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)`)
  26003. * * 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
  26004. * * 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
  26005. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26006. * * If you create a double-sided mesh, you can choose what parts of 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
  26007. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26008. * @param name defines the name of the mesh to create
  26009. * @param options defines the options used to create the mesh
  26010. * @param scene defines the hosting scene
  26011. * @returns a new Mesh
  26012. */
  26013. static CreatePolyhedron(name: string, options: {
  26014. type?: number;
  26015. size?: number;
  26016. sizeX?: number;
  26017. sizeY?: number;
  26018. sizeZ?: number;
  26019. custom?: any;
  26020. faceUV?: Vector4[];
  26021. faceColors?: Color4[];
  26022. updatable?: boolean;
  26023. sideOrientation?: number;
  26024. }, scene: Scene): Mesh;
  26025. /**
  26026. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26027. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26028. * * 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`)
  26029. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26030. * * 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
  26031. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26032. * * If you create a double-sided mesh, you can choose what parts of 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
  26033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26034. * @param name defines the name of the mesh
  26035. * @param options defines the options used to create the mesh
  26036. * @param scene defines the hosting scene
  26037. * @returns a new Mesh
  26038. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26039. */
  26040. static CreateIcoSphere(name: string, options: {
  26041. radius?: number;
  26042. flat?: boolean;
  26043. subdivisions?: number;
  26044. sideOrientation?: number;
  26045. updatable?: boolean;
  26046. }, scene: Scene): Mesh;
  26047. /**
  26048. * Creates a decal mesh.
  26049. * Please consider using the same method from the MeshBuilder class instead.
  26050. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26051. * @param name defines the name of the mesh
  26052. * @param sourceMesh defines the mesh receiving the decal
  26053. * @param position sets the position of the decal in world coordinates
  26054. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26055. * @param size sets the decal scaling
  26056. * @param angle sets the angle to rotate the decal
  26057. * @returns a new Mesh
  26058. */
  26059. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26060. /**
  26061. * Prepare internal position array for software CPU skinning
  26062. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26063. */
  26064. setPositionsForCPUSkinning(): Float32Array;
  26065. /**
  26066. * Prepare internal normal array for software CPU skinning
  26067. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26068. */
  26069. setNormalsForCPUSkinning(): Float32Array;
  26070. /**
  26071. * Updates the vertex buffer by applying transformation from the bones
  26072. * @param skeleton defines the skeleton to apply to current mesh
  26073. * @returns the current mesh
  26074. */
  26075. applySkeleton(skeleton: Skeleton): Mesh;
  26076. /**
  26077. * 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
  26078. * @param meshes defines the list of meshes to scan
  26079. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26080. */
  26081. static MinMax(meshes: AbstractMesh[]): {
  26082. min: Vector3;
  26083. max: Vector3;
  26084. };
  26085. /**
  26086. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26087. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26088. * @returns a vector3
  26089. */
  26090. static Center(meshesOrMinMaxVector: {
  26091. min: Vector3;
  26092. max: Vector3;
  26093. } | AbstractMesh[]): Vector3;
  26094. /**
  26095. * Merge the array of meshes into a single mesh for performance reasons.
  26096. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26097. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26098. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26099. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26100. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26101. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26102. * @returns a new mesh
  26103. */
  26104. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26105. /** @hidden */
  26106. addInstance(instance: InstancedMesh): void;
  26107. /** @hidden */
  26108. removeInstance(instance: InstancedMesh): void;
  26109. }
  26110. }
  26111. declare module "babylonjs/Cameras/camera" {
  26112. import { SmartArray } from "babylonjs/Misc/smartArray";
  26113. import { Observable } from "babylonjs/Misc/observable";
  26114. import { Nullable } from "babylonjs/types";
  26115. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26116. import { Scene } from "babylonjs/scene";
  26117. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26118. import { Node } from "babylonjs/node";
  26119. import { Mesh } from "babylonjs/Meshes/mesh";
  26120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26121. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26122. import { Viewport } from "babylonjs/Maths/math.viewport";
  26123. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26124. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26125. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26126. import { Ray } from "babylonjs/Culling/ray";
  26127. /**
  26128. * This is the base class of all the camera used in the application.
  26129. * @see http://doc.babylonjs.com/features/cameras
  26130. */
  26131. export class Camera extends Node {
  26132. /** @hidden */
  26133. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26134. /**
  26135. * This is the default projection mode used by the cameras.
  26136. * It helps recreating a feeling of perspective and better appreciate depth.
  26137. * This is the best way to simulate real life cameras.
  26138. */
  26139. static readonly PERSPECTIVE_CAMERA: number;
  26140. /**
  26141. * This helps creating camera with an orthographic mode.
  26142. * 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.
  26143. */
  26144. static readonly ORTHOGRAPHIC_CAMERA: number;
  26145. /**
  26146. * This is the default FOV mode for perspective cameras.
  26147. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26148. */
  26149. static readonly FOVMODE_VERTICAL_FIXED: number;
  26150. /**
  26151. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26152. */
  26153. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26154. /**
  26155. * This specifies ther is no need for a camera rig.
  26156. * Basically only one eye is rendered corresponding to the camera.
  26157. */
  26158. static readonly RIG_MODE_NONE: number;
  26159. /**
  26160. * Simulates a camera Rig with one blue eye and one red eye.
  26161. * This can be use with 3d blue and red glasses.
  26162. */
  26163. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26164. /**
  26165. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26166. */
  26167. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26168. /**
  26169. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26170. */
  26171. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26172. /**
  26173. * Defines that both eyes of the camera will be rendered over under each other.
  26174. */
  26175. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26176. /**
  26177. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26178. */
  26179. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26180. /**
  26181. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26182. */
  26183. static readonly RIG_MODE_VR: number;
  26184. /**
  26185. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26186. */
  26187. static readonly RIG_MODE_WEBVR: number;
  26188. /**
  26189. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26190. */
  26191. static readonly RIG_MODE_CUSTOM: number;
  26192. /**
  26193. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26194. */
  26195. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26196. /**
  26197. * Define the input manager associated with the camera.
  26198. */
  26199. inputs: CameraInputsManager<Camera>;
  26200. /** @hidden */
  26201. _position: Vector3;
  26202. /**
  26203. * Define the current local position of the camera in the scene
  26204. */
  26205. get position(): Vector3;
  26206. set position(newPosition: Vector3);
  26207. /**
  26208. * The vector the camera should consider as up.
  26209. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26210. */
  26211. upVector: Vector3;
  26212. /**
  26213. * Define the current limit on the left side for an orthographic camera
  26214. * In scene unit
  26215. */
  26216. orthoLeft: Nullable<number>;
  26217. /**
  26218. * Define the current limit on the right side for an orthographic camera
  26219. * In scene unit
  26220. */
  26221. orthoRight: Nullable<number>;
  26222. /**
  26223. * Define the current limit on the bottom side for an orthographic camera
  26224. * In scene unit
  26225. */
  26226. orthoBottom: Nullable<number>;
  26227. /**
  26228. * Define the current limit on the top side for an orthographic camera
  26229. * In scene unit
  26230. */
  26231. orthoTop: Nullable<number>;
  26232. /**
  26233. * Field Of View is set in Radians. (default is 0.8)
  26234. */
  26235. fov: number;
  26236. /**
  26237. * Define the minimum distance the camera can see from.
  26238. * This is important to note that the depth buffer are not infinite and the closer it starts
  26239. * the more your scene might encounter depth fighting issue.
  26240. */
  26241. minZ: number;
  26242. /**
  26243. * Define the maximum distance the camera can see to.
  26244. * This is important to note that the depth buffer are not infinite and the further it end
  26245. * the more your scene might encounter depth fighting issue.
  26246. */
  26247. maxZ: number;
  26248. /**
  26249. * Define the default inertia of the camera.
  26250. * This helps giving a smooth feeling to the camera movement.
  26251. */
  26252. inertia: number;
  26253. /**
  26254. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26255. */
  26256. mode: number;
  26257. /**
  26258. * Define whether the camera is intermediate.
  26259. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26260. */
  26261. isIntermediate: boolean;
  26262. /**
  26263. * Define the viewport of the camera.
  26264. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26265. */
  26266. viewport: Viewport;
  26267. /**
  26268. * Restricts the camera to viewing objects with the same layerMask.
  26269. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26270. */
  26271. layerMask: number;
  26272. /**
  26273. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26274. */
  26275. fovMode: number;
  26276. /**
  26277. * Rig mode of the camera.
  26278. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26279. * This is normally controlled byt the camera themselves as internal use.
  26280. */
  26281. cameraRigMode: number;
  26282. /**
  26283. * Defines the distance between both "eyes" in case of a RIG
  26284. */
  26285. interaxialDistance: number;
  26286. /**
  26287. * Defines if stereoscopic rendering is done side by side or over under.
  26288. */
  26289. isStereoscopicSideBySide: boolean;
  26290. /**
  26291. * 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
  26292. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26293. * else in the scene. (Eg. security camera)
  26294. *
  26295. * 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)
  26296. */
  26297. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26298. /**
  26299. * When set, the camera will render to this render target instead of the default canvas
  26300. *
  26301. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26302. */
  26303. outputRenderTarget: Nullable<RenderTargetTexture>;
  26304. /**
  26305. * Observable triggered when the camera view matrix has changed.
  26306. */
  26307. onViewMatrixChangedObservable: Observable<Camera>;
  26308. /**
  26309. * Observable triggered when the camera Projection matrix has changed.
  26310. */
  26311. onProjectionMatrixChangedObservable: Observable<Camera>;
  26312. /**
  26313. * Observable triggered when the inputs have been processed.
  26314. */
  26315. onAfterCheckInputsObservable: Observable<Camera>;
  26316. /**
  26317. * Observable triggered when reset has been called and applied to the camera.
  26318. */
  26319. onRestoreStateObservable: Observable<Camera>;
  26320. /**
  26321. * Is this camera a part of a rig system?
  26322. */
  26323. isRigCamera: boolean;
  26324. /**
  26325. * If isRigCamera set to true this will be set with the parent camera.
  26326. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26327. */
  26328. rigParent?: Camera;
  26329. /** @hidden */
  26330. _cameraRigParams: any;
  26331. /** @hidden */
  26332. _rigCameras: Camera[];
  26333. /** @hidden */
  26334. _rigPostProcess: Nullable<PostProcess>;
  26335. protected _webvrViewMatrix: Matrix;
  26336. /** @hidden */
  26337. _skipRendering: boolean;
  26338. /** @hidden */
  26339. _projectionMatrix: Matrix;
  26340. /** @hidden */
  26341. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26342. /** @hidden */
  26343. _activeMeshes: SmartArray<AbstractMesh>;
  26344. protected _globalPosition: Vector3;
  26345. /** @hidden */
  26346. _computedViewMatrix: Matrix;
  26347. private _doNotComputeProjectionMatrix;
  26348. private _transformMatrix;
  26349. private _frustumPlanes;
  26350. private _refreshFrustumPlanes;
  26351. private _storedFov;
  26352. private _stateStored;
  26353. /**
  26354. * Instantiates a new camera object.
  26355. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26356. * @see http://doc.babylonjs.com/features/cameras
  26357. * @param name Defines the name of the camera in the scene
  26358. * @param position Defines the position of the camera
  26359. * @param scene Defines the scene the camera belongs too
  26360. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26361. */
  26362. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26363. /**
  26364. * Store current camera state (fov, position, etc..)
  26365. * @returns the camera
  26366. */
  26367. storeState(): Camera;
  26368. /**
  26369. * Restores the camera state values if it has been stored. You must call storeState() first
  26370. */
  26371. protected _restoreStateValues(): boolean;
  26372. /**
  26373. * Restored camera state. You must call storeState() first.
  26374. * @returns true if restored and false otherwise
  26375. */
  26376. restoreState(): boolean;
  26377. /**
  26378. * Gets the class name of the camera.
  26379. * @returns the class name
  26380. */
  26381. getClassName(): string;
  26382. /** @hidden */
  26383. readonly _isCamera: boolean;
  26384. /**
  26385. * Gets a string representation of the camera useful for debug purpose.
  26386. * @param fullDetails Defines that a more verboe level of logging is required
  26387. * @returns the string representation
  26388. */
  26389. toString(fullDetails?: boolean): string;
  26390. /**
  26391. * Gets the current world space position of the camera.
  26392. */
  26393. get globalPosition(): Vector3;
  26394. /**
  26395. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26396. * @returns the active meshe list
  26397. */
  26398. getActiveMeshes(): SmartArray<AbstractMesh>;
  26399. /**
  26400. * Check whether a mesh is part of the current active mesh list of the camera
  26401. * @param mesh Defines the mesh to check
  26402. * @returns true if active, false otherwise
  26403. */
  26404. isActiveMesh(mesh: Mesh): boolean;
  26405. /**
  26406. * Is this camera ready to be used/rendered
  26407. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26408. * @return true if the camera is ready
  26409. */
  26410. isReady(completeCheck?: boolean): boolean;
  26411. /** @hidden */
  26412. _initCache(): void;
  26413. /** @hidden */
  26414. _updateCache(ignoreParentClass?: boolean): void;
  26415. /** @hidden */
  26416. _isSynchronized(): boolean;
  26417. /** @hidden */
  26418. _isSynchronizedViewMatrix(): boolean;
  26419. /** @hidden */
  26420. _isSynchronizedProjectionMatrix(): boolean;
  26421. /**
  26422. * Attach the input controls to a specific dom element to get the input from.
  26423. * @param element Defines the element the controls should be listened from
  26424. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26425. */
  26426. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26427. /**
  26428. * Detach the current controls from the specified dom element.
  26429. * @param element Defines the element to stop listening the inputs from
  26430. */
  26431. detachControl(element: HTMLElement): void;
  26432. /**
  26433. * Update the camera state according to the different inputs gathered during the frame.
  26434. */
  26435. update(): void;
  26436. /** @hidden */
  26437. _checkInputs(): void;
  26438. /** @hidden */
  26439. get rigCameras(): Camera[];
  26440. /**
  26441. * Gets the post process used by the rig cameras
  26442. */
  26443. get rigPostProcess(): Nullable<PostProcess>;
  26444. /**
  26445. * Internal, gets the first post proces.
  26446. * @returns the first post process to be run on this camera.
  26447. */
  26448. _getFirstPostProcess(): Nullable<PostProcess>;
  26449. private _cascadePostProcessesToRigCams;
  26450. /**
  26451. * Attach a post process to the camera.
  26452. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26453. * @param postProcess The post process to attach to the camera
  26454. * @param insertAt The position of the post process in case several of them are in use in the scene
  26455. * @returns the position the post process has been inserted at
  26456. */
  26457. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26458. /**
  26459. * Detach a post process to the camera.
  26460. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26461. * @param postProcess The post process to detach from the camera
  26462. */
  26463. detachPostProcess(postProcess: PostProcess): void;
  26464. /**
  26465. * Gets the current world matrix of the camera
  26466. */
  26467. getWorldMatrix(): Matrix;
  26468. /** @hidden */
  26469. _getViewMatrix(): Matrix;
  26470. /**
  26471. * Gets the current view matrix of the camera.
  26472. * @param force forces the camera to recompute the matrix without looking at the cached state
  26473. * @returns the view matrix
  26474. */
  26475. getViewMatrix(force?: boolean): Matrix;
  26476. /**
  26477. * Freeze the projection matrix.
  26478. * It will prevent the cache check of the camera projection compute and can speed up perf
  26479. * if no parameter of the camera are meant to change
  26480. * @param projection Defines manually a projection if necessary
  26481. */
  26482. freezeProjectionMatrix(projection?: Matrix): void;
  26483. /**
  26484. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26485. */
  26486. unfreezeProjectionMatrix(): void;
  26487. /**
  26488. * Gets the current projection matrix of the camera.
  26489. * @param force forces the camera to recompute the matrix without looking at the cached state
  26490. * @returns the projection matrix
  26491. */
  26492. getProjectionMatrix(force?: boolean): Matrix;
  26493. /**
  26494. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26495. * @returns a Matrix
  26496. */
  26497. getTransformationMatrix(): Matrix;
  26498. private _updateFrustumPlanes;
  26499. /**
  26500. * Checks if a cullable object (mesh...) is in the camera frustum
  26501. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26502. * @param target The object to check
  26503. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26504. * @returns true if the object is in frustum otherwise false
  26505. */
  26506. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26507. /**
  26508. * Checks if a cullable object (mesh...) is in the camera frustum
  26509. * Unlike isInFrustum this cheks the full bounding box
  26510. * @param target The object to check
  26511. * @returns true if the object is in frustum otherwise false
  26512. */
  26513. isCompletelyInFrustum(target: ICullable): boolean;
  26514. /**
  26515. * Gets a ray in the forward direction from the camera.
  26516. * @param length Defines the length of the ray to create
  26517. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26518. * @param origin Defines the start point of the ray which defaults to the camera position
  26519. * @returns the forward ray
  26520. */
  26521. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26522. /**
  26523. * Releases resources associated with this node.
  26524. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26525. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26526. */
  26527. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26528. /** @hidden */
  26529. _isLeftCamera: boolean;
  26530. /**
  26531. * Gets the left camera of a rig setup in case of Rigged Camera
  26532. */
  26533. get isLeftCamera(): boolean;
  26534. /** @hidden */
  26535. _isRightCamera: boolean;
  26536. /**
  26537. * Gets the right camera of a rig setup in case of Rigged Camera
  26538. */
  26539. get isRightCamera(): boolean;
  26540. /**
  26541. * Gets the left camera of a rig setup in case of Rigged Camera
  26542. */
  26543. get leftCamera(): Nullable<FreeCamera>;
  26544. /**
  26545. * Gets the right camera of a rig setup in case of Rigged Camera
  26546. */
  26547. get rightCamera(): Nullable<FreeCamera>;
  26548. /**
  26549. * Gets the left camera target of a rig setup in case of Rigged Camera
  26550. * @returns the target position
  26551. */
  26552. getLeftTarget(): Nullable<Vector3>;
  26553. /**
  26554. * Gets the right camera target of a rig setup in case of Rigged Camera
  26555. * @returns the target position
  26556. */
  26557. getRightTarget(): Nullable<Vector3>;
  26558. /**
  26559. * @hidden
  26560. */
  26561. setCameraRigMode(mode: number, rigParams: any): void;
  26562. /** @hidden */
  26563. static _setStereoscopicRigMode(camera: Camera): void;
  26564. /** @hidden */
  26565. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26566. /** @hidden */
  26567. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26568. /** @hidden */
  26569. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26570. /** @hidden */
  26571. _getVRProjectionMatrix(): Matrix;
  26572. protected _updateCameraRotationMatrix(): void;
  26573. protected _updateWebVRCameraRotationMatrix(): void;
  26574. /**
  26575. * This function MUST be overwritten by the different WebVR cameras available.
  26576. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26577. * @hidden
  26578. */
  26579. _getWebVRProjectionMatrix(): Matrix;
  26580. /**
  26581. * This function MUST be overwritten by the different WebVR cameras available.
  26582. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26583. * @hidden
  26584. */
  26585. _getWebVRViewMatrix(): Matrix;
  26586. /** @hidden */
  26587. setCameraRigParameter(name: string, value: any): void;
  26588. /**
  26589. * needs to be overridden by children so sub has required properties to be copied
  26590. * @hidden
  26591. */
  26592. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26593. /**
  26594. * May need to be overridden by children
  26595. * @hidden
  26596. */
  26597. _updateRigCameras(): void;
  26598. /** @hidden */
  26599. _setupInputs(): void;
  26600. /**
  26601. * Serialiaze the camera setup to a json represention
  26602. * @returns the JSON representation
  26603. */
  26604. serialize(): any;
  26605. /**
  26606. * Clones the current camera.
  26607. * @param name The cloned camera name
  26608. * @returns the cloned camera
  26609. */
  26610. clone(name: string): Camera;
  26611. /**
  26612. * Gets the direction of the camera relative to a given local axis.
  26613. * @param localAxis Defines the reference axis to provide a relative direction.
  26614. * @return the direction
  26615. */
  26616. getDirection(localAxis: Vector3): Vector3;
  26617. /**
  26618. * Returns the current camera absolute rotation
  26619. */
  26620. get absoluteRotation(): Quaternion;
  26621. /**
  26622. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26623. * @param localAxis Defines the reference axis to provide a relative direction.
  26624. * @param result Defines the vector to store the result in
  26625. */
  26626. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26627. /**
  26628. * Gets a camera constructor for a given camera type
  26629. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26630. * @param name The name of the camera the result will be able to instantiate
  26631. * @param scene The scene the result will construct the camera in
  26632. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26633. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26634. * @returns a factory method to construc the camera
  26635. */
  26636. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26637. /**
  26638. * Compute the world matrix of the camera.
  26639. * @returns the camera world matrix
  26640. */
  26641. computeWorldMatrix(): Matrix;
  26642. /**
  26643. * Parse a JSON and creates the camera from the parsed information
  26644. * @param parsedCamera The JSON to parse
  26645. * @param scene The scene to instantiate the camera in
  26646. * @returns the newly constructed camera
  26647. */
  26648. static Parse(parsedCamera: any, scene: Scene): Camera;
  26649. }
  26650. }
  26651. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26652. import { Nullable } from "babylonjs/types";
  26653. import { Scene } from "babylonjs/scene";
  26654. import { Vector4 } from "babylonjs/Maths/math.vector";
  26655. import { Mesh } from "babylonjs/Meshes/mesh";
  26656. /**
  26657. * Class containing static functions to help procedurally build meshes
  26658. */
  26659. export class DiscBuilder {
  26660. /**
  26661. * Creates a plane polygonal mesh. By default, this is a disc
  26662. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26663. * * 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
  26664. * * 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
  26665. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26666. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26667. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26668. * @param name defines the name of the mesh
  26669. * @param options defines the options used to create the mesh
  26670. * @param scene defines the hosting scene
  26671. * @returns the plane polygonal mesh
  26672. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26673. */
  26674. static CreateDisc(name: string, options: {
  26675. radius?: number;
  26676. tessellation?: number;
  26677. arc?: number;
  26678. updatable?: boolean;
  26679. sideOrientation?: number;
  26680. frontUVs?: Vector4;
  26681. backUVs?: Vector4;
  26682. }, scene?: Nullable<Scene>): Mesh;
  26683. }
  26684. }
  26685. declare module "babylonjs/Materials/fresnelParameters" {
  26686. import { Color3 } from "babylonjs/Maths/math.color";
  26687. /**
  26688. * This represents all the required information to add a fresnel effect on a material:
  26689. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26690. */
  26691. export class FresnelParameters {
  26692. private _isEnabled;
  26693. /**
  26694. * Define if the fresnel effect is enable or not.
  26695. */
  26696. get isEnabled(): boolean;
  26697. set isEnabled(value: boolean);
  26698. /**
  26699. * Define the color used on edges (grazing angle)
  26700. */
  26701. leftColor: Color3;
  26702. /**
  26703. * Define the color used on center
  26704. */
  26705. rightColor: Color3;
  26706. /**
  26707. * Define bias applied to computed fresnel term
  26708. */
  26709. bias: number;
  26710. /**
  26711. * Defined the power exponent applied to fresnel term
  26712. */
  26713. power: number;
  26714. /**
  26715. * Clones the current fresnel and its valuues
  26716. * @returns a clone fresnel configuration
  26717. */
  26718. clone(): FresnelParameters;
  26719. /**
  26720. * Serializes the current fresnel parameters to a JSON representation.
  26721. * @return the JSON serialization
  26722. */
  26723. serialize(): any;
  26724. /**
  26725. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26726. * @param parsedFresnelParameters Define the JSON representation
  26727. * @returns the parsed parameters
  26728. */
  26729. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26730. }
  26731. }
  26732. declare module "babylonjs/Materials/pushMaterial" {
  26733. import { Nullable } from "babylonjs/types";
  26734. import { Scene } from "babylonjs/scene";
  26735. import { Matrix } from "babylonjs/Maths/math.vector";
  26736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26737. import { Mesh } from "babylonjs/Meshes/mesh";
  26738. import { Material } from "babylonjs/Materials/material";
  26739. import { Effect } from "babylonjs/Materials/effect";
  26740. /**
  26741. * Base class of materials working in push mode in babylon JS
  26742. * @hidden
  26743. */
  26744. export class PushMaterial extends Material {
  26745. protected _activeEffect: Effect;
  26746. protected _normalMatrix: Matrix;
  26747. /**
  26748. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26749. * This means that the material can keep using a previous shader while a new one is being compiled.
  26750. * This is mostly used when shader parallel compilation is supported (true by default)
  26751. */
  26752. allowShaderHotSwapping: boolean;
  26753. constructor(name: string, scene: Scene);
  26754. getEffect(): Effect;
  26755. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26756. /**
  26757. * Binds the given world matrix to the active effect
  26758. *
  26759. * @param world the matrix to bind
  26760. */
  26761. bindOnlyWorldMatrix(world: Matrix): void;
  26762. /**
  26763. * Binds the given normal matrix to the active effect
  26764. *
  26765. * @param normalMatrix the matrix to bind
  26766. */
  26767. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26768. bind(world: Matrix, mesh?: Mesh): void;
  26769. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26770. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26771. }
  26772. }
  26773. declare module "babylonjs/Materials/materialFlags" {
  26774. /**
  26775. * This groups all the flags used to control the materials channel.
  26776. */
  26777. export class MaterialFlags {
  26778. private static _DiffuseTextureEnabled;
  26779. /**
  26780. * Are diffuse textures enabled in the application.
  26781. */
  26782. static get DiffuseTextureEnabled(): boolean;
  26783. static set DiffuseTextureEnabled(value: boolean);
  26784. private static _AmbientTextureEnabled;
  26785. /**
  26786. * Are ambient textures enabled in the application.
  26787. */
  26788. static get AmbientTextureEnabled(): boolean;
  26789. static set AmbientTextureEnabled(value: boolean);
  26790. private static _OpacityTextureEnabled;
  26791. /**
  26792. * Are opacity textures enabled in the application.
  26793. */
  26794. static get OpacityTextureEnabled(): boolean;
  26795. static set OpacityTextureEnabled(value: boolean);
  26796. private static _ReflectionTextureEnabled;
  26797. /**
  26798. * Are reflection textures enabled in the application.
  26799. */
  26800. static get ReflectionTextureEnabled(): boolean;
  26801. static set ReflectionTextureEnabled(value: boolean);
  26802. private static _EmissiveTextureEnabled;
  26803. /**
  26804. * Are emissive textures enabled in the application.
  26805. */
  26806. static get EmissiveTextureEnabled(): boolean;
  26807. static set EmissiveTextureEnabled(value: boolean);
  26808. private static _SpecularTextureEnabled;
  26809. /**
  26810. * Are specular textures enabled in the application.
  26811. */
  26812. static get SpecularTextureEnabled(): boolean;
  26813. static set SpecularTextureEnabled(value: boolean);
  26814. private static _BumpTextureEnabled;
  26815. /**
  26816. * Are bump textures enabled in the application.
  26817. */
  26818. static get BumpTextureEnabled(): boolean;
  26819. static set BumpTextureEnabled(value: boolean);
  26820. private static _LightmapTextureEnabled;
  26821. /**
  26822. * Are lightmap textures enabled in the application.
  26823. */
  26824. static get LightmapTextureEnabled(): boolean;
  26825. static set LightmapTextureEnabled(value: boolean);
  26826. private static _RefractionTextureEnabled;
  26827. /**
  26828. * Are refraction textures enabled in the application.
  26829. */
  26830. static get RefractionTextureEnabled(): boolean;
  26831. static set RefractionTextureEnabled(value: boolean);
  26832. private static _ColorGradingTextureEnabled;
  26833. /**
  26834. * Are color grading textures enabled in the application.
  26835. */
  26836. static get ColorGradingTextureEnabled(): boolean;
  26837. static set ColorGradingTextureEnabled(value: boolean);
  26838. private static _FresnelEnabled;
  26839. /**
  26840. * Are fresnels enabled in the application.
  26841. */
  26842. static get FresnelEnabled(): boolean;
  26843. static set FresnelEnabled(value: boolean);
  26844. private static _ClearCoatTextureEnabled;
  26845. /**
  26846. * Are clear coat textures enabled in the application.
  26847. */
  26848. static get ClearCoatTextureEnabled(): boolean;
  26849. static set ClearCoatTextureEnabled(value: boolean);
  26850. private static _ClearCoatBumpTextureEnabled;
  26851. /**
  26852. * Are clear coat bump textures enabled in the application.
  26853. */
  26854. static get ClearCoatBumpTextureEnabled(): boolean;
  26855. static set ClearCoatBumpTextureEnabled(value: boolean);
  26856. private static _ClearCoatTintTextureEnabled;
  26857. /**
  26858. * Are clear coat tint textures enabled in the application.
  26859. */
  26860. static get ClearCoatTintTextureEnabled(): boolean;
  26861. static set ClearCoatTintTextureEnabled(value: boolean);
  26862. private static _SheenTextureEnabled;
  26863. /**
  26864. * Are sheen textures enabled in the application.
  26865. */
  26866. static get SheenTextureEnabled(): boolean;
  26867. static set SheenTextureEnabled(value: boolean);
  26868. private static _AnisotropicTextureEnabled;
  26869. /**
  26870. * Are anisotropic textures enabled in the application.
  26871. */
  26872. static get AnisotropicTextureEnabled(): boolean;
  26873. static set AnisotropicTextureEnabled(value: boolean);
  26874. private static _ThicknessTextureEnabled;
  26875. /**
  26876. * Are thickness textures enabled in the application.
  26877. */
  26878. static get ThicknessTextureEnabled(): boolean;
  26879. static set ThicknessTextureEnabled(value: boolean);
  26880. }
  26881. }
  26882. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26883. /** @hidden */
  26884. export var defaultFragmentDeclaration: {
  26885. name: string;
  26886. shader: string;
  26887. };
  26888. }
  26889. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26890. /** @hidden */
  26891. export var defaultUboDeclaration: {
  26892. name: string;
  26893. shader: string;
  26894. };
  26895. }
  26896. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26897. /** @hidden */
  26898. export var lightFragmentDeclaration: {
  26899. name: string;
  26900. shader: string;
  26901. };
  26902. }
  26903. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26904. /** @hidden */
  26905. export var lightUboDeclaration: {
  26906. name: string;
  26907. shader: string;
  26908. };
  26909. }
  26910. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26911. /** @hidden */
  26912. export var lightsFragmentFunctions: {
  26913. name: string;
  26914. shader: string;
  26915. };
  26916. }
  26917. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26918. /** @hidden */
  26919. export var shadowsFragmentFunctions: {
  26920. name: string;
  26921. shader: string;
  26922. };
  26923. }
  26924. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26925. /** @hidden */
  26926. export var fresnelFunction: {
  26927. name: string;
  26928. shader: string;
  26929. };
  26930. }
  26931. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26932. /** @hidden */
  26933. export var reflectionFunction: {
  26934. name: string;
  26935. shader: string;
  26936. };
  26937. }
  26938. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26939. /** @hidden */
  26940. export var bumpFragmentFunctions: {
  26941. name: string;
  26942. shader: string;
  26943. };
  26944. }
  26945. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26946. /** @hidden */
  26947. export var logDepthDeclaration: {
  26948. name: string;
  26949. shader: string;
  26950. };
  26951. }
  26952. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26953. /** @hidden */
  26954. export var bumpFragment: {
  26955. name: string;
  26956. shader: string;
  26957. };
  26958. }
  26959. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26960. /** @hidden */
  26961. export var depthPrePass: {
  26962. name: string;
  26963. shader: string;
  26964. };
  26965. }
  26966. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26967. /** @hidden */
  26968. export var lightFragment: {
  26969. name: string;
  26970. shader: string;
  26971. };
  26972. }
  26973. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26974. /** @hidden */
  26975. export var logDepthFragment: {
  26976. name: string;
  26977. shader: string;
  26978. };
  26979. }
  26980. declare module "babylonjs/Shaders/default.fragment" {
  26981. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26982. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26983. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26984. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26985. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26986. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26987. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26988. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26989. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26990. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26991. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26992. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26993. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26994. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26995. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26996. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  26997. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  26998. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  26999. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27000. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27001. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27002. /** @hidden */
  27003. export var defaultPixelShader: {
  27004. name: string;
  27005. shader: string;
  27006. };
  27007. }
  27008. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27009. /** @hidden */
  27010. export var defaultVertexDeclaration: {
  27011. name: string;
  27012. shader: string;
  27013. };
  27014. }
  27015. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27016. /** @hidden */
  27017. export var bumpVertexDeclaration: {
  27018. name: string;
  27019. shader: string;
  27020. };
  27021. }
  27022. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27023. /** @hidden */
  27024. export var bumpVertex: {
  27025. name: string;
  27026. shader: string;
  27027. };
  27028. }
  27029. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27030. /** @hidden */
  27031. export var fogVertex: {
  27032. name: string;
  27033. shader: string;
  27034. };
  27035. }
  27036. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27037. /** @hidden */
  27038. export var shadowsVertex: {
  27039. name: string;
  27040. shader: string;
  27041. };
  27042. }
  27043. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27044. /** @hidden */
  27045. export var pointCloudVertex: {
  27046. name: string;
  27047. shader: string;
  27048. };
  27049. }
  27050. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27051. /** @hidden */
  27052. export var logDepthVertex: {
  27053. name: string;
  27054. shader: string;
  27055. };
  27056. }
  27057. declare module "babylonjs/Shaders/default.vertex" {
  27058. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27059. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27060. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27061. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27062. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27063. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27064. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27065. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27066. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27067. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27068. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27069. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27070. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27071. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27072. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27073. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27074. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27075. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27076. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27077. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27078. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27079. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27080. /** @hidden */
  27081. export var defaultVertexShader: {
  27082. name: string;
  27083. shader: string;
  27084. };
  27085. }
  27086. declare module "babylonjs/Materials/standardMaterial" {
  27087. import { SmartArray } from "babylonjs/Misc/smartArray";
  27088. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27089. import { Nullable } from "babylonjs/types";
  27090. import { Scene } from "babylonjs/scene";
  27091. import { Matrix } from "babylonjs/Maths/math.vector";
  27092. import { Color3 } from "babylonjs/Maths/math.color";
  27093. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27094. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27095. import { Mesh } from "babylonjs/Meshes/mesh";
  27096. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27097. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27098. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27099. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27100. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27101. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27102. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27103. import "babylonjs/Shaders/default.fragment";
  27104. import "babylonjs/Shaders/default.vertex";
  27105. /** @hidden */
  27106. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27107. MAINUV1: boolean;
  27108. MAINUV2: boolean;
  27109. DIFFUSE: boolean;
  27110. DIFFUSEDIRECTUV: number;
  27111. AMBIENT: boolean;
  27112. AMBIENTDIRECTUV: number;
  27113. OPACITY: boolean;
  27114. OPACITYDIRECTUV: number;
  27115. OPACITYRGB: boolean;
  27116. REFLECTION: boolean;
  27117. EMISSIVE: boolean;
  27118. EMISSIVEDIRECTUV: number;
  27119. SPECULAR: boolean;
  27120. SPECULARDIRECTUV: number;
  27121. BUMP: boolean;
  27122. BUMPDIRECTUV: number;
  27123. PARALLAX: boolean;
  27124. PARALLAXOCCLUSION: boolean;
  27125. SPECULAROVERALPHA: boolean;
  27126. CLIPPLANE: boolean;
  27127. CLIPPLANE2: boolean;
  27128. CLIPPLANE3: boolean;
  27129. CLIPPLANE4: boolean;
  27130. CLIPPLANE5: boolean;
  27131. CLIPPLANE6: boolean;
  27132. ALPHATEST: boolean;
  27133. DEPTHPREPASS: boolean;
  27134. ALPHAFROMDIFFUSE: boolean;
  27135. POINTSIZE: boolean;
  27136. FOG: boolean;
  27137. SPECULARTERM: boolean;
  27138. DIFFUSEFRESNEL: boolean;
  27139. OPACITYFRESNEL: boolean;
  27140. REFLECTIONFRESNEL: boolean;
  27141. REFRACTIONFRESNEL: boolean;
  27142. EMISSIVEFRESNEL: boolean;
  27143. FRESNEL: boolean;
  27144. NORMAL: boolean;
  27145. UV1: boolean;
  27146. UV2: boolean;
  27147. VERTEXCOLOR: boolean;
  27148. VERTEXALPHA: boolean;
  27149. NUM_BONE_INFLUENCERS: number;
  27150. BonesPerMesh: number;
  27151. BONETEXTURE: boolean;
  27152. INSTANCES: boolean;
  27153. GLOSSINESS: boolean;
  27154. ROUGHNESS: boolean;
  27155. EMISSIVEASILLUMINATION: boolean;
  27156. LINKEMISSIVEWITHDIFFUSE: boolean;
  27157. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27158. LIGHTMAP: boolean;
  27159. LIGHTMAPDIRECTUV: number;
  27160. OBJECTSPACE_NORMALMAP: boolean;
  27161. USELIGHTMAPASSHADOWMAP: boolean;
  27162. REFLECTIONMAP_3D: boolean;
  27163. REFLECTIONMAP_SPHERICAL: boolean;
  27164. REFLECTIONMAP_PLANAR: boolean;
  27165. REFLECTIONMAP_CUBIC: boolean;
  27166. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27167. REFLECTIONMAP_PROJECTION: boolean;
  27168. REFLECTIONMAP_SKYBOX: boolean;
  27169. REFLECTIONMAP_EXPLICIT: boolean;
  27170. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27171. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27172. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27173. INVERTCUBICMAP: boolean;
  27174. LOGARITHMICDEPTH: boolean;
  27175. REFRACTION: boolean;
  27176. REFRACTIONMAP_3D: boolean;
  27177. REFLECTIONOVERALPHA: boolean;
  27178. TWOSIDEDLIGHTING: boolean;
  27179. SHADOWFLOAT: boolean;
  27180. MORPHTARGETS: boolean;
  27181. MORPHTARGETS_NORMAL: boolean;
  27182. MORPHTARGETS_TANGENT: boolean;
  27183. MORPHTARGETS_UV: boolean;
  27184. NUM_MORPH_INFLUENCERS: number;
  27185. NONUNIFORMSCALING: boolean;
  27186. PREMULTIPLYALPHA: boolean;
  27187. IMAGEPROCESSING: boolean;
  27188. VIGNETTE: boolean;
  27189. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27190. VIGNETTEBLENDMODEOPAQUE: boolean;
  27191. TONEMAPPING: boolean;
  27192. TONEMAPPING_ACES: boolean;
  27193. CONTRAST: boolean;
  27194. COLORCURVES: boolean;
  27195. COLORGRADING: boolean;
  27196. COLORGRADING3D: boolean;
  27197. SAMPLER3DGREENDEPTH: boolean;
  27198. SAMPLER3DBGRMAP: boolean;
  27199. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27200. MULTIVIEW: boolean;
  27201. /**
  27202. * If the reflection texture on this material is in linear color space
  27203. * @hidden
  27204. */
  27205. IS_REFLECTION_LINEAR: boolean;
  27206. /**
  27207. * If the refraction texture on this material is in linear color space
  27208. * @hidden
  27209. */
  27210. IS_REFRACTION_LINEAR: boolean;
  27211. EXPOSURE: boolean;
  27212. constructor();
  27213. setReflectionMode(modeToEnable: string): void;
  27214. }
  27215. /**
  27216. * This is the default material used in Babylon. It is the best trade off between quality
  27217. * and performances.
  27218. * @see http://doc.babylonjs.com/babylon101/materials
  27219. */
  27220. export class StandardMaterial extends PushMaterial {
  27221. private _diffuseTexture;
  27222. /**
  27223. * The basic texture of the material as viewed under a light.
  27224. */
  27225. diffuseTexture: Nullable<BaseTexture>;
  27226. private _ambientTexture;
  27227. /**
  27228. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27229. */
  27230. ambientTexture: Nullable<BaseTexture>;
  27231. private _opacityTexture;
  27232. /**
  27233. * Define the transparency of the material from a texture.
  27234. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27235. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27236. */
  27237. opacityTexture: Nullable<BaseTexture>;
  27238. private _reflectionTexture;
  27239. /**
  27240. * Define the texture used to display the reflection.
  27241. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27242. */
  27243. reflectionTexture: Nullable<BaseTexture>;
  27244. private _emissiveTexture;
  27245. /**
  27246. * Define texture of the material as if self lit.
  27247. * This will be mixed in the final result even in the absence of light.
  27248. */
  27249. emissiveTexture: Nullable<BaseTexture>;
  27250. private _specularTexture;
  27251. /**
  27252. * Define how the color and intensity of the highlight given by the light in the material.
  27253. */
  27254. specularTexture: Nullable<BaseTexture>;
  27255. private _bumpTexture;
  27256. /**
  27257. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27258. * 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.
  27259. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27260. */
  27261. bumpTexture: Nullable<BaseTexture>;
  27262. private _lightmapTexture;
  27263. /**
  27264. * Complex lighting can be computationally expensive to compute at runtime.
  27265. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27266. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27267. */
  27268. lightmapTexture: Nullable<BaseTexture>;
  27269. private _refractionTexture;
  27270. /**
  27271. * Define the texture used to display the refraction.
  27272. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27273. */
  27274. refractionTexture: Nullable<BaseTexture>;
  27275. /**
  27276. * The color of the material lit by the environmental background lighting.
  27277. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27278. */
  27279. ambientColor: Color3;
  27280. /**
  27281. * The basic color of the material as viewed under a light.
  27282. */
  27283. diffuseColor: Color3;
  27284. /**
  27285. * Define how the color and intensity of the highlight given by the light in the material.
  27286. */
  27287. specularColor: Color3;
  27288. /**
  27289. * Define the color of the material as if self lit.
  27290. * This will be mixed in the final result even in the absence of light.
  27291. */
  27292. emissiveColor: Color3;
  27293. /**
  27294. * Defines how sharp are the highlights in the material.
  27295. * The bigger the value the sharper giving a more glossy feeling to the result.
  27296. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27297. */
  27298. specularPower: number;
  27299. private _useAlphaFromDiffuseTexture;
  27300. /**
  27301. * Does the transparency come from the diffuse texture alpha channel.
  27302. */
  27303. useAlphaFromDiffuseTexture: boolean;
  27304. private _useEmissiveAsIllumination;
  27305. /**
  27306. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27307. */
  27308. useEmissiveAsIllumination: boolean;
  27309. private _linkEmissiveWithDiffuse;
  27310. /**
  27311. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27312. * the emissive level when the final color is close to one.
  27313. */
  27314. linkEmissiveWithDiffuse: boolean;
  27315. private _useSpecularOverAlpha;
  27316. /**
  27317. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27318. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27319. */
  27320. useSpecularOverAlpha: boolean;
  27321. private _useReflectionOverAlpha;
  27322. /**
  27323. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27324. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27325. */
  27326. useReflectionOverAlpha: boolean;
  27327. private _disableLighting;
  27328. /**
  27329. * Does lights from the scene impacts this material.
  27330. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27331. */
  27332. disableLighting: boolean;
  27333. private _useObjectSpaceNormalMap;
  27334. /**
  27335. * Allows using an object space normal map (instead of tangent space).
  27336. */
  27337. useObjectSpaceNormalMap: boolean;
  27338. private _useParallax;
  27339. /**
  27340. * Is parallax enabled or not.
  27341. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27342. */
  27343. useParallax: boolean;
  27344. private _useParallaxOcclusion;
  27345. /**
  27346. * Is parallax occlusion enabled or not.
  27347. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27348. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27349. */
  27350. useParallaxOcclusion: boolean;
  27351. /**
  27352. * 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.
  27353. */
  27354. parallaxScaleBias: number;
  27355. private _roughness;
  27356. /**
  27357. * Helps to define how blurry the reflections should appears in the material.
  27358. */
  27359. roughness: number;
  27360. /**
  27361. * In case of refraction, define the value of the index of refraction.
  27362. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27363. */
  27364. indexOfRefraction: number;
  27365. /**
  27366. * Invert the refraction texture alongside the y axis.
  27367. * It can be useful with procedural textures or probe for instance.
  27368. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27369. */
  27370. invertRefractionY: boolean;
  27371. /**
  27372. * Defines the alpha limits in alpha test mode.
  27373. */
  27374. alphaCutOff: number;
  27375. private _useLightmapAsShadowmap;
  27376. /**
  27377. * In case of light mapping, define whether the map contains light or shadow informations.
  27378. */
  27379. useLightmapAsShadowmap: boolean;
  27380. private _diffuseFresnelParameters;
  27381. /**
  27382. * Define the diffuse fresnel parameters of the material.
  27383. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27384. */
  27385. diffuseFresnelParameters: FresnelParameters;
  27386. private _opacityFresnelParameters;
  27387. /**
  27388. * Define the opacity fresnel parameters of the material.
  27389. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27390. */
  27391. opacityFresnelParameters: FresnelParameters;
  27392. private _reflectionFresnelParameters;
  27393. /**
  27394. * Define the reflection fresnel parameters of the material.
  27395. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27396. */
  27397. reflectionFresnelParameters: FresnelParameters;
  27398. private _refractionFresnelParameters;
  27399. /**
  27400. * Define the refraction fresnel parameters of the material.
  27401. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27402. */
  27403. refractionFresnelParameters: FresnelParameters;
  27404. private _emissiveFresnelParameters;
  27405. /**
  27406. * Define the emissive fresnel parameters of the material.
  27407. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27408. */
  27409. emissiveFresnelParameters: FresnelParameters;
  27410. private _useReflectionFresnelFromSpecular;
  27411. /**
  27412. * If true automatically deducts the fresnels values from the material specularity.
  27413. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27414. */
  27415. useReflectionFresnelFromSpecular: boolean;
  27416. private _useGlossinessFromSpecularMapAlpha;
  27417. /**
  27418. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27419. */
  27420. useGlossinessFromSpecularMapAlpha: boolean;
  27421. private _maxSimultaneousLights;
  27422. /**
  27423. * Defines the maximum number of lights that can be used in the material
  27424. */
  27425. maxSimultaneousLights: number;
  27426. private _invertNormalMapX;
  27427. /**
  27428. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27429. */
  27430. invertNormalMapX: boolean;
  27431. private _invertNormalMapY;
  27432. /**
  27433. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27434. */
  27435. invertNormalMapY: boolean;
  27436. private _twoSidedLighting;
  27437. /**
  27438. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27439. */
  27440. twoSidedLighting: boolean;
  27441. /**
  27442. * Default configuration related to image processing available in the standard Material.
  27443. */
  27444. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27445. /**
  27446. * Gets the image processing configuration used either in this material.
  27447. */
  27448. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27449. /**
  27450. * Sets the Default image processing configuration used either in the this material.
  27451. *
  27452. * If sets to null, the scene one is in use.
  27453. */
  27454. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27455. /**
  27456. * Keep track of the image processing observer to allow dispose and replace.
  27457. */
  27458. private _imageProcessingObserver;
  27459. /**
  27460. * Attaches a new image processing configuration to the Standard Material.
  27461. * @param configuration
  27462. */
  27463. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27464. /**
  27465. * Gets wether the color curves effect is enabled.
  27466. */
  27467. get cameraColorCurvesEnabled(): boolean;
  27468. /**
  27469. * Sets wether the color curves effect is enabled.
  27470. */
  27471. set cameraColorCurvesEnabled(value: boolean);
  27472. /**
  27473. * Gets wether the color grading effect is enabled.
  27474. */
  27475. get cameraColorGradingEnabled(): boolean;
  27476. /**
  27477. * Gets wether the color grading effect is enabled.
  27478. */
  27479. set cameraColorGradingEnabled(value: boolean);
  27480. /**
  27481. * Gets wether tonemapping is enabled or not.
  27482. */
  27483. get cameraToneMappingEnabled(): boolean;
  27484. /**
  27485. * Sets wether tonemapping is enabled or not
  27486. */
  27487. set cameraToneMappingEnabled(value: boolean);
  27488. /**
  27489. * The camera exposure used on this material.
  27490. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27491. * This corresponds to a photographic exposure.
  27492. */
  27493. get cameraExposure(): number;
  27494. /**
  27495. * The camera exposure used on this material.
  27496. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27497. * This corresponds to a photographic exposure.
  27498. */
  27499. set cameraExposure(value: number);
  27500. /**
  27501. * Gets The camera contrast used on this material.
  27502. */
  27503. get cameraContrast(): number;
  27504. /**
  27505. * Sets The camera contrast used on this material.
  27506. */
  27507. set cameraContrast(value: number);
  27508. /**
  27509. * Gets the Color Grading 2D Lookup Texture.
  27510. */
  27511. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27512. /**
  27513. * Sets the Color Grading 2D Lookup Texture.
  27514. */
  27515. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27516. /**
  27517. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27518. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27519. * 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;
  27520. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27521. */
  27522. get cameraColorCurves(): Nullable<ColorCurves>;
  27523. /**
  27524. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27525. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27526. * 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;
  27527. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27528. */
  27529. set cameraColorCurves(value: Nullable<ColorCurves>);
  27530. /**
  27531. * Custom callback helping to override the default shader used in the material.
  27532. */
  27533. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27534. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27535. protected _worldViewProjectionMatrix: Matrix;
  27536. protected _globalAmbientColor: Color3;
  27537. protected _useLogarithmicDepth: boolean;
  27538. protected _rebuildInParallel: boolean;
  27539. /**
  27540. * Instantiates a new standard material.
  27541. * This is the default material used in Babylon. It is the best trade off between quality
  27542. * and performances.
  27543. * @see http://doc.babylonjs.com/babylon101/materials
  27544. * @param name Define the name of the material in the scene
  27545. * @param scene Define the scene the material belong to
  27546. */
  27547. constructor(name: string, scene: Scene);
  27548. /**
  27549. * Gets a boolean indicating that current material needs to register RTT
  27550. */
  27551. get hasRenderTargetTextures(): boolean;
  27552. /**
  27553. * Gets the current class name of the material e.g. "StandardMaterial"
  27554. * Mainly use in serialization.
  27555. * @returns the class name
  27556. */
  27557. getClassName(): string;
  27558. /**
  27559. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27560. * You can try switching to logarithmic depth.
  27561. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27562. */
  27563. get useLogarithmicDepth(): boolean;
  27564. set useLogarithmicDepth(value: boolean);
  27565. /**
  27566. * Specifies if the material will require alpha blending
  27567. * @returns a boolean specifying if alpha blending is needed
  27568. */
  27569. needAlphaBlending(): boolean;
  27570. /**
  27571. * Specifies if this material should be rendered in alpha test mode
  27572. * @returns a boolean specifying if an alpha test is needed.
  27573. */
  27574. needAlphaTesting(): boolean;
  27575. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27576. /**
  27577. * Get the texture used for alpha test purpose.
  27578. * @returns the diffuse texture in case of the standard material.
  27579. */
  27580. getAlphaTestTexture(): Nullable<BaseTexture>;
  27581. /**
  27582. * Get if the submesh is ready to be used and all its information available.
  27583. * Child classes can use it to update shaders
  27584. * @param mesh defines the mesh to check
  27585. * @param subMesh defines which submesh to check
  27586. * @param useInstances specifies that instances should be used
  27587. * @returns a boolean indicating that the submesh is ready or not
  27588. */
  27589. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27590. /**
  27591. * Builds the material UBO layouts.
  27592. * Used internally during the effect preparation.
  27593. */
  27594. buildUniformLayout(): void;
  27595. /**
  27596. * Unbinds the material from the mesh
  27597. */
  27598. unbind(): void;
  27599. /**
  27600. * Binds the submesh to this material by preparing the effect and shader to draw
  27601. * @param world defines the world transformation matrix
  27602. * @param mesh defines the mesh containing the submesh
  27603. * @param subMesh defines the submesh to bind the material to
  27604. */
  27605. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27606. /**
  27607. * Get the list of animatables in the material.
  27608. * @returns the list of animatables object used in the material
  27609. */
  27610. getAnimatables(): IAnimatable[];
  27611. /**
  27612. * Gets the active textures from the material
  27613. * @returns an array of textures
  27614. */
  27615. getActiveTextures(): BaseTexture[];
  27616. /**
  27617. * Specifies if the material uses a texture
  27618. * @param texture defines the texture to check against the material
  27619. * @returns a boolean specifying if the material uses the texture
  27620. */
  27621. hasTexture(texture: BaseTexture): boolean;
  27622. /**
  27623. * Disposes the material
  27624. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27625. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27626. */
  27627. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27628. /**
  27629. * Makes a duplicate of the material, and gives it a new name
  27630. * @param name defines the new name for the duplicated material
  27631. * @returns the cloned material
  27632. */
  27633. clone(name: string): StandardMaterial;
  27634. /**
  27635. * Serializes this material in a JSON representation
  27636. * @returns the serialized material object
  27637. */
  27638. serialize(): any;
  27639. /**
  27640. * Creates a standard material from parsed material data
  27641. * @param source defines the JSON representation of the material
  27642. * @param scene defines the hosting scene
  27643. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27644. * @returns a new standard material
  27645. */
  27646. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27647. /**
  27648. * Are diffuse textures enabled in the application.
  27649. */
  27650. static get DiffuseTextureEnabled(): boolean;
  27651. static set DiffuseTextureEnabled(value: boolean);
  27652. /**
  27653. * Are ambient textures enabled in the application.
  27654. */
  27655. static get AmbientTextureEnabled(): boolean;
  27656. static set AmbientTextureEnabled(value: boolean);
  27657. /**
  27658. * Are opacity textures enabled in the application.
  27659. */
  27660. static get OpacityTextureEnabled(): boolean;
  27661. static set OpacityTextureEnabled(value: boolean);
  27662. /**
  27663. * Are reflection textures enabled in the application.
  27664. */
  27665. static get ReflectionTextureEnabled(): boolean;
  27666. static set ReflectionTextureEnabled(value: boolean);
  27667. /**
  27668. * Are emissive textures enabled in the application.
  27669. */
  27670. static get EmissiveTextureEnabled(): boolean;
  27671. static set EmissiveTextureEnabled(value: boolean);
  27672. /**
  27673. * Are specular textures enabled in the application.
  27674. */
  27675. static get SpecularTextureEnabled(): boolean;
  27676. static set SpecularTextureEnabled(value: boolean);
  27677. /**
  27678. * Are bump textures enabled in the application.
  27679. */
  27680. static get BumpTextureEnabled(): boolean;
  27681. static set BumpTextureEnabled(value: boolean);
  27682. /**
  27683. * Are lightmap textures enabled in the application.
  27684. */
  27685. static get LightmapTextureEnabled(): boolean;
  27686. static set LightmapTextureEnabled(value: boolean);
  27687. /**
  27688. * Are refraction textures enabled in the application.
  27689. */
  27690. static get RefractionTextureEnabled(): boolean;
  27691. static set RefractionTextureEnabled(value: boolean);
  27692. /**
  27693. * Are color grading textures enabled in the application.
  27694. */
  27695. static get ColorGradingTextureEnabled(): boolean;
  27696. static set ColorGradingTextureEnabled(value: boolean);
  27697. /**
  27698. * Are fresnels enabled in the application.
  27699. */
  27700. static get FresnelEnabled(): boolean;
  27701. static set FresnelEnabled(value: boolean);
  27702. }
  27703. }
  27704. declare module "babylonjs/Particles/solidParticleSystem" {
  27705. import { Nullable } from "babylonjs/types";
  27706. import { Vector3 } from "babylonjs/Maths/math.vector";
  27707. import { Mesh } from "babylonjs/Meshes/mesh";
  27708. import { Scene, IDisposable } from "babylonjs/scene";
  27709. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27710. import { Material } from "babylonjs/Materials/material";
  27711. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27712. /**
  27713. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27714. *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.
  27715. * The SPS is also a particle system. It provides some methods to manage the particles.
  27716. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27717. *
  27718. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27719. */
  27720. export class SolidParticleSystem implements IDisposable {
  27721. /**
  27722. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27723. * Example : var p = SPS.particles[i];
  27724. */
  27725. particles: SolidParticle[];
  27726. /**
  27727. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27728. */
  27729. nbParticles: number;
  27730. /**
  27731. * If the particles must ever face the camera (default false). Useful for planar particles.
  27732. */
  27733. billboard: boolean;
  27734. /**
  27735. * Recompute normals when adding a shape
  27736. */
  27737. recomputeNormals: boolean;
  27738. /**
  27739. * This a counter ofr your own usage. It's not set by any SPS functions.
  27740. */
  27741. counter: number;
  27742. /**
  27743. * The SPS name. This name is also given to the underlying mesh.
  27744. */
  27745. name: string;
  27746. /**
  27747. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27748. */
  27749. mesh: Mesh;
  27750. /**
  27751. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27752. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27753. */
  27754. vars: any;
  27755. /**
  27756. * This array is populated when the SPS is set as 'pickable'.
  27757. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27758. * Each element of this array is an object `{idx: int, faceId: int}`.
  27759. * `idx` is the picked particle index in the `SPS.particles` array
  27760. * `faceId` is the picked face index counted within this particle.
  27761. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27762. */
  27763. pickedParticles: {
  27764. idx: number;
  27765. faceId: number;
  27766. }[];
  27767. /**
  27768. * This array is populated when `enableDepthSort` is set to true.
  27769. * Each element of this array is an instance of the class DepthSortedParticle.
  27770. */
  27771. depthSortedParticles: DepthSortedParticle[];
  27772. /**
  27773. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27774. * @hidden
  27775. */
  27776. _bSphereOnly: boolean;
  27777. /**
  27778. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27779. * @hidden
  27780. */
  27781. _bSphereRadiusFactor: number;
  27782. private _scene;
  27783. private _positions;
  27784. private _indices;
  27785. private _normals;
  27786. private _colors;
  27787. private _uvs;
  27788. private _indices32;
  27789. private _positions32;
  27790. private _normals32;
  27791. private _fixedNormal32;
  27792. private _colors32;
  27793. private _uvs32;
  27794. private _index;
  27795. private _updatable;
  27796. private _pickable;
  27797. private _isVisibilityBoxLocked;
  27798. private _alwaysVisible;
  27799. private _depthSort;
  27800. private _expandable;
  27801. private _shapeCounter;
  27802. private _copy;
  27803. private _color;
  27804. private _computeParticleColor;
  27805. private _computeParticleTexture;
  27806. private _computeParticleRotation;
  27807. private _computeParticleVertex;
  27808. private _computeBoundingBox;
  27809. private _depthSortParticles;
  27810. private _camera;
  27811. private _mustUnrotateFixedNormals;
  27812. private _particlesIntersect;
  27813. private _needs32Bits;
  27814. private _isNotBuilt;
  27815. private _lastParticleId;
  27816. private _idxOfId;
  27817. private _multimaterialEnabled;
  27818. private _useModelMaterial;
  27819. private _indicesByMaterial;
  27820. private _materialIndexes;
  27821. private _depthSortFunction;
  27822. private _materialSortFunction;
  27823. private _materials;
  27824. private _multimaterial;
  27825. private _materialIndexesById;
  27826. private _defaultMaterial;
  27827. private _autoUpdateSubMeshes;
  27828. /**
  27829. * Creates a SPS (Solid Particle System) object.
  27830. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27831. * @param scene (Scene) is the scene in which the SPS is added.
  27832. * @param options defines the options of the sps e.g.
  27833. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27834. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27835. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27836. * * 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.
  27837. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27838. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27839. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27840. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27841. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27842. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27843. */
  27844. constructor(name: string, scene: Scene, options?: {
  27845. updatable?: boolean;
  27846. isPickable?: boolean;
  27847. enableDepthSort?: boolean;
  27848. particleIntersection?: boolean;
  27849. boundingSphereOnly?: boolean;
  27850. bSphereRadiusFactor?: number;
  27851. expandable?: boolean;
  27852. useModelMaterial?: boolean;
  27853. enableMultiMaterial?: boolean;
  27854. });
  27855. /**
  27856. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27857. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27858. * @returns the created mesh
  27859. */
  27860. buildMesh(): Mesh;
  27861. /**
  27862. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27863. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27864. * Thus the particles generated from `digest()` have their property `position` set yet.
  27865. * @param mesh ( Mesh ) is the mesh to be digested
  27866. * @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
  27867. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27868. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27869. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27870. * @returns the current SPS
  27871. */
  27872. digest(mesh: Mesh, options?: {
  27873. facetNb?: number;
  27874. number?: number;
  27875. delta?: number;
  27876. storage?: [];
  27877. }): SolidParticleSystem;
  27878. /**
  27879. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27880. * @hidden
  27881. */
  27882. private _unrotateFixedNormals;
  27883. /**
  27884. * Resets the temporary working copy particle
  27885. * @hidden
  27886. */
  27887. private _resetCopy;
  27888. /**
  27889. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27890. * @param p the current index in the positions array to be updated
  27891. * @param ind the current index in the indices array
  27892. * @param shape a Vector3 array, the shape geometry
  27893. * @param positions the positions array to be updated
  27894. * @param meshInd the shape indices array
  27895. * @param indices the indices array to be updated
  27896. * @param meshUV the shape uv array
  27897. * @param uvs the uv array to be updated
  27898. * @param meshCol the shape color array
  27899. * @param colors the color array to be updated
  27900. * @param meshNor the shape normals array
  27901. * @param normals the normals array to be updated
  27902. * @param idx the particle index
  27903. * @param idxInShape the particle index in its shape
  27904. * @param options the addShape() method passed options
  27905. * @model the particle model
  27906. * @hidden
  27907. */
  27908. private _meshBuilder;
  27909. /**
  27910. * Returns a shape Vector3 array from positions float array
  27911. * @param positions float array
  27912. * @returns a vector3 array
  27913. * @hidden
  27914. */
  27915. private _posToShape;
  27916. /**
  27917. * Returns a shapeUV array from a float uvs (array deep copy)
  27918. * @param uvs as a float array
  27919. * @returns a shapeUV array
  27920. * @hidden
  27921. */
  27922. private _uvsToShapeUV;
  27923. /**
  27924. * Adds a new particle object in the particles array
  27925. * @param idx particle index in particles array
  27926. * @param id particle id
  27927. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27928. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27929. * @param model particle ModelShape object
  27930. * @param shapeId model shape identifier
  27931. * @param idxInShape index of the particle in the current model
  27932. * @param bInfo model bounding info object
  27933. * @param storage target storage array, if any
  27934. * @hidden
  27935. */
  27936. private _addParticle;
  27937. /**
  27938. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27939. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27940. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27941. * @param nb (positive integer) the number of particles to be created from this model
  27942. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27943. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27944. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27945. * @returns the number of shapes in the system
  27946. */
  27947. addShape(mesh: Mesh, nb: number, options?: {
  27948. positionFunction?: any;
  27949. vertexFunction?: any;
  27950. storage?: [];
  27951. }): number;
  27952. /**
  27953. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27954. * @hidden
  27955. */
  27956. private _rebuildParticle;
  27957. /**
  27958. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27959. * @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.
  27960. * @returns the SPS.
  27961. */
  27962. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27963. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27964. * Returns an array with the removed particles.
  27965. * 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.
  27966. * The SPS can't be empty so at least one particle needs to remain in place.
  27967. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27968. * @param start index of the first particle to remove
  27969. * @param end index of the last particle to remove (included)
  27970. * @returns an array populated with the removed particles
  27971. */
  27972. removeParticles(start: number, end: number): SolidParticle[];
  27973. /**
  27974. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27975. * @param solidParticleArray an array populated with Solid Particles objects
  27976. * @returns the SPS
  27977. */
  27978. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27979. /**
  27980. * Creates a new particle and modifies the SPS mesh geometry :
  27981. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27982. * - calls _addParticle() to populate the particle array
  27983. * factorized code from addShape() and insertParticlesFromArray()
  27984. * @param idx particle index in the particles array
  27985. * @param i particle index in its shape
  27986. * @param modelShape particle ModelShape object
  27987. * @param shape shape vertex array
  27988. * @param meshInd shape indices array
  27989. * @param meshUV shape uv array
  27990. * @param meshCol shape color array
  27991. * @param meshNor shape normals array
  27992. * @param bbInfo shape bounding info
  27993. * @param storage target particle storage
  27994. * @options addShape() passed options
  27995. * @hidden
  27996. */
  27997. private _insertNewParticle;
  27998. /**
  27999. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28000. * This method calls `updateParticle()` for each particle of the SPS.
  28001. * For an animated SPS, it is usually called within the render loop.
  28002. * 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.
  28003. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28004. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28005. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28006. * @returns the SPS.
  28007. */
  28008. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28009. /**
  28010. * Disposes the SPS.
  28011. */
  28012. dispose(): void;
  28013. /**
  28014. * Returns a SolidParticle object from its identifier : particle.id
  28015. * @param id (integer) the particle Id
  28016. * @returns the searched particle or null if not found in the SPS.
  28017. */
  28018. getParticleById(id: number): Nullable<SolidParticle>;
  28019. /**
  28020. * Returns a new array populated with the particles having the passed shapeId.
  28021. * @param shapeId (integer) the shape identifier
  28022. * @returns a new solid particle array
  28023. */
  28024. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28025. /**
  28026. * Populates the passed array "ref" with the particles having the passed shapeId.
  28027. * @param shapeId the shape identifier
  28028. * @returns the SPS
  28029. * @param ref
  28030. */
  28031. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28032. /**
  28033. * Computes the required SubMeshes according the materials assigned to the particles.
  28034. * @returns the solid particle system.
  28035. * Does nothing if called before the SPS mesh is built.
  28036. */
  28037. computeSubMeshes(): SolidParticleSystem;
  28038. /**
  28039. * Sorts the solid particles by material when MultiMaterial is enabled.
  28040. * Updates the indices32 array.
  28041. * Updates the indicesByMaterial array.
  28042. * Updates the mesh indices array.
  28043. * @returns the SPS
  28044. * @hidden
  28045. */
  28046. private _sortParticlesByMaterial;
  28047. /**
  28048. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28049. * @hidden
  28050. */
  28051. private _setMaterialIndexesById;
  28052. /**
  28053. * Returns an array with unique values of Materials from the passed array
  28054. * @param array the material array to be checked and filtered
  28055. * @hidden
  28056. */
  28057. private _filterUniqueMaterialId;
  28058. /**
  28059. * Sets a new Standard Material as _defaultMaterial if not already set.
  28060. * @hidden
  28061. */
  28062. private _setDefaultMaterial;
  28063. /**
  28064. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28065. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28066. * @returns the SPS.
  28067. */
  28068. refreshVisibleSize(): SolidParticleSystem;
  28069. /**
  28070. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28071. * @param size the size (float) of the visibility box
  28072. * note : this doesn't lock the SPS mesh bounding box.
  28073. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28074. */
  28075. setVisibilityBox(size: number): void;
  28076. /**
  28077. * Gets whether the SPS as always visible or not
  28078. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28079. */
  28080. get isAlwaysVisible(): boolean;
  28081. /**
  28082. * Sets the SPS as always visible or not
  28083. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28084. */
  28085. set isAlwaysVisible(val: boolean);
  28086. /**
  28087. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28088. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28089. */
  28090. set isVisibilityBoxLocked(val: boolean);
  28091. /**
  28092. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28093. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28094. */
  28095. get isVisibilityBoxLocked(): boolean;
  28096. /**
  28097. * Tells to `setParticles()` to compute the particle rotations or not.
  28098. * Default value : true. The SPS is faster when it's set to false.
  28099. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28100. */
  28101. set computeParticleRotation(val: boolean);
  28102. /**
  28103. * Tells to `setParticles()` to compute the particle colors or not.
  28104. * Default value : true. The SPS is faster when it's set to false.
  28105. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28106. */
  28107. set computeParticleColor(val: boolean);
  28108. set computeParticleTexture(val: boolean);
  28109. /**
  28110. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28111. * Default value : false. The SPS is faster when it's set to false.
  28112. * Note : the particle custom vertex positions aren't stored values.
  28113. */
  28114. set computeParticleVertex(val: boolean);
  28115. /**
  28116. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28117. */
  28118. set computeBoundingBox(val: boolean);
  28119. /**
  28120. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28121. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28122. * Default : `true`
  28123. */
  28124. set depthSortParticles(val: boolean);
  28125. /**
  28126. * Gets if `setParticles()` computes the particle rotations or not.
  28127. * Default value : true. The SPS is faster when it's set to false.
  28128. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28129. */
  28130. get computeParticleRotation(): boolean;
  28131. /**
  28132. * Gets if `setParticles()` computes the particle colors or not.
  28133. * Default value : true. The SPS is faster when it's set to false.
  28134. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28135. */
  28136. get computeParticleColor(): boolean;
  28137. /**
  28138. * Gets if `setParticles()` computes the particle textures or not.
  28139. * Default value : true. The SPS is faster when it's set to false.
  28140. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28141. */
  28142. get computeParticleTexture(): boolean;
  28143. /**
  28144. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28145. * Default value : false. The SPS is faster when it's set to false.
  28146. * Note : the particle custom vertex positions aren't stored values.
  28147. */
  28148. get computeParticleVertex(): boolean;
  28149. /**
  28150. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28151. */
  28152. get computeBoundingBox(): boolean;
  28153. /**
  28154. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28155. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28156. * Default : `true`
  28157. */
  28158. get depthSortParticles(): boolean;
  28159. /**
  28160. * Gets if the SPS is created as expandable at construction time.
  28161. * Default : `false`
  28162. */
  28163. get expandable(): boolean;
  28164. /**
  28165. * Gets if the SPS supports the Multi Materials
  28166. */
  28167. get multimaterialEnabled(): boolean;
  28168. /**
  28169. * Gets if the SPS uses the model materials for its own multimaterial.
  28170. */
  28171. get useModelMaterial(): boolean;
  28172. /**
  28173. * The SPS used material array.
  28174. */
  28175. get materials(): Material[];
  28176. /**
  28177. * Sets the SPS MultiMaterial from the passed materials.
  28178. * Note : the passed array is internally copied and not used then by reference.
  28179. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28180. */
  28181. setMultiMaterial(materials: Material[]): void;
  28182. /**
  28183. * The SPS computed multimaterial object
  28184. */
  28185. get multimaterial(): MultiMaterial;
  28186. set multimaterial(mm: MultiMaterial);
  28187. /**
  28188. * If the subMeshes must be updated on the next call to setParticles()
  28189. */
  28190. get autoUpdateSubMeshes(): boolean;
  28191. set autoUpdateSubMeshes(val: boolean);
  28192. /**
  28193. * This function does nothing. It may be overwritten to set all the particle first values.
  28194. * The SPS doesn't call this function, you may have to call it by your own.
  28195. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28196. */
  28197. initParticles(): void;
  28198. /**
  28199. * This function does nothing. It may be overwritten to recycle a particle.
  28200. * The SPS doesn't call this function, you may have to call it by your own.
  28201. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28202. * @param particle The particle to recycle
  28203. * @returns the recycled particle
  28204. */
  28205. recycleParticle(particle: SolidParticle): SolidParticle;
  28206. /**
  28207. * Updates a particle : this function should be overwritten by the user.
  28208. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28209. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28210. * @example : just set a particle position or velocity and recycle conditions
  28211. * @param particle The particle to update
  28212. * @returns the updated particle
  28213. */
  28214. updateParticle(particle: SolidParticle): SolidParticle;
  28215. /**
  28216. * Updates a vertex of a particle : it can be overwritten by the user.
  28217. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28218. * @param particle the current particle
  28219. * @param vertex the current index of the current particle
  28220. * @param pt the index of the current vertex in the particle shape
  28221. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28222. * @example : just set a vertex particle position
  28223. * @returns the updated vertex
  28224. */
  28225. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28226. /**
  28227. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28228. * This does nothing and may be overwritten by the user.
  28229. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28230. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28231. * @param update the boolean update value actually passed to setParticles()
  28232. */
  28233. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28234. /**
  28235. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28236. * This will be passed three parameters.
  28237. * This does nothing and may be overwritten by the user.
  28238. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28239. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28240. * @param update the boolean update value actually passed to setParticles()
  28241. */
  28242. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28243. }
  28244. }
  28245. declare module "babylonjs/Particles/solidParticle" {
  28246. import { Nullable } from "babylonjs/types";
  28247. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28248. import { Color4 } from "babylonjs/Maths/math.color";
  28249. import { Mesh } from "babylonjs/Meshes/mesh";
  28250. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28251. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28252. import { Plane } from "babylonjs/Maths/math.plane";
  28253. import { Material } from "babylonjs/Materials/material";
  28254. /**
  28255. * Represents one particle of a solid particle system.
  28256. */
  28257. export class SolidParticle {
  28258. /**
  28259. * particle global index
  28260. */
  28261. idx: number;
  28262. /**
  28263. * particle identifier
  28264. */
  28265. id: number;
  28266. /**
  28267. * The color of the particle
  28268. */
  28269. color: Nullable<Color4>;
  28270. /**
  28271. * The world space position of the particle.
  28272. */
  28273. position: Vector3;
  28274. /**
  28275. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28276. */
  28277. rotation: Vector3;
  28278. /**
  28279. * The world space rotation quaternion of the particle.
  28280. */
  28281. rotationQuaternion: Nullable<Quaternion>;
  28282. /**
  28283. * The scaling of the particle.
  28284. */
  28285. scaling: Vector3;
  28286. /**
  28287. * The uvs of the particle.
  28288. */
  28289. uvs: Vector4;
  28290. /**
  28291. * The current speed of the particle.
  28292. */
  28293. velocity: Vector3;
  28294. /**
  28295. * The pivot point in the particle local space.
  28296. */
  28297. pivot: Vector3;
  28298. /**
  28299. * Must the particle be translated from its pivot point in its local space ?
  28300. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28301. * Default : false
  28302. */
  28303. translateFromPivot: boolean;
  28304. /**
  28305. * Is the particle active or not ?
  28306. */
  28307. alive: boolean;
  28308. /**
  28309. * Is the particle visible or not ?
  28310. */
  28311. isVisible: boolean;
  28312. /**
  28313. * Index of this particle in the global "positions" array (Internal use)
  28314. * @hidden
  28315. */
  28316. _pos: number;
  28317. /**
  28318. * @hidden Index of this particle in the global "indices" array (Internal use)
  28319. */
  28320. _ind: number;
  28321. /**
  28322. * @hidden ModelShape of this particle (Internal use)
  28323. */
  28324. _model: ModelShape;
  28325. /**
  28326. * ModelShape id of this particle
  28327. */
  28328. shapeId: number;
  28329. /**
  28330. * Index of the particle in its shape id
  28331. */
  28332. idxInShape: number;
  28333. /**
  28334. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28335. */
  28336. _modelBoundingInfo: BoundingInfo;
  28337. /**
  28338. * @hidden Particle BoundingInfo object (Internal use)
  28339. */
  28340. _boundingInfo: BoundingInfo;
  28341. /**
  28342. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28343. */
  28344. _sps: SolidParticleSystem;
  28345. /**
  28346. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28347. */
  28348. _stillInvisible: boolean;
  28349. /**
  28350. * @hidden Last computed particle rotation matrix
  28351. */
  28352. _rotationMatrix: number[];
  28353. /**
  28354. * Parent particle Id, if any.
  28355. * Default null.
  28356. */
  28357. parentId: Nullable<number>;
  28358. /**
  28359. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28360. */
  28361. materialIndex: Nullable<number>;
  28362. /**
  28363. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28364. * The possible values are :
  28365. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28366. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28367. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28368. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28369. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28370. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28371. * */
  28372. cullingStrategy: number;
  28373. /**
  28374. * @hidden Internal global position in the SPS.
  28375. */
  28376. _globalPosition: Vector3;
  28377. /**
  28378. * Creates a Solid Particle object.
  28379. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28380. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28381. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28382. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28383. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28384. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28385. * @param shapeId (integer) is the model shape identifier in the SPS.
  28386. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28387. * @param sps defines the sps it is associated to
  28388. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28389. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28390. */
  28391. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28392. /**
  28393. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28394. * @param target the particle target
  28395. * @returns the current particle
  28396. */
  28397. copyToRef(target: SolidParticle): SolidParticle;
  28398. /**
  28399. * Legacy support, changed scale to scaling
  28400. */
  28401. get scale(): Vector3;
  28402. /**
  28403. * Legacy support, changed scale to scaling
  28404. */
  28405. set scale(scale: Vector3);
  28406. /**
  28407. * Legacy support, changed quaternion to rotationQuaternion
  28408. */
  28409. get quaternion(): Nullable<Quaternion>;
  28410. /**
  28411. * Legacy support, changed quaternion to rotationQuaternion
  28412. */
  28413. set quaternion(q: Nullable<Quaternion>);
  28414. /**
  28415. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28416. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28417. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28418. * @returns true if it intersects
  28419. */
  28420. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28421. /**
  28422. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28423. * A particle is in the frustum if its bounding box intersects the frustum
  28424. * @param frustumPlanes defines the frustum to test
  28425. * @returns true if the particle is in the frustum planes
  28426. */
  28427. isInFrustum(frustumPlanes: Plane[]): boolean;
  28428. /**
  28429. * get the rotation matrix of the particle
  28430. * @hidden
  28431. */
  28432. getRotationMatrix(m: Matrix): void;
  28433. }
  28434. /**
  28435. * Represents the shape of the model used by one particle of a solid particle system.
  28436. * SPS internal tool, don't use it manually.
  28437. */
  28438. export class ModelShape {
  28439. /**
  28440. * The shape id
  28441. * @hidden
  28442. */
  28443. shapeID: number;
  28444. /**
  28445. * flat array of model positions (internal use)
  28446. * @hidden
  28447. */
  28448. _shape: Vector3[];
  28449. /**
  28450. * flat array of model UVs (internal use)
  28451. * @hidden
  28452. */
  28453. _shapeUV: number[];
  28454. /**
  28455. * color array of the model
  28456. * @hidden
  28457. */
  28458. _shapeColors: number[];
  28459. /**
  28460. * indices array of the model
  28461. * @hidden
  28462. */
  28463. _indices: number[];
  28464. /**
  28465. * normals array of the model
  28466. * @hidden
  28467. */
  28468. _normals: number[];
  28469. /**
  28470. * length of the shape in the model indices array (internal use)
  28471. * @hidden
  28472. */
  28473. _indicesLength: number;
  28474. /**
  28475. * Custom position function (internal use)
  28476. * @hidden
  28477. */
  28478. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28479. /**
  28480. * Custom vertex function (internal use)
  28481. * @hidden
  28482. */
  28483. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28484. /**
  28485. * Model material (internal use)
  28486. * @hidden
  28487. */
  28488. _material: Nullable<Material>;
  28489. /**
  28490. * 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.
  28491. * SPS internal tool, don't use it manually.
  28492. * @hidden
  28493. */
  28494. 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>);
  28495. }
  28496. /**
  28497. * Represents a Depth Sorted Particle in the solid particle system.
  28498. * @hidden
  28499. */
  28500. export class DepthSortedParticle {
  28501. /**
  28502. * Index of the particle in the "indices" array
  28503. */
  28504. ind: number;
  28505. /**
  28506. * Length of the particle shape in the "indices" array
  28507. */
  28508. indicesLength: number;
  28509. /**
  28510. * Squared distance from the particle to the camera
  28511. */
  28512. sqDistance: number;
  28513. /**
  28514. * Material index when used with MultiMaterials
  28515. */
  28516. materialIndex: number;
  28517. /**
  28518. * Creates a new sorted particle
  28519. * @param materialIndex
  28520. */
  28521. constructor(ind: number, indLength: number, materialIndex: number);
  28522. }
  28523. }
  28524. declare module "babylonjs/Collisions/meshCollisionData" {
  28525. import { Collider } from "babylonjs/Collisions/collider";
  28526. import { Vector3 } from "babylonjs/Maths/math.vector";
  28527. import { Nullable } from "babylonjs/types";
  28528. import { Observer } from "babylonjs/Misc/observable";
  28529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28530. /**
  28531. * @hidden
  28532. */
  28533. export class _MeshCollisionData {
  28534. _checkCollisions: boolean;
  28535. _collisionMask: number;
  28536. _collisionGroup: number;
  28537. _collider: Nullable<Collider>;
  28538. _oldPositionForCollisions: Vector3;
  28539. _diffPositionForCollisions: Vector3;
  28540. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28541. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28542. }
  28543. }
  28544. declare module "babylonjs/Meshes/abstractMesh" {
  28545. import { Observable } from "babylonjs/Misc/observable";
  28546. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28547. import { Camera } from "babylonjs/Cameras/camera";
  28548. import { Scene, IDisposable } from "babylonjs/scene";
  28549. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28550. import { Node } from "babylonjs/node";
  28551. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28552. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28553. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28554. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28555. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28556. import { Material } from "babylonjs/Materials/material";
  28557. import { Light } from "babylonjs/Lights/light";
  28558. import { Skeleton } from "babylonjs/Bones/skeleton";
  28559. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28560. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28561. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28562. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28563. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28564. import { Plane } from "babylonjs/Maths/math.plane";
  28565. import { Ray } from "babylonjs/Culling/ray";
  28566. import { Collider } from "babylonjs/Collisions/collider";
  28567. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28568. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28569. /** @hidden */
  28570. class _FacetDataStorage {
  28571. facetPositions: Vector3[];
  28572. facetNormals: Vector3[];
  28573. facetPartitioning: number[][];
  28574. facetNb: number;
  28575. partitioningSubdivisions: number;
  28576. partitioningBBoxRatio: number;
  28577. facetDataEnabled: boolean;
  28578. facetParameters: any;
  28579. bbSize: Vector3;
  28580. subDiv: {
  28581. max: number;
  28582. X: number;
  28583. Y: number;
  28584. Z: number;
  28585. };
  28586. facetDepthSort: boolean;
  28587. facetDepthSortEnabled: boolean;
  28588. depthSortedIndices: IndicesArray;
  28589. depthSortedFacets: {
  28590. ind: number;
  28591. sqDistance: number;
  28592. }[];
  28593. facetDepthSortFunction: (f1: {
  28594. ind: number;
  28595. sqDistance: number;
  28596. }, f2: {
  28597. ind: number;
  28598. sqDistance: number;
  28599. }) => number;
  28600. facetDepthSortFrom: Vector3;
  28601. facetDepthSortOrigin: Vector3;
  28602. invertedMatrix: Matrix;
  28603. }
  28604. /**
  28605. * @hidden
  28606. **/
  28607. class _InternalAbstractMeshDataInfo {
  28608. _hasVertexAlpha: boolean;
  28609. _useVertexColors: boolean;
  28610. _numBoneInfluencers: number;
  28611. _applyFog: boolean;
  28612. _receiveShadows: boolean;
  28613. _facetData: _FacetDataStorage;
  28614. _visibility: number;
  28615. _skeleton: Nullable<Skeleton>;
  28616. _layerMask: number;
  28617. _computeBonesUsingShaders: boolean;
  28618. _isActive: boolean;
  28619. _onlyForInstances: boolean;
  28620. _isActiveIntermediate: boolean;
  28621. _onlyForInstancesIntermediate: boolean;
  28622. _actAsRegularMesh: boolean;
  28623. }
  28624. /**
  28625. * Class used to store all common mesh properties
  28626. */
  28627. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28628. /** No occlusion */
  28629. static OCCLUSION_TYPE_NONE: number;
  28630. /** Occlusion set to optimisitic */
  28631. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28632. /** Occlusion set to strict */
  28633. static OCCLUSION_TYPE_STRICT: number;
  28634. /** Use an accurante occlusion algorithm */
  28635. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28636. /** Use a conservative occlusion algorithm */
  28637. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28638. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28639. * Test order :
  28640. * Is the bounding sphere outside the frustum ?
  28641. * If not, are the bounding box vertices outside the frustum ?
  28642. * It not, then the cullable object is in the frustum.
  28643. */
  28644. static readonly CULLINGSTRATEGY_STANDARD: number;
  28645. /** Culling strategy : Bounding Sphere Only.
  28646. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28647. * It's also less accurate than the standard because some not visible objects can still be selected.
  28648. * Test : is the bounding sphere outside the frustum ?
  28649. * If not, then the cullable object is in the frustum.
  28650. */
  28651. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28652. /** Culling strategy : Optimistic Inclusion.
  28653. * This in an inclusion test first, then the standard exclusion test.
  28654. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28655. * 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.
  28656. * Anyway, it's as accurate as the standard strategy.
  28657. * Test :
  28658. * Is the cullable object bounding sphere center in the frustum ?
  28659. * If not, apply the default culling strategy.
  28660. */
  28661. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28662. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28663. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28664. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28665. * 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.
  28666. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28667. * Test :
  28668. * Is the cullable object bounding sphere center in the frustum ?
  28669. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28670. */
  28671. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28672. /**
  28673. * No billboard
  28674. */
  28675. static get BILLBOARDMODE_NONE(): number;
  28676. /** Billboard on X axis */
  28677. static get BILLBOARDMODE_X(): number;
  28678. /** Billboard on Y axis */
  28679. static get BILLBOARDMODE_Y(): number;
  28680. /** Billboard on Z axis */
  28681. static get BILLBOARDMODE_Z(): number;
  28682. /** Billboard on all axes */
  28683. static get BILLBOARDMODE_ALL(): number;
  28684. /** Billboard on using position instead of orientation */
  28685. static get BILLBOARDMODE_USE_POSITION(): number;
  28686. /** @hidden */
  28687. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28688. /**
  28689. * The culling strategy to use to check whether the mesh must be rendered or not.
  28690. * This value can be changed at any time and will be used on the next render mesh selection.
  28691. * The possible values are :
  28692. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28693. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28694. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28695. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28696. * Please read each static variable documentation to get details about the culling process.
  28697. * */
  28698. cullingStrategy: number;
  28699. /**
  28700. * Gets the number of facets in the mesh
  28701. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28702. */
  28703. get facetNb(): number;
  28704. /**
  28705. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28706. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28707. */
  28708. get partitioningSubdivisions(): number;
  28709. set partitioningSubdivisions(nb: number);
  28710. /**
  28711. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28712. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28713. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28714. */
  28715. get partitioningBBoxRatio(): number;
  28716. set partitioningBBoxRatio(ratio: number);
  28717. /**
  28718. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28719. * Works only for updatable meshes.
  28720. * Doesn't work with multi-materials
  28721. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28722. */
  28723. get mustDepthSortFacets(): boolean;
  28724. set mustDepthSortFacets(sort: boolean);
  28725. /**
  28726. * The location (Vector3) where the facet depth sort must be computed from.
  28727. * By default, the active camera position.
  28728. * Used only when facet depth sort is enabled
  28729. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28730. */
  28731. get facetDepthSortFrom(): Vector3;
  28732. set facetDepthSortFrom(location: Vector3);
  28733. /**
  28734. * gets a boolean indicating if facetData is enabled
  28735. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28736. */
  28737. get isFacetDataEnabled(): boolean;
  28738. /** @hidden */
  28739. _updateNonUniformScalingState(value: boolean): boolean;
  28740. /**
  28741. * An event triggered when this mesh collides with another one
  28742. */
  28743. onCollideObservable: Observable<AbstractMesh>;
  28744. /** Set a function to call when this mesh collides with another one */
  28745. set onCollide(callback: () => void);
  28746. /**
  28747. * An event triggered when the collision's position changes
  28748. */
  28749. onCollisionPositionChangeObservable: Observable<Vector3>;
  28750. /** Set a function to call when the collision's position changes */
  28751. set onCollisionPositionChange(callback: () => void);
  28752. /**
  28753. * An event triggered when material is changed
  28754. */
  28755. onMaterialChangedObservable: Observable<AbstractMesh>;
  28756. /**
  28757. * Gets or sets the orientation for POV movement & rotation
  28758. */
  28759. definedFacingForward: boolean;
  28760. /** @hidden */
  28761. _occlusionQuery: Nullable<WebGLQuery>;
  28762. /** @hidden */
  28763. _renderingGroup: Nullable<RenderingGroup>;
  28764. /**
  28765. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28766. */
  28767. get visibility(): number;
  28768. /**
  28769. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28770. */
  28771. set visibility(value: number);
  28772. /** Gets or sets the alpha index used to sort transparent meshes
  28773. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28774. */
  28775. alphaIndex: number;
  28776. /**
  28777. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28778. */
  28779. isVisible: boolean;
  28780. /**
  28781. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28782. */
  28783. isPickable: boolean;
  28784. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28785. showSubMeshesBoundingBox: boolean;
  28786. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28787. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28788. */
  28789. isBlocker: boolean;
  28790. /**
  28791. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28792. */
  28793. enablePointerMoveEvents: boolean;
  28794. /**
  28795. * Specifies the rendering group id for this mesh (0 by default)
  28796. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28797. */
  28798. renderingGroupId: number;
  28799. private _material;
  28800. /** Gets or sets current material */
  28801. get material(): Nullable<Material>;
  28802. set material(value: Nullable<Material>);
  28803. /**
  28804. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28805. * @see http://doc.babylonjs.com/babylon101/shadows
  28806. */
  28807. get receiveShadows(): boolean;
  28808. set receiveShadows(value: boolean);
  28809. /** Defines color to use when rendering outline */
  28810. outlineColor: Color3;
  28811. /** Define width to use when rendering outline */
  28812. outlineWidth: number;
  28813. /** Defines color to use when rendering overlay */
  28814. overlayColor: Color3;
  28815. /** Defines alpha to use when rendering overlay */
  28816. overlayAlpha: number;
  28817. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28818. get hasVertexAlpha(): boolean;
  28819. set hasVertexAlpha(value: boolean);
  28820. /** 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) */
  28821. get useVertexColors(): boolean;
  28822. set useVertexColors(value: boolean);
  28823. /**
  28824. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28825. */
  28826. get computeBonesUsingShaders(): boolean;
  28827. set computeBonesUsingShaders(value: boolean);
  28828. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28829. get numBoneInfluencers(): number;
  28830. set numBoneInfluencers(value: number);
  28831. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28832. get applyFog(): boolean;
  28833. set applyFog(value: boolean);
  28834. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28835. useOctreeForRenderingSelection: boolean;
  28836. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28837. useOctreeForPicking: boolean;
  28838. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28839. useOctreeForCollisions: boolean;
  28840. /**
  28841. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28842. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28843. */
  28844. get layerMask(): number;
  28845. set layerMask(value: number);
  28846. /**
  28847. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28848. */
  28849. alwaysSelectAsActiveMesh: boolean;
  28850. /**
  28851. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28852. */
  28853. doNotSyncBoundingInfo: boolean;
  28854. /**
  28855. * Gets or sets the current action manager
  28856. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28857. */
  28858. actionManager: Nullable<AbstractActionManager>;
  28859. private _meshCollisionData;
  28860. /**
  28861. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28862. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28863. */
  28864. ellipsoid: Vector3;
  28865. /**
  28866. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28867. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28868. */
  28869. ellipsoidOffset: Vector3;
  28870. /**
  28871. * Gets or sets a collision mask used to mask collisions (default is -1).
  28872. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28873. */
  28874. get collisionMask(): number;
  28875. set collisionMask(mask: number);
  28876. /**
  28877. * Gets or sets the current collision group mask (-1 by default).
  28878. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28879. */
  28880. get collisionGroup(): number;
  28881. set collisionGroup(mask: number);
  28882. /**
  28883. * Defines edge width used when edgesRenderer is enabled
  28884. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28885. */
  28886. edgesWidth: number;
  28887. /**
  28888. * Defines edge color used when edgesRenderer is enabled
  28889. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28890. */
  28891. edgesColor: Color4;
  28892. /** @hidden */
  28893. _edgesRenderer: Nullable<IEdgesRenderer>;
  28894. /** @hidden */
  28895. _masterMesh: Nullable<AbstractMesh>;
  28896. /** @hidden */
  28897. _boundingInfo: Nullable<BoundingInfo>;
  28898. /** @hidden */
  28899. _renderId: number;
  28900. /**
  28901. * Gets or sets the list of subMeshes
  28902. * @see http://doc.babylonjs.com/how_to/multi_materials
  28903. */
  28904. subMeshes: SubMesh[];
  28905. /** @hidden */
  28906. _intersectionsInProgress: AbstractMesh[];
  28907. /** @hidden */
  28908. _unIndexed: boolean;
  28909. /** @hidden */
  28910. _lightSources: Light[];
  28911. /** Gets the list of lights affecting that mesh */
  28912. get lightSources(): Light[];
  28913. /** @hidden */
  28914. get _positions(): Nullable<Vector3[]>;
  28915. /** @hidden */
  28916. _waitingData: {
  28917. lods: Nullable<any>;
  28918. actions: Nullable<any>;
  28919. freezeWorldMatrix: Nullable<boolean>;
  28920. };
  28921. /** @hidden */
  28922. _bonesTransformMatrices: Nullable<Float32Array>;
  28923. /** @hidden */
  28924. _transformMatrixTexture: Nullable<RawTexture>;
  28925. /**
  28926. * Gets or sets a skeleton to apply skining transformations
  28927. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28928. */
  28929. set skeleton(value: Nullable<Skeleton>);
  28930. get skeleton(): Nullable<Skeleton>;
  28931. /**
  28932. * An event triggered when the mesh is rebuilt.
  28933. */
  28934. onRebuildObservable: Observable<AbstractMesh>;
  28935. /**
  28936. * Creates a new AbstractMesh
  28937. * @param name defines the name of the mesh
  28938. * @param scene defines the hosting scene
  28939. */
  28940. constructor(name: string, scene?: Nullable<Scene>);
  28941. /**
  28942. * Returns the string "AbstractMesh"
  28943. * @returns "AbstractMesh"
  28944. */
  28945. getClassName(): string;
  28946. /**
  28947. * Gets a string representation of the current mesh
  28948. * @param fullDetails defines a boolean indicating if full details must be included
  28949. * @returns a string representation of the current mesh
  28950. */
  28951. toString(fullDetails?: boolean): string;
  28952. /**
  28953. * @hidden
  28954. */
  28955. protected _getEffectiveParent(): Nullable<Node>;
  28956. /** @hidden */
  28957. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28958. /** @hidden */
  28959. _rebuild(): void;
  28960. /** @hidden */
  28961. _resyncLightSources(): void;
  28962. /** @hidden */
  28963. _resyncLightSource(light: Light): void;
  28964. /** @hidden */
  28965. _unBindEffect(): void;
  28966. /** @hidden */
  28967. _removeLightSource(light: Light, dispose: boolean): void;
  28968. private _markSubMeshesAsDirty;
  28969. /** @hidden */
  28970. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28971. /** @hidden */
  28972. _markSubMeshesAsAttributesDirty(): void;
  28973. /** @hidden */
  28974. _markSubMeshesAsMiscDirty(): void;
  28975. /**
  28976. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28977. */
  28978. get scaling(): Vector3;
  28979. set scaling(newScaling: Vector3);
  28980. /**
  28981. * Returns true if the mesh is blocked. Implemented by child classes
  28982. */
  28983. get isBlocked(): boolean;
  28984. /**
  28985. * Returns the mesh itself by default. Implemented by child classes
  28986. * @param camera defines the camera to use to pick the right LOD level
  28987. * @returns the currentAbstractMesh
  28988. */
  28989. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28990. /**
  28991. * Returns 0 by default. Implemented by child classes
  28992. * @returns an integer
  28993. */
  28994. getTotalVertices(): number;
  28995. /**
  28996. * Returns a positive integer : the total number of indices in this mesh geometry.
  28997. * @returns the numner of indices or zero if the mesh has no geometry.
  28998. */
  28999. getTotalIndices(): number;
  29000. /**
  29001. * Returns null by default. Implemented by child classes
  29002. * @returns null
  29003. */
  29004. getIndices(): Nullable<IndicesArray>;
  29005. /**
  29006. * Returns the array of the requested vertex data kind. Implemented by child classes
  29007. * @param kind defines the vertex data kind to use
  29008. * @returns null
  29009. */
  29010. getVerticesData(kind: string): Nullable<FloatArray>;
  29011. /**
  29012. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29013. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29014. * Note that a new underlying VertexBuffer object is created each call.
  29015. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29016. * @param kind defines vertex data kind:
  29017. * * VertexBuffer.PositionKind
  29018. * * VertexBuffer.UVKind
  29019. * * VertexBuffer.UV2Kind
  29020. * * VertexBuffer.UV3Kind
  29021. * * VertexBuffer.UV4Kind
  29022. * * VertexBuffer.UV5Kind
  29023. * * VertexBuffer.UV6Kind
  29024. * * VertexBuffer.ColorKind
  29025. * * VertexBuffer.MatricesIndicesKind
  29026. * * VertexBuffer.MatricesIndicesExtraKind
  29027. * * VertexBuffer.MatricesWeightsKind
  29028. * * VertexBuffer.MatricesWeightsExtraKind
  29029. * @param data defines the data source
  29030. * @param updatable defines if the data must be flagged as updatable (or static)
  29031. * @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
  29032. * @returns the current mesh
  29033. */
  29034. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29035. /**
  29036. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29037. * If the mesh has no geometry, it is simply returned as it is.
  29038. * @param kind defines vertex data kind:
  29039. * * VertexBuffer.PositionKind
  29040. * * VertexBuffer.UVKind
  29041. * * VertexBuffer.UV2Kind
  29042. * * VertexBuffer.UV3Kind
  29043. * * VertexBuffer.UV4Kind
  29044. * * VertexBuffer.UV5Kind
  29045. * * VertexBuffer.UV6Kind
  29046. * * VertexBuffer.ColorKind
  29047. * * VertexBuffer.MatricesIndicesKind
  29048. * * VertexBuffer.MatricesIndicesExtraKind
  29049. * * VertexBuffer.MatricesWeightsKind
  29050. * * VertexBuffer.MatricesWeightsExtraKind
  29051. * @param data defines the data source
  29052. * @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
  29053. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29054. * @returns the current mesh
  29055. */
  29056. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29057. /**
  29058. * Sets the mesh indices,
  29059. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29060. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29061. * @param totalVertices Defines the total number of vertices
  29062. * @returns the current mesh
  29063. */
  29064. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29065. /**
  29066. * Gets a boolean indicating if specific vertex data is present
  29067. * @param kind defines the vertex data kind to use
  29068. * @returns true is data kind is present
  29069. */
  29070. isVerticesDataPresent(kind: string): boolean;
  29071. /**
  29072. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29073. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29074. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29075. * @returns a BoundingInfo
  29076. */
  29077. getBoundingInfo(): BoundingInfo;
  29078. /**
  29079. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29080. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29081. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29082. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29083. * @returns the current mesh
  29084. */
  29085. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29086. /**
  29087. * Overwrite the current bounding info
  29088. * @param boundingInfo defines the new bounding info
  29089. * @returns the current mesh
  29090. */
  29091. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29092. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29093. get useBones(): boolean;
  29094. /** @hidden */
  29095. _preActivate(): void;
  29096. /** @hidden */
  29097. _preActivateForIntermediateRendering(renderId: number): void;
  29098. /** @hidden */
  29099. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29100. /** @hidden */
  29101. _postActivate(): void;
  29102. /** @hidden */
  29103. _freeze(): void;
  29104. /** @hidden */
  29105. _unFreeze(): void;
  29106. /**
  29107. * Gets the current world matrix
  29108. * @returns a Matrix
  29109. */
  29110. getWorldMatrix(): Matrix;
  29111. /** @hidden */
  29112. _getWorldMatrixDeterminant(): number;
  29113. /**
  29114. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29115. */
  29116. get isAnInstance(): boolean;
  29117. /**
  29118. * Gets a boolean indicating if this mesh has instances
  29119. */
  29120. get hasInstances(): boolean;
  29121. /**
  29122. * Perform relative position change from the point of view of behind the front of the mesh.
  29123. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29124. * Supports definition of mesh facing forward or backward
  29125. * @param amountRight defines the distance on the right axis
  29126. * @param amountUp defines the distance on the up axis
  29127. * @param amountForward defines the distance on the forward axis
  29128. * @returns the current mesh
  29129. */
  29130. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29131. /**
  29132. * Calculate relative position change from the point of view of behind the front of the mesh.
  29133. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29134. * Supports definition of mesh facing forward or backward
  29135. * @param amountRight defines the distance on the right axis
  29136. * @param amountUp defines the distance on the up axis
  29137. * @param amountForward defines the distance on the forward axis
  29138. * @returns the new displacement vector
  29139. */
  29140. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29141. /**
  29142. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29143. * Supports definition of mesh facing forward or backward
  29144. * @param flipBack defines the flip
  29145. * @param twirlClockwise defines the twirl
  29146. * @param tiltRight defines the tilt
  29147. * @returns the current mesh
  29148. */
  29149. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29150. /**
  29151. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29152. * Supports definition of mesh facing forward or backward.
  29153. * @param flipBack defines the flip
  29154. * @param twirlClockwise defines the twirl
  29155. * @param tiltRight defines the tilt
  29156. * @returns the new rotation vector
  29157. */
  29158. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29159. /**
  29160. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29161. * This means the mesh underlying bounding box and sphere are recomputed.
  29162. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29163. * @returns the current mesh
  29164. */
  29165. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29166. /** @hidden */
  29167. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29168. /** @hidden */
  29169. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29170. /** @hidden */
  29171. _updateBoundingInfo(): AbstractMesh;
  29172. /** @hidden */
  29173. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29174. /** @hidden */
  29175. protected _afterComputeWorldMatrix(): void;
  29176. /** @hidden */
  29177. get _effectiveMesh(): AbstractMesh;
  29178. /**
  29179. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29180. * A mesh is in the frustum if its bounding box intersects the frustum
  29181. * @param frustumPlanes defines the frustum to test
  29182. * @returns true if the mesh is in the frustum planes
  29183. */
  29184. isInFrustum(frustumPlanes: Plane[]): boolean;
  29185. /**
  29186. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29187. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29188. * @param frustumPlanes defines the frustum to test
  29189. * @returns true if the mesh is completely in the frustum planes
  29190. */
  29191. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29192. /**
  29193. * True if the mesh intersects another mesh or a SolidParticle object
  29194. * @param mesh defines a target mesh or SolidParticle to test
  29195. * @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)
  29196. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29197. * @returns true if there is an intersection
  29198. */
  29199. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29200. /**
  29201. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29202. * @param point defines the point to test
  29203. * @returns true if there is an intersection
  29204. */
  29205. intersectsPoint(point: Vector3): boolean;
  29206. /**
  29207. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29208. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29209. */
  29210. get checkCollisions(): boolean;
  29211. set checkCollisions(collisionEnabled: boolean);
  29212. /**
  29213. * Gets Collider object used to compute collisions (not physics)
  29214. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29215. */
  29216. get collider(): Nullable<Collider>;
  29217. /**
  29218. * Move the mesh using collision engine
  29219. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29220. * @param displacement defines the requested displacement vector
  29221. * @returns the current mesh
  29222. */
  29223. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29224. private _onCollisionPositionChange;
  29225. /** @hidden */
  29226. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29227. /** @hidden */
  29228. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29229. /** @hidden */
  29230. _checkCollision(collider: Collider): AbstractMesh;
  29231. /** @hidden */
  29232. _generatePointsArray(): boolean;
  29233. /**
  29234. * Checks if the passed Ray intersects with the mesh
  29235. * @param ray defines the ray to use
  29236. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29237. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29238. * @returns the picking info
  29239. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29240. */
  29241. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29242. /**
  29243. * Clones the current mesh
  29244. * @param name defines the mesh name
  29245. * @param newParent defines the new mesh parent
  29246. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29247. * @returns the new mesh
  29248. */
  29249. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29250. /**
  29251. * Disposes all the submeshes of the current meshnp
  29252. * @returns the current mesh
  29253. */
  29254. releaseSubMeshes(): AbstractMesh;
  29255. /**
  29256. * Releases resources associated with this abstract mesh.
  29257. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29258. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29259. */
  29260. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29261. /**
  29262. * Adds the passed mesh as a child to the current mesh
  29263. * @param mesh defines the child mesh
  29264. * @returns the current mesh
  29265. */
  29266. addChild(mesh: AbstractMesh): AbstractMesh;
  29267. /**
  29268. * Removes the passed mesh from the current mesh children list
  29269. * @param mesh defines the child mesh
  29270. * @returns the current mesh
  29271. */
  29272. removeChild(mesh: AbstractMesh): AbstractMesh;
  29273. /** @hidden */
  29274. private _initFacetData;
  29275. /**
  29276. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29277. * This method can be called within the render loop.
  29278. * 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
  29279. * @returns the current mesh
  29280. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29281. */
  29282. updateFacetData(): AbstractMesh;
  29283. /**
  29284. * Returns the facetLocalNormals array.
  29285. * The normals are expressed in the mesh local spac
  29286. * @returns an array of Vector3
  29287. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29288. */
  29289. getFacetLocalNormals(): Vector3[];
  29290. /**
  29291. * Returns the facetLocalPositions array.
  29292. * The facet positions are expressed in the mesh local space
  29293. * @returns an array of Vector3
  29294. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29295. */
  29296. getFacetLocalPositions(): Vector3[];
  29297. /**
  29298. * Returns the facetLocalPartioning array
  29299. * @returns an array of array of numbers
  29300. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29301. */
  29302. getFacetLocalPartitioning(): number[][];
  29303. /**
  29304. * Returns the i-th facet position in the world system.
  29305. * This method allocates a new Vector3 per call
  29306. * @param i defines the facet index
  29307. * @returns a new Vector3
  29308. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29309. */
  29310. getFacetPosition(i: number): Vector3;
  29311. /**
  29312. * Sets the reference Vector3 with the i-th facet position in the world system
  29313. * @param i defines the facet index
  29314. * @param ref defines the target vector
  29315. * @returns the current mesh
  29316. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29317. */
  29318. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29319. /**
  29320. * Returns the i-th facet normal in the world system.
  29321. * This method allocates a new Vector3 per call
  29322. * @param i defines the facet index
  29323. * @returns a new Vector3
  29324. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29325. */
  29326. getFacetNormal(i: number): Vector3;
  29327. /**
  29328. * Sets the reference Vector3 with the i-th facet normal in the world system
  29329. * @param i defines the facet index
  29330. * @param ref defines the target vector
  29331. * @returns the current mesh
  29332. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29333. */
  29334. getFacetNormalToRef(i: number, ref: Vector3): this;
  29335. /**
  29336. * 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)
  29337. * @param x defines x coordinate
  29338. * @param y defines y coordinate
  29339. * @param z defines z coordinate
  29340. * @returns the array of facet indexes
  29341. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29342. */
  29343. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29344. /**
  29345. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29346. * @param projected sets as the (x,y,z) world projection on the facet
  29347. * @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
  29348. * @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
  29349. * @param x defines x coordinate
  29350. * @param y defines y coordinate
  29351. * @param z defines z coordinate
  29352. * @returns the face index if found (or null instead)
  29353. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29354. */
  29355. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29356. /**
  29357. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29358. * @param projected sets as the (x,y,z) local projection on the facet
  29359. * @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
  29360. * @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
  29361. * @param x defines x coordinate
  29362. * @param y defines y coordinate
  29363. * @param z defines z coordinate
  29364. * @returns the face index if found (or null instead)
  29365. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29366. */
  29367. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29368. /**
  29369. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29370. * @returns the parameters
  29371. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29372. */
  29373. getFacetDataParameters(): any;
  29374. /**
  29375. * Disables the feature FacetData and frees the related memory
  29376. * @returns the current mesh
  29377. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29378. */
  29379. disableFacetData(): AbstractMesh;
  29380. /**
  29381. * Updates the AbstractMesh indices array
  29382. * @param indices defines the data source
  29383. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29384. * @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)
  29385. * @returns the current mesh
  29386. */
  29387. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29388. /**
  29389. * Creates new normals data for the mesh
  29390. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29391. * @returns the current mesh
  29392. */
  29393. createNormals(updatable: boolean): AbstractMesh;
  29394. /**
  29395. * Align the mesh with a normal
  29396. * @param normal defines the normal to use
  29397. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29398. * @returns the current mesh
  29399. */
  29400. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29401. /** @hidden */
  29402. _checkOcclusionQuery(): boolean;
  29403. /**
  29404. * Disables the mesh edge rendering mode
  29405. * @returns the currentAbstractMesh
  29406. */
  29407. disableEdgesRendering(): AbstractMesh;
  29408. /**
  29409. * Enables the edge rendering mode on the mesh.
  29410. * This mode makes the mesh edges visible
  29411. * @param epsilon defines the maximal distance between two angles to detect a face
  29412. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29413. * @returns the currentAbstractMesh
  29414. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29415. */
  29416. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29417. }
  29418. }
  29419. declare module "babylonjs/Actions/actionEvent" {
  29420. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29421. import { Nullable } from "babylonjs/types";
  29422. import { Sprite } from "babylonjs/Sprites/sprite";
  29423. import { Scene } from "babylonjs/scene";
  29424. import { Vector2 } from "babylonjs/Maths/math.vector";
  29425. /**
  29426. * Interface used to define ActionEvent
  29427. */
  29428. export interface IActionEvent {
  29429. /** The mesh or sprite that triggered the action */
  29430. source: any;
  29431. /** The X mouse cursor position at the time of the event */
  29432. pointerX: number;
  29433. /** The Y mouse cursor position at the time of the event */
  29434. pointerY: number;
  29435. /** The mesh that is currently pointed at (can be null) */
  29436. meshUnderPointer: Nullable<AbstractMesh>;
  29437. /** the original (browser) event that triggered the ActionEvent */
  29438. sourceEvent?: any;
  29439. /** additional data for the event */
  29440. additionalData?: any;
  29441. }
  29442. /**
  29443. * ActionEvent is the event being sent when an action is triggered.
  29444. */
  29445. export class ActionEvent implements IActionEvent {
  29446. /** The mesh or sprite that triggered the action */
  29447. source: any;
  29448. /** The X mouse cursor position at the time of the event */
  29449. pointerX: number;
  29450. /** The Y mouse cursor position at the time of the event */
  29451. pointerY: number;
  29452. /** The mesh that is currently pointed at (can be null) */
  29453. meshUnderPointer: Nullable<AbstractMesh>;
  29454. /** the original (browser) event that triggered the ActionEvent */
  29455. sourceEvent?: any;
  29456. /** additional data for the event */
  29457. additionalData?: any;
  29458. /**
  29459. * Creates a new ActionEvent
  29460. * @param source The mesh or sprite that triggered the action
  29461. * @param pointerX The X mouse cursor position at the time of the event
  29462. * @param pointerY The Y mouse cursor position at the time of the event
  29463. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29464. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29465. * @param additionalData additional data for the event
  29466. */
  29467. constructor(
  29468. /** The mesh or sprite that triggered the action */
  29469. source: any,
  29470. /** The X mouse cursor position at the time of the event */
  29471. pointerX: number,
  29472. /** The Y mouse cursor position at the time of the event */
  29473. pointerY: number,
  29474. /** The mesh that is currently pointed at (can be null) */
  29475. meshUnderPointer: Nullable<AbstractMesh>,
  29476. /** the original (browser) event that triggered the ActionEvent */
  29477. sourceEvent?: any,
  29478. /** additional data for the event */
  29479. additionalData?: any);
  29480. /**
  29481. * Helper function to auto-create an ActionEvent from a source mesh.
  29482. * @param source The source mesh that triggered the event
  29483. * @param evt The original (browser) event
  29484. * @param additionalData additional data for the event
  29485. * @returns the new ActionEvent
  29486. */
  29487. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29488. /**
  29489. * Helper function to auto-create an ActionEvent from a source sprite
  29490. * @param source The source sprite that triggered the event
  29491. * @param scene Scene associated with the sprite
  29492. * @param evt The original (browser) event
  29493. * @param additionalData additional data for the event
  29494. * @returns the new ActionEvent
  29495. */
  29496. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29497. /**
  29498. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29499. * @param scene the scene where the event occurred
  29500. * @param evt The original (browser) event
  29501. * @returns the new ActionEvent
  29502. */
  29503. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29504. /**
  29505. * Helper function to auto-create an ActionEvent from a primitive
  29506. * @param prim defines the target primitive
  29507. * @param pointerPos defines the pointer position
  29508. * @param evt The original (browser) event
  29509. * @param additionalData additional data for the event
  29510. * @returns the new ActionEvent
  29511. */
  29512. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29513. }
  29514. }
  29515. declare module "babylonjs/Actions/abstractActionManager" {
  29516. import { IDisposable } from "babylonjs/scene";
  29517. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29518. import { IAction } from "babylonjs/Actions/action";
  29519. import { Nullable } from "babylonjs/types";
  29520. /**
  29521. * Abstract class used to decouple action Manager from scene and meshes.
  29522. * Do not instantiate.
  29523. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29524. */
  29525. export abstract class AbstractActionManager implements IDisposable {
  29526. /** Gets the list of active triggers */
  29527. static Triggers: {
  29528. [key: string]: number;
  29529. };
  29530. /** Gets the cursor to use when hovering items */
  29531. hoverCursor: string;
  29532. /** Gets the list of actions */
  29533. actions: IAction[];
  29534. /**
  29535. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29536. */
  29537. isRecursive: boolean;
  29538. /**
  29539. * Releases all associated resources
  29540. */
  29541. abstract dispose(): void;
  29542. /**
  29543. * Does this action manager has pointer triggers
  29544. */
  29545. abstract get hasPointerTriggers(): boolean;
  29546. /**
  29547. * Does this action manager has pick triggers
  29548. */
  29549. abstract get hasPickTriggers(): boolean;
  29550. /**
  29551. * Process a specific trigger
  29552. * @param trigger defines the trigger to process
  29553. * @param evt defines the event details to be processed
  29554. */
  29555. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29556. /**
  29557. * Does this action manager handles actions of any of the given triggers
  29558. * @param triggers defines the triggers to be tested
  29559. * @return a boolean indicating whether one (or more) of the triggers is handled
  29560. */
  29561. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29562. /**
  29563. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29564. * speed.
  29565. * @param triggerA defines the trigger to be tested
  29566. * @param triggerB defines the trigger to be tested
  29567. * @return a boolean indicating whether one (or more) of the triggers is handled
  29568. */
  29569. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29570. /**
  29571. * Does this action manager handles actions of a given trigger
  29572. * @param trigger defines the trigger to be tested
  29573. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29574. * @return whether the trigger is handled
  29575. */
  29576. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29577. /**
  29578. * Serialize this manager to a JSON object
  29579. * @param name defines the property name to store this manager
  29580. * @returns a JSON representation of this manager
  29581. */
  29582. abstract serialize(name: string): any;
  29583. /**
  29584. * Registers an action to this action manager
  29585. * @param action defines the action to be registered
  29586. * @return the action amended (prepared) after registration
  29587. */
  29588. abstract registerAction(action: IAction): Nullable<IAction>;
  29589. /**
  29590. * Unregisters an action to this action manager
  29591. * @param action defines the action to be unregistered
  29592. * @return a boolean indicating whether the action has been unregistered
  29593. */
  29594. abstract unregisterAction(action: IAction): Boolean;
  29595. /**
  29596. * Does exist one action manager with at least one trigger
  29597. **/
  29598. static get HasTriggers(): boolean;
  29599. /**
  29600. * Does exist one action manager with at least one pick trigger
  29601. **/
  29602. static get HasPickTriggers(): boolean;
  29603. /**
  29604. * Does exist one action manager that handles actions of a given trigger
  29605. * @param trigger defines the trigger to be tested
  29606. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29607. **/
  29608. static HasSpecificTrigger(trigger: number): boolean;
  29609. }
  29610. }
  29611. declare module "babylonjs/node" {
  29612. import { Scene } from "babylonjs/scene";
  29613. import { Nullable } from "babylonjs/types";
  29614. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29615. import { Engine } from "babylonjs/Engines/engine";
  29616. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29617. import { Observable } from "babylonjs/Misc/observable";
  29618. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29619. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29620. import { Animatable } from "babylonjs/Animations/animatable";
  29621. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29622. import { Animation } from "babylonjs/Animations/animation";
  29623. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29625. /**
  29626. * Defines how a node can be built from a string name.
  29627. */
  29628. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29629. /**
  29630. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29631. */
  29632. export class Node implements IBehaviorAware<Node> {
  29633. /** @hidden */
  29634. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29635. private static _NodeConstructors;
  29636. /**
  29637. * Add a new node constructor
  29638. * @param type defines the type name of the node to construct
  29639. * @param constructorFunc defines the constructor function
  29640. */
  29641. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29642. /**
  29643. * Returns a node constructor based on type name
  29644. * @param type defines the type name
  29645. * @param name defines the new node name
  29646. * @param scene defines the hosting scene
  29647. * @param options defines optional options to transmit to constructors
  29648. * @returns the new constructor or null
  29649. */
  29650. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29651. /**
  29652. * Gets or sets the name of the node
  29653. */
  29654. name: string;
  29655. /**
  29656. * Gets or sets the id of the node
  29657. */
  29658. id: string;
  29659. /**
  29660. * Gets or sets the unique id of the node
  29661. */
  29662. uniqueId: number;
  29663. /**
  29664. * Gets or sets a string used to store user defined state for the node
  29665. */
  29666. state: string;
  29667. /**
  29668. * Gets or sets an object used to store user defined information for the node
  29669. */
  29670. metadata: any;
  29671. /**
  29672. * For internal use only. Please do not use.
  29673. */
  29674. reservedDataStore: any;
  29675. /**
  29676. * List of inspectable custom properties (used by the Inspector)
  29677. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29678. */
  29679. inspectableCustomProperties: IInspectable[];
  29680. private _doNotSerialize;
  29681. /**
  29682. * Gets or sets a boolean used to define if the node must be serialized
  29683. */
  29684. get doNotSerialize(): boolean;
  29685. set doNotSerialize(value: boolean);
  29686. /** @hidden */
  29687. _isDisposed: boolean;
  29688. /**
  29689. * Gets a list of Animations associated with the node
  29690. */
  29691. animations: import("babylonjs/Animations/animation").Animation[];
  29692. protected _ranges: {
  29693. [name: string]: Nullable<AnimationRange>;
  29694. };
  29695. /**
  29696. * Callback raised when the node is ready to be used
  29697. */
  29698. onReady: Nullable<(node: Node) => void>;
  29699. private _isEnabled;
  29700. private _isParentEnabled;
  29701. private _isReady;
  29702. /** @hidden */
  29703. _currentRenderId: number;
  29704. private _parentUpdateId;
  29705. /** @hidden */
  29706. _childUpdateId: number;
  29707. /** @hidden */
  29708. _waitingParentId: Nullable<string>;
  29709. /** @hidden */
  29710. _scene: Scene;
  29711. /** @hidden */
  29712. _cache: any;
  29713. private _parentNode;
  29714. private _children;
  29715. /** @hidden */
  29716. _worldMatrix: Matrix;
  29717. /** @hidden */
  29718. _worldMatrixDeterminant: number;
  29719. /** @hidden */
  29720. _worldMatrixDeterminantIsDirty: boolean;
  29721. /** @hidden */
  29722. private _sceneRootNodesIndex;
  29723. /**
  29724. * Gets a boolean indicating if the node has been disposed
  29725. * @returns true if the node was disposed
  29726. */
  29727. isDisposed(): boolean;
  29728. /**
  29729. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29730. * @see https://doc.babylonjs.com/how_to/parenting
  29731. */
  29732. set parent(parent: Nullable<Node>);
  29733. get parent(): Nullable<Node>;
  29734. /** @hidden */
  29735. _addToSceneRootNodes(): void;
  29736. /** @hidden */
  29737. _removeFromSceneRootNodes(): void;
  29738. private _animationPropertiesOverride;
  29739. /**
  29740. * Gets or sets the animation properties override
  29741. */
  29742. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29743. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29744. /**
  29745. * Gets a string idenfifying the name of the class
  29746. * @returns "Node" string
  29747. */
  29748. getClassName(): string;
  29749. /** @hidden */
  29750. readonly _isNode: boolean;
  29751. /**
  29752. * An event triggered when the mesh is disposed
  29753. */
  29754. onDisposeObservable: Observable<Node>;
  29755. private _onDisposeObserver;
  29756. /**
  29757. * Sets a callback that will be raised when the node will be disposed
  29758. */
  29759. set onDispose(callback: () => void);
  29760. /**
  29761. * Creates a new Node
  29762. * @param name the name and id to be given to this node
  29763. * @param scene the scene this node will be added to
  29764. */
  29765. constructor(name: string, scene?: Nullable<Scene>);
  29766. /**
  29767. * Gets the scene of the node
  29768. * @returns a scene
  29769. */
  29770. getScene(): Scene;
  29771. /**
  29772. * Gets the engine of the node
  29773. * @returns a Engine
  29774. */
  29775. getEngine(): Engine;
  29776. private _behaviors;
  29777. /**
  29778. * Attach a behavior to the node
  29779. * @see http://doc.babylonjs.com/features/behaviour
  29780. * @param behavior defines the behavior to attach
  29781. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29782. * @returns the current Node
  29783. */
  29784. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29785. /**
  29786. * Remove an attached behavior
  29787. * @see http://doc.babylonjs.com/features/behaviour
  29788. * @param behavior defines the behavior to attach
  29789. * @returns the current Node
  29790. */
  29791. removeBehavior(behavior: Behavior<Node>): Node;
  29792. /**
  29793. * Gets the list of attached behaviors
  29794. * @see http://doc.babylonjs.com/features/behaviour
  29795. */
  29796. get behaviors(): Behavior<Node>[];
  29797. /**
  29798. * Gets an attached behavior by name
  29799. * @param name defines the name of the behavior to look for
  29800. * @see http://doc.babylonjs.com/features/behaviour
  29801. * @returns null if behavior was not found else the requested behavior
  29802. */
  29803. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29804. /**
  29805. * Returns the latest update of the World matrix
  29806. * @returns a Matrix
  29807. */
  29808. getWorldMatrix(): Matrix;
  29809. /** @hidden */
  29810. _getWorldMatrixDeterminant(): number;
  29811. /**
  29812. * Returns directly the latest state of the mesh World matrix.
  29813. * A Matrix is returned.
  29814. */
  29815. get worldMatrixFromCache(): Matrix;
  29816. /** @hidden */
  29817. _initCache(): void;
  29818. /** @hidden */
  29819. updateCache(force?: boolean): void;
  29820. /** @hidden */
  29821. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29822. /** @hidden */
  29823. _updateCache(ignoreParentClass?: boolean): void;
  29824. /** @hidden */
  29825. _isSynchronized(): boolean;
  29826. /** @hidden */
  29827. _markSyncedWithParent(): void;
  29828. /** @hidden */
  29829. isSynchronizedWithParent(): boolean;
  29830. /** @hidden */
  29831. isSynchronized(): boolean;
  29832. /**
  29833. * Is this node ready to be used/rendered
  29834. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29835. * @return true if the node is ready
  29836. */
  29837. isReady(completeCheck?: boolean): boolean;
  29838. /**
  29839. * Is this node enabled?
  29840. * 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
  29841. * @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
  29842. * @return whether this node (and its parent) is enabled
  29843. */
  29844. isEnabled(checkAncestors?: boolean): boolean;
  29845. /** @hidden */
  29846. protected _syncParentEnabledState(): void;
  29847. /**
  29848. * Set the enabled state of this node
  29849. * @param value defines the new enabled state
  29850. */
  29851. setEnabled(value: boolean): void;
  29852. /**
  29853. * Is this node a descendant of the given node?
  29854. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29855. * @param ancestor defines the parent node to inspect
  29856. * @returns a boolean indicating if this node is a descendant of the given node
  29857. */
  29858. isDescendantOf(ancestor: Node): boolean;
  29859. /** @hidden */
  29860. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29861. /**
  29862. * Will return all nodes that have this node as ascendant
  29863. * @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
  29864. * @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
  29865. * @return all children nodes of all types
  29866. */
  29867. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29868. /**
  29869. * Get all child-meshes of this node
  29870. * @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)
  29871. * @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
  29872. * @returns an array of AbstractMesh
  29873. */
  29874. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29875. /**
  29876. * Get all direct children of this node
  29877. * @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
  29878. * @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)
  29879. * @returns an array of Node
  29880. */
  29881. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29882. /** @hidden */
  29883. _setReady(state: boolean): void;
  29884. /**
  29885. * Get an animation by name
  29886. * @param name defines the name of the animation to look for
  29887. * @returns null if not found else the requested animation
  29888. */
  29889. getAnimationByName(name: string): Nullable<Animation>;
  29890. /**
  29891. * Creates an animation range for this node
  29892. * @param name defines the name of the range
  29893. * @param from defines the starting key
  29894. * @param to defines the end key
  29895. */
  29896. createAnimationRange(name: string, from: number, to: number): void;
  29897. /**
  29898. * Delete a specific animation range
  29899. * @param name defines the name of the range to delete
  29900. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29901. */
  29902. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29903. /**
  29904. * Get an animation range by name
  29905. * @param name defines the name of the animation range to look for
  29906. * @returns null if not found else the requested animation range
  29907. */
  29908. getAnimationRange(name: string): Nullable<AnimationRange>;
  29909. /**
  29910. * Gets the list of all animation ranges defined on this node
  29911. * @returns an array
  29912. */
  29913. getAnimationRanges(): Nullable<AnimationRange>[];
  29914. /**
  29915. * Will start the animation sequence
  29916. * @param name defines the range frames for animation sequence
  29917. * @param loop defines if the animation should loop (false by default)
  29918. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29919. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29920. * @returns the object created for this animation. If range does not exist, it will return null
  29921. */
  29922. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29923. /**
  29924. * Serialize animation ranges into a JSON compatible object
  29925. * @returns serialization object
  29926. */
  29927. serializeAnimationRanges(): any;
  29928. /**
  29929. * Computes the world matrix of the node
  29930. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29931. * @returns the world matrix
  29932. */
  29933. computeWorldMatrix(force?: boolean): Matrix;
  29934. /**
  29935. * Releases resources associated with this node.
  29936. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29937. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29938. */
  29939. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29940. /**
  29941. * Parse animation range data from a serialization object and store them into a given node
  29942. * @param node defines where to store the animation ranges
  29943. * @param parsedNode defines the serialization object to read data from
  29944. * @param scene defines the hosting scene
  29945. */
  29946. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29947. /**
  29948. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29949. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29950. * @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
  29951. * @returns the new bounding vectors
  29952. */
  29953. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29954. min: Vector3;
  29955. max: Vector3;
  29956. };
  29957. }
  29958. }
  29959. declare module "babylonjs/Animations/animation" {
  29960. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29961. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29962. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29963. import { Nullable } from "babylonjs/types";
  29964. import { Scene } from "babylonjs/scene";
  29965. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29966. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29967. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29968. import { Node } from "babylonjs/node";
  29969. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29970. import { Size } from "babylonjs/Maths/math.size";
  29971. import { Animatable } from "babylonjs/Animations/animatable";
  29972. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29973. /**
  29974. * @hidden
  29975. */
  29976. export class _IAnimationState {
  29977. key: number;
  29978. repeatCount: number;
  29979. workValue?: any;
  29980. loopMode?: number;
  29981. offsetValue?: any;
  29982. highLimitValue?: any;
  29983. }
  29984. /**
  29985. * Class used to store any kind of animation
  29986. */
  29987. export class Animation {
  29988. /**Name of the animation */
  29989. name: string;
  29990. /**Property to animate */
  29991. targetProperty: string;
  29992. /**The frames per second of the animation */
  29993. framePerSecond: number;
  29994. /**The data type of the animation */
  29995. dataType: number;
  29996. /**The loop mode of the animation */
  29997. loopMode?: number | undefined;
  29998. /**Specifies if blending should be enabled */
  29999. enableBlending?: boolean | undefined;
  30000. /**
  30001. * Use matrix interpolation instead of using direct key value when animating matrices
  30002. */
  30003. static AllowMatricesInterpolation: boolean;
  30004. /**
  30005. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30006. */
  30007. static AllowMatrixDecomposeForInterpolation: boolean;
  30008. /**
  30009. * Stores the key frames of the animation
  30010. */
  30011. private _keys;
  30012. /**
  30013. * Stores the easing function of the animation
  30014. */
  30015. private _easingFunction;
  30016. /**
  30017. * @hidden Internal use only
  30018. */
  30019. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30020. /**
  30021. * The set of event that will be linked to this animation
  30022. */
  30023. private _events;
  30024. /**
  30025. * Stores an array of target property paths
  30026. */
  30027. targetPropertyPath: string[];
  30028. /**
  30029. * Stores the blending speed of the animation
  30030. */
  30031. blendingSpeed: number;
  30032. /**
  30033. * Stores the animation ranges for the animation
  30034. */
  30035. private _ranges;
  30036. /**
  30037. * @hidden Internal use
  30038. */
  30039. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30040. /**
  30041. * Sets up an animation
  30042. * @param property The property to animate
  30043. * @param animationType The animation type to apply
  30044. * @param framePerSecond The frames per second of the animation
  30045. * @param easingFunction The easing function used in the animation
  30046. * @returns The created animation
  30047. */
  30048. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30049. /**
  30050. * Create and start an animation on a node
  30051. * @param name defines the name of the global animation that will be run on all nodes
  30052. * @param node defines the root node where the animation will take place
  30053. * @param targetProperty defines property to animate
  30054. * @param framePerSecond defines the number of frame per second yo use
  30055. * @param totalFrame defines the number of frames in total
  30056. * @param from defines the initial value
  30057. * @param to defines the final value
  30058. * @param loopMode defines which loop mode you want to use (off by default)
  30059. * @param easingFunction defines the easing function to use (linear by default)
  30060. * @param onAnimationEnd defines the callback to call when animation end
  30061. * @returns the animatable created for this animation
  30062. */
  30063. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30064. /**
  30065. * Create and start an animation on a node and its descendants
  30066. * @param name defines the name of the global animation that will be run on all nodes
  30067. * @param node defines the root node where the animation will take place
  30068. * @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
  30069. * @param targetProperty defines property to animate
  30070. * @param framePerSecond defines the number of frame per second to use
  30071. * @param totalFrame defines the number of frames in total
  30072. * @param from defines the initial value
  30073. * @param to defines the final value
  30074. * @param loopMode defines which loop mode you want to use (off by default)
  30075. * @param easingFunction defines the easing function to use (linear by default)
  30076. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30077. * @returns the list of animatables created for all nodes
  30078. * @example https://www.babylonjs-playground.com/#MH0VLI
  30079. */
  30080. 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[]>;
  30081. /**
  30082. * Creates a new animation, merges it with the existing animations and starts it
  30083. * @param name Name of the animation
  30084. * @param node Node which contains the scene that begins the animations
  30085. * @param targetProperty Specifies which property to animate
  30086. * @param framePerSecond The frames per second of the animation
  30087. * @param totalFrame The total number of frames
  30088. * @param from The frame at the beginning of the animation
  30089. * @param to The frame at the end of the animation
  30090. * @param loopMode Specifies the loop mode of the animation
  30091. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30092. * @param onAnimationEnd Callback to run once the animation is complete
  30093. * @returns Nullable animation
  30094. */
  30095. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30096. /**
  30097. * Transition property of an host to the target Value
  30098. * @param property The property to transition
  30099. * @param targetValue The target Value of the property
  30100. * @param host The object where the property to animate belongs
  30101. * @param scene Scene used to run the animation
  30102. * @param frameRate Framerate (in frame/s) to use
  30103. * @param transition The transition type we want to use
  30104. * @param duration The duration of the animation, in milliseconds
  30105. * @param onAnimationEnd Callback trigger at the end of the animation
  30106. * @returns Nullable animation
  30107. */
  30108. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30109. /**
  30110. * Return the array of runtime animations currently using this animation
  30111. */
  30112. get runtimeAnimations(): RuntimeAnimation[];
  30113. /**
  30114. * Specifies if any of the runtime animations are currently running
  30115. */
  30116. get hasRunningRuntimeAnimations(): boolean;
  30117. /**
  30118. * Initializes the animation
  30119. * @param name Name of the animation
  30120. * @param targetProperty Property to animate
  30121. * @param framePerSecond The frames per second of the animation
  30122. * @param dataType The data type of the animation
  30123. * @param loopMode The loop mode of the animation
  30124. * @param enableBlending Specifies if blending should be enabled
  30125. */
  30126. constructor(
  30127. /**Name of the animation */
  30128. name: string,
  30129. /**Property to animate */
  30130. targetProperty: string,
  30131. /**The frames per second of the animation */
  30132. framePerSecond: number,
  30133. /**The data type of the animation */
  30134. dataType: number,
  30135. /**The loop mode of the animation */
  30136. loopMode?: number | undefined,
  30137. /**Specifies if blending should be enabled */
  30138. enableBlending?: boolean | undefined);
  30139. /**
  30140. * Converts the animation to a string
  30141. * @param fullDetails support for multiple levels of logging within scene loading
  30142. * @returns String form of the animation
  30143. */
  30144. toString(fullDetails?: boolean): string;
  30145. /**
  30146. * Add an event to this animation
  30147. * @param event Event to add
  30148. */
  30149. addEvent(event: AnimationEvent): void;
  30150. /**
  30151. * Remove all events found at the given frame
  30152. * @param frame The frame to remove events from
  30153. */
  30154. removeEvents(frame: number): void;
  30155. /**
  30156. * Retrieves all the events from the animation
  30157. * @returns Events from the animation
  30158. */
  30159. getEvents(): AnimationEvent[];
  30160. /**
  30161. * Creates an animation range
  30162. * @param name Name of the animation range
  30163. * @param from Starting frame of the animation range
  30164. * @param to Ending frame of the animation
  30165. */
  30166. createRange(name: string, from: number, to: number): void;
  30167. /**
  30168. * Deletes an animation range by name
  30169. * @param name Name of the animation range to delete
  30170. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30171. */
  30172. deleteRange(name: string, deleteFrames?: boolean): void;
  30173. /**
  30174. * Gets the animation range by name, or null if not defined
  30175. * @param name Name of the animation range
  30176. * @returns Nullable animation range
  30177. */
  30178. getRange(name: string): Nullable<AnimationRange>;
  30179. /**
  30180. * Gets the key frames from the animation
  30181. * @returns The key frames of the animation
  30182. */
  30183. getKeys(): Array<IAnimationKey>;
  30184. /**
  30185. * Gets the highest frame rate of the animation
  30186. * @returns Highest frame rate of the animation
  30187. */
  30188. getHighestFrame(): number;
  30189. /**
  30190. * Gets the easing function of the animation
  30191. * @returns Easing function of the animation
  30192. */
  30193. getEasingFunction(): IEasingFunction;
  30194. /**
  30195. * Sets the easing function of the animation
  30196. * @param easingFunction A custom mathematical formula for animation
  30197. */
  30198. setEasingFunction(easingFunction: EasingFunction): void;
  30199. /**
  30200. * Interpolates a scalar linearly
  30201. * @param startValue Start value of the animation curve
  30202. * @param endValue End value of the animation curve
  30203. * @param gradient Scalar amount to interpolate
  30204. * @returns Interpolated scalar value
  30205. */
  30206. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30207. /**
  30208. * Interpolates a scalar cubically
  30209. * @param startValue Start value of the animation curve
  30210. * @param outTangent End tangent of the animation
  30211. * @param endValue End value of the animation curve
  30212. * @param inTangent Start tangent of the animation curve
  30213. * @param gradient Scalar amount to interpolate
  30214. * @returns Interpolated scalar value
  30215. */
  30216. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30217. /**
  30218. * Interpolates a quaternion using a spherical linear interpolation
  30219. * @param startValue Start value of the animation curve
  30220. * @param endValue End value of the animation curve
  30221. * @param gradient Scalar amount to interpolate
  30222. * @returns Interpolated quaternion value
  30223. */
  30224. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30225. /**
  30226. * Interpolates a quaternion cubically
  30227. * @param startValue Start value of the animation curve
  30228. * @param outTangent End tangent of the animation curve
  30229. * @param endValue End value of the animation curve
  30230. * @param inTangent Start tangent of the animation curve
  30231. * @param gradient Scalar amount to interpolate
  30232. * @returns Interpolated quaternion value
  30233. */
  30234. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30235. /**
  30236. * Interpolates a Vector3 linearl
  30237. * @param startValue Start value of the animation curve
  30238. * @param endValue End value of the animation curve
  30239. * @param gradient Scalar amount to interpolate
  30240. * @returns Interpolated scalar value
  30241. */
  30242. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30243. /**
  30244. * Interpolates a Vector3 cubically
  30245. * @param startValue Start value of the animation curve
  30246. * @param outTangent End tangent of the animation
  30247. * @param endValue End value of the animation curve
  30248. * @param inTangent Start tangent of the animation curve
  30249. * @param gradient Scalar amount to interpolate
  30250. * @returns InterpolatedVector3 value
  30251. */
  30252. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30253. /**
  30254. * Interpolates a Vector2 linearly
  30255. * @param startValue Start value of the animation curve
  30256. * @param endValue End value of the animation curve
  30257. * @param gradient Scalar amount to interpolate
  30258. * @returns Interpolated Vector2 value
  30259. */
  30260. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30261. /**
  30262. * Interpolates a Vector2 cubically
  30263. * @param startValue Start value of the animation curve
  30264. * @param outTangent End tangent of the animation
  30265. * @param endValue End value of the animation curve
  30266. * @param inTangent Start tangent of the animation curve
  30267. * @param gradient Scalar amount to interpolate
  30268. * @returns Interpolated Vector2 value
  30269. */
  30270. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30271. /**
  30272. * Interpolates a size linearly
  30273. * @param startValue Start value of the animation curve
  30274. * @param endValue End value of the animation curve
  30275. * @param gradient Scalar amount to interpolate
  30276. * @returns Interpolated Size value
  30277. */
  30278. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30279. /**
  30280. * Interpolates a Color3 linearly
  30281. * @param startValue Start value of the animation curve
  30282. * @param endValue End value of the animation curve
  30283. * @param gradient Scalar amount to interpolate
  30284. * @returns Interpolated Color3 value
  30285. */
  30286. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30287. /**
  30288. * Interpolates a Color4 linearly
  30289. * @param startValue Start value of the animation curve
  30290. * @param endValue End value of the animation curve
  30291. * @param gradient Scalar amount to interpolate
  30292. * @returns Interpolated Color3 value
  30293. */
  30294. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30295. /**
  30296. * @hidden Internal use only
  30297. */
  30298. _getKeyValue(value: any): any;
  30299. /**
  30300. * @hidden Internal use only
  30301. */
  30302. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30303. /**
  30304. * Defines the function to use to interpolate matrices
  30305. * @param startValue defines the start matrix
  30306. * @param endValue defines the end matrix
  30307. * @param gradient defines the gradient between both matrices
  30308. * @param result defines an optional target matrix where to store the interpolation
  30309. * @returns the interpolated matrix
  30310. */
  30311. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30312. /**
  30313. * Makes a copy of the animation
  30314. * @returns Cloned animation
  30315. */
  30316. clone(): Animation;
  30317. /**
  30318. * Sets the key frames of the animation
  30319. * @param values The animation key frames to set
  30320. */
  30321. setKeys(values: Array<IAnimationKey>): void;
  30322. /**
  30323. * Serializes the animation to an object
  30324. * @returns Serialized object
  30325. */
  30326. serialize(): any;
  30327. /**
  30328. * Float animation type
  30329. */
  30330. static readonly ANIMATIONTYPE_FLOAT: number;
  30331. /**
  30332. * Vector3 animation type
  30333. */
  30334. static readonly ANIMATIONTYPE_VECTOR3: number;
  30335. /**
  30336. * Quaternion animation type
  30337. */
  30338. static readonly ANIMATIONTYPE_QUATERNION: number;
  30339. /**
  30340. * Matrix animation type
  30341. */
  30342. static readonly ANIMATIONTYPE_MATRIX: number;
  30343. /**
  30344. * Color3 animation type
  30345. */
  30346. static readonly ANIMATIONTYPE_COLOR3: number;
  30347. /**
  30348. * Color3 animation type
  30349. */
  30350. static readonly ANIMATIONTYPE_COLOR4: number;
  30351. /**
  30352. * Vector2 animation type
  30353. */
  30354. static readonly ANIMATIONTYPE_VECTOR2: number;
  30355. /**
  30356. * Size animation type
  30357. */
  30358. static readonly ANIMATIONTYPE_SIZE: number;
  30359. /**
  30360. * Relative Loop Mode
  30361. */
  30362. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30363. /**
  30364. * Cycle Loop Mode
  30365. */
  30366. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30367. /**
  30368. * Constant Loop Mode
  30369. */
  30370. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30371. /** @hidden */
  30372. static _UniversalLerp(left: any, right: any, amount: number): any;
  30373. /**
  30374. * Parses an animation object and creates an animation
  30375. * @param parsedAnimation Parsed animation object
  30376. * @returns Animation object
  30377. */
  30378. static Parse(parsedAnimation: any): Animation;
  30379. /**
  30380. * Appends the serialized animations from the source animations
  30381. * @param source Source containing the animations
  30382. * @param destination Target to store the animations
  30383. */
  30384. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30385. }
  30386. }
  30387. declare module "babylonjs/Animations/animatable.interface" {
  30388. import { Nullable } from "babylonjs/types";
  30389. import { Animation } from "babylonjs/Animations/animation";
  30390. /**
  30391. * Interface containing an array of animations
  30392. */
  30393. export interface IAnimatable {
  30394. /**
  30395. * Array of animations
  30396. */
  30397. animations: Nullable<Array<Animation>>;
  30398. }
  30399. }
  30400. declare module "babylonjs/Misc/decorators" {
  30401. import { Nullable } from "babylonjs/types";
  30402. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30403. import { Scene } from "babylonjs/scene";
  30404. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30405. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30406. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30407. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30408. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30409. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30410. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30411. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30412. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30413. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30414. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30415. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30416. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30417. /**
  30418. * Decorator used to define property that can be serialized as reference to a camera
  30419. * @param sourceName defines the name of the property to decorate
  30420. */
  30421. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30422. /**
  30423. * Class used to help serialization objects
  30424. */
  30425. export class SerializationHelper {
  30426. /** @hidden */
  30427. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30428. /** @hidden */
  30429. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30430. /** @hidden */
  30431. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30432. /** @hidden */
  30433. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30434. /**
  30435. * Appends the serialized animations from the source animations
  30436. * @param source Source containing the animations
  30437. * @param destination Target to store the animations
  30438. */
  30439. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30440. /**
  30441. * Static function used to serialized a specific entity
  30442. * @param entity defines the entity to serialize
  30443. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30444. * @returns a JSON compatible object representing the serialization of the entity
  30445. */
  30446. static Serialize<T>(entity: T, serializationObject?: any): any;
  30447. /**
  30448. * Creates a new entity from a serialization data object
  30449. * @param creationFunction defines a function used to instanciated the new entity
  30450. * @param source defines the source serialization data
  30451. * @param scene defines the hosting scene
  30452. * @param rootUrl defines the root url for resources
  30453. * @returns a new entity
  30454. */
  30455. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30456. /**
  30457. * Clones an object
  30458. * @param creationFunction defines the function used to instanciate the new object
  30459. * @param source defines the source object
  30460. * @returns the cloned object
  30461. */
  30462. static Clone<T>(creationFunction: () => T, source: T): T;
  30463. /**
  30464. * Instanciates a new object based on a source one (some data will be shared between both object)
  30465. * @param creationFunction defines the function used to instanciate the new object
  30466. * @param source defines the source object
  30467. * @returns the new object
  30468. */
  30469. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30470. }
  30471. }
  30472. declare module "babylonjs/Misc/guid" {
  30473. /**
  30474. * Class used to manipulate GUIDs
  30475. */
  30476. export class GUID {
  30477. /**
  30478. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30479. * Be aware Math.random() could cause collisions, but:
  30480. * "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"
  30481. * @returns a pseudo random id
  30482. */
  30483. static RandomId(): string;
  30484. }
  30485. }
  30486. declare module "babylonjs/Materials/Textures/baseTexture" {
  30487. import { Observable } from "babylonjs/Misc/observable";
  30488. import { Nullable } from "babylonjs/types";
  30489. import { Scene } from "babylonjs/scene";
  30490. import { Matrix } from "babylonjs/Maths/math.vector";
  30491. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30492. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30493. import { ISize } from "babylonjs/Maths/math.size";
  30494. import "babylonjs/Misc/fileTools";
  30495. /**
  30496. * Base class of all the textures in babylon.
  30497. * It groups all the common properties the materials, post process, lights... might need
  30498. * in order to make a correct use of the texture.
  30499. */
  30500. export class BaseTexture implements IAnimatable {
  30501. /**
  30502. * Default anisotropic filtering level for the application.
  30503. * It is set to 4 as a good tradeoff between perf and quality.
  30504. */
  30505. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30506. /**
  30507. * Gets or sets the unique id of the texture
  30508. */
  30509. uniqueId: number;
  30510. /**
  30511. * Define the name of the texture.
  30512. */
  30513. name: string;
  30514. /**
  30515. * Gets or sets an object used to store user defined information.
  30516. */
  30517. metadata: any;
  30518. /**
  30519. * For internal use only. Please do not use.
  30520. */
  30521. reservedDataStore: any;
  30522. private _hasAlpha;
  30523. /**
  30524. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30525. */
  30526. set hasAlpha(value: boolean);
  30527. get hasAlpha(): boolean;
  30528. /**
  30529. * Defines if the alpha value should be determined via the rgb values.
  30530. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30531. */
  30532. getAlphaFromRGB: boolean;
  30533. /**
  30534. * Intensity or strength of the texture.
  30535. * It is commonly used by materials to fine tune the intensity of the texture
  30536. */
  30537. level: number;
  30538. /**
  30539. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30540. * This is part of the texture as textures usually maps to one uv set.
  30541. */
  30542. coordinatesIndex: number;
  30543. private _coordinatesMode;
  30544. /**
  30545. * How a texture is mapped.
  30546. *
  30547. * | Value | Type | Description |
  30548. * | ----- | ----------------------------------- | ----------- |
  30549. * | 0 | EXPLICIT_MODE | |
  30550. * | 1 | SPHERICAL_MODE | |
  30551. * | 2 | PLANAR_MODE | |
  30552. * | 3 | CUBIC_MODE | |
  30553. * | 4 | PROJECTION_MODE | |
  30554. * | 5 | SKYBOX_MODE | |
  30555. * | 6 | INVCUBIC_MODE | |
  30556. * | 7 | EQUIRECTANGULAR_MODE | |
  30557. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30558. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30559. */
  30560. set coordinatesMode(value: number);
  30561. get coordinatesMode(): number;
  30562. /**
  30563. * | Value | Type | Description |
  30564. * | ----- | ------------------ | ----------- |
  30565. * | 0 | CLAMP_ADDRESSMODE | |
  30566. * | 1 | WRAP_ADDRESSMODE | |
  30567. * | 2 | MIRROR_ADDRESSMODE | |
  30568. */
  30569. wrapU: number;
  30570. /**
  30571. * | Value | Type | Description |
  30572. * | ----- | ------------------ | ----------- |
  30573. * | 0 | CLAMP_ADDRESSMODE | |
  30574. * | 1 | WRAP_ADDRESSMODE | |
  30575. * | 2 | MIRROR_ADDRESSMODE | |
  30576. */
  30577. wrapV: number;
  30578. /**
  30579. * | Value | Type | Description |
  30580. * | ----- | ------------------ | ----------- |
  30581. * | 0 | CLAMP_ADDRESSMODE | |
  30582. * | 1 | WRAP_ADDRESSMODE | |
  30583. * | 2 | MIRROR_ADDRESSMODE | |
  30584. */
  30585. wrapR: number;
  30586. /**
  30587. * With compliant hardware and browser (supporting anisotropic filtering)
  30588. * this defines the level of anisotropic filtering in the texture.
  30589. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30590. */
  30591. anisotropicFilteringLevel: number;
  30592. /**
  30593. * Define if the texture is a cube texture or if false a 2d texture.
  30594. */
  30595. get isCube(): boolean;
  30596. set isCube(value: boolean);
  30597. /**
  30598. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30599. */
  30600. get is3D(): boolean;
  30601. set is3D(value: boolean);
  30602. /**
  30603. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30604. */
  30605. get is2DArray(): boolean;
  30606. set is2DArray(value: boolean);
  30607. /**
  30608. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30609. * HDR texture are usually stored in linear space.
  30610. * This only impacts the PBR and Background materials
  30611. */
  30612. gammaSpace: boolean;
  30613. /**
  30614. * Gets or sets whether or not the texture contains RGBD data.
  30615. */
  30616. get isRGBD(): boolean;
  30617. set isRGBD(value: boolean);
  30618. /**
  30619. * Is Z inverted in the texture (useful in a cube texture).
  30620. */
  30621. invertZ: boolean;
  30622. /**
  30623. * Are mip maps generated for this texture or not.
  30624. */
  30625. get noMipmap(): boolean;
  30626. /**
  30627. * @hidden
  30628. */
  30629. lodLevelInAlpha: boolean;
  30630. /**
  30631. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30632. */
  30633. get lodGenerationOffset(): number;
  30634. set lodGenerationOffset(value: number);
  30635. /**
  30636. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30637. */
  30638. get lodGenerationScale(): number;
  30639. set lodGenerationScale(value: number);
  30640. /**
  30641. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30642. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30643. * average roughness values.
  30644. */
  30645. get linearSpecularLOD(): boolean;
  30646. set linearSpecularLOD(value: boolean);
  30647. /**
  30648. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30649. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30650. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30651. */
  30652. get irradianceTexture(): Nullable<BaseTexture>;
  30653. set irradianceTexture(value: Nullable<BaseTexture>);
  30654. /**
  30655. * Define if the texture is a render target.
  30656. */
  30657. isRenderTarget: boolean;
  30658. /**
  30659. * Define the unique id of the texture in the scene.
  30660. */
  30661. get uid(): string;
  30662. /**
  30663. * Return a string representation of the texture.
  30664. * @returns the texture as a string
  30665. */
  30666. toString(): string;
  30667. /**
  30668. * Get the class name of the texture.
  30669. * @returns "BaseTexture"
  30670. */
  30671. getClassName(): string;
  30672. /**
  30673. * Define the list of animation attached to the texture.
  30674. */
  30675. animations: import("babylonjs/Animations/animation").Animation[];
  30676. /**
  30677. * An event triggered when the texture is disposed.
  30678. */
  30679. onDisposeObservable: Observable<BaseTexture>;
  30680. private _onDisposeObserver;
  30681. /**
  30682. * Callback triggered when the texture has been disposed.
  30683. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30684. */
  30685. set onDispose(callback: () => void);
  30686. /**
  30687. * Define the current state of the loading sequence when in delayed load mode.
  30688. */
  30689. delayLoadState: number;
  30690. private _scene;
  30691. /** @hidden */
  30692. _texture: Nullable<InternalTexture>;
  30693. private _uid;
  30694. /**
  30695. * Define if the texture is preventinga material to render or not.
  30696. * If not and the texture is not ready, the engine will use a default black texture instead.
  30697. */
  30698. get isBlocking(): boolean;
  30699. /**
  30700. * Instantiates a new BaseTexture.
  30701. * Base class of all the textures in babylon.
  30702. * It groups all the common properties the materials, post process, lights... might need
  30703. * in order to make a correct use of the texture.
  30704. * @param scene Define the scene the texture blongs to
  30705. */
  30706. constructor(scene: Nullable<Scene>);
  30707. /**
  30708. * Get the scene the texture belongs to.
  30709. * @returns the scene or null if undefined
  30710. */
  30711. getScene(): Nullable<Scene>;
  30712. /**
  30713. * Get the texture transform matrix used to offset tile the texture for istance.
  30714. * @returns the transformation matrix
  30715. */
  30716. getTextureMatrix(): Matrix;
  30717. /**
  30718. * Get the texture reflection matrix used to rotate/transform the reflection.
  30719. * @returns the reflection matrix
  30720. */
  30721. getReflectionTextureMatrix(): Matrix;
  30722. /**
  30723. * Get the underlying lower level texture from Babylon.
  30724. * @returns the insternal texture
  30725. */
  30726. getInternalTexture(): Nullable<InternalTexture>;
  30727. /**
  30728. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30729. * @returns true if ready or not blocking
  30730. */
  30731. isReadyOrNotBlocking(): boolean;
  30732. /**
  30733. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30734. * @returns true if fully ready
  30735. */
  30736. isReady(): boolean;
  30737. private _cachedSize;
  30738. /**
  30739. * Get the size of the texture.
  30740. * @returns the texture size.
  30741. */
  30742. getSize(): ISize;
  30743. /**
  30744. * Get the base size of the texture.
  30745. * It can be different from the size if the texture has been resized for POT for instance
  30746. * @returns the base size
  30747. */
  30748. getBaseSize(): ISize;
  30749. /**
  30750. * Update the sampling mode of the texture.
  30751. * Default is Trilinear mode.
  30752. *
  30753. * | Value | Type | Description |
  30754. * | ----- | ------------------ | ----------- |
  30755. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30756. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30757. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30758. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30759. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30760. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30761. * | 7 | NEAREST_LINEAR | |
  30762. * | 8 | NEAREST_NEAREST | |
  30763. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30764. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30765. * | 11 | LINEAR_LINEAR | |
  30766. * | 12 | LINEAR_NEAREST | |
  30767. *
  30768. * > _mag_: magnification filter (close to the viewer)
  30769. * > _min_: minification filter (far from the viewer)
  30770. * > _mip_: filter used between mip map levels
  30771. *@param samplingMode Define the new sampling mode of the texture
  30772. */
  30773. updateSamplingMode(samplingMode: number): void;
  30774. /**
  30775. * Scales the texture if is `canRescale()`
  30776. * @param ratio the resize factor we want to use to rescale
  30777. */
  30778. scale(ratio: number): void;
  30779. /**
  30780. * Get if the texture can rescale.
  30781. */
  30782. get canRescale(): boolean;
  30783. /** @hidden */
  30784. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30785. /** @hidden */
  30786. _rebuild(): void;
  30787. /**
  30788. * Triggers the load sequence in delayed load mode.
  30789. */
  30790. delayLoad(): void;
  30791. /**
  30792. * Clones the texture.
  30793. * @returns the cloned texture
  30794. */
  30795. clone(): Nullable<BaseTexture>;
  30796. /**
  30797. * Get the texture underlying type (INT, FLOAT...)
  30798. */
  30799. get textureType(): number;
  30800. /**
  30801. * Get the texture underlying format (RGB, RGBA...)
  30802. */
  30803. get textureFormat(): number;
  30804. /**
  30805. * Indicates that textures need to be re-calculated for all materials
  30806. */
  30807. protected _markAllSubMeshesAsTexturesDirty(): void;
  30808. /**
  30809. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30810. * This will returns an RGBA array buffer containing either in values (0-255) or
  30811. * float values (0-1) depending of the underlying buffer type.
  30812. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30813. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30814. * @param buffer defines a user defined buffer to fill with data (can be null)
  30815. * @returns The Array buffer containing the pixels data.
  30816. */
  30817. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30818. /**
  30819. * Release and destroy the underlying lower level texture aka internalTexture.
  30820. */
  30821. releaseInternalTexture(): void;
  30822. /** @hidden */
  30823. get _lodTextureHigh(): Nullable<BaseTexture>;
  30824. /** @hidden */
  30825. get _lodTextureMid(): Nullable<BaseTexture>;
  30826. /** @hidden */
  30827. get _lodTextureLow(): Nullable<BaseTexture>;
  30828. /**
  30829. * Dispose the texture and release its associated resources.
  30830. */
  30831. dispose(): void;
  30832. /**
  30833. * Serialize the texture into a JSON representation that can be parsed later on.
  30834. * @returns the JSON representation of the texture
  30835. */
  30836. serialize(): any;
  30837. /**
  30838. * Helper function to be called back once a list of texture contains only ready textures.
  30839. * @param textures Define the list of textures to wait for
  30840. * @param callback Define the callback triggered once the entire list will be ready
  30841. */
  30842. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30843. }
  30844. }
  30845. declare module "babylonjs/Materials/effect" {
  30846. import { Observable } from "babylonjs/Misc/observable";
  30847. import { Nullable } from "babylonjs/types";
  30848. import { IDisposable } from "babylonjs/scene";
  30849. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30850. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30851. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30852. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30853. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30854. import { Engine } from "babylonjs/Engines/engine";
  30855. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30856. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30857. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30858. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30859. /**
  30860. * Options to be used when creating an effect.
  30861. */
  30862. export interface IEffectCreationOptions {
  30863. /**
  30864. * Atrributes that will be used in the shader.
  30865. */
  30866. attributes: string[];
  30867. /**
  30868. * Uniform varible names that will be set in the shader.
  30869. */
  30870. uniformsNames: string[];
  30871. /**
  30872. * Uniform buffer variable names that will be set in the shader.
  30873. */
  30874. uniformBuffersNames: string[];
  30875. /**
  30876. * Sampler texture variable names that will be set in the shader.
  30877. */
  30878. samplers: string[];
  30879. /**
  30880. * Define statements that will be set in the shader.
  30881. */
  30882. defines: any;
  30883. /**
  30884. * Possible fallbacks for this effect to improve performance when needed.
  30885. */
  30886. fallbacks: Nullable<IEffectFallbacks>;
  30887. /**
  30888. * Callback that will be called when the shader is compiled.
  30889. */
  30890. onCompiled: Nullable<(effect: Effect) => void>;
  30891. /**
  30892. * Callback that will be called if an error occurs during shader compilation.
  30893. */
  30894. onError: Nullable<(effect: Effect, errors: string) => void>;
  30895. /**
  30896. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30897. */
  30898. indexParameters?: any;
  30899. /**
  30900. * Max number of lights that can be used in the shader.
  30901. */
  30902. maxSimultaneousLights?: number;
  30903. /**
  30904. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30905. */
  30906. transformFeedbackVaryings?: Nullable<string[]>;
  30907. }
  30908. /**
  30909. * Effect containing vertex and fragment shader that can be executed on an object.
  30910. */
  30911. export class Effect implements IDisposable {
  30912. /**
  30913. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30914. */
  30915. static ShadersRepository: string;
  30916. /**
  30917. * Name of the effect.
  30918. */
  30919. name: any;
  30920. /**
  30921. * String container all the define statements that should be set on the shader.
  30922. */
  30923. defines: string;
  30924. /**
  30925. * Callback that will be called when the shader is compiled.
  30926. */
  30927. onCompiled: Nullable<(effect: Effect) => void>;
  30928. /**
  30929. * Callback that will be called if an error occurs during shader compilation.
  30930. */
  30931. onError: Nullable<(effect: Effect, errors: string) => void>;
  30932. /**
  30933. * Callback that will be called when effect is bound.
  30934. */
  30935. onBind: Nullable<(effect: Effect) => void>;
  30936. /**
  30937. * Unique ID of the effect.
  30938. */
  30939. uniqueId: number;
  30940. /**
  30941. * Observable that will be called when the shader is compiled.
  30942. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30943. */
  30944. onCompileObservable: Observable<Effect>;
  30945. /**
  30946. * Observable that will be called if an error occurs during shader compilation.
  30947. */
  30948. onErrorObservable: Observable<Effect>;
  30949. /** @hidden */
  30950. _onBindObservable: Nullable<Observable<Effect>>;
  30951. /**
  30952. * @hidden
  30953. * Specifies if the effect was previously ready
  30954. */
  30955. _wasPreviouslyReady: boolean;
  30956. /**
  30957. * Observable that will be called when effect is bound.
  30958. */
  30959. get onBindObservable(): Observable<Effect>;
  30960. /** @hidden */
  30961. _bonesComputationForcedToCPU: boolean;
  30962. private static _uniqueIdSeed;
  30963. private _engine;
  30964. private _uniformBuffersNames;
  30965. private _uniformsNames;
  30966. private _samplerList;
  30967. private _samplers;
  30968. private _isReady;
  30969. private _compilationError;
  30970. private _allFallbacksProcessed;
  30971. private _attributesNames;
  30972. private _attributes;
  30973. private _attributeLocationByName;
  30974. private _uniforms;
  30975. /**
  30976. * Key for the effect.
  30977. * @hidden
  30978. */
  30979. _key: string;
  30980. private _indexParameters;
  30981. private _fallbacks;
  30982. private _vertexSourceCode;
  30983. private _fragmentSourceCode;
  30984. private _vertexSourceCodeOverride;
  30985. private _fragmentSourceCodeOverride;
  30986. private _transformFeedbackVaryings;
  30987. /**
  30988. * Compiled shader to webGL program.
  30989. * @hidden
  30990. */
  30991. _pipelineContext: Nullable<IPipelineContext>;
  30992. private _valueCache;
  30993. private static _baseCache;
  30994. /**
  30995. * Instantiates an effect.
  30996. * An effect can be used to create/manage/execute vertex and fragment shaders.
  30997. * @param baseName Name of the effect.
  30998. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  30999. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31000. * @param samplers List of sampler variables that will be passed to the shader.
  31001. * @param engine Engine to be used to render the effect
  31002. * @param defines Define statements to be added to the shader.
  31003. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31004. * @param onCompiled Callback that will be called when the shader is compiled.
  31005. * @param onError Callback that will be called if an error occurs during shader compilation.
  31006. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31007. */
  31008. 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);
  31009. private _useFinalCode;
  31010. /**
  31011. * Unique key for this effect
  31012. */
  31013. get key(): string;
  31014. /**
  31015. * If the effect has been compiled and prepared.
  31016. * @returns if the effect is compiled and prepared.
  31017. */
  31018. isReady(): boolean;
  31019. private _isReadyInternal;
  31020. /**
  31021. * The engine the effect was initialized with.
  31022. * @returns the engine.
  31023. */
  31024. getEngine(): Engine;
  31025. /**
  31026. * The pipeline context for this effect
  31027. * @returns the associated pipeline context
  31028. */
  31029. getPipelineContext(): Nullable<IPipelineContext>;
  31030. /**
  31031. * The set of names of attribute variables for the shader.
  31032. * @returns An array of attribute names.
  31033. */
  31034. getAttributesNames(): string[];
  31035. /**
  31036. * Returns the attribute at the given index.
  31037. * @param index The index of the attribute.
  31038. * @returns The location of the attribute.
  31039. */
  31040. getAttributeLocation(index: number): number;
  31041. /**
  31042. * Returns the attribute based on the name of the variable.
  31043. * @param name of the attribute to look up.
  31044. * @returns the attribute location.
  31045. */
  31046. getAttributeLocationByName(name: string): number;
  31047. /**
  31048. * The number of attributes.
  31049. * @returns the numnber of attributes.
  31050. */
  31051. getAttributesCount(): number;
  31052. /**
  31053. * Gets the index of a uniform variable.
  31054. * @param uniformName of the uniform to look up.
  31055. * @returns the index.
  31056. */
  31057. getUniformIndex(uniformName: string): number;
  31058. /**
  31059. * Returns the attribute based on the name of the variable.
  31060. * @param uniformName of the uniform to look up.
  31061. * @returns the location of the uniform.
  31062. */
  31063. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31064. /**
  31065. * Returns an array of sampler variable names
  31066. * @returns The array of sampler variable neames.
  31067. */
  31068. getSamplers(): string[];
  31069. /**
  31070. * The error from the last compilation.
  31071. * @returns the error string.
  31072. */
  31073. getCompilationError(): string;
  31074. /**
  31075. * Gets a boolean indicating that all fallbacks were used during compilation
  31076. * @returns true if all fallbacks were used
  31077. */
  31078. allFallbacksProcessed(): boolean;
  31079. /**
  31080. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31081. * @param func The callback to be used.
  31082. */
  31083. executeWhenCompiled(func: (effect: Effect) => void): void;
  31084. private _checkIsReady;
  31085. private _loadShader;
  31086. /**
  31087. * Recompiles the webGL program
  31088. * @param vertexSourceCode The source code for the vertex shader.
  31089. * @param fragmentSourceCode The source code for the fragment shader.
  31090. * @param onCompiled Callback called when completed.
  31091. * @param onError Callback called on error.
  31092. * @hidden
  31093. */
  31094. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31095. /**
  31096. * Prepares the effect
  31097. * @hidden
  31098. */
  31099. _prepareEffect(): void;
  31100. private _processCompilationErrors;
  31101. /**
  31102. * Checks if the effect is supported. (Must be called after compilation)
  31103. */
  31104. get isSupported(): boolean;
  31105. /**
  31106. * Binds a texture to the engine to be used as output of the shader.
  31107. * @param channel Name of the output variable.
  31108. * @param texture Texture to bind.
  31109. * @hidden
  31110. */
  31111. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31112. /**
  31113. * Sets a texture on the engine to be used in the shader.
  31114. * @param channel Name of the sampler variable.
  31115. * @param texture Texture to set.
  31116. */
  31117. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31118. /**
  31119. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31120. * @param channel Name of the sampler variable.
  31121. * @param texture Texture to set.
  31122. */
  31123. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31124. /**
  31125. * Sets an array of textures on the engine to be used in the shader.
  31126. * @param channel Name of the variable.
  31127. * @param textures Textures to set.
  31128. */
  31129. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31130. /**
  31131. * 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)
  31132. * @param channel Name of the sampler variable.
  31133. * @param postProcess Post process to get the input texture from.
  31134. */
  31135. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31136. /**
  31137. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31138. * 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)
  31139. * @param channel Name of the sampler variable.
  31140. * @param postProcess Post process to get the output texture from.
  31141. */
  31142. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31143. /** @hidden */
  31144. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31145. /** @hidden */
  31146. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31147. /** @hidden */
  31148. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31149. /** @hidden */
  31150. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31151. /**
  31152. * Binds a buffer to a uniform.
  31153. * @param buffer Buffer to bind.
  31154. * @param name Name of the uniform variable to bind to.
  31155. */
  31156. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31157. /**
  31158. * Binds block to a uniform.
  31159. * @param blockName Name of the block to bind.
  31160. * @param index Index to bind.
  31161. */
  31162. bindUniformBlock(blockName: string, index: number): void;
  31163. /**
  31164. * Sets an interger value on a uniform variable.
  31165. * @param uniformName Name of the variable.
  31166. * @param value Value to be set.
  31167. * @returns this effect.
  31168. */
  31169. setInt(uniformName: string, value: number): Effect;
  31170. /**
  31171. * Sets an int array on a uniform variable.
  31172. * @param uniformName Name of the variable.
  31173. * @param array array to be set.
  31174. * @returns this effect.
  31175. */
  31176. setIntArray(uniformName: string, array: Int32Array): Effect;
  31177. /**
  31178. * 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)
  31179. * @param uniformName Name of the variable.
  31180. * @param array array to be set.
  31181. * @returns this effect.
  31182. */
  31183. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31184. /**
  31185. * 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)
  31186. * @param uniformName Name of the variable.
  31187. * @param array array to be set.
  31188. * @returns this effect.
  31189. */
  31190. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31191. /**
  31192. * 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)
  31193. * @param uniformName Name of the variable.
  31194. * @param array array to be set.
  31195. * @returns this effect.
  31196. */
  31197. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31198. /**
  31199. * Sets an float array on a uniform variable.
  31200. * @param uniformName Name of the variable.
  31201. * @param array array to be set.
  31202. * @returns this effect.
  31203. */
  31204. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31205. /**
  31206. * 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)
  31207. * @param uniformName Name of the variable.
  31208. * @param array array to be set.
  31209. * @returns this effect.
  31210. */
  31211. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31212. /**
  31213. * 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)
  31214. * @param uniformName Name of the variable.
  31215. * @param array array to be set.
  31216. * @returns this effect.
  31217. */
  31218. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31219. /**
  31220. * 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)
  31221. * @param uniformName Name of the variable.
  31222. * @param array array to be set.
  31223. * @returns this effect.
  31224. */
  31225. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31226. /**
  31227. * Sets an array on a uniform variable.
  31228. * @param uniformName Name of the variable.
  31229. * @param array array to be set.
  31230. * @returns this effect.
  31231. */
  31232. setArray(uniformName: string, array: number[]): Effect;
  31233. /**
  31234. * 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)
  31235. * @param uniformName Name of the variable.
  31236. * @param array array to be set.
  31237. * @returns this effect.
  31238. */
  31239. setArray2(uniformName: string, array: number[]): Effect;
  31240. /**
  31241. * 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)
  31242. * @param uniformName Name of the variable.
  31243. * @param array array to be set.
  31244. * @returns this effect.
  31245. */
  31246. setArray3(uniformName: string, array: number[]): Effect;
  31247. /**
  31248. * 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)
  31249. * @param uniformName Name of the variable.
  31250. * @param array array to be set.
  31251. * @returns this effect.
  31252. */
  31253. setArray4(uniformName: string, array: number[]): Effect;
  31254. /**
  31255. * Sets matrices on a uniform variable.
  31256. * @param uniformName Name of the variable.
  31257. * @param matrices matrices to be set.
  31258. * @returns this effect.
  31259. */
  31260. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31261. /**
  31262. * Sets matrix on a uniform variable.
  31263. * @param uniformName Name of the variable.
  31264. * @param matrix matrix to be set.
  31265. * @returns this effect.
  31266. */
  31267. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31268. /**
  31269. * 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)
  31270. * @param uniformName Name of the variable.
  31271. * @param matrix matrix to be set.
  31272. * @returns this effect.
  31273. */
  31274. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31275. /**
  31276. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31277. * @param uniformName Name of the variable.
  31278. * @param matrix matrix to be set.
  31279. * @returns this effect.
  31280. */
  31281. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31282. /**
  31283. * Sets a float on a uniform variable.
  31284. * @param uniformName Name of the variable.
  31285. * @param value value to be set.
  31286. * @returns this effect.
  31287. */
  31288. setFloat(uniformName: string, value: number): Effect;
  31289. /**
  31290. * Sets a boolean on a uniform variable.
  31291. * @param uniformName Name of the variable.
  31292. * @param bool value to be set.
  31293. * @returns this effect.
  31294. */
  31295. setBool(uniformName: string, bool: boolean): Effect;
  31296. /**
  31297. * Sets a Vector2 on a uniform variable.
  31298. * @param uniformName Name of the variable.
  31299. * @param vector2 vector2 to be set.
  31300. * @returns this effect.
  31301. */
  31302. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31303. /**
  31304. * Sets a float2 on a uniform variable.
  31305. * @param uniformName Name of the variable.
  31306. * @param x First float in float2.
  31307. * @param y Second float in float2.
  31308. * @returns this effect.
  31309. */
  31310. setFloat2(uniformName: string, x: number, y: number): Effect;
  31311. /**
  31312. * Sets a Vector3 on a uniform variable.
  31313. * @param uniformName Name of the variable.
  31314. * @param vector3 Value to be set.
  31315. * @returns this effect.
  31316. */
  31317. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31318. /**
  31319. * Sets a float3 on a uniform variable.
  31320. * @param uniformName Name of the variable.
  31321. * @param x First float in float3.
  31322. * @param y Second float in float3.
  31323. * @param z Third float in float3.
  31324. * @returns this effect.
  31325. */
  31326. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31327. /**
  31328. * Sets a Vector4 on a uniform variable.
  31329. * @param uniformName Name of the variable.
  31330. * @param vector4 Value to be set.
  31331. * @returns this effect.
  31332. */
  31333. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31334. /**
  31335. * Sets a float4 on a uniform variable.
  31336. * @param uniformName Name of the variable.
  31337. * @param x First float in float4.
  31338. * @param y Second float in float4.
  31339. * @param z Third float in float4.
  31340. * @param w Fourth float in float4.
  31341. * @returns this effect.
  31342. */
  31343. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31344. /**
  31345. * Sets a Color3 on a uniform variable.
  31346. * @param uniformName Name of the variable.
  31347. * @param color3 Value to be set.
  31348. * @returns this effect.
  31349. */
  31350. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31351. /**
  31352. * Sets a Color4 on a uniform variable.
  31353. * @param uniformName Name of the variable.
  31354. * @param color3 Value to be set.
  31355. * @param alpha Alpha value to be set.
  31356. * @returns this effect.
  31357. */
  31358. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31359. /**
  31360. * Sets a Color4 on a uniform variable
  31361. * @param uniformName defines the name of the variable
  31362. * @param color4 defines the value to be set
  31363. * @returns this effect.
  31364. */
  31365. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31366. /** Release all associated resources */
  31367. dispose(): void;
  31368. /**
  31369. * This function will add a new shader to the shader store
  31370. * @param name the name of the shader
  31371. * @param pixelShader optional pixel shader content
  31372. * @param vertexShader optional vertex shader content
  31373. */
  31374. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31375. /**
  31376. * Store of each shader (The can be looked up using effect.key)
  31377. */
  31378. static ShadersStore: {
  31379. [key: string]: string;
  31380. };
  31381. /**
  31382. * Store of each included file for a shader (The can be looked up using effect.key)
  31383. */
  31384. static IncludesShadersStore: {
  31385. [key: string]: string;
  31386. };
  31387. /**
  31388. * Resets the cache of effects.
  31389. */
  31390. static ResetCache(): void;
  31391. }
  31392. }
  31393. declare module "babylonjs/Engines/engineCapabilities" {
  31394. /**
  31395. * Interface used to describe the capabilities of the engine relatively to the current browser
  31396. */
  31397. export interface EngineCapabilities {
  31398. /** Maximum textures units per fragment shader */
  31399. maxTexturesImageUnits: number;
  31400. /** Maximum texture units per vertex shader */
  31401. maxVertexTextureImageUnits: number;
  31402. /** Maximum textures units in the entire pipeline */
  31403. maxCombinedTexturesImageUnits: number;
  31404. /** Maximum texture size */
  31405. maxTextureSize: number;
  31406. /** Maximum texture samples */
  31407. maxSamples?: number;
  31408. /** Maximum cube texture size */
  31409. maxCubemapTextureSize: number;
  31410. /** Maximum render texture size */
  31411. maxRenderTextureSize: number;
  31412. /** Maximum number of vertex attributes */
  31413. maxVertexAttribs: number;
  31414. /** Maximum number of varyings */
  31415. maxVaryingVectors: number;
  31416. /** Maximum number of uniforms per vertex shader */
  31417. maxVertexUniformVectors: number;
  31418. /** Maximum number of uniforms per fragment shader */
  31419. maxFragmentUniformVectors: number;
  31420. /** Defines if standard derivates (dx/dy) are supported */
  31421. standardDerivatives: boolean;
  31422. /** Defines if s3tc texture compression is supported */
  31423. s3tc?: WEBGL_compressed_texture_s3tc;
  31424. /** Defines if pvrtc texture compression is supported */
  31425. pvrtc: any;
  31426. /** Defines if etc1 texture compression is supported */
  31427. etc1: any;
  31428. /** Defines if etc2 texture compression is supported */
  31429. etc2: any;
  31430. /** Defines if astc texture compression is supported */
  31431. astc: any;
  31432. /** Defines if float textures are supported */
  31433. textureFloat: boolean;
  31434. /** Defines if vertex array objects are supported */
  31435. vertexArrayObject: boolean;
  31436. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31437. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31438. /** Gets the maximum level of anisotropy supported */
  31439. maxAnisotropy: number;
  31440. /** Defines if instancing is supported */
  31441. instancedArrays: boolean;
  31442. /** Defines if 32 bits indices are supported */
  31443. uintIndices: boolean;
  31444. /** Defines if high precision shaders are supported */
  31445. highPrecisionShaderSupported: boolean;
  31446. /** Defines if depth reading in the fragment shader is supported */
  31447. fragmentDepthSupported: boolean;
  31448. /** Defines if float texture linear filtering is supported*/
  31449. textureFloatLinearFiltering: boolean;
  31450. /** Defines if rendering to float textures is supported */
  31451. textureFloatRender: boolean;
  31452. /** Defines if half float textures are supported*/
  31453. textureHalfFloat: boolean;
  31454. /** Defines if half float texture linear filtering is supported*/
  31455. textureHalfFloatLinearFiltering: boolean;
  31456. /** Defines if rendering to half float textures is supported */
  31457. textureHalfFloatRender: boolean;
  31458. /** Defines if textureLOD shader command is supported */
  31459. textureLOD: boolean;
  31460. /** Defines if draw buffers extension is supported */
  31461. drawBuffersExtension: boolean;
  31462. /** Defines if depth textures are supported */
  31463. depthTextureExtension: boolean;
  31464. /** Defines if float color buffer are supported */
  31465. colorBufferFloat: boolean;
  31466. /** Gets disjoint timer query extension (null if not supported) */
  31467. timerQuery?: EXT_disjoint_timer_query;
  31468. /** Defines if timestamp can be used with timer query */
  31469. canUseTimestampForTimerQuery: boolean;
  31470. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31471. multiview?: any;
  31472. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31473. oculusMultiview?: any;
  31474. /** Function used to let the system compiles shaders in background */
  31475. parallelShaderCompile?: {
  31476. COMPLETION_STATUS_KHR: number;
  31477. };
  31478. /** Max number of texture samples for MSAA */
  31479. maxMSAASamples: number;
  31480. /** Defines if the blend min max extension is supported */
  31481. blendMinMax: boolean;
  31482. }
  31483. }
  31484. declare module "babylonjs/States/depthCullingState" {
  31485. import { Nullable } from "babylonjs/types";
  31486. /**
  31487. * @hidden
  31488. **/
  31489. export class DepthCullingState {
  31490. private _isDepthTestDirty;
  31491. private _isDepthMaskDirty;
  31492. private _isDepthFuncDirty;
  31493. private _isCullFaceDirty;
  31494. private _isCullDirty;
  31495. private _isZOffsetDirty;
  31496. private _isFrontFaceDirty;
  31497. private _depthTest;
  31498. private _depthMask;
  31499. private _depthFunc;
  31500. private _cull;
  31501. private _cullFace;
  31502. private _zOffset;
  31503. private _frontFace;
  31504. /**
  31505. * Initializes the state.
  31506. */
  31507. constructor();
  31508. get isDirty(): boolean;
  31509. get zOffset(): number;
  31510. set zOffset(value: number);
  31511. get cullFace(): Nullable<number>;
  31512. set cullFace(value: Nullable<number>);
  31513. get cull(): Nullable<boolean>;
  31514. set cull(value: Nullable<boolean>);
  31515. get depthFunc(): Nullable<number>;
  31516. set depthFunc(value: Nullable<number>);
  31517. get depthMask(): boolean;
  31518. set depthMask(value: boolean);
  31519. get depthTest(): boolean;
  31520. set depthTest(value: boolean);
  31521. get frontFace(): Nullable<number>;
  31522. set frontFace(value: Nullable<number>);
  31523. reset(): void;
  31524. apply(gl: WebGLRenderingContext): void;
  31525. }
  31526. }
  31527. declare module "babylonjs/States/stencilState" {
  31528. /**
  31529. * @hidden
  31530. **/
  31531. export class StencilState {
  31532. /** 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 */
  31533. static readonly ALWAYS: number;
  31534. /** Passed to stencilOperation to specify that stencil value must be kept */
  31535. static readonly KEEP: number;
  31536. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31537. static readonly REPLACE: number;
  31538. private _isStencilTestDirty;
  31539. private _isStencilMaskDirty;
  31540. private _isStencilFuncDirty;
  31541. private _isStencilOpDirty;
  31542. private _stencilTest;
  31543. private _stencilMask;
  31544. private _stencilFunc;
  31545. private _stencilFuncRef;
  31546. private _stencilFuncMask;
  31547. private _stencilOpStencilFail;
  31548. private _stencilOpDepthFail;
  31549. private _stencilOpStencilDepthPass;
  31550. get isDirty(): boolean;
  31551. get stencilFunc(): number;
  31552. set stencilFunc(value: number);
  31553. get stencilFuncRef(): number;
  31554. set stencilFuncRef(value: number);
  31555. get stencilFuncMask(): number;
  31556. set stencilFuncMask(value: number);
  31557. get stencilOpStencilFail(): number;
  31558. set stencilOpStencilFail(value: number);
  31559. get stencilOpDepthFail(): number;
  31560. set stencilOpDepthFail(value: number);
  31561. get stencilOpStencilDepthPass(): number;
  31562. set stencilOpStencilDepthPass(value: number);
  31563. get stencilMask(): number;
  31564. set stencilMask(value: number);
  31565. get stencilTest(): boolean;
  31566. set stencilTest(value: boolean);
  31567. constructor();
  31568. reset(): void;
  31569. apply(gl: WebGLRenderingContext): void;
  31570. }
  31571. }
  31572. declare module "babylonjs/States/alphaCullingState" {
  31573. /**
  31574. * @hidden
  31575. **/
  31576. export class AlphaState {
  31577. private _isAlphaBlendDirty;
  31578. private _isBlendFunctionParametersDirty;
  31579. private _isBlendEquationParametersDirty;
  31580. private _isBlendConstantsDirty;
  31581. private _alphaBlend;
  31582. private _blendFunctionParameters;
  31583. private _blendEquationParameters;
  31584. private _blendConstants;
  31585. /**
  31586. * Initializes the state.
  31587. */
  31588. constructor();
  31589. get isDirty(): boolean;
  31590. get alphaBlend(): boolean;
  31591. set alphaBlend(value: boolean);
  31592. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31593. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31594. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31595. reset(): void;
  31596. apply(gl: WebGLRenderingContext): void;
  31597. }
  31598. }
  31599. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31600. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31601. /** @hidden */
  31602. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31603. attributeProcessor(attribute: string): string;
  31604. varyingProcessor(varying: string, isFragment: boolean): string;
  31605. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31606. }
  31607. }
  31608. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31609. /**
  31610. * Interface for attribute information associated with buffer instanciation
  31611. */
  31612. export interface InstancingAttributeInfo {
  31613. /**
  31614. * Name of the GLSL attribute
  31615. * if attribute index is not specified, this is used to retrieve the index from the effect
  31616. */
  31617. attributeName: string;
  31618. /**
  31619. * Index/offset of the attribute in the vertex shader
  31620. * if not specified, this will be computes from the name.
  31621. */
  31622. index?: number;
  31623. /**
  31624. * size of the attribute, 1, 2, 3 or 4
  31625. */
  31626. attributeSize: number;
  31627. /**
  31628. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31629. */
  31630. offset: number;
  31631. /**
  31632. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31633. * default to 1
  31634. */
  31635. divisor?: number;
  31636. /**
  31637. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31638. * default is FLOAT
  31639. */
  31640. attributeType?: number;
  31641. /**
  31642. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31643. */
  31644. normalized?: boolean;
  31645. }
  31646. }
  31647. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31648. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31649. import { Nullable } from "babylonjs/types";
  31650. module "babylonjs/Engines/thinEngine" {
  31651. interface ThinEngine {
  31652. /**
  31653. * Update a video texture
  31654. * @param texture defines the texture to update
  31655. * @param video defines the video element to use
  31656. * @param invertY defines if data must be stored with Y axis inverted
  31657. */
  31658. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31659. }
  31660. }
  31661. }
  31662. declare module "babylonjs/Materials/Textures/videoTexture" {
  31663. import { Observable } from "babylonjs/Misc/observable";
  31664. import { Nullable } from "babylonjs/types";
  31665. import { Scene } from "babylonjs/scene";
  31666. import { Texture } from "babylonjs/Materials/Textures/texture";
  31667. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31668. /**
  31669. * Settings for finer control over video usage
  31670. */
  31671. export interface VideoTextureSettings {
  31672. /**
  31673. * Applies `autoplay` to video, if specified
  31674. */
  31675. autoPlay?: boolean;
  31676. /**
  31677. * Applies `loop` to video, if specified
  31678. */
  31679. loop?: boolean;
  31680. /**
  31681. * Automatically updates internal texture from video at every frame in the render loop
  31682. */
  31683. autoUpdateTexture: boolean;
  31684. /**
  31685. * Image src displayed during the video loading or until the user interacts with the video.
  31686. */
  31687. poster?: string;
  31688. }
  31689. /**
  31690. * If you want to display a video in your scene, this is the special texture for that.
  31691. * This special texture works similar to other textures, with the exception of a few parameters.
  31692. * @see https://doc.babylonjs.com/how_to/video_texture
  31693. */
  31694. export class VideoTexture extends Texture {
  31695. /**
  31696. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31697. */
  31698. readonly autoUpdateTexture: boolean;
  31699. /**
  31700. * The video instance used by the texture internally
  31701. */
  31702. readonly video: HTMLVideoElement;
  31703. private _onUserActionRequestedObservable;
  31704. /**
  31705. * Event triggerd when a dom action is required by the user to play the video.
  31706. * This happens due to recent changes in browser policies preventing video to auto start.
  31707. */
  31708. get onUserActionRequestedObservable(): Observable<Texture>;
  31709. private _generateMipMaps;
  31710. private _engine;
  31711. private _stillImageCaptured;
  31712. private _displayingPosterTexture;
  31713. private _settings;
  31714. private _createInternalTextureOnEvent;
  31715. private _frameId;
  31716. private _currentSrc;
  31717. /**
  31718. * Creates a video texture.
  31719. * If you want to display a video in your scene, this is the special texture for that.
  31720. * This special texture works similar to other textures, with the exception of a few parameters.
  31721. * @see https://doc.babylonjs.com/how_to/video_texture
  31722. * @param name optional name, will detect from video source, if not defined
  31723. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31724. * @param scene is obviously the current scene.
  31725. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31726. * @param invertY is false by default but can be used to invert video on Y axis
  31727. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31728. * @param settings allows finer control over video usage
  31729. */
  31730. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31731. private _getName;
  31732. private _getVideo;
  31733. private _createInternalTexture;
  31734. private reset;
  31735. /**
  31736. * @hidden Internal method to initiate `update`.
  31737. */
  31738. _rebuild(): void;
  31739. /**
  31740. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31741. */
  31742. update(): void;
  31743. /**
  31744. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31745. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31746. */
  31747. updateTexture(isVisible: boolean): void;
  31748. protected _updateInternalTexture: () => void;
  31749. /**
  31750. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31751. * @param url New url.
  31752. */
  31753. updateURL(url: string): void;
  31754. /**
  31755. * Clones the texture.
  31756. * @returns the cloned texture
  31757. */
  31758. clone(): VideoTexture;
  31759. /**
  31760. * Dispose the texture and release its associated resources.
  31761. */
  31762. dispose(): void;
  31763. /**
  31764. * Creates a video texture straight from a stream.
  31765. * @param scene Define the scene the texture should be created in
  31766. * @param stream Define the stream the texture should be created from
  31767. * @returns The created video texture as a promise
  31768. */
  31769. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31770. /**
  31771. * Creates a video texture straight from your WebCam video feed.
  31772. * @param scene Define the scene the texture should be created in
  31773. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31774. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31775. * @returns The created video texture as a promise
  31776. */
  31777. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31778. minWidth: number;
  31779. maxWidth: number;
  31780. minHeight: number;
  31781. maxHeight: number;
  31782. deviceId: string;
  31783. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31784. /**
  31785. * Creates a video texture straight from your WebCam video feed.
  31786. * @param scene Define the scene the texture should be created in
  31787. * @param onReady Define a callback to triggered once the texture will be ready
  31788. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31789. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31790. */
  31791. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31792. minWidth: number;
  31793. maxWidth: number;
  31794. minHeight: number;
  31795. maxHeight: number;
  31796. deviceId: string;
  31797. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31798. }
  31799. }
  31800. declare module "babylonjs/Engines/thinEngine" {
  31801. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31802. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31803. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31804. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31805. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31806. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31807. import { Observable } from "babylonjs/Misc/observable";
  31808. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31809. import { StencilState } from "babylonjs/States/stencilState";
  31810. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31811. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31812. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31813. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31814. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31815. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31816. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31817. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31818. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31819. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31820. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31821. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31822. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31823. import { WebRequest } from "babylonjs/Misc/webRequest";
  31824. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31825. /**
  31826. * Defines the interface used by objects working like Scene
  31827. * @hidden
  31828. */
  31829. export interface ISceneLike {
  31830. _addPendingData(data: any): void;
  31831. _removePendingData(data: any): void;
  31832. offlineProvider: IOfflineProvider;
  31833. }
  31834. /** Interface defining initialization parameters for Engine class */
  31835. export interface EngineOptions extends WebGLContextAttributes {
  31836. /**
  31837. * Defines if the engine should no exceed a specified device ratio
  31838. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31839. */
  31840. limitDeviceRatio?: number;
  31841. /**
  31842. * Defines if webvr should be enabled automatically
  31843. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31844. */
  31845. autoEnableWebVR?: boolean;
  31846. /**
  31847. * Defines if webgl2 should be turned off even if supported
  31848. * @see http://doc.babylonjs.com/features/webgl2
  31849. */
  31850. disableWebGL2Support?: boolean;
  31851. /**
  31852. * Defines if webaudio should be initialized as well
  31853. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31854. */
  31855. audioEngine?: boolean;
  31856. /**
  31857. * Defines if animations should run using a deterministic lock step
  31858. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31859. */
  31860. deterministicLockstep?: boolean;
  31861. /** Defines the maximum steps to use with deterministic lock step mode */
  31862. lockstepMaxSteps?: number;
  31863. /** Defines the seconds between each deterministic lock step */
  31864. timeStep?: number;
  31865. /**
  31866. * Defines that engine should ignore context lost events
  31867. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31868. */
  31869. doNotHandleContextLost?: boolean;
  31870. /**
  31871. * Defines that engine should ignore modifying touch action attribute and style
  31872. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31873. */
  31874. doNotHandleTouchAction?: boolean;
  31875. /**
  31876. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31877. */
  31878. useHighPrecisionFloats?: boolean;
  31879. }
  31880. /**
  31881. * The base engine class (root of all engines)
  31882. */
  31883. export class ThinEngine {
  31884. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31885. static ExceptionList: ({
  31886. key: string;
  31887. capture: string;
  31888. captureConstraint: number;
  31889. targets: string[];
  31890. } | {
  31891. key: string;
  31892. capture: null;
  31893. captureConstraint: null;
  31894. targets: string[];
  31895. })[];
  31896. /** @hidden */
  31897. static _TextureLoaders: IInternalTextureLoader[];
  31898. /**
  31899. * Returns the current npm package of the sdk
  31900. */
  31901. static get NpmPackage(): string;
  31902. /**
  31903. * Returns the current version of the framework
  31904. */
  31905. static get Version(): string;
  31906. /**
  31907. * Returns a string describing the current engine
  31908. */
  31909. get description(): string;
  31910. /**
  31911. * Gets or sets the epsilon value used by collision engine
  31912. */
  31913. static CollisionsEpsilon: number;
  31914. /**
  31915. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31916. */
  31917. static get ShadersRepository(): string;
  31918. static set ShadersRepository(value: string);
  31919. /** @hidden */
  31920. _shaderProcessor: IShaderProcessor;
  31921. /**
  31922. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31923. */
  31924. forcePOTTextures: boolean;
  31925. /**
  31926. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31927. */
  31928. isFullscreen: boolean;
  31929. /**
  31930. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31931. */
  31932. cullBackFaces: boolean;
  31933. /**
  31934. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31935. */
  31936. renderEvenInBackground: boolean;
  31937. /**
  31938. * Gets or sets a boolean indicating that cache can be kept between frames
  31939. */
  31940. preventCacheWipeBetweenFrames: boolean;
  31941. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31942. validateShaderPrograms: boolean;
  31943. /**
  31944. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31945. * This can provide greater z depth for distant objects.
  31946. */
  31947. useReverseDepthBuffer: boolean;
  31948. /**
  31949. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31950. */
  31951. disableUniformBuffers: boolean;
  31952. /** @hidden */
  31953. _uniformBuffers: UniformBuffer[];
  31954. /**
  31955. * Gets a boolean indicating that the engine supports uniform buffers
  31956. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31957. */
  31958. get supportsUniformBuffers(): boolean;
  31959. /** @hidden */
  31960. _gl: WebGLRenderingContext;
  31961. /** @hidden */
  31962. _webGLVersion: number;
  31963. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31964. protected _windowIsBackground: boolean;
  31965. protected _creationOptions: EngineOptions;
  31966. protected _highPrecisionShadersAllowed: boolean;
  31967. /** @hidden */
  31968. get _shouldUseHighPrecisionShader(): boolean;
  31969. /**
  31970. * Gets a boolean indicating that only power of 2 textures are supported
  31971. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31972. */
  31973. get needPOTTextures(): boolean;
  31974. /** @hidden */
  31975. _badOS: boolean;
  31976. /** @hidden */
  31977. _badDesktopOS: boolean;
  31978. private _hardwareScalingLevel;
  31979. /** @hidden */
  31980. _caps: EngineCapabilities;
  31981. private _isStencilEnable;
  31982. private _glVersion;
  31983. private _glRenderer;
  31984. private _glVendor;
  31985. /** @hidden */
  31986. _videoTextureSupported: boolean;
  31987. protected _renderingQueueLaunched: boolean;
  31988. protected _activeRenderLoops: (() => void)[];
  31989. /**
  31990. * Observable signaled when a context lost event is raised
  31991. */
  31992. onContextLostObservable: Observable<ThinEngine>;
  31993. /**
  31994. * Observable signaled when a context restored event is raised
  31995. */
  31996. onContextRestoredObservable: Observable<ThinEngine>;
  31997. private _onContextLost;
  31998. private _onContextRestored;
  31999. protected _contextWasLost: boolean;
  32000. /** @hidden */
  32001. _doNotHandleContextLost: boolean;
  32002. /**
  32003. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32004. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32005. */
  32006. get doNotHandleContextLost(): boolean;
  32007. set doNotHandleContextLost(value: boolean);
  32008. /**
  32009. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32010. */
  32011. disableVertexArrayObjects: boolean;
  32012. /** @hidden */
  32013. protected _colorWrite: boolean;
  32014. /** @hidden */
  32015. protected _colorWriteChanged: boolean;
  32016. /** @hidden */
  32017. protected _depthCullingState: DepthCullingState;
  32018. /** @hidden */
  32019. protected _stencilState: StencilState;
  32020. /** @hidden */
  32021. _alphaState: AlphaState;
  32022. /** @hidden */
  32023. _alphaMode: number;
  32024. /** @hidden */
  32025. _alphaEquation: number;
  32026. /** @hidden */
  32027. _internalTexturesCache: InternalTexture[];
  32028. /** @hidden */
  32029. protected _activeChannel: number;
  32030. private _currentTextureChannel;
  32031. /** @hidden */
  32032. protected _boundTexturesCache: {
  32033. [key: string]: Nullable<InternalTexture>;
  32034. };
  32035. /** @hidden */
  32036. protected _currentEffect: Nullable<Effect>;
  32037. /** @hidden */
  32038. protected _currentProgram: Nullable<WebGLProgram>;
  32039. private _compiledEffects;
  32040. private _vertexAttribArraysEnabled;
  32041. /** @hidden */
  32042. protected _cachedViewport: Nullable<IViewportLike>;
  32043. private _cachedVertexArrayObject;
  32044. /** @hidden */
  32045. protected _cachedVertexBuffers: any;
  32046. /** @hidden */
  32047. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32048. /** @hidden */
  32049. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32050. /** @hidden */
  32051. _currentRenderTarget: Nullable<InternalTexture>;
  32052. private _uintIndicesCurrentlySet;
  32053. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32054. /** @hidden */
  32055. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32056. private _currentBufferPointers;
  32057. private _currentInstanceLocations;
  32058. private _currentInstanceBuffers;
  32059. private _textureUnits;
  32060. /** @hidden */
  32061. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32062. /** @hidden */
  32063. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32064. /** @hidden */
  32065. _boundRenderFunction: any;
  32066. private _vaoRecordInProgress;
  32067. private _mustWipeVertexAttributes;
  32068. private _emptyTexture;
  32069. private _emptyCubeTexture;
  32070. private _emptyTexture3D;
  32071. private _emptyTexture2DArray;
  32072. /** @hidden */
  32073. _frameHandler: number;
  32074. private _nextFreeTextureSlots;
  32075. private _maxSimultaneousTextures;
  32076. private _activeRequests;
  32077. protected _texturesSupported: string[];
  32078. /** @hidden */
  32079. _textureFormatInUse: Nullable<string>;
  32080. protected get _supportsHardwareTextureRescaling(): boolean;
  32081. /**
  32082. * Gets the list of texture formats supported
  32083. */
  32084. get texturesSupported(): Array<string>;
  32085. /**
  32086. * Gets the list of texture formats in use
  32087. */
  32088. get textureFormatInUse(): Nullable<string>;
  32089. /**
  32090. * Gets the current viewport
  32091. */
  32092. get currentViewport(): Nullable<IViewportLike>;
  32093. /**
  32094. * Gets the default empty texture
  32095. */
  32096. get emptyTexture(): InternalTexture;
  32097. /**
  32098. * Gets the default empty 3D texture
  32099. */
  32100. get emptyTexture3D(): InternalTexture;
  32101. /**
  32102. * Gets the default empty 2D array texture
  32103. */
  32104. get emptyTexture2DArray(): InternalTexture;
  32105. /**
  32106. * Gets the default empty cube texture
  32107. */
  32108. get emptyCubeTexture(): InternalTexture;
  32109. /**
  32110. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32111. */
  32112. readonly premultipliedAlpha: boolean;
  32113. /**
  32114. * Observable event triggered before each texture is initialized
  32115. */
  32116. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32117. /**
  32118. * Creates a new engine
  32119. * @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
  32120. * @param antialias defines enable antialiasing (default: false)
  32121. * @param options defines further options to be sent to the getContext() function
  32122. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32123. */
  32124. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32125. private _rebuildInternalTextures;
  32126. private _rebuildEffects;
  32127. /**
  32128. * Gets a boolean indicating if all created effects are ready
  32129. * @returns true if all effects are ready
  32130. */
  32131. areAllEffectsReady(): boolean;
  32132. protected _rebuildBuffers(): void;
  32133. private _initGLContext;
  32134. /**
  32135. * Gets version of the current webGL context
  32136. */
  32137. get webGLVersion(): number;
  32138. /**
  32139. * Gets a string idenfifying the name of the class
  32140. * @returns "Engine" string
  32141. */
  32142. getClassName(): string;
  32143. /**
  32144. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32145. */
  32146. get isStencilEnable(): boolean;
  32147. /** @hidden */
  32148. _prepareWorkingCanvas(): void;
  32149. /**
  32150. * Reset the texture cache to empty state
  32151. */
  32152. resetTextureCache(): void;
  32153. /**
  32154. * Gets an object containing information about the current webGL context
  32155. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32156. */
  32157. getGlInfo(): {
  32158. vendor: string;
  32159. renderer: string;
  32160. version: string;
  32161. };
  32162. /**
  32163. * Defines the hardware scaling level.
  32164. * By default the hardware scaling level is computed from the window device ratio.
  32165. * 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.
  32166. * @param level defines the level to use
  32167. */
  32168. setHardwareScalingLevel(level: number): void;
  32169. /**
  32170. * Gets the current hardware scaling level.
  32171. * By default the hardware scaling level is computed from the window device ratio.
  32172. * 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.
  32173. * @returns a number indicating the current hardware scaling level
  32174. */
  32175. getHardwareScalingLevel(): number;
  32176. /**
  32177. * Gets the list of loaded textures
  32178. * @returns an array containing all loaded textures
  32179. */
  32180. getLoadedTexturesCache(): InternalTexture[];
  32181. /**
  32182. * Gets the object containing all engine capabilities
  32183. * @returns the EngineCapabilities object
  32184. */
  32185. getCaps(): EngineCapabilities;
  32186. /**
  32187. * stop executing a render loop function and remove it from the execution array
  32188. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32189. */
  32190. stopRenderLoop(renderFunction?: () => void): void;
  32191. /** @hidden */
  32192. _renderLoop(): void;
  32193. /**
  32194. * Gets the HTML canvas attached with the current webGL context
  32195. * @returns a HTML canvas
  32196. */
  32197. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32198. /**
  32199. * Gets host window
  32200. * @returns the host window object
  32201. */
  32202. getHostWindow(): Nullable<Window>;
  32203. /**
  32204. * Gets the current render width
  32205. * @param useScreen defines if screen size must be used (or the current render target if any)
  32206. * @returns a number defining the current render width
  32207. */
  32208. getRenderWidth(useScreen?: boolean): number;
  32209. /**
  32210. * Gets the current render height
  32211. * @param useScreen defines if screen size must be used (or the current render target if any)
  32212. * @returns a number defining the current render height
  32213. */
  32214. getRenderHeight(useScreen?: boolean): number;
  32215. /**
  32216. * Can be used to override the current requestAnimationFrame requester.
  32217. * @hidden
  32218. */
  32219. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32220. /**
  32221. * Register and execute a render loop. The engine can have more than one render function
  32222. * @param renderFunction defines the function to continuously execute
  32223. */
  32224. runRenderLoop(renderFunction: () => void): void;
  32225. /**
  32226. * Clear the current render buffer or the current render target (if any is set up)
  32227. * @param color defines the color to use
  32228. * @param backBuffer defines if the back buffer must be cleared
  32229. * @param depth defines if the depth buffer must be cleared
  32230. * @param stencil defines if the stencil buffer must be cleared
  32231. */
  32232. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32233. private _viewportCached;
  32234. /** @hidden */
  32235. _viewport(x: number, y: number, width: number, height: number): void;
  32236. /**
  32237. * Set the WebGL's viewport
  32238. * @param viewport defines the viewport element to be used
  32239. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32240. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32241. */
  32242. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32243. /**
  32244. * Begin a new frame
  32245. */
  32246. beginFrame(): void;
  32247. /**
  32248. * Enf the current frame
  32249. */
  32250. endFrame(): void;
  32251. /**
  32252. * Resize the view according to the canvas' size
  32253. */
  32254. resize(): void;
  32255. /**
  32256. * Force a specific size of the canvas
  32257. * @param width defines the new canvas' width
  32258. * @param height defines the new canvas' height
  32259. */
  32260. setSize(width: number, height: number): void;
  32261. /**
  32262. * Binds the frame buffer to the specified texture.
  32263. * @param texture The texture to render to or null for the default canvas
  32264. * @param faceIndex The face of the texture to render to in case of cube texture
  32265. * @param requiredWidth The width of the target to render to
  32266. * @param requiredHeight The height of the target to render to
  32267. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32268. * @param lodLevel defines the lod level to bind to the frame buffer
  32269. * @param layer defines the 2d array index to bind to frame buffer to
  32270. */
  32271. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32272. /** @hidden */
  32273. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32274. /**
  32275. * Unbind the current render target texture from the webGL context
  32276. * @param texture defines the render target texture to unbind
  32277. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32278. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32279. */
  32280. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32281. /**
  32282. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32283. */
  32284. flushFramebuffer(): void;
  32285. /**
  32286. * Unbind the current render target and bind the default framebuffer
  32287. */
  32288. restoreDefaultFramebuffer(): void;
  32289. /** @hidden */
  32290. protected _resetVertexBufferBinding(): void;
  32291. /**
  32292. * Creates a vertex buffer
  32293. * @param data the data for the vertex buffer
  32294. * @returns the new WebGL static buffer
  32295. */
  32296. createVertexBuffer(data: DataArray): DataBuffer;
  32297. private _createVertexBuffer;
  32298. /**
  32299. * Creates a dynamic vertex buffer
  32300. * @param data the data for the dynamic vertex buffer
  32301. * @returns the new WebGL dynamic buffer
  32302. */
  32303. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32304. protected _resetIndexBufferBinding(): void;
  32305. /**
  32306. * Creates a new index buffer
  32307. * @param indices defines the content of the index buffer
  32308. * @param updatable defines if the index buffer must be updatable
  32309. * @returns a new webGL buffer
  32310. */
  32311. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32312. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32313. /**
  32314. * Bind a webGL buffer to the webGL context
  32315. * @param buffer defines the buffer to bind
  32316. */
  32317. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32318. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32319. private bindBuffer;
  32320. /**
  32321. * update the bound buffer with the given data
  32322. * @param data defines the data to update
  32323. */
  32324. updateArrayBuffer(data: Float32Array): void;
  32325. private _vertexAttribPointer;
  32326. /** @hidden */
  32327. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32328. private _bindVertexBuffersAttributes;
  32329. /**
  32330. * Records a vertex array object
  32331. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32332. * @param vertexBuffers defines the list of vertex buffers to store
  32333. * @param indexBuffer defines the index buffer to store
  32334. * @param effect defines the effect to store
  32335. * @returns the new vertex array object
  32336. */
  32337. recordVertexArrayObject(vertexBuffers: {
  32338. [key: string]: VertexBuffer;
  32339. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32340. /**
  32341. * Bind a specific vertex array object
  32342. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32343. * @param vertexArrayObject defines the vertex array object to bind
  32344. * @param indexBuffer defines the index buffer to bind
  32345. */
  32346. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32347. /**
  32348. * Bind webGl buffers directly to the webGL context
  32349. * @param vertexBuffer defines the vertex buffer to bind
  32350. * @param indexBuffer defines the index buffer to bind
  32351. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32352. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32353. * @param effect defines the effect associated with the vertex buffer
  32354. */
  32355. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32356. private _unbindVertexArrayObject;
  32357. /**
  32358. * Bind a list of vertex buffers to the webGL context
  32359. * @param vertexBuffers defines the list of vertex buffers to bind
  32360. * @param indexBuffer defines the index buffer to bind
  32361. * @param effect defines the effect associated with the vertex buffers
  32362. */
  32363. bindBuffers(vertexBuffers: {
  32364. [key: string]: Nullable<VertexBuffer>;
  32365. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32366. /**
  32367. * Unbind all instance attributes
  32368. */
  32369. unbindInstanceAttributes(): void;
  32370. /**
  32371. * Release and free the memory of a vertex array object
  32372. * @param vao defines the vertex array object to delete
  32373. */
  32374. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32375. /** @hidden */
  32376. _releaseBuffer(buffer: DataBuffer): boolean;
  32377. protected _deleteBuffer(buffer: DataBuffer): void;
  32378. /**
  32379. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32380. * @param instancesBuffer defines the webGL buffer to update and bind
  32381. * @param data defines the data to store in the buffer
  32382. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32383. */
  32384. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32385. /**
  32386. * Bind the content of a webGL buffer used with instantiation
  32387. * @param instancesBuffer defines the webGL buffer to bind
  32388. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32389. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32390. */
  32391. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32392. /**
  32393. * Disable the instance attribute corresponding to the name in parameter
  32394. * @param name defines the name of the attribute to disable
  32395. */
  32396. disableInstanceAttributeByName(name: string): void;
  32397. /**
  32398. * Disable the instance attribute corresponding to the location in parameter
  32399. * @param attributeLocation defines the attribute location of the attribute to disable
  32400. */
  32401. disableInstanceAttribute(attributeLocation: number): void;
  32402. /**
  32403. * Disable the attribute corresponding to the location in parameter
  32404. * @param attributeLocation defines the attribute location of the attribute to disable
  32405. */
  32406. disableAttributeByIndex(attributeLocation: number): void;
  32407. /**
  32408. * Send a draw order
  32409. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32410. * @param indexStart defines the starting index
  32411. * @param indexCount defines the number of index to draw
  32412. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32413. */
  32414. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32415. /**
  32416. * Draw a list of points
  32417. * @param verticesStart defines the index of first vertex to draw
  32418. * @param verticesCount defines the count of vertices to draw
  32419. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32420. */
  32421. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32422. /**
  32423. * Draw a list of unindexed primitives
  32424. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32425. * @param verticesStart defines the index of first vertex to draw
  32426. * @param verticesCount defines the count of vertices to draw
  32427. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32428. */
  32429. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32430. /**
  32431. * Draw a list of indexed primitives
  32432. * @param fillMode defines the primitive to use
  32433. * @param indexStart defines the starting index
  32434. * @param indexCount defines the number of index to draw
  32435. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32436. */
  32437. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32438. /**
  32439. * Draw a list of unindexed primitives
  32440. * @param fillMode defines the primitive to use
  32441. * @param verticesStart defines the index of first vertex to draw
  32442. * @param verticesCount defines the count of vertices to draw
  32443. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32444. */
  32445. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32446. private _drawMode;
  32447. /** @hidden */
  32448. protected _reportDrawCall(): void;
  32449. /** @hidden */
  32450. _releaseEffect(effect: Effect): void;
  32451. /** @hidden */
  32452. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32453. /**
  32454. * Create a new effect (used to store vertex/fragment shaders)
  32455. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32456. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32457. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32458. * @param samplers defines an array of string used to represent textures
  32459. * @param defines defines the string containing the defines to use to compile the shaders
  32460. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32461. * @param onCompiled defines a function to call when the effect creation is successful
  32462. * @param onError defines a function to call when the effect creation has failed
  32463. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32464. * @returns the new Effect
  32465. */
  32466. 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;
  32467. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32468. private _compileShader;
  32469. private _compileRawShader;
  32470. /**
  32471. * Directly creates a webGL program
  32472. * @param pipelineContext defines the pipeline context to attach to
  32473. * @param vertexCode defines the vertex shader code to use
  32474. * @param fragmentCode defines the fragment shader code to use
  32475. * @param context defines the webGL context to use (if not set, the current one will be used)
  32476. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32477. * @returns the new webGL program
  32478. */
  32479. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32480. /**
  32481. * Creates a webGL program
  32482. * @param pipelineContext defines the pipeline context to attach to
  32483. * @param vertexCode defines the vertex shader code to use
  32484. * @param fragmentCode defines the fragment shader code to use
  32485. * @param defines defines the string containing the defines to use to compile the shaders
  32486. * @param context defines the webGL context to use (if not set, the current one will be used)
  32487. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32488. * @returns the new webGL program
  32489. */
  32490. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32491. /**
  32492. * Creates a new pipeline context
  32493. * @returns the new pipeline
  32494. */
  32495. createPipelineContext(): IPipelineContext;
  32496. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32497. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32498. /** @hidden */
  32499. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32500. /** @hidden */
  32501. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32502. /** @hidden */
  32503. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32504. /**
  32505. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32506. * @param pipelineContext defines the pipeline context to use
  32507. * @param uniformsNames defines the list of uniform names
  32508. * @returns an array of webGL uniform locations
  32509. */
  32510. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32511. /**
  32512. * Gets the lsit of active attributes for a given webGL program
  32513. * @param pipelineContext defines the pipeline context to use
  32514. * @param attributesNames defines the list of attribute names to get
  32515. * @returns an array of indices indicating the offset of each attribute
  32516. */
  32517. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32518. /**
  32519. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32520. * @param effect defines the effect to activate
  32521. */
  32522. enableEffect(effect: Nullable<Effect>): void;
  32523. /**
  32524. * Set the value of an uniform to a number (int)
  32525. * @param uniform defines the webGL uniform location where to store the value
  32526. * @param value defines the int number to store
  32527. */
  32528. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32529. /**
  32530. * Set the value of an uniform to an array of int32
  32531. * @param uniform defines the webGL uniform location where to store the value
  32532. * @param array defines the array of int32 to store
  32533. */
  32534. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32535. /**
  32536. * Set the value of an uniform to an array of int32 (stored as vec2)
  32537. * @param uniform defines the webGL uniform location where to store the value
  32538. * @param array defines the array of int32 to store
  32539. */
  32540. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32541. /**
  32542. * Set the value of an uniform to an array of int32 (stored as vec3)
  32543. * @param uniform defines the webGL uniform location where to store the value
  32544. * @param array defines the array of int32 to store
  32545. */
  32546. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32547. /**
  32548. * Set the value of an uniform to an array of int32 (stored as vec4)
  32549. * @param uniform defines the webGL uniform location where to store the value
  32550. * @param array defines the array of int32 to store
  32551. */
  32552. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32553. /**
  32554. * Set the value of an uniform to an array of number
  32555. * @param uniform defines the webGL uniform location where to store the value
  32556. * @param array defines the array of number to store
  32557. */
  32558. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32559. /**
  32560. * Set the value of an uniform to an array of number (stored as vec2)
  32561. * @param uniform defines the webGL uniform location where to store the value
  32562. * @param array defines the array of number to store
  32563. */
  32564. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32565. /**
  32566. * Set the value of an uniform to an array of number (stored as vec3)
  32567. * @param uniform defines the webGL uniform location where to store the value
  32568. * @param array defines the array of number to store
  32569. */
  32570. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32571. /**
  32572. * Set the value of an uniform to an array of number (stored as vec4)
  32573. * @param uniform defines the webGL uniform location where to store the value
  32574. * @param array defines the array of number to store
  32575. */
  32576. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32577. /**
  32578. * Set the value of an uniform to an array of float32 (stored as matrices)
  32579. * @param uniform defines the webGL uniform location where to store the value
  32580. * @param matrices defines the array of float32 to store
  32581. */
  32582. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32583. /**
  32584. * Set the value of an uniform to a matrix (3x3)
  32585. * @param uniform defines the webGL uniform location where to store the value
  32586. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32587. */
  32588. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32589. /**
  32590. * Set the value of an uniform to a matrix (2x2)
  32591. * @param uniform defines the webGL uniform location where to store the value
  32592. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32593. */
  32594. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32595. /**
  32596. * Set the value of an uniform to a number (float)
  32597. * @param uniform defines the webGL uniform location where to store the value
  32598. * @param value defines the float number to store
  32599. */
  32600. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32601. /**
  32602. * Set the value of an uniform to a vec2
  32603. * @param uniform defines the webGL uniform location where to store the value
  32604. * @param x defines the 1st component of the value
  32605. * @param y defines the 2nd component of the value
  32606. */
  32607. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32608. /**
  32609. * Set the value of an uniform to a vec3
  32610. * @param uniform defines the webGL uniform location where to store the value
  32611. * @param x defines the 1st component of the value
  32612. * @param y defines the 2nd component of the value
  32613. * @param z defines the 3rd component of the value
  32614. */
  32615. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32616. /**
  32617. * Set the value of an uniform to a vec4
  32618. * @param uniform defines the webGL uniform location where to store the value
  32619. * @param x defines the 1st component of the value
  32620. * @param y defines the 2nd component of the value
  32621. * @param z defines the 3rd component of the value
  32622. * @param w defines the 4th component of the value
  32623. */
  32624. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32625. /**
  32626. * Apply all cached states (depth, culling, stencil and alpha)
  32627. */
  32628. applyStates(): void;
  32629. /**
  32630. * Enable or disable color writing
  32631. * @param enable defines the state to set
  32632. */
  32633. setColorWrite(enable: boolean): void;
  32634. /**
  32635. * Gets a boolean indicating if color writing is enabled
  32636. * @returns the current color writing state
  32637. */
  32638. getColorWrite(): boolean;
  32639. /**
  32640. * Gets the depth culling state manager
  32641. */
  32642. get depthCullingState(): DepthCullingState;
  32643. /**
  32644. * Gets the alpha state manager
  32645. */
  32646. get alphaState(): AlphaState;
  32647. /**
  32648. * Gets the stencil state manager
  32649. */
  32650. get stencilState(): StencilState;
  32651. /**
  32652. * Clears the list of texture accessible through engine.
  32653. * This can help preventing texture load conflict due to name collision.
  32654. */
  32655. clearInternalTexturesCache(): void;
  32656. /**
  32657. * Force the entire cache to be cleared
  32658. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32659. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32660. */
  32661. wipeCaches(bruteForce?: boolean): void;
  32662. /** @hidden */
  32663. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32664. min: number;
  32665. mag: number;
  32666. };
  32667. /** @hidden */
  32668. _createTexture(): WebGLTexture;
  32669. /**
  32670. * Usually called from Texture.ts.
  32671. * Passed information to create a WebGLTexture
  32672. * @param urlArg defines a value which contains one of the following:
  32673. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32674. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32675. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32676. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32677. * @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)
  32678. * @param scene needed for loading to the correct scene
  32679. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32680. * @param onLoad optional callback to be called upon successful completion
  32681. * @param onError optional callback to be called upon failure
  32682. * @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
  32683. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32684. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32685. * @param forcedExtension defines the extension to use to pick the right loader
  32686. * @param mimeType defines an optional mime type
  32687. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32688. */
  32689. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  32690. /**
  32691. * Loads an image as an HTMLImageElement.
  32692. * @param input url string, ArrayBuffer, or Blob to load
  32693. * @param onLoad callback called when the image successfully loads
  32694. * @param onError callback called when the image fails to load
  32695. * @param offlineProvider offline provider for caching
  32696. * @param mimeType optional mime type
  32697. * @returns the HTMLImageElement of the loaded image
  32698. * @hidden
  32699. */
  32700. 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>;
  32701. /**
  32702. * @hidden
  32703. */
  32704. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32705. /**
  32706. * Creates a raw texture
  32707. * @param data defines the data to store in the texture
  32708. * @param width defines the width of the texture
  32709. * @param height defines the height of the texture
  32710. * @param format defines the format of the data
  32711. * @param generateMipMaps defines if the engine should generate the mip levels
  32712. * @param invertY defines if data must be stored with Y axis inverted
  32713. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32714. * @param compression defines the compression used (null by default)
  32715. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32716. * @returns the raw texture inside an InternalTexture
  32717. */
  32718. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32719. /**
  32720. * Creates a new raw cube texture
  32721. * @param data defines the array of data to use to create each face
  32722. * @param size defines the size of the textures
  32723. * @param format defines the format of the data
  32724. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32725. * @param generateMipMaps defines if the engine should generate the mip levels
  32726. * @param invertY defines if data must be stored with Y axis inverted
  32727. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32728. * @param compression defines the compression used (null by default)
  32729. * @returns the cube texture as an InternalTexture
  32730. */
  32731. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32732. /**
  32733. * Creates a new raw 3D texture
  32734. * @param data defines the data used to create the texture
  32735. * @param width defines the width of the texture
  32736. * @param height defines the height of the texture
  32737. * @param depth defines the depth of the texture
  32738. * @param format defines the format of the texture
  32739. * @param generateMipMaps defines if the engine must generate mip levels
  32740. * @param invertY defines if data must be stored with Y axis inverted
  32741. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32742. * @param compression defines the compressed used (can be null)
  32743. * @param textureType defines the compressed used (can be null)
  32744. * @returns a new raw 3D texture (stored in an InternalTexture)
  32745. */
  32746. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32747. /**
  32748. * Creates a new raw 2D array texture
  32749. * @param data defines the data used to create the texture
  32750. * @param width defines the width of the texture
  32751. * @param height defines the height of the texture
  32752. * @param depth defines the number of layers of the texture
  32753. * @param format defines the format of the texture
  32754. * @param generateMipMaps defines if the engine must generate mip levels
  32755. * @param invertY defines if data must be stored with Y axis inverted
  32756. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32757. * @param compression defines the compressed used (can be null)
  32758. * @param textureType defines the compressed used (can be null)
  32759. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32760. */
  32761. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32762. private _unpackFlipYCached;
  32763. /**
  32764. * In case you are sharing the context with other applications, it might
  32765. * be interested to not cache the unpack flip y state to ensure a consistent
  32766. * value would be set.
  32767. */
  32768. enableUnpackFlipYCached: boolean;
  32769. /** @hidden */
  32770. _unpackFlipY(value: boolean): void;
  32771. /** @hidden */
  32772. _getUnpackAlignement(): number;
  32773. private _getTextureTarget;
  32774. /**
  32775. * Update the sampling mode of a given texture
  32776. * @param samplingMode defines the required sampling mode
  32777. * @param texture defines the texture to update
  32778. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32779. */
  32780. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32781. /**
  32782. * Update the sampling mode of a given texture
  32783. * @param texture defines the texture to update
  32784. * @param wrapU defines the texture wrap mode of the u coordinates
  32785. * @param wrapV defines the texture wrap mode of the v coordinates
  32786. * @param wrapR defines the texture wrap mode of the r coordinates
  32787. */
  32788. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32789. /** @hidden */
  32790. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32791. width: number;
  32792. height: number;
  32793. layers?: number;
  32794. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32795. /** @hidden */
  32796. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32797. /** @hidden */
  32798. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32799. /**
  32800. * Update a portion of an internal texture
  32801. * @param texture defines the texture to update
  32802. * @param imageData defines the data to store into the texture
  32803. * @param xOffset defines the x coordinates of the update rectangle
  32804. * @param yOffset defines the y coordinates of the update rectangle
  32805. * @param width defines the width of the update rectangle
  32806. * @param height defines the height of the update rectangle
  32807. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32808. * @param lod defines the lod level to update (0 by default)
  32809. */
  32810. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32811. /** @hidden */
  32812. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32813. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32814. private _prepareWebGLTexture;
  32815. /** @hidden */
  32816. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32817. private _getDepthStencilBuffer;
  32818. /** @hidden */
  32819. _releaseFramebufferObjects(texture: InternalTexture): void;
  32820. /** @hidden */
  32821. _releaseTexture(texture: InternalTexture): void;
  32822. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32823. protected _setProgram(program: WebGLProgram): void;
  32824. protected _boundUniforms: {
  32825. [key: number]: WebGLUniformLocation;
  32826. };
  32827. /**
  32828. * Binds an effect to the webGL context
  32829. * @param effect defines the effect to bind
  32830. */
  32831. bindSamplers(effect: Effect): void;
  32832. private _activateCurrentTexture;
  32833. /** @hidden */
  32834. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32835. /** @hidden */
  32836. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32837. /**
  32838. * Unbind all textures from the webGL context
  32839. */
  32840. unbindAllTextures(): void;
  32841. /**
  32842. * Sets a texture to the according uniform.
  32843. * @param channel The texture channel
  32844. * @param uniform The uniform to set
  32845. * @param texture The texture to apply
  32846. */
  32847. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32848. private _bindSamplerUniformToChannel;
  32849. private _getTextureWrapMode;
  32850. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32851. /**
  32852. * Sets an array of texture to the webGL context
  32853. * @param channel defines the channel where the texture array must be set
  32854. * @param uniform defines the associated uniform location
  32855. * @param textures defines the array of textures to bind
  32856. */
  32857. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32858. /** @hidden */
  32859. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32860. private _setTextureParameterFloat;
  32861. private _setTextureParameterInteger;
  32862. /**
  32863. * Unbind all vertex attributes from the webGL context
  32864. */
  32865. unbindAllAttributes(): void;
  32866. /**
  32867. * 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
  32868. */
  32869. releaseEffects(): void;
  32870. /**
  32871. * Dispose and release all associated resources
  32872. */
  32873. dispose(): void;
  32874. /**
  32875. * Attach a new callback raised when context lost event is fired
  32876. * @param callback defines the callback to call
  32877. */
  32878. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32879. /**
  32880. * Attach a new callback raised when context restored event is fired
  32881. * @param callback defines the callback to call
  32882. */
  32883. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32884. /**
  32885. * Get the current error code of the webGL context
  32886. * @returns the error code
  32887. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32888. */
  32889. getError(): number;
  32890. private _canRenderToFloatFramebuffer;
  32891. private _canRenderToHalfFloatFramebuffer;
  32892. private _canRenderToFramebuffer;
  32893. /** @hidden */
  32894. _getWebGLTextureType(type: number): number;
  32895. /** @hidden */
  32896. _getInternalFormat(format: number): number;
  32897. /** @hidden */
  32898. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32899. /** @hidden */
  32900. _getRGBAMultiSampleBufferFormat(type: number): number;
  32901. /** @hidden */
  32902. _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;
  32903. /**
  32904. * Loads a file from a url
  32905. * @param url url to load
  32906. * @param onSuccess callback called when the file successfully loads
  32907. * @param onProgress callback called while file is loading (if the server supports this mode)
  32908. * @param offlineProvider defines the offline provider for caching
  32909. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32910. * @param onError callback called when the file fails to load
  32911. * @returns a file request object
  32912. * @hidden
  32913. */
  32914. 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;
  32915. /**
  32916. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32917. * @param x defines the x coordinate of the rectangle where pixels must be read
  32918. * @param y defines the y coordinate of the rectangle where pixels must be read
  32919. * @param width defines the width of the rectangle where pixels must be read
  32920. * @param height defines the height of the rectangle where pixels must be read
  32921. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32922. * @returns a Uint8Array containing RGBA colors
  32923. */
  32924. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32925. private static _isSupported;
  32926. /**
  32927. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32928. * @returns true if the engine can be created
  32929. * @ignorenaming
  32930. */
  32931. static isSupported(): boolean;
  32932. /**
  32933. * Find the next highest power of two.
  32934. * @param x Number to start search from.
  32935. * @return Next highest power of two.
  32936. */
  32937. static CeilingPOT(x: number): number;
  32938. /**
  32939. * Find the next lowest power of two.
  32940. * @param x Number to start search from.
  32941. * @return Next lowest power of two.
  32942. */
  32943. static FloorPOT(x: number): number;
  32944. /**
  32945. * Find the nearest power of two.
  32946. * @param x Number to start search from.
  32947. * @return Next nearest power of two.
  32948. */
  32949. static NearestPOT(x: number): number;
  32950. /**
  32951. * Get the closest exponent of two
  32952. * @param value defines the value to approximate
  32953. * @param max defines the maximum value to return
  32954. * @param mode defines how to define the closest value
  32955. * @returns closest exponent of two of the given value
  32956. */
  32957. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32958. /**
  32959. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32960. * @param func - the function to be called
  32961. * @param requester - the object that will request the next frame. Falls back to window.
  32962. * @returns frame number
  32963. */
  32964. static QueueNewFrame(func: () => void, requester?: any): number;
  32965. /**
  32966. * Gets host document
  32967. * @returns the host document object
  32968. */
  32969. getHostDocument(): Nullable<Document>;
  32970. }
  32971. }
  32972. declare module "babylonjs/Maths/sphericalPolynomial" {
  32973. import { Vector3 } from "babylonjs/Maths/math.vector";
  32974. import { Color3 } from "babylonjs/Maths/math.color";
  32975. /**
  32976. * Class representing spherical harmonics coefficients to the 3rd degree
  32977. */
  32978. export class SphericalHarmonics {
  32979. /**
  32980. * Defines whether or not the harmonics have been prescaled for rendering.
  32981. */
  32982. preScaled: boolean;
  32983. /**
  32984. * The l0,0 coefficients of the spherical harmonics
  32985. */
  32986. l00: Vector3;
  32987. /**
  32988. * The l1,-1 coefficients of the spherical harmonics
  32989. */
  32990. l1_1: Vector3;
  32991. /**
  32992. * The l1,0 coefficients of the spherical harmonics
  32993. */
  32994. l10: Vector3;
  32995. /**
  32996. * The l1,1 coefficients of the spherical harmonics
  32997. */
  32998. l11: Vector3;
  32999. /**
  33000. * The l2,-2 coefficients of the spherical harmonics
  33001. */
  33002. l2_2: Vector3;
  33003. /**
  33004. * The l2,-1 coefficients of the spherical harmonics
  33005. */
  33006. l2_1: Vector3;
  33007. /**
  33008. * The l2,0 coefficients of the spherical harmonics
  33009. */
  33010. l20: Vector3;
  33011. /**
  33012. * The l2,1 coefficients of the spherical harmonics
  33013. */
  33014. l21: Vector3;
  33015. /**
  33016. * The l2,2 coefficients of the spherical harmonics
  33017. */
  33018. l22: Vector3;
  33019. /**
  33020. * Adds a light to the spherical harmonics
  33021. * @param direction the direction of the light
  33022. * @param color the color of the light
  33023. * @param deltaSolidAngle the delta solid angle of the light
  33024. */
  33025. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33026. /**
  33027. * Scales the spherical harmonics by the given amount
  33028. * @param scale the amount to scale
  33029. */
  33030. scaleInPlace(scale: number): void;
  33031. /**
  33032. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33033. *
  33034. * ```
  33035. * E_lm = A_l * L_lm
  33036. * ```
  33037. *
  33038. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33039. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33040. * the scaling factors are given in equation 9.
  33041. */
  33042. convertIncidentRadianceToIrradiance(): void;
  33043. /**
  33044. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33045. *
  33046. * ```
  33047. * L = (1/pi) * E * rho
  33048. * ```
  33049. *
  33050. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33051. */
  33052. convertIrradianceToLambertianRadiance(): void;
  33053. /**
  33054. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33055. * required operations at run time.
  33056. *
  33057. * This is simply done by scaling back the SH with Ylm constants parameter.
  33058. * The trigonometric part being applied by the shader at run time.
  33059. */
  33060. preScaleForRendering(): void;
  33061. /**
  33062. * Constructs a spherical harmonics from an array.
  33063. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33064. * @returns the spherical harmonics
  33065. */
  33066. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33067. /**
  33068. * Gets the spherical harmonics from polynomial
  33069. * @param polynomial the spherical polynomial
  33070. * @returns the spherical harmonics
  33071. */
  33072. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33073. }
  33074. /**
  33075. * Class representing spherical polynomial coefficients to the 3rd degree
  33076. */
  33077. export class SphericalPolynomial {
  33078. private _harmonics;
  33079. /**
  33080. * The spherical harmonics used to create the polynomials.
  33081. */
  33082. get preScaledHarmonics(): SphericalHarmonics;
  33083. /**
  33084. * The x coefficients of the spherical polynomial
  33085. */
  33086. x: Vector3;
  33087. /**
  33088. * The y coefficients of the spherical polynomial
  33089. */
  33090. y: Vector3;
  33091. /**
  33092. * The z coefficients of the spherical polynomial
  33093. */
  33094. z: Vector3;
  33095. /**
  33096. * The xx coefficients of the spherical polynomial
  33097. */
  33098. xx: Vector3;
  33099. /**
  33100. * The yy coefficients of the spherical polynomial
  33101. */
  33102. yy: Vector3;
  33103. /**
  33104. * The zz coefficients of the spherical polynomial
  33105. */
  33106. zz: Vector3;
  33107. /**
  33108. * The xy coefficients of the spherical polynomial
  33109. */
  33110. xy: Vector3;
  33111. /**
  33112. * The yz coefficients of the spherical polynomial
  33113. */
  33114. yz: Vector3;
  33115. /**
  33116. * The zx coefficients of the spherical polynomial
  33117. */
  33118. zx: Vector3;
  33119. /**
  33120. * Adds an ambient color to the spherical polynomial
  33121. * @param color the color to add
  33122. */
  33123. addAmbient(color: Color3): void;
  33124. /**
  33125. * Scales the spherical polynomial by the given amount
  33126. * @param scale the amount to scale
  33127. */
  33128. scaleInPlace(scale: number): void;
  33129. /**
  33130. * Gets the spherical polynomial from harmonics
  33131. * @param harmonics the spherical harmonics
  33132. * @returns the spherical polynomial
  33133. */
  33134. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33135. /**
  33136. * Constructs a spherical polynomial from an array.
  33137. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33138. * @returns the spherical polynomial
  33139. */
  33140. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33141. }
  33142. }
  33143. declare module "babylonjs/Materials/Textures/internalTexture" {
  33144. import { Observable } from "babylonjs/Misc/observable";
  33145. import { Nullable, int } from "babylonjs/types";
  33146. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33147. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33148. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33149. /**
  33150. * Defines the source of the internal texture
  33151. */
  33152. export enum InternalTextureSource {
  33153. /**
  33154. * The source of the texture data is unknown
  33155. */
  33156. Unknown = 0,
  33157. /**
  33158. * Texture data comes from an URL
  33159. */
  33160. Url = 1,
  33161. /**
  33162. * Texture data is only used for temporary storage
  33163. */
  33164. Temp = 2,
  33165. /**
  33166. * Texture data comes from raw data (ArrayBuffer)
  33167. */
  33168. Raw = 3,
  33169. /**
  33170. * Texture content is dynamic (video or dynamic texture)
  33171. */
  33172. Dynamic = 4,
  33173. /**
  33174. * Texture content is generated by rendering to it
  33175. */
  33176. RenderTarget = 5,
  33177. /**
  33178. * Texture content is part of a multi render target process
  33179. */
  33180. MultiRenderTarget = 6,
  33181. /**
  33182. * Texture data comes from a cube data file
  33183. */
  33184. Cube = 7,
  33185. /**
  33186. * Texture data comes from a raw cube data
  33187. */
  33188. CubeRaw = 8,
  33189. /**
  33190. * Texture data come from a prefiltered cube data file
  33191. */
  33192. CubePrefiltered = 9,
  33193. /**
  33194. * Texture content is raw 3D data
  33195. */
  33196. Raw3D = 10,
  33197. /**
  33198. * Texture content is raw 2D array data
  33199. */
  33200. Raw2DArray = 11,
  33201. /**
  33202. * Texture content is a depth texture
  33203. */
  33204. Depth = 12,
  33205. /**
  33206. * Texture data comes from a raw cube data encoded with RGBD
  33207. */
  33208. CubeRawRGBD = 13
  33209. }
  33210. /**
  33211. * Class used to store data associated with WebGL texture data for the engine
  33212. * This class should not be used directly
  33213. */
  33214. export class InternalTexture {
  33215. /** @hidden */
  33216. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33217. /**
  33218. * Defines if the texture is ready
  33219. */
  33220. isReady: boolean;
  33221. /**
  33222. * Defines if the texture is a cube texture
  33223. */
  33224. isCube: boolean;
  33225. /**
  33226. * Defines if the texture contains 3D data
  33227. */
  33228. is3D: boolean;
  33229. /**
  33230. * Defines if the texture contains 2D array data
  33231. */
  33232. is2DArray: boolean;
  33233. /**
  33234. * Defines if the texture contains multiview data
  33235. */
  33236. isMultiview: boolean;
  33237. /**
  33238. * Gets the URL used to load this texture
  33239. */
  33240. url: string;
  33241. /**
  33242. * Gets the sampling mode of the texture
  33243. */
  33244. samplingMode: number;
  33245. /**
  33246. * Gets a boolean indicating if the texture needs mipmaps generation
  33247. */
  33248. generateMipMaps: boolean;
  33249. /**
  33250. * Gets the number of samples used by the texture (WebGL2+ only)
  33251. */
  33252. samples: number;
  33253. /**
  33254. * Gets the type of the texture (int, float...)
  33255. */
  33256. type: number;
  33257. /**
  33258. * Gets the format of the texture (RGB, RGBA...)
  33259. */
  33260. format: number;
  33261. /**
  33262. * Observable called when the texture is loaded
  33263. */
  33264. onLoadedObservable: Observable<InternalTexture>;
  33265. /**
  33266. * Gets the width of the texture
  33267. */
  33268. width: number;
  33269. /**
  33270. * Gets the height of the texture
  33271. */
  33272. height: number;
  33273. /**
  33274. * Gets the depth of the texture
  33275. */
  33276. depth: number;
  33277. /**
  33278. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33279. */
  33280. baseWidth: number;
  33281. /**
  33282. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33283. */
  33284. baseHeight: number;
  33285. /**
  33286. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33287. */
  33288. baseDepth: number;
  33289. /**
  33290. * Gets a boolean indicating if the texture is inverted on Y axis
  33291. */
  33292. invertY: boolean;
  33293. /** @hidden */
  33294. _invertVScale: boolean;
  33295. /** @hidden */
  33296. _associatedChannel: number;
  33297. /** @hidden */
  33298. _source: InternalTextureSource;
  33299. /** @hidden */
  33300. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33301. /** @hidden */
  33302. _bufferView: Nullable<ArrayBufferView>;
  33303. /** @hidden */
  33304. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33305. /** @hidden */
  33306. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33307. /** @hidden */
  33308. _size: number;
  33309. /** @hidden */
  33310. _extension: string;
  33311. /** @hidden */
  33312. _files: Nullable<string[]>;
  33313. /** @hidden */
  33314. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33315. /** @hidden */
  33316. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33317. /** @hidden */
  33318. _framebuffer: Nullable<WebGLFramebuffer>;
  33319. /** @hidden */
  33320. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33321. /** @hidden */
  33322. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33323. /** @hidden */
  33324. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33325. /** @hidden */
  33326. _attachments: Nullable<number[]>;
  33327. /** @hidden */
  33328. _cachedCoordinatesMode: Nullable<number>;
  33329. /** @hidden */
  33330. _cachedWrapU: Nullable<number>;
  33331. /** @hidden */
  33332. _cachedWrapV: Nullable<number>;
  33333. /** @hidden */
  33334. _cachedWrapR: Nullable<number>;
  33335. /** @hidden */
  33336. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33337. /** @hidden */
  33338. _isDisabled: boolean;
  33339. /** @hidden */
  33340. _compression: Nullable<string>;
  33341. /** @hidden */
  33342. _generateStencilBuffer: boolean;
  33343. /** @hidden */
  33344. _generateDepthBuffer: boolean;
  33345. /** @hidden */
  33346. _comparisonFunction: number;
  33347. /** @hidden */
  33348. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33349. /** @hidden */
  33350. _lodGenerationScale: number;
  33351. /** @hidden */
  33352. _lodGenerationOffset: number;
  33353. /** @hidden */
  33354. _depthStencilTexture: Nullable<InternalTexture>;
  33355. /** @hidden */
  33356. _colorTextureArray: Nullable<WebGLTexture>;
  33357. /** @hidden */
  33358. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33359. /** @hidden */
  33360. _lodTextureHigh: Nullable<BaseTexture>;
  33361. /** @hidden */
  33362. _lodTextureMid: Nullable<BaseTexture>;
  33363. /** @hidden */
  33364. _lodTextureLow: Nullable<BaseTexture>;
  33365. /** @hidden */
  33366. _isRGBD: boolean;
  33367. /** @hidden */
  33368. _linearSpecularLOD: boolean;
  33369. /** @hidden */
  33370. _irradianceTexture: Nullable<BaseTexture>;
  33371. /** @hidden */
  33372. _webGLTexture: Nullable<WebGLTexture>;
  33373. /** @hidden */
  33374. _references: number;
  33375. private _engine;
  33376. /**
  33377. * Gets the Engine the texture belongs to.
  33378. * @returns The babylon engine
  33379. */
  33380. getEngine(): ThinEngine;
  33381. /**
  33382. * Gets the data source type of the texture
  33383. */
  33384. get source(): InternalTextureSource;
  33385. /**
  33386. * Creates a new InternalTexture
  33387. * @param engine defines the engine to use
  33388. * @param source defines the type of data that will be used
  33389. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33390. */
  33391. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33392. /**
  33393. * Increments the number of references (ie. the number of Texture that point to it)
  33394. */
  33395. incrementReferences(): void;
  33396. /**
  33397. * Change the size of the texture (not the size of the content)
  33398. * @param width defines the new width
  33399. * @param height defines the new height
  33400. * @param depth defines the new depth (1 by default)
  33401. */
  33402. updateSize(width: int, height: int, depth?: int): void;
  33403. /** @hidden */
  33404. _rebuild(): void;
  33405. /** @hidden */
  33406. _swapAndDie(target: InternalTexture): void;
  33407. /**
  33408. * Dispose the current allocated resources
  33409. */
  33410. dispose(): void;
  33411. }
  33412. }
  33413. declare module "babylonjs/Audio/analyser" {
  33414. import { Scene } from "babylonjs/scene";
  33415. /**
  33416. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33417. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33418. */
  33419. export class Analyser {
  33420. /**
  33421. * Gets or sets the smoothing
  33422. * @ignorenaming
  33423. */
  33424. SMOOTHING: number;
  33425. /**
  33426. * Gets or sets the FFT table size
  33427. * @ignorenaming
  33428. */
  33429. FFT_SIZE: number;
  33430. /**
  33431. * Gets or sets the bar graph amplitude
  33432. * @ignorenaming
  33433. */
  33434. BARGRAPHAMPLITUDE: number;
  33435. /**
  33436. * Gets or sets the position of the debug canvas
  33437. * @ignorenaming
  33438. */
  33439. DEBUGCANVASPOS: {
  33440. x: number;
  33441. y: number;
  33442. };
  33443. /**
  33444. * Gets or sets the debug canvas size
  33445. * @ignorenaming
  33446. */
  33447. DEBUGCANVASSIZE: {
  33448. width: number;
  33449. height: number;
  33450. };
  33451. private _byteFreqs;
  33452. private _byteTime;
  33453. private _floatFreqs;
  33454. private _webAudioAnalyser;
  33455. private _debugCanvas;
  33456. private _debugCanvasContext;
  33457. private _scene;
  33458. private _registerFunc;
  33459. private _audioEngine;
  33460. /**
  33461. * Creates a new analyser
  33462. * @param scene defines hosting scene
  33463. */
  33464. constructor(scene: Scene);
  33465. /**
  33466. * Get the number of data values you will have to play with for the visualization
  33467. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33468. * @returns a number
  33469. */
  33470. getFrequencyBinCount(): number;
  33471. /**
  33472. * Gets the current frequency data as a byte array
  33473. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33474. * @returns a Uint8Array
  33475. */
  33476. getByteFrequencyData(): Uint8Array;
  33477. /**
  33478. * Gets the current waveform as a byte array
  33479. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33480. * @returns a Uint8Array
  33481. */
  33482. getByteTimeDomainData(): Uint8Array;
  33483. /**
  33484. * Gets the current frequency data as a float array
  33485. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33486. * @returns a Float32Array
  33487. */
  33488. getFloatFrequencyData(): Float32Array;
  33489. /**
  33490. * Renders the debug canvas
  33491. */
  33492. drawDebugCanvas(): void;
  33493. /**
  33494. * Stops rendering the debug canvas and removes it
  33495. */
  33496. stopDebugCanvas(): void;
  33497. /**
  33498. * Connects two audio nodes
  33499. * @param inputAudioNode defines first node to connect
  33500. * @param outputAudioNode defines second node to connect
  33501. */
  33502. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33503. /**
  33504. * Releases all associated resources
  33505. */
  33506. dispose(): void;
  33507. }
  33508. }
  33509. declare module "babylonjs/Audio/audioEngine" {
  33510. import { IDisposable } from "babylonjs/scene";
  33511. import { Analyser } from "babylonjs/Audio/analyser";
  33512. import { Nullable } from "babylonjs/types";
  33513. import { Observable } from "babylonjs/Misc/observable";
  33514. /**
  33515. * This represents an audio engine and it is responsible
  33516. * to play, synchronize and analyse sounds throughout the application.
  33517. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33518. */
  33519. export interface IAudioEngine extends IDisposable {
  33520. /**
  33521. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33522. */
  33523. readonly canUseWebAudio: boolean;
  33524. /**
  33525. * Gets the current AudioContext if available.
  33526. */
  33527. readonly audioContext: Nullable<AudioContext>;
  33528. /**
  33529. * The master gain node defines the global audio volume of your audio engine.
  33530. */
  33531. readonly masterGain: GainNode;
  33532. /**
  33533. * Gets whether or not mp3 are supported by your browser.
  33534. */
  33535. readonly isMP3supported: boolean;
  33536. /**
  33537. * Gets whether or not ogg are supported by your browser.
  33538. */
  33539. readonly isOGGsupported: boolean;
  33540. /**
  33541. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33542. * @ignoreNaming
  33543. */
  33544. WarnedWebAudioUnsupported: boolean;
  33545. /**
  33546. * Defines if the audio engine relies on a custom unlocked button.
  33547. * In this case, the embedded button will not be displayed.
  33548. */
  33549. useCustomUnlockedButton: boolean;
  33550. /**
  33551. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33552. */
  33553. readonly unlocked: boolean;
  33554. /**
  33555. * Event raised when audio has been unlocked on the browser.
  33556. */
  33557. onAudioUnlockedObservable: Observable<AudioEngine>;
  33558. /**
  33559. * Event raised when audio has been locked on the browser.
  33560. */
  33561. onAudioLockedObservable: Observable<AudioEngine>;
  33562. /**
  33563. * Flags the audio engine in Locked state.
  33564. * This happens due to new browser policies preventing audio to autoplay.
  33565. */
  33566. lock(): void;
  33567. /**
  33568. * Unlocks the audio engine once a user action has been done on the dom.
  33569. * This is helpful to resume play once browser policies have been satisfied.
  33570. */
  33571. unlock(): void;
  33572. }
  33573. /**
  33574. * This represents the default audio engine used in babylon.
  33575. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33576. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33577. */
  33578. export class AudioEngine implements IAudioEngine {
  33579. private _audioContext;
  33580. private _audioContextInitialized;
  33581. private _muteButton;
  33582. private _hostElement;
  33583. /**
  33584. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33585. */
  33586. canUseWebAudio: boolean;
  33587. /**
  33588. * The master gain node defines the global audio volume of your audio engine.
  33589. */
  33590. masterGain: GainNode;
  33591. /**
  33592. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33593. * @ignoreNaming
  33594. */
  33595. WarnedWebAudioUnsupported: boolean;
  33596. /**
  33597. * Gets whether or not mp3 are supported by your browser.
  33598. */
  33599. isMP3supported: boolean;
  33600. /**
  33601. * Gets whether or not ogg are supported by your browser.
  33602. */
  33603. isOGGsupported: boolean;
  33604. /**
  33605. * Gets whether audio has been unlocked on the device.
  33606. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33607. * a user interaction has happened.
  33608. */
  33609. unlocked: boolean;
  33610. /**
  33611. * Defines if the audio engine relies on a custom unlocked button.
  33612. * In this case, the embedded button will not be displayed.
  33613. */
  33614. useCustomUnlockedButton: boolean;
  33615. /**
  33616. * Event raised when audio has been unlocked on the browser.
  33617. */
  33618. onAudioUnlockedObservable: Observable<AudioEngine>;
  33619. /**
  33620. * Event raised when audio has been locked on the browser.
  33621. */
  33622. onAudioLockedObservable: Observable<AudioEngine>;
  33623. /**
  33624. * Gets the current AudioContext if available.
  33625. */
  33626. get audioContext(): Nullable<AudioContext>;
  33627. private _connectedAnalyser;
  33628. /**
  33629. * Instantiates a new audio engine.
  33630. *
  33631. * There should be only one per page as some browsers restrict the number
  33632. * of audio contexts you can create.
  33633. * @param hostElement defines the host element where to display the mute icon if necessary
  33634. */
  33635. constructor(hostElement?: Nullable<HTMLElement>);
  33636. /**
  33637. * Flags the audio engine in Locked state.
  33638. * This happens due to new browser policies preventing audio to autoplay.
  33639. */
  33640. lock(): void;
  33641. /**
  33642. * Unlocks the audio engine once a user action has been done on the dom.
  33643. * This is helpful to resume play once browser policies have been satisfied.
  33644. */
  33645. unlock(): void;
  33646. private _resumeAudioContext;
  33647. private _initializeAudioContext;
  33648. private _tryToRun;
  33649. private _triggerRunningState;
  33650. private _triggerSuspendedState;
  33651. private _displayMuteButton;
  33652. private _moveButtonToTopLeft;
  33653. private _onResize;
  33654. private _hideMuteButton;
  33655. /**
  33656. * Destroy and release the resources associated with the audio ccontext.
  33657. */
  33658. dispose(): void;
  33659. /**
  33660. * Gets the global volume sets on the master gain.
  33661. * @returns the global volume if set or -1 otherwise
  33662. */
  33663. getGlobalVolume(): number;
  33664. /**
  33665. * Sets the global volume of your experience (sets on the master gain).
  33666. * @param newVolume Defines the new global volume of the application
  33667. */
  33668. setGlobalVolume(newVolume: number): void;
  33669. /**
  33670. * Connect the audio engine to an audio analyser allowing some amazing
  33671. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33672. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33673. * @param analyser The analyser to connect to the engine
  33674. */
  33675. connectToAnalyser(analyser: Analyser): void;
  33676. }
  33677. }
  33678. declare module "babylonjs/Loading/loadingScreen" {
  33679. /**
  33680. * Interface used to present a loading screen while loading a scene
  33681. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33682. */
  33683. export interface ILoadingScreen {
  33684. /**
  33685. * Function called to display the loading screen
  33686. */
  33687. displayLoadingUI: () => void;
  33688. /**
  33689. * Function called to hide the loading screen
  33690. */
  33691. hideLoadingUI: () => void;
  33692. /**
  33693. * Gets or sets the color to use for the background
  33694. */
  33695. loadingUIBackgroundColor: string;
  33696. /**
  33697. * Gets or sets the text to display while loading
  33698. */
  33699. loadingUIText: string;
  33700. }
  33701. /**
  33702. * Class used for the default loading screen
  33703. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33704. */
  33705. export class DefaultLoadingScreen implements ILoadingScreen {
  33706. private _renderingCanvas;
  33707. private _loadingText;
  33708. private _loadingDivBackgroundColor;
  33709. private _loadingDiv;
  33710. private _loadingTextDiv;
  33711. /** Gets or sets the logo url to use for the default loading screen */
  33712. static DefaultLogoUrl: string;
  33713. /** Gets or sets the spinner url to use for the default loading screen */
  33714. static DefaultSpinnerUrl: string;
  33715. /**
  33716. * Creates a new default loading screen
  33717. * @param _renderingCanvas defines the canvas used to render the scene
  33718. * @param _loadingText defines the default text to display
  33719. * @param _loadingDivBackgroundColor defines the default background color
  33720. */
  33721. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33722. /**
  33723. * Function called to display the loading screen
  33724. */
  33725. displayLoadingUI(): void;
  33726. /**
  33727. * Function called to hide the loading screen
  33728. */
  33729. hideLoadingUI(): void;
  33730. /**
  33731. * Gets or sets the text to display while loading
  33732. */
  33733. set loadingUIText(text: string);
  33734. get loadingUIText(): string;
  33735. /**
  33736. * Gets or sets the color to use for the background
  33737. */
  33738. get loadingUIBackgroundColor(): string;
  33739. set loadingUIBackgroundColor(color: string);
  33740. private _resizeLoadingUI;
  33741. }
  33742. }
  33743. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33744. /**
  33745. * Interface for any object that can request an animation frame
  33746. */
  33747. export interface ICustomAnimationFrameRequester {
  33748. /**
  33749. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33750. */
  33751. renderFunction?: Function;
  33752. /**
  33753. * Called to request the next frame to render to
  33754. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33755. */
  33756. requestAnimationFrame: Function;
  33757. /**
  33758. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33759. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33760. */
  33761. requestID?: number;
  33762. }
  33763. }
  33764. declare module "babylonjs/Misc/performanceMonitor" {
  33765. /**
  33766. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33767. */
  33768. export class PerformanceMonitor {
  33769. private _enabled;
  33770. private _rollingFrameTime;
  33771. private _lastFrameTimeMs;
  33772. /**
  33773. * constructor
  33774. * @param frameSampleSize The number of samples required to saturate the sliding window
  33775. */
  33776. constructor(frameSampleSize?: number);
  33777. /**
  33778. * Samples current frame
  33779. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33780. */
  33781. sampleFrame(timeMs?: number): void;
  33782. /**
  33783. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33784. */
  33785. get averageFrameTime(): number;
  33786. /**
  33787. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33788. */
  33789. get averageFrameTimeVariance(): number;
  33790. /**
  33791. * Returns the frame time of the most recent frame
  33792. */
  33793. get instantaneousFrameTime(): number;
  33794. /**
  33795. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33796. */
  33797. get averageFPS(): number;
  33798. /**
  33799. * Returns the average framerate in frames per second using the most recent frame time
  33800. */
  33801. get instantaneousFPS(): number;
  33802. /**
  33803. * Returns true if enough samples have been taken to completely fill the sliding window
  33804. */
  33805. get isSaturated(): boolean;
  33806. /**
  33807. * Enables contributions to the sliding window sample set
  33808. */
  33809. enable(): void;
  33810. /**
  33811. * Disables contributions to the sliding window sample set
  33812. * Samples will not be interpolated over the disabled period
  33813. */
  33814. disable(): void;
  33815. /**
  33816. * Returns true if sampling is enabled
  33817. */
  33818. get isEnabled(): boolean;
  33819. /**
  33820. * Resets performance monitor
  33821. */
  33822. reset(): void;
  33823. }
  33824. /**
  33825. * RollingAverage
  33826. *
  33827. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33828. */
  33829. export class RollingAverage {
  33830. /**
  33831. * Current average
  33832. */
  33833. average: number;
  33834. /**
  33835. * Current variance
  33836. */
  33837. variance: number;
  33838. protected _samples: Array<number>;
  33839. protected _sampleCount: number;
  33840. protected _pos: number;
  33841. protected _m2: number;
  33842. /**
  33843. * constructor
  33844. * @param length The number of samples required to saturate the sliding window
  33845. */
  33846. constructor(length: number);
  33847. /**
  33848. * Adds a sample to the sample set
  33849. * @param v The sample value
  33850. */
  33851. add(v: number): void;
  33852. /**
  33853. * Returns previously added values or null if outside of history or outside the sliding window domain
  33854. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33855. * @return Value previously recorded with add() or null if outside of range
  33856. */
  33857. history(i: number): number;
  33858. /**
  33859. * Returns true if enough samples have been taken to completely fill the sliding window
  33860. * @return true if sample-set saturated
  33861. */
  33862. isSaturated(): boolean;
  33863. /**
  33864. * Resets the rolling average (equivalent to 0 samples taken so far)
  33865. */
  33866. reset(): void;
  33867. /**
  33868. * Wraps a value around the sample range boundaries
  33869. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33870. * @return Wrapped position in sample range
  33871. */
  33872. protected _wrapPosition(i: number): number;
  33873. }
  33874. }
  33875. declare module "babylonjs/Misc/perfCounter" {
  33876. /**
  33877. * This class is used to track a performance counter which is number based.
  33878. * The user has access to many properties which give statistics of different nature.
  33879. *
  33880. * The implementer can track two kinds of Performance Counter: time and count.
  33881. * 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.
  33882. * 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.
  33883. */
  33884. export class PerfCounter {
  33885. /**
  33886. * Gets or sets a global boolean to turn on and off all the counters
  33887. */
  33888. static Enabled: boolean;
  33889. /**
  33890. * Returns the smallest value ever
  33891. */
  33892. get min(): number;
  33893. /**
  33894. * Returns the biggest value ever
  33895. */
  33896. get max(): number;
  33897. /**
  33898. * Returns the average value since the performance counter is running
  33899. */
  33900. get average(): number;
  33901. /**
  33902. * Returns the average value of the last second the counter was monitored
  33903. */
  33904. get lastSecAverage(): number;
  33905. /**
  33906. * Returns the current value
  33907. */
  33908. get current(): number;
  33909. /**
  33910. * Gets the accumulated total
  33911. */
  33912. get total(): number;
  33913. /**
  33914. * Gets the total value count
  33915. */
  33916. get count(): number;
  33917. /**
  33918. * Creates a new counter
  33919. */
  33920. constructor();
  33921. /**
  33922. * Call this method to start monitoring a new frame.
  33923. * 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.
  33924. */
  33925. fetchNewFrame(): void;
  33926. /**
  33927. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33928. * @param newCount the count value to add to the monitored count
  33929. * @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.
  33930. */
  33931. addCount(newCount: number, fetchResult: boolean): void;
  33932. /**
  33933. * Start monitoring this performance counter
  33934. */
  33935. beginMonitoring(): void;
  33936. /**
  33937. * Compute the time lapsed since the previous beginMonitoring() call.
  33938. * @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
  33939. */
  33940. endMonitoring(newFrame?: boolean): void;
  33941. private _fetchResult;
  33942. private _startMonitoringTime;
  33943. private _min;
  33944. private _max;
  33945. private _average;
  33946. private _current;
  33947. private _totalValueCount;
  33948. private _totalAccumulated;
  33949. private _lastSecAverage;
  33950. private _lastSecAccumulated;
  33951. private _lastSecTime;
  33952. private _lastSecValueCount;
  33953. }
  33954. }
  33955. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33956. module "babylonjs/Engines/thinEngine" {
  33957. interface ThinEngine {
  33958. /**
  33959. * Sets alpha constants used by some alpha blending modes
  33960. * @param r defines the red component
  33961. * @param g defines the green component
  33962. * @param b defines the blue component
  33963. * @param a defines the alpha component
  33964. */
  33965. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33966. /**
  33967. * Sets the current alpha mode
  33968. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33969. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33970. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33971. */
  33972. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33973. /**
  33974. * Gets the current alpha mode
  33975. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33976. * @returns the current alpha mode
  33977. */
  33978. getAlphaMode(): number;
  33979. /**
  33980. * Sets the current alpha equation
  33981. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33982. */
  33983. setAlphaEquation(equation: number): void;
  33984. /**
  33985. * Gets the current alpha equation.
  33986. * @returns the current alpha equation
  33987. */
  33988. getAlphaEquation(): number;
  33989. }
  33990. }
  33991. }
  33992. declare module "babylonjs/Engines/engine" {
  33993. import { Observable } from "babylonjs/Misc/observable";
  33994. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  33995. import { Scene } from "babylonjs/scene";
  33996. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  33997. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  33998. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33999. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34000. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34001. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34002. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34003. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34004. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34005. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34006. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34007. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34008. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34009. import "babylonjs/Engines/Extensions/engine.alpha";
  34010. import { Material } from "babylonjs/Materials/material";
  34011. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34012. /**
  34013. * Defines the interface used by display changed events
  34014. */
  34015. export interface IDisplayChangedEventArgs {
  34016. /** Gets the vrDisplay object (if any) */
  34017. vrDisplay: Nullable<any>;
  34018. /** Gets a boolean indicating if webVR is supported */
  34019. vrSupported: boolean;
  34020. }
  34021. /**
  34022. * Defines the interface used by objects containing a viewport (like a camera)
  34023. */
  34024. interface IViewportOwnerLike {
  34025. /**
  34026. * Gets or sets the viewport
  34027. */
  34028. viewport: IViewportLike;
  34029. }
  34030. /**
  34031. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34032. */
  34033. export class Engine extends ThinEngine {
  34034. /** Defines that alpha blending is disabled */
  34035. static readonly ALPHA_DISABLE: number;
  34036. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34037. static readonly ALPHA_ADD: number;
  34038. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34039. static readonly ALPHA_COMBINE: number;
  34040. /** Defines that alpha blending to DEST - SRC * DEST */
  34041. static readonly ALPHA_SUBTRACT: number;
  34042. /** Defines that alpha blending to SRC * DEST */
  34043. static readonly ALPHA_MULTIPLY: number;
  34044. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34045. static readonly ALPHA_MAXIMIZED: number;
  34046. /** Defines that alpha blending to SRC + DEST */
  34047. static readonly ALPHA_ONEONE: number;
  34048. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34049. static readonly ALPHA_PREMULTIPLIED: number;
  34050. /**
  34051. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34052. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34053. */
  34054. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34055. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34056. static readonly ALPHA_INTERPOLATE: number;
  34057. /**
  34058. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34059. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34060. */
  34061. static readonly ALPHA_SCREENMODE: number;
  34062. /** Defines that the ressource is not delayed*/
  34063. static readonly DELAYLOADSTATE_NONE: number;
  34064. /** Defines that the ressource was successfully delay loaded */
  34065. static readonly DELAYLOADSTATE_LOADED: number;
  34066. /** Defines that the ressource is currently delay loading */
  34067. static readonly DELAYLOADSTATE_LOADING: number;
  34068. /** Defines that the ressource is delayed and has not started loading */
  34069. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34070. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34071. static readonly NEVER: number;
  34072. /** 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 */
  34073. static readonly ALWAYS: number;
  34074. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34075. static readonly LESS: number;
  34076. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34077. static readonly EQUAL: number;
  34078. /** 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 */
  34079. static readonly LEQUAL: number;
  34080. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34081. static readonly GREATER: number;
  34082. /** 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 */
  34083. static readonly GEQUAL: number;
  34084. /** 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 */
  34085. static readonly NOTEQUAL: number;
  34086. /** Passed to stencilOperation to specify that stencil value must be kept */
  34087. static readonly KEEP: number;
  34088. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34089. static readonly REPLACE: number;
  34090. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34091. static readonly INCR: number;
  34092. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34093. static readonly DECR: number;
  34094. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34095. static readonly INVERT: number;
  34096. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34097. static readonly INCR_WRAP: number;
  34098. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34099. static readonly DECR_WRAP: number;
  34100. /** Texture is not repeating outside of 0..1 UVs */
  34101. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34102. /** Texture is repeating outside of 0..1 UVs */
  34103. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34104. /** Texture is repeating and mirrored */
  34105. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34106. /** ALPHA */
  34107. static readonly TEXTUREFORMAT_ALPHA: number;
  34108. /** LUMINANCE */
  34109. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34110. /** LUMINANCE_ALPHA */
  34111. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34112. /** RGB */
  34113. static readonly TEXTUREFORMAT_RGB: number;
  34114. /** RGBA */
  34115. static readonly TEXTUREFORMAT_RGBA: number;
  34116. /** RED */
  34117. static readonly TEXTUREFORMAT_RED: number;
  34118. /** RED (2nd reference) */
  34119. static readonly TEXTUREFORMAT_R: number;
  34120. /** RG */
  34121. static readonly TEXTUREFORMAT_RG: number;
  34122. /** RED_INTEGER */
  34123. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34124. /** RED_INTEGER (2nd reference) */
  34125. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34126. /** RG_INTEGER */
  34127. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34128. /** RGB_INTEGER */
  34129. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34130. /** RGBA_INTEGER */
  34131. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34132. /** UNSIGNED_BYTE */
  34133. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34134. /** UNSIGNED_BYTE (2nd reference) */
  34135. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34136. /** FLOAT */
  34137. static readonly TEXTURETYPE_FLOAT: number;
  34138. /** HALF_FLOAT */
  34139. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34140. /** BYTE */
  34141. static readonly TEXTURETYPE_BYTE: number;
  34142. /** SHORT */
  34143. static readonly TEXTURETYPE_SHORT: number;
  34144. /** UNSIGNED_SHORT */
  34145. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34146. /** INT */
  34147. static readonly TEXTURETYPE_INT: number;
  34148. /** UNSIGNED_INT */
  34149. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34150. /** UNSIGNED_SHORT_4_4_4_4 */
  34151. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34152. /** UNSIGNED_SHORT_5_5_5_1 */
  34153. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34154. /** UNSIGNED_SHORT_5_6_5 */
  34155. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34156. /** UNSIGNED_INT_2_10_10_10_REV */
  34157. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34158. /** UNSIGNED_INT_24_8 */
  34159. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34160. /** UNSIGNED_INT_10F_11F_11F_REV */
  34161. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34162. /** UNSIGNED_INT_5_9_9_9_REV */
  34163. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34164. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34165. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34166. /** nearest is mag = nearest and min = nearest and mip = linear */
  34167. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34168. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34169. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34170. /** Trilinear is mag = linear and min = linear and mip = linear */
  34171. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34172. /** nearest is mag = nearest and min = nearest and mip = linear */
  34173. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34174. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34175. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34176. /** Trilinear is mag = linear and min = linear and mip = linear */
  34177. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34178. /** mag = nearest and min = nearest and mip = nearest */
  34179. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34180. /** mag = nearest and min = linear and mip = nearest */
  34181. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34182. /** mag = nearest and min = linear and mip = linear */
  34183. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34184. /** mag = nearest and min = linear and mip = none */
  34185. static readonly TEXTURE_NEAREST_LINEAR: number;
  34186. /** mag = nearest and min = nearest and mip = none */
  34187. static readonly TEXTURE_NEAREST_NEAREST: number;
  34188. /** mag = linear and min = nearest and mip = nearest */
  34189. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34190. /** mag = linear and min = nearest and mip = linear */
  34191. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34192. /** mag = linear and min = linear and mip = none */
  34193. static readonly TEXTURE_LINEAR_LINEAR: number;
  34194. /** mag = linear and min = nearest and mip = none */
  34195. static readonly TEXTURE_LINEAR_NEAREST: number;
  34196. /** Explicit coordinates mode */
  34197. static readonly TEXTURE_EXPLICIT_MODE: number;
  34198. /** Spherical coordinates mode */
  34199. static readonly TEXTURE_SPHERICAL_MODE: number;
  34200. /** Planar coordinates mode */
  34201. static readonly TEXTURE_PLANAR_MODE: number;
  34202. /** Cubic coordinates mode */
  34203. static readonly TEXTURE_CUBIC_MODE: number;
  34204. /** Projection coordinates mode */
  34205. static readonly TEXTURE_PROJECTION_MODE: number;
  34206. /** Skybox coordinates mode */
  34207. static readonly TEXTURE_SKYBOX_MODE: number;
  34208. /** Inverse Cubic coordinates mode */
  34209. static readonly TEXTURE_INVCUBIC_MODE: number;
  34210. /** Equirectangular coordinates mode */
  34211. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34212. /** Equirectangular Fixed coordinates mode */
  34213. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34214. /** Equirectangular Fixed Mirrored coordinates mode */
  34215. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34216. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34217. static readonly SCALEMODE_FLOOR: number;
  34218. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34219. static readonly SCALEMODE_NEAREST: number;
  34220. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34221. static readonly SCALEMODE_CEILING: number;
  34222. /**
  34223. * Returns the current npm package of the sdk
  34224. */
  34225. static get NpmPackage(): string;
  34226. /**
  34227. * Returns the current version of the framework
  34228. */
  34229. static get Version(): string;
  34230. /** Gets the list of created engines */
  34231. static get Instances(): Engine[];
  34232. /**
  34233. * Gets the latest created engine
  34234. */
  34235. static get LastCreatedEngine(): Nullable<Engine>;
  34236. /**
  34237. * Gets the latest created scene
  34238. */
  34239. static get LastCreatedScene(): Nullable<Scene>;
  34240. /**
  34241. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34242. * @param flag defines which part of the materials must be marked as dirty
  34243. * @param predicate defines a predicate used to filter which materials should be affected
  34244. */
  34245. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34246. /**
  34247. * Method called to create the default loading screen.
  34248. * This can be overriden in your own app.
  34249. * @param canvas The rendering canvas element
  34250. * @returns The loading screen
  34251. */
  34252. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34253. /**
  34254. * Method called to create the default rescale post process on each engine.
  34255. */
  34256. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34257. /**
  34258. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34259. **/
  34260. enableOfflineSupport: boolean;
  34261. /**
  34262. * 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)
  34263. **/
  34264. disableManifestCheck: boolean;
  34265. /**
  34266. * Gets the list of created scenes
  34267. */
  34268. scenes: Scene[];
  34269. /**
  34270. * Event raised when a new scene is created
  34271. */
  34272. onNewSceneAddedObservable: Observable<Scene>;
  34273. /**
  34274. * Gets the list of created postprocesses
  34275. */
  34276. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34277. /**
  34278. * Gets a boolean indicating if the pointer is currently locked
  34279. */
  34280. isPointerLock: boolean;
  34281. /**
  34282. * Observable event triggered each time the rendering canvas is resized
  34283. */
  34284. onResizeObservable: Observable<Engine>;
  34285. /**
  34286. * Observable event triggered each time the canvas loses focus
  34287. */
  34288. onCanvasBlurObservable: Observable<Engine>;
  34289. /**
  34290. * Observable event triggered each time the canvas gains focus
  34291. */
  34292. onCanvasFocusObservable: Observable<Engine>;
  34293. /**
  34294. * Observable event triggered each time the canvas receives pointerout event
  34295. */
  34296. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34297. /**
  34298. * Observable raised when the engine begins a new frame
  34299. */
  34300. onBeginFrameObservable: Observable<Engine>;
  34301. /**
  34302. * If set, will be used to request the next animation frame for the render loop
  34303. */
  34304. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34305. /**
  34306. * Observable raised when the engine ends the current frame
  34307. */
  34308. onEndFrameObservable: Observable<Engine>;
  34309. /**
  34310. * Observable raised when the engine is about to compile a shader
  34311. */
  34312. onBeforeShaderCompilationObservable: Observable<Engine>;
  34313. /**
  34314. * Observable raised when the engine has jsut compiled a shader
  34315. */
  34316. onAfterShaderCompilationObservable: Observable<Engine>;
  34317. /**
  34318. * Gets the audio engine
  34319. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34320. * @ignorenaming
  34321. */
  34322. static audioEngine: IAudioEngine;
  34323. /**
  34324. * Default AudioEngine factory responsible of creating the Audio Engine.
  34325. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34326. */
  34327. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34328. /**
  34329. * Default offline support factory responsible of creating a tool used to store data locally.
  34330. * By default, this will create a Database object if the workload has been embedded.
  34331. */
  34332. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34333. private _loadingScreen;
  34334. private _pointerLockRequested;
  34335. private _dummyFramebuffer;
  34336. private _rescalePostProcess;
  34337. private _deterministicLockstep;
  34338. private _lockstepMaxSteps;
  34339. private _timeStep;
  34340. protected get _supportsHardwareTextureRescaling(): boolean;
  34341. private _fps;
  34342. private _deltaTime;
  34343. /** @hidden */
  34344. _drawCalls: PerfCounter;
  34345. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  34346. canvasTabIndex: number;
  34347. /**
  34348. * Turn this value on if you want to pause FPS computation when in background
  34349. */
  34350. disablePerformanceMonitorInBackground: boolean;
  34351. private _performanceMonitor;
  34352. /**
  34353. * Gets the performance monitor attached to this engine
  34354. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34355. */
  34356. get performanceMonitor(): PerformanceMonitor;
  34357. private _onFocus;
  34358. private _onBlur;
  34359. private _onCanvasPointerOut;
  34360. private _onCanvasBlur;
  34361. private _onCanvasFocus;
  34362. private _onFullscreenChange;
  34363. private _onPointerLockChange;
  34364. /**
  34365. * Gets the HTML element used to attach event listeners
  34366. * @returns a HTML element
  34367. */
  34368. getInputElement(): Nullable<HTMLElement>;
  34369. /**
  34370. * Creates a new engine
  34371. * @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
  34372. * @param antialias defines enable antialiasing (default: false)
  34373. * @param options defines further options to be sent to the getContext() function
  34374. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34375. */
  34376. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34377. /**
  34378. * Gets current aspect ratio
  34379. * @param viewportOwner defines the camera to use to get the aspect ratio
  34380. * @param useScreen defines if screen size must be used (or the current render target if any)
  34381. * @returns a number defining the aspect ratio
  34382. */
  34383. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34384. /**
  34385. * Gets current screen aspect ratio
  34386. * @returns a number defining the aspect ratio
  34387. */
  34388. getScreenAspectRatio(): number;
  34389. /**
  34390. * Gets the client rect of the HTML canvas attached with the current webGL context
  34391. * @returns a client rectanglee
  34392. */
  34393. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34394. /**
  34395. * Gets the client rect of the HTML element used for events
  34396. * @returns a client rectanglee
  34397. */
  34398. getInputElementClientRect(): Nullable<ClientRect>;
  34399. /**
  34400. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34401. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34402. * @returns true if engine is in deterministic lock step mode
  34403. */
  34404. isDeterministicLockStep(): boolean;
  34405. /**
  34406. * Gets the max steps when engine is running in deterministic lock step
  34407. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34408. * @returns the max steps
  34409. */
  34410. getLockstepMaxSteps(): number;
  34411. /**
  34412. * Returns the time in ms between steps when using deterministic lock step.
  34413. * @returns time step in (ms)
  34414. */
  34415. getTimeStep(): number;
  34416. /**
  34417. * Force the mipmap generation for the given render target texture
  34418. * @param texture defines the render target texture to use
  34419. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34420. */
  34421. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34422. /** States */
  34423. /**
  34424. * Set various states to the webGL context
  34425. * @param culling defines backface culling state
  34426. * @param zOffset defines the value to apply to zOffset (0 by default)
  34427. * @param force defines if states must be applied even if cache is up to date
  34428. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34429. */
  34430. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34431. /**
  34432. * Set the z offset to apply to current rendering
  34433. * @param value defines the offset to apply
  34434. */
  34435. setZOffset(value: number): void;
  34436. /**
  34437. * Gets the current value of the zOffset
  34438. * @returns the current zOffset state
  34439. */
  34440. getZOffset(): number;
  34441. /**
  34442. * Enable or disable depth buffering
  34443. * @param enable defines the state to set
  34444. */
  34445. setDepthBuffer(enable: boolean): void;
  34446. /**
  34447. * Gets a boolean indicating if depth writing is enabled
  34448. * @returns the current depth writing state
  34449. */
  34450. getDepthWrite(): boolean;
  34451. /**
  34452. * Enable or disable depth writing
  34453. * @param enable defines the state to set
  34454. */
  34455. setDepthWrite(enable: boolean): void;
  34456. /**
  34457. * Gets a boolean indicating if stencil buffer is enabled
  34458. * @returns the current stencil buffer state
  34459. */
  34460. getStencilBuffer(): boolean;
  34461. /**
  34462. * Enable or disable the stencil buffer
  34463. * @param enable defines if the stencil buffer must be enabled or disabled
  34464. */
  34465. setStencilBuffer(enable: boolean): void;
  34466. /**
  34467. * Gets the current stencil mask
  34468. * @returns a number defining the new stencil mask to use
  34469. */
  34470. getStencilMask(): number;
  34471. /**
  34472. * Sets the current stencil mask
  34473. * @param mask defines the new stencil mask to use
  34474. */
  34475. setStencilMask(mask: number): void;
  34476. /**
  34477. * Gets the current stencil function
  34478. * @returns a number defining the stencil function to use
  34479. */
  34480. getStencilFunction(): number;
  34481. /**
  34482. * Gets the current stencil reference value
  34483. * @returns a number defining the stencil reference value to use
  34484. */
  34485. getStencilFunctionReference(): number;
  34486. /**
  34487. * Gets the current stencil mask
  34488. * @returns a number defining the stencil mask to use
  34489. */
  34490. getStencilFunctionMask(): number;
  34491. /**
  34492. * Sets the current stencil function
  34493. * @param stencilFunc defines the new stencil function to use
  34494. */
  34495. setStencilFunction(stencilFunc: number): void;
  34496. /**
  34497. * Sets the current stencil reference
  34498. * @param reference defines the new stencil reference to use
  34499. */
  34500. setStencilFunctionReference(reference: number): void;
  34501. /**
  34502. * Sets the current stencil mask
  34503. * @param mask defines the new stencil mask to use
  34504. */
  34505. setStencilFunctionMask(mask: number): void;
  34506. /**
  34507. * Gets the current stencil operation when stencil fails
  34508. * @returns a number defining stencil operation to use when stencil fails
  34509. */
  34510. getStencilOperationFail(): number;
  34511. /**
  34512. * Gets the current stencil operation when depth fails
  34513. * @returns a number defining stencil operation to use when depth fails
  34514. */
  34515. getStencilOperationDepthFail(): number;
  34516. /**
  34517. * Gets the current stencil operation when stencil passes
  34518. * @returns a number defining stencil operation to use when stencil passes
  34519. */
  34520. getStencilOperationPass(): number;
  34521. /**
  34522. * Sets the stencil operation to use when stencil fails
  34523. * @param operation defines the stencil operation to use when stencil fails
  34524. */
  34525. setStencilOperationFail(operation: number): void;
  34526. /**
  34527. * Sets the stencil operation to use when depth fails
  34528. * @param operation defines the stencil operation to use when depth fails
  34529. */
  34530. setStencilOperationDepthFail(operation: number): void;
  34531. /**
  34532. * Sets the stencil operation to use when stencil passes
  34533. * @param operation defines the stencil operation to use when stencil passes
  34534. */
  34535. setStencilOperationPass(operation: number): void;
  34536. /**
  34537. * Sets a boolean indicating if the dithering state is enabled or disabled
  34538. * @param value defines the dithering state
  34539. */
  34540. setDitheringState(value: boolean): void;
  34541. /**
  34542. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34543. * @param value defines the rasterizer state
  34544. */
  34545. setRasterizerState(value: boolean): void;
  34546. /**
  34547. * Gets the current depth function
  34548. * @returns a number defining the depth function
  34549. */
  34550. getDepthFunction(): Nullable<number>;
  34551. /**
  34552. * Sets the current depth function
  34553. * @param depthFunc defines the function to use
  34554. */
  34555. setDepthFunction(depthFunc: number): void;
  34556. /**
  34557. * Sets the current depth function to GREATER
  34558. */
  34559. setDepthFunctionToGreater(): void;
  34560. /**
  34561. * Sets the current depth function to GEQUAL
  34562. */
  34563. setDepthFunctionToGreaterOrEqual(): void;
  34564. /**
  34565. * Sets the current depth function to LESS
  34566. */
  34567. setDepthFunctionToLess(): void;
  34568. /**
  34569. * Sets the current depth function to LEQUAL
  34570. */
  34571. setDepthFunctionToLessOrEqual(): void;
  34572. private _cachedStencilBuffer;
  34573. private _cachedStencilFunction;
  34574. private _cachedStencilMask;
  34575. private _cachedStencilOperationPass;
  34576. private _cachedStencilOperationFail;
  34577. private _cachedStencilOperationDepthFail;
  34578. private _cachedStencilReference;
  34579. /**
  34580. * Caches the the state of the stencil buffer
  34581. */
  34582. cacheStencilState(): void;
  34583. /**
  34584. * Restores the state of the stencil buffer
  34585. */
  34586. restoreStencilState(): void;
  34587. /**
  34588. * Directly set the WebGL Viewport
  34589. * @param x defines the x coordinate of the viewport (in screen space)
  34590. * @param y defines the y coordinate of the viewport (in screen space)
  34591. * @param width defines the width of the viewport (in screen space)
  34592. * @param height defines the height of the viewport (in screen space)
  34593. * @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
  34594. */
  34595. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34596. /**
  34597. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34598. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34599. * @param y defines the y-coordinate of the corner of the clear rectangle
  34600. * @param width defines the width of the clear rectangle
  34601. * @param height defines the height of the clear rectangle
  34602. * @param clearColor defines the clear color
  34603. */
  34604. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34605. /**
  34606. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34607. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34608. * @param y defines the y-coordinate of the corner of the clear rectangle
  34609. * @param width defines the width of the clear rectangle
  34610. * @param height defines the height of the clear rectangle
  34611. */
  34612. enableScissor(x: number, y: number, width: number, height: number): void;
  34613. /**
  34614. * Disable previously set scissor test rectangle
  34615. */
  34616. disableScissor(): void;
  34617. protected _reportDrawCall(): void;
  34618. /**
  34619. * Initializes a webVR display and starts listening to display change events
  34620. * The onVRDisplayChangedObservable will be notified upon these changes
  34621. * @returns The onVRDisplayChangedObservable
  34622. */
  34623. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34624. /** @hidden */
  34625. _prepareVRComponent(): void;
  34626. /** @hidden */
  34627. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34628. /** @hidden */
  34629. _submitVRFrame(): void;
  34630. /**
  34631. * Call this function to leave webVR mode
  34632. * Will do nothing if webVR is not supported or if there is no webVR device
  34633. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34634. */
  34635. disableVR(): void;
  34636. /**
  34637. * Gets a boolean indicating that the system is in VR mode and is presenting
  34638. * @returns true if VR mode is engaged
  34639. */
  34640. isVRPresenting(): boolean;
  34641. /** @hidden */
  34642. _requestVRFrame(): void;
  34643. /** @hidden */
  34644. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34645. /**
  34646. * Gets the source code of the vertex shader associated with a specific webGL program
  34647. * @param program defines the program to use
  34648. * @returns a string containing the source code of the vertex shader associated with the program
  34649. */
  34650. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34651. /**
  34652. * Gets the source code of the fragment shader associated with a specific webGL program
  34653. * @param program defines the program to use
  34654. * @returns a string containing the source code of the fragment shader associated with the program
  34655. */
  34656. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34657. /**
  34658. * Sets a depth stencil texture from a render target to the according uniform.
  34659. * @param channel The texture channel
  34660. * @param uniform The uniform to set
  34661. * @param texture The render target texture containing the depth stencil texture to apply
  34662. */
  34663. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34664. /**
  34665. * Sets a texture to the webGL context from a postprocess
  34666. * @param channel defines the channel to use
  34667. * @param postProcess defines the source postprocess
  34668. */
  34669. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34670. /**
  34671. * Binds the output of the passed in post process to the texture channel specified
  34672. * @param channel The channel the texture should be bound to
  34673. * @param postProcess The post process which's output should be bound
  34674. */
  34675. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34676. /** @hidden */
  34677. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34678. protected _rebuildBuffers(): void;
  34679. /** @hidden */
  34680. _renderFrame(): void;
  34681. _renderLoop(): void;
  34682. /** @hidden */
  34683. _renderViews(): boolean;
  34684. /**
  34685. * Toggle full screen mode
  34686. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34687. */
  34688. switchFullscreen(requestPointerLock: boolean): void;
  34689. /**
  34690. * Enters full screen mode
  34691. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34692. */
  34693. enterFullscreen(requestPointerLock: boolean): void;
  34694. /**
  34695. * Exits full screen mode
  34696. */
  34697. exitFullscreen(): void;
  34698. /**
  34699. * Enters Pointerlock mode
  34700. */
  34701. enterPointerlock(): void;
  34702. /**
  34703. * Exits Pointerlock mode
  34704. */
  34705. exitPointerlock(): void;
  34706. /**
  34707. * Begin a new frame
  34708. */
  34709. beginFrame(): void;
  34710. /**
  34711. * Enf the current frame
  34712. */
  34713. endFrame(): void;
  34714. resize(): void;
  34715. /**
  34716. * Force a specific size of the canvas
  34717. * @param width defines the new canvas' width
  34718. * @param height defines the new canvas' height
  34719. */
  34720. setSize(width: number, height: number): void;
  34721. /**
  34722. * Updates a dynamic vertex buffer.
  34723. * @param vertexBuffer the vertex buffer to update
  34724. * @param data the data used to update the vertex buffer
  34725. * @param byteOffset the byte offset of the data
  34726. * @param byteLength the byte length of the data
  34727. */
  34728. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34729. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34730. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34731. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34732. _releaseTexture(texture: InternalTexture): void;
  34733. /**
  34734. * @hidden
  34735. * Rescales a texture
  34736. * @param source input texutre
  34737. * @param destination destination texture
  34738. * @param scene scene to use to render the resize
  34739. * @param internalFormat format to use when resizing
  34740. * @param onComplete callback to be called when resize has completed
  34741. */
  34742. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34743. /**
  34744. * Gets the current framerate
  34745. * @returns a number representing the framerate
  34746. */
  34747. getFps(): number;
  34748. /**
  34749. * Gets the time spent between current and previous frame
  34750. * @returns a number representing the delta time in ms
  34751. */
  34752. getDeltaTime(): number;
  34753. private _measureFps;
  34754. /** @hidden */
  34755. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34756. /**
  34757. * Update a dynamic index buffer
  34758. * @param indexBuffer defines the target index buffer
  34759. * @param indices defines the data to update
  34760. * @param offset defines the offset in the target index buffer where update should start
  34761. */
  34762. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34763. /**
  34764. * Updates the sample count of a render target texture
  34765. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34766. * @param texture defines the texture to update
  34767. * @param samples defines the sample count to set
  34768. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34769. */
  34770. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34771. /**
  34772. * Updates a depth texture Comparison Mode and Function.
  34773. * If the comparison Function is equal to 0, the mode will be set to none.
  34774. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34775. * @param texture The texture to set the comparison function for
  34776. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34777. */
  34778. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34779. /**
  34780. * Creates a webGL buffer to use with instanciation
  34781. * @param capacity defines the size of the buffer
  34782. * @returns the webGL buffer
  34783. */
  34784. createInstancesBuffer(capacity: number): DataBuffer;
  34785. /**
  34786. * Delete a webGL buffer used with instanciation
  34787. * @param buffer defines the webGL buffer to delete
  34788. */
  34789. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34790. private _clientWaitAsync;
  34791. /** @hidden */
  34792. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  34793. /** @hidden */
  34794. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34795. dispose(): void;
  34796. private _disableTouchAction;
  34797. /**
  34798. * Display the loading screen
  34799. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34800. */
  34801. displayLoadingUI(): void;
  34802. /**
  34803. * Hide the loading screen
  34804. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34805. */
  34806. hideLoadingUI(): void;
  34807. /**
  34808. * Gets the current loading screen object
  34809. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34810. */
  34811. get loadingScreen(): ILoadingScreen;
  34812. /**
  34813. * Sets the current loading screen object
  34814. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34815. */
  34816. set loadingScreen(loadingScreen: ILoadingScreen);
  34817. /**
  34818. * Sets the current loading screen text
  34819. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34820. */
  34821. set loadingUIText(text: string);
  34822. /**
  34823. * Sets the current loading screen background color
  34824. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34825. */
  34826. set loadingUIBackgroundColor(color: string);
  34827. /** Pointerlock and fullscreen */
  34828. /**
  34829. * Ask the browser to promote the current element to pointerlock mode
  34830. * @param element defines the DOM element to promote
  34831. */
  34832. static _RequestPointerlock(element: HTMLElement): void;
  34833. /**
  34834. * Asks the browser to exit pointerlock mode
  34835. */
  34836. static _ExitPointerlock(): void;
  34837. /**
  34838. * Ask the browser to promote the current element to fullscreen rendering mode
  34839. * @param element defines the DOM element to promote
  34840. */
  34841. static _RequestFullscreen(element: HTMLElement): void;
  34842. /**
  34843. * Asks the browser to exit fullscreen mode
  34844. */
  34845. static _ExitFullscreen(): void;
  34846. }
  34847. }
  34848. declare module "babylonjs/Engines/engineStore" {
  34849. import { Nullable } from "babylonjs/types";
  34850. import { Engine } from "babylonjs/Engines/engine";
  34851. import { Scene } from "babylonjs/scene";
  34852. /**
  34853. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34854. * during the life time of the application.
  34855. */
  34856. export class EngineStore {
  34857. /** Gets the list of created engines */
  34858. static Instances: import("babylonjs/Engines/engine").Engine[];
  34859. /** @hidden */
  34860. static _LastCreatedScene: Nullable<Scene>;
  34861. /**
  34862. * Gets the latest created engine
  34863. */
  34864. static get LastCreatedEngine(): Nullable<Engine>;
  34865. /**
  34866. * Gets the latest created scene
  34867. */
  34868. static get LastCreatedScene(): Nullable<Scene>;
  34869. /**
  34870. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34871. * @ignorenaming
  34872. */
  34873. static UseFallbackTexture: boolean;
  34874. /**
  34875. * Texture content used if a texture cannot loaded
  34876. * @ignorenaming
  34877. */
  34878. static FallbackTexture: string;
  34879. }
  34880. }
  34881. declare module "babylonjs/Misc/promise" {
  34882. /**
  34883. * Helper class that provides a small promise polyfill
  34884. */
  34885. export class PromisePolyfill {
  34886. /**
  34887. * Static function used to check if the polyfill is required
  34888. * If this is the case then the function will inject the polyfill to window.Promise
  34889. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34890. */
  34891. static Apply(force?: boolean): void;
  34892. }
  34893. }
  34894. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34895. /**
  34896. * Interface for screenshot methods with describe argument called `size` as object with options
  34897. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34898. */
  34899. export interface IScreenshotSize {
  34900. /**
  34901. * number in pixels for canvas height
  34902. */
  34903. height?: number;
  34904. /**
  34905. * multiplier allowing render at a higher or lower resolution
  34906. * If value is defined then height and width will be ignored and taken from camera
  34907. */
  34908. precision?: number;
  34909. /**
  34910. * number in pixels for canvas width
  34911. */
  34912. width?: number;
  34913. }
  34914. }
  34915. declare module "babylonjs/Misc/tools" {
  34916. import { Nullable, float } from "babylonjs/types";
  34917. import { DomManagement } from "babylonjs/Misc/domManagement";
  34918. import { WebRequest } from "babylonjs/Misc/webRequest";
  34919. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34920. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34921. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34922. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34923. import { Camera } from "babylonjs/Cameras/camera";
  34924. import { Engine } from "babylonjs/Engines/engine";
  34925. interface IColor4Like {
  34926. r: float;
  34927. g: float;
  34928. b: float;
  34929. a: float;
  34930. }
  34931. /**
  34932. * Class containing a set of static utilities functions
  34933. */
  34934. export class Tools {
  34935. /**
  34936. * Gets or sets the base URL to use to load assets
  34937. */
  34938. static get BaseUrl(): string;
  34939. static set BaseUrl(value: string);
  34940. /**
  34941. * Enable/Disable Custom HTTP Request Headers globally.
  34942. * default = false
  34943. * @see CustomRequestHeaders
  34944. */
  34945. static UseCustomRequestHeaders: boolean;
  34946. /**
  34947. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34948. * i.e. when loading files, where the server/service expects an Authorization header
  34949. */
  34950. static CustomRequestHeaders: {
  34951. [key: string]: string;
  34952. };
  34953. /**
  34954. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34955. */
  34956. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34957. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34958. /**
  34959. * Default behaviour for cors in the application.
  34960. * It can be a string if the expected behavior is identical in the entire app.
  34961. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  34962. */
  34963. static CorsBehavior: string | ((url: string | string[]) => string);
  34964. /**
  34965. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34966. * @ignorenaming
  34967. */
  34968. static get UseFallbackTexture(): boolean;
  34969. static set UseFallbackTexture(value: boolean);
  34970. /**
  34971. * Use this object to register external classes like custom textures or material
  34972. * to allow the laoders to instantiate them
  34973. */
  34974. static get RegisteredExternalClasses(): {
  34975. [key: string]: Object;
  34976. };
  34977. static set RegisteredExternalClasses(classes: {
  34978. [key: string]: Object;
  34979. });
  34980. /**
  34981. * Texture content used if a texture cannot loaded
  34982. * @ignorenaming
  34983. */
  34984. static get fallbackTexture(): string;
  34985. static set fallbackTexture(value: string);
  34986. /**
  34987. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  34988. * @param u defines the coordinate on X axis
  34989. * @param v defines the coordinate on Y axis
  34990. * @param width defines the width of the source data
  34991. * @param height defines the height of the source data
  34992. * @param pixels defines the source byte array
  34993. * @param color defines the output color
  34994. */
  34995. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  34996. /**
  34997. * Interpolates between a and b via alpha
  34998. * @param a The lower value (returned when alpha = 0)
  34999. * @param b The upper value (returned when alpha = 1)
  35000. * @param alpha The interpolation-factor
  35001. * @return The mixed value
  35002. */
  35003. static Mix(a: number, b: number, alpha: number): number;
  35004. /**
  35005. * Tries to instantiate a new object from a given class name
  35006. * @param className defines the class name to instantiate
  35007. * @returns the new object or null if the system was not able to do the instantiation
  35008. */
  35009. static Instantiate(className: string): any;
  35010. /**
  35011. * Provides a slice function that will work even on IE
  35012. * @param data defines the array to slice
  35013. * @param start defines the start of the data (optional)
  35014. * @param end defines the end of the data (optional)
  35015. * @returns the new sliced array
  35016. */
  35017. static Slice<T>(data: T, start?: number, end?: number): T;
  35018. /**
  35019. * Polyfill for setImmediate
  35020. * @param action defines the action to execute after the current execution block
  35021. */
  35022. static SetImmediate(action: () => void): void;
  35023. /**
  35024. * Function indicating if a number is an exponent of 2
  35025. * @param value defines the value to test
  35026. * @returns true if the value is an exponent of 2
  35027. */
  35028. static IsExponentOfTwo(value: number): boolean;
  35029. private static _tmpFloatArray;
  35030. /**
  35031. * Returns the nearest 32-bit single precision float representation of a Number
  35032. * @param value A Number. If the parameter is of a different type, it will get converted
  35033. * to a number or to NaN if it cannot be converted
  35034. * @returns number
  35035. */
  35036. static FloatRound(value: number): number;
  35037. /**
  35038. * Extracts the filename from a path
  35039. * @param path defines the path to use
  35040. * @returns the filename
  35041. */
  35042. static GetFilename(path: string): string;
  35043. /**
  35044. * Extracts the "folder" part of a path (everything before the filename).
  35045. * @param uri The URI to extract the info from
  35046. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35047. * @returns The "folder" part of the path
  35048. */
  35049. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35050. /**
  35051. * Extracts text content from a DOM element hierarchy
  35052. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35053. */
  35054. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35055. /**
  35056. * Convert an angle in radians to degrees
  35057. * @param angle defines the angle to convert
  35058. * @returns the angle in degrees
  35059. */
  35060. static ToDegrees(angle: number): number;
  35061. /**
  35062. * Convert an angle in degrees to radians
  35063. * @param angle defines the angle to convert
  35064. * @returns the angle in radians
  35065. */
  35066. static ToRadians(angle: number): number;
  35067. /**
  35068. * Returns an array if obj is not an array
  35069. * @param obj defines the object to evaluate as an array
  35070. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35071. * @returns either obj directly if obj is an array or a new array containing obj
  35072. */
  35073. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35074. /**
  35075. * Gets the pointer prefix to use
  35076. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35077. */
  35078. static GetPointerPrefix(): string;
  35079. /**
  35080. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35081. * @param url define the url we are trying
  35082. * @param element define the dom element where to configure the cors policy
  35083. */
  35084. static SetCorsBehavior(url: string | string[], element: {
  35085. crossOrigin: string | null;
  35086. }): void;
  35087. /**
  35088. * Removes unwanted characters from an url
  35089. * @param url defines the url to clean
  35090. * @returns the cleaned url
  35091. */
  35092. static CleanUrl(url: string): string;
  35093. /**
  35094. * Gets or sets a function used to pre-process url before using them to load assets
  35095. */
  35096. static get PreprocessUrl(): (url: string) => string;
  35097. static set PreprocessUrl(processor: (url: string) => string);
  35098. /**
  35099. * Loads an image as an HTMLImageElement.
  35100. * @param input url string, ArrayBuffer, or Blob to load
  35101. * @param onLoad callback called when the image successfully loads
  35102. * @param onError callback called when the image fails to load
  35103. * @param offlineProvider offline provider for caching
  35104. * @param mimeType optional mime type
  35105. * @returns the HTMLImageElement of the loaded image
  35106. */
  35107. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35108. /**
  35109. * Loads a file from a url
  35110. * @param url url string, ArrayBuffer, or Blob to load
  35111. * @param onSuccess callback called when the file successfully loads
  35112. * @param onProgress callback called while file is loading (if the server supports this mode)
  35113. * @param offlineProvider defines the offline provider for caching
  35114. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35115. * @param onError callback called when the file fails to load
  35116. * @returns a file request object
  35117. */
  35118. 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;
  35119. /**
  35120. * Loads a file from a url
  35121. * @param url the file url to load
  35122. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35123. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35124. */
  35125. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35126. /**
  35127. * Load a script (identified by an url). When the url returns, the
  35128. * content of this file is added into a new script element, attached to the DOM (body element)
  35129. * @param scriptUrl defines the url of the script to laod
  35130. * @param onSuccess defines the callback called when the script is loaded
  35131. * @param onError defines the callback to call if an error occurs
  35132. * @param scriptId defines the id of the script element
  35133. */
  35134. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35135. /**
  35136. * Load an asynchronous script (identified by an url). When the url returns, the
  35137. * content of this file is added into a new script element, attached to the DOM (body element)
  35138. * @param scriptUrl defines the url of the script to laod
  35139. * @param scriptId defines the id of the script element
  35140. * @returns a promise request object
  35141. */
  35142. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35143. /**
  35144. * Loads a file from a blob
  35145. * @param fileToLoad defines the blob to use
  35146. * @param callback defines the callback to call when data is loaded
  35147. * @param progressCallback defines the callback to call during loading process
  35148. * @returns a file request object
  35149. */
  35150. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35151. /**
  35152. * Reads a file from a File object
  35153. * @param file defines the file to load
  35154. * @param onSuccess defines the callback to call when data is loaded
  35155. * @param onProgress defines the callback to call during loading process
  35156. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35157. * @param onError defines the callback to call when an error occurs
  35158. * @returns a file request object
  35159. */
  35160. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35161. /**
  35162. * Creates a data url from a given string content
  35163. * @param content defines the content to convert
  35164. * @returns the new data url link
  35165. */
  35166. static FileAsURL(content: string): string;
  35167. /**
  35168. * Format the given number to a specific decimal format
  35169. * @param value defines the number to format
  35170. * @param decimals defines the number of decimals to use
  35171. * @returns the formatted string
  35172. */
  35173. static Format(value: number, decimals?: number): string;
  35174. /**
  35175. * Tries to copy an object by duplicating every property
  35176. * @param source defines the source object
  35177. * @param destination defines the target object
  35178. * @param doNotCopyList defines a list of properties to avoid
  35179. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35180. */
  35181. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35182. /**
  35183. * Gets a boolean indicating if the given object has no own property
  35184. * @param obj defines the object to test
  35185. * @returns true if object has no own property
  35186. */
  35187. static IsEmpty(obj: any): boolean;
  35188. /**
  35189. * Function used to register events at window level
  35190. * @param windowElement defines the Window object to use
  35191. * @param events defines the events to register
  35192. */
  35193. static RegisterTopRootEvents(windowElement: Window, events: {
  35194. name: string;
  35195. handler: Nullable<(e: FocusEvent) => any>;
  35196. }[]): void;
  35197. /**
  35198. * Function used to unregister events from window level
  35199. * @param windowElement defines the Window object to use
  35200. * @param events defines the events to unregister
  35201. */
  35202. static UnregisterTopRootEvents(windowElement: Window, events: {
  35203. name: string;
  35204. handler: Nullable<(e: FocusEvent) => any>;
  35205. }[]): void;
  35206. /**
  35207. * @ignore
  35208. */
  35209. static _ScreenshotCanvas: HTMLCanvasElement;
  35210. /**
  35211. * Dumps the current bound framebuffer
  35212. * @param width defines the rendering width
  35213. * @param height defines the rendering height
  35214. * @param engine defines the hosting engine
  35215. * @param successCallback defines the callback triggered once the data are available
  35216. * @param mimeType defines the mime type of the result
  35217. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35218. */
  35219. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35220. /**
  35221. * Converts the canvas data to blob.
  35222. * This acts as a polyfill for browsers not supporting the to blob function.
  35223. * @param canvas Defines the canvas to extract the data from
  35224. * @param successCallback Defines the callback triggered once the data are available
  35225. * @param mimeType Defines the mime type of the result
  35226. */
  35227. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35228. /**
  35229. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35230. * @param successCallback defines the callback triggered once the data are available
  35231. * @param mimeType defines the mime type of the result
  35232. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35233. */
  35234. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35235. /**
  35236. * Downloads a blob in the browser
  35237. * @param blob defines the blob to download
  35238. * @param fileName defines the name of the downloaded file
  35239. */
  35240. static Download(blob: Blob, fileName: string): void;
  35241. /**
  35242. * Captures a screenshot of the current rendering
  35243. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35244. * @param engine defines the rendering engine
  35245. * @param camera defines the source camera
  35246. * @param size This parameter can be set to a single number or to an object with the
  35247. * following (optional) properties: precision, width, height. If a single number is passed,
  35248. * it will be used for both width and height. If an object is passed, the screenshot size
  35249. * will be derived from the parameters. The precision property is a multiplier allowing
  35250. * rendering at a higher or lower resolution
  35251. * @param successCallback defines the callback receives a single parameter which contains the
  35252. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35253. * src parameter of an <img> to display it
  35254. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35255. * Check your browser for supported MIME types
  35256. */
  35257. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35258. /**
  35259. * Captures a screenshot of the current rendering
  35260. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35261. * @param engine defines the rendering engine
  35262. * @param camera defines the source camera
  35263. * @param size This parameter can be set to a single number or to an object with the
  35264. * following (optional) properties: precision, width, height. If a single number is passed,
  35265. * it will be used for both width and height. If an object is passed, the screenshot size
  35266. * will be derived from the parameters. The precision property is a multiplier allowing
  35267. * rendering at a higher or lower resolution
  35268. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35269. * Check your browser for supported MIME types
  35270. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35271. * to the src parameter of an <img> to display it
  35272. */
  35273. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35274. /**
  35275. * Generates an image screenshot from the specified camera.
  35276. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35277. * @param engine The engine to use for rendering
  35278. * @param camera The camera to use for rendering
  35279. * @param size This parameter can be set to a single number or to an object with the
  35280. * following (optional) properties: precision, width, height. If a single number is passed,
  35281. * it will be used for both width and height. If an object is passed, the screenshot size
  35282. * will be derived from the parameters. The precision property is a multiplier allowing
  35283. * rendering at a higher or lower resolution
  35284. * @param successCallback The callback receives a single parameter which contains the
  35285. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35286. * src parameter of an <img> to display it
  35287. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35288. * Check your browser for supported MIME types
  35289. * @param samples Texture samples (default: 1)
  35290. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35291. * @param fileName A name for for the downloaded file.
  35292. */
  35293. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35294. /**
  35295. * Generates an image screenshot from the specified camera.
  35296. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35297. * @param engine The engine to use for rendering
  35298. * @param camera The camera to use for rendering
  35299. * @param size This parameter can be set to a single number or to an object with the
  35300. * following (optional) properties: precision, width, height. If a single number is passed,
  35301. * it will be used for both width and height. If an object is passed, the screenshot size
  35302. * will be derived from the parameters. The precision property is a multiplier allowing
  35303. * rendering at a higher or lower resolution
  35304. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35305. * Check your browser for supported MIME types
  35306. * @param samples Texture samples (default: 1)
  35307. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35308. * @param fileName A name for for the downloaded file.
  35309. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35310. * to the src parameter of an <img> to display it
  35311. */
  35312. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35313. /**
  35314. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35315. * Be aware Math.random() could cause collisions, but:
  35316. * "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"
  35317. * @returns a pseudo random id
  35318. */
  35319. static RandomId(): string;
  35320. /**
  35321. * Test if the given uri is a base64 string
  35322. * @param uri The uri to test
  35323. * @return True if the uri is a base64 string or false otherwise
  35324. */
  35325. static IsBase64(uri: string): boolean;
  35326. /**
  35327. * Decode the given base64 uri.
  35328. * @param uri The uri to decode
  35329. * @return The decoded base64 data.
  35330. */
  35331. static DecodeBase64(uri: string): ArrayBuffer;
  35332. /**
  35333. * Gets the absolute url.
  35334. * @param url the input url
  35335. * @return the absolute url
  35336. */
  35337. static GetAbsoluteUrl(url: string): string;
  35338. /**
  35339. * No log
  35340. */
  35341. static readonly NoneLogLevel: number;
  35342. /**
  35343. * Only message logs
  35344. */
  35345. static readonly MessageLogLevel: number;
  35346. /**
  35347. * Only warning logs
  35348. */
  35349. static readonly WarningLogLevel: number;
  35350. /**
  35351. * Only error logs
  35352. */
  35353. static readonly ErrorLogLevel: number;
  35354. /**
  35355. * All logs
  35356. */
  35357. static readonly AllLogLevel: number;
  35358. /**
  35359. * Gets a value indicating the number of loading errors
  35360. * @ignorenaming
  35361. */
  35362. static get errorsCount(): number;
  35363. /**
  35364. * Callback called when a new log is added
  35365. */
  35366. static OnNewCacheEntry: (entry: string) => void;
  35367. /**
  35368. * Log a message to the console
  35369. * @param message defines the message to log
  35370. */
  35371. static Log(message: string): void;
  35372. /**
  35373. * Write a warning message to the console
  35374. * @param message defines the message to log
  35375. */
  35376. static Warn(message: string): void;
  35377. /**
  35378. * Write an error message to the console
  35379. * @param message defines the message to log
  35380. */
  35381. static Error(message: string): void;
  35382. /**
  35383. * Gets current log cache (list of logs)
  35384. */
  35385. static get LogCache(): string;
  35386. /**
  35387. * Clears the log cache
  35388. */
  35389. static ClearLogCache(): void;
  35390. /**
  35391. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35392. */
  35393. static set LogLevels(level: number);
  35394. /**
  35395. * Checks if the window object exists
  35396. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35397. */
  35398. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35399. /**
  35400. * No performance log
  35401. */
  35402. static readonly PerformanceNoneLogLevel: number;
  35403. /**
  35404. * Use user marks to log performance
  35405. */
  35406. static readonly PerformanceUserMarkLogLevel: number;
  35407. /**
  35408. * Log performance to the console
  35409. */
  35410. static readonly PerformanceConsoleLogLevel: number;
  35411. private static _performance;
  35412. /**
  35413. * Sets the current performance log level
  35414. */
  35415. static set PerformanceLogLevel(level: number);
  35416. private static _StartPerformanceCounterDisabled;
  35417. private static _EndPerformanceCounterDisabled;
  35418. private static _StartUserMark;
  35419. private static _EndUserMark;
  35420. private static _StartPerformanceConsole;
  35421. private static _EndPerformanceConsole;
  35422. /**
  35423. * Starts a performance counter
  35424. */
  35425. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35426. /**
  35427. * Ends a specific performance coutner
  35428. */
  35429. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35430. /**
  35431. * Gets either window.performance.now() if supported or Date.now() else
  35432. */
  35433. static get Now(): number;
  35434. /**
  35435. * This method will return the name of the class used to create the instance of the given object.
  35436. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35437. * @param object the object to get the class name from
  35438. * @param isType defines if the object is actually a type
  35439. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35440. */
  35441. static GetClassName(object: any, isType?: boolean): string;
  35442. /**
  35443. * Gets the first element of an array satisfying a given predicate
  35444. * @param array defines the array to browse
  35445. * @param predicate defines the predicate to use
  35446. * @returns null if not found or the element
  35447. */
  35448. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35449. /**
  35450. * This method will return the name of the full name of the class, including its owning module (if any).
  35451. * 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).
  35452. * @param object the object to get the class name from
  35453. * @param isType defines if the object is actually a type
  35454. * @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.
  35455. * @ignorenaming
  35456. */
  35457. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35458. /**
  35459. * Returns a promise that resolves after the given amount of time.
  35460. * @param delay Number of milliseconds to delay
  35461. * @returns Promise that resolves after the given amount of time
  35462. */
  35463. static DelayAsync(delay: number): Promise<void>;
  35464. /**
  35465. * Utility function to detect if the current user agent is Safari
  35466. * @returns whether or not the current user agent is safari
  35467. */
  35468. static IsSafari(): boolean;
  35469. }
  35470. /**
  35471. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35472. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35473. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35474. * @param name The name of the class, case should be preserved
  35475. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35476. */
  35477. export function className(name: string, module?: string): (target: Object) => void;
  35478. /**
  35479. * An implementation of a loop for asynchronous functions.
  35480. */
  35481. export class AsyncLoop {
  35482. /**
  35483. * Defines the number of iterations for the loop
  35484. */
  35485. iterations: number;
  35486. /**
  35487. * Defines the current index of the loop.
  35488. */
  35489. index: number;
  35490. private _done;
  35491. private _fn;
  35492. private _successCallback;
  35493. /**
  35494. * Constructor.
  35495. * @param iterations the number of iterations.
  35496. * @param func the function to run each iteration
  35497. * @param successCallback the callback that will be called upon succesful execution
  35498. * @param offset starting offset.
  35499. */
  35500. constructor(
  35501. /**
  35502. * Defines the number of iterations for the loop
  35503. */
  35504. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35505. /**
  35506. * Execute the next iteration. Must be called after the last iteration was finished.
  35507. */
  35508. executeNext(): void;
  35509. /**
  35510. * Break the loop and run the success callback.
  35511. */
  35512. breakLoop(): void;
  35513. /**
  35514. * Create and run an async loop.
  35515. * @param iterations the number of iterations.
  35516. * @param fn the function to run each iteration
  35517. * @param successCallback the callback that will be called upon succesful execution
  35518. * @param offset starting offset.
  35519. * @returns the created async loop object
  35520. */
  35521. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35522. /**
  35523. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35524. * @param iterations total number of iterations
  35525. * @param syncedIterations number of synchronous iterations in each async iteration.
  35526. * @param fn the function to call each iteration.
  35527. * @param callback a success call back that will be called when iterating stops.
  35528. * @param breakFunction a break condition (optional)
  35529. * @param timeout timeout settings for the setTimeout function. default - 0.
  35530. * @returns the created async loop object
  35531. */
  35532. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35533. }
  35534. }
  35535. declare module "babylonjs/Misc/stringDictionary" {
  35536. import { Nullable } from "babylonjs/types";
  35537. /**
  35538. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35539. * The underlying implementation relies on an associative array to ensure the best performances.
  35540. * The value can be anything including 'null' but except 'undefined'
  35541. */
  35542. export class StringDictionary<T> {
  35543. /**
  35544. * This will clear this dictionary and copy the content from the 'source' one.
  35545. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35546. * @param source the dictionary to take the content from and copy to this dictionary
  35547. */
  35548. copyFrom(source: StringDictionary<T>): void;
  35549. /**
  35550. * Get a value based from its key
  35551. * @param key the given key to get the matching value from
  35552. * @return the value if found, otherwise undefined is returned
  35553. */
  35554. get(key: string): T | undefined;
  35555. /**
  35556. * Get a value from its key or add it if it doesn't exist.
  35557. * This method will ensure you that a given key/data will be present in the dictionary.
  35558. * @param key the given key to get the matching value from
  35559. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35560. * The factory will only be invoked if there's no data for the given key.
  35561. * @return the value corresponding to the key.
  35562. */
  35563. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35564. /**
  35565. * Get a value from its key if present in the dictionary otherwise add it
  35566. * @param key the key to get the value from
  35567. * @param val if there's no such key/value pair in the dictionary add it with this value
  35568. * @return the value corresponding to the key
  35569. */
  35570. getOrAdd(key: string, val: T): T;
  35571. /**
  35572. * Check if there's a given key in the dictionary
  35573. * @param key the key to check for
  35574. * @return true if the key is present, false otherwise
  35575. */
  35576. contains(key: string): boolean;
  35577. /**
  35578. * Add a new key and its corresponding value
  35579. * @param key the key to add
  35580. * @param value the value corresponding to the key
  35581. * @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
  35582. */
  35583. add(key: string, value: T): boolean;
  35584. /**
  35585. * Update a specific value associated to a key
  35586. * @param key defines the key to use
  35587. * @param value defines the value to store
  35588. * @returns true if the value was updated (or false if the key was not found)
  35589. */
  35590. set(key: string, value: T): boolean;
  35591. /**
  35592. * Get the element of the given key and remove it from the dictionary
  35593. * @param key defines the key to search
  35594. * @returns the value associated with the key or null if not found
  35595. */
  35596. getAndRemove(key: string): Nullable<T>;
  35597. /**
  35598. * Remove a key/value from the dictionary.
  35599. * @param key the key to remove
  35600. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35601. */
  35602. remove(key: string): boolean;
  35603. /**
  35604. * Clear the whole content of the dictionary
  35605. */
  35606. clear(): void;
  35607. /**
  35608. * Gets the current count
  35609. */
  35610. get count(): number;
  35611. /**
  35612. * Execute a callback on each key/val of the dictionary.
  35613. * Note that you can remove any element in this dictionary in the callback implementation
  35614. * @param callback the callback to execute on a given key/value pair
  35615. */
  35616. forEach(callback: (key: string, val: T) => void): void;
  35617. /**
  35618. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35619. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35620. * Note that you can remove any element in this dictionary in the callback implementation
  35621. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35622. * @returns the first item
  35623. */
  35624. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35625. private _count;
  35626. private _data;
  35627. }
  35628. }
  35629. declare module "babylonjs/Collisions/collisionCoordinator" {
  35630. import { Nullable } from "babylonjs/types";
  35631. import { Scene } from "babylonjs/scene";
  35632. import { Vector3 } from "babylonjs/Maths/math.vector";
  35633. import { Collider } from "babylonjs/Collisions/collider";
  35634. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35635. /** @hidden */
  35636. export interface ICollisionCoordinator {
  35637. createCollider(): Collider;
  35638. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35639. init(scene: Scene): void;
  35640. }
  35641. /** @hidden */
  35642. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35643. private _scene;
  35644. private _scaledPosition;
  35645. private _scaledVelocity;
  35646. private _finalPosition;
  35647. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35648. createCollider(): Collider;
  35649. init(scene: Scene): void;
  35650. private _collideWithWorld;
  35651. }
  35652. }
  35653. declare module "babylonjs/Inputs/scene.inputManager" {
  35654. import { Nullable } from "babylonjs/types";
  35655. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35656. import { Vector2 } from "babylonjs/Maths/math.vector";
  35657. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35658. import { Scene } from "babylonjs/scene";
  35659. /**
  35660. * Class used to manage all inputs for the scene.
  35661. */
  35662. export class InputManager {
  35663. /** The distance in pixel that you have to move to prevent some events */
  35664. static DragMovementThreshold: number;
  35665. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35666. static LongPressDelay: number;
  35667. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35668. static DoubleClickDelay: number;
  35669. /** If you need to check double click without raising a single click at first click, enable this flag */
  35670. static ExclusiveDoubleClickMode: boolean;
  35671. private _wheelEventName;
  35672. private _onPointerMove;
  35673. private _onPointerDown;
  35674. private _onPointerUp;
  35675. private _initClickEvent;
  35676. private _initActionManager;
  35677. private _delayedSimpleClick;
  35678. private _delayedSimpleClickTimeout;
  35679. private _previousDelayedSimpleClickTimeout;
  35680. private _meshPickProceed;
  35681. private _previousButtonPressed;
  35682. private _currentPickResult;
  35683. private _previousPickResult;
  35684. private _totalPointersPressed;
  35685. private _doubleClickOccured;
  35686. private _pointerOverMesh;
  35687. private _pickedDownMesh;
  35688. private _pickedUpMesh;
  35689. private _pointerX;
  35690. private _pointerY;
  35691. private _unTranslatedPointerX;
  35692. private _unTranslatedPointerY;
  35693. private _startingPointerPosition;
  35694. private _previousStartingPointerPosition;
  35695. private _startingPointerTime;
  35696. private _previousStartingPointerTime;
  35697. private _pointerCaptures;
  35698. private _onKeyDown;
  35699. private _onKeyUp;
  35700. private _onCanvasFocusObserver;
  35701. private _onCanvasBlurObserver;
  35702. private _scene;
  35703. /**
  35704. * Creates a new InputManager
  35705. * @param scene defines the hosting scene
  35706. */
  35707. constructor(scene: Scene);
  35708. /**
  35709. * Gets the mesh that is currently under the pointer
  35710. */
  35711. get meshUnderPointer(): Nullable<AbstractMesh>;
  35712. /**
  35713. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35714. */
  35715. get unTranslatedPointer(): Vector2;
  35716. /**
  35717. * Gets or sets the current on-screen X position of the pointer
  35718. */
  35719. get pointerX(): number;
  35720. set pointerX(value: number);
  35721. /**
  35722. * Gets or sets the current on-screen Y position of the pointer
  35723. */
  35724. get pointerY(): number;
  35725. set pointerY(value: number);
  35726. private _updatePointerPosition;
  35727. private _processPointerMove;
  35728. private _setRayOnPointerInfo;
  35729. private _checkPrePointerObservable;
  35730. /**
  35731. * Use this method to simulate a pointer move on a mesh
  35732. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35733. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35734. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35735. */
  35736. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35737. /**
  35738. * Use this method to simulate a pointer down on a mesh
  35739. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35740. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35741. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35742. */
  35743. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35744. private _processPointerDown;
  35745. /** @hidden */
  35746. _isPointerSwiping(): boolean;
  35747. /**
  35748. * Use this method to simulate a pointer up on a mesh
  35749. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35750. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35751. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35752. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35753. */
  35754. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35755. private _processPointerUp;
  35756. /**
  35757. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35758. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35759. * @returns true if the pointer was captured
  35760. */
  35761. isPointerCaptured(pointerId?: number): boolean;
  35762. /**
  35763. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35764. * @param attachUp defines if you want to attach events to pointerup
  35765. * @param attachDown defines if you want to attach events to pointerdown
  35766. * @param attachMove defines if you want to attach events to pointermove
  35767. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35768. */
  35769. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35770. /**
  35771. * Detaches all event handlers
  35772. */
  35773. detachControl(): void;
  35774. /**
  35775. * Force the value of meshUnderPointer
  35776. * @param mesh defines the mesh to use
  35777. */
  35778. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35779. /**
  35780. * Gets the mesh under the pointer
  35781. * @returns a Mesh or null if no mesh is under the pointer
  35782. */
  35783. getPointerOverMesh(): Nullable<AbstractMesh>;
  35784. }
  35785. }
  35786. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35787. /**
  35788. * Helper class used to generate session unique ID
  35789. */
  35790. export class UniqueIdGenerator {
  35791. private static _UniqueIdCounter;
  35792. /**
  35793. * Gets an unique (relatively to the current scene) Id
  35794. */
  35795. static get UniqueId(): number;
  35796. }
  35797. }
  35798. declare module "babylonjs/Animations/animationGroup" {
  35799. import { Animatable } from "babylonjs/Animations/animatable";
  35800. import { Animation } from "babylonjs/Animations/animation";
  35801. import { Scene, IDisposable } from "babylonjs/scene";
  35802. import { Observable } from "babylonjs/Misc/observable";
  35803. import { Nullable } from "babylonjs/types";
  35804. import "babylonjs/Animations/animatable";
  35805. /**
  35806. * This class defines the direct association between an animation and a target
  35807. */
  35808. export class TargetedAnimation {
  35809. /**
  35810. * Animation to perform
  35811. */
  35812. animation: Animation;
  35813. /**
  35814. * Target to animate
  35815. */
  35816. target: any;
  35817. /**
  35818. * Serialize the object
  35819. * @returns the JSON object representing the current entity
  35820. */
  35821. serialize(): any;
  35822. }
  35823. /**
  35824. * Use this class to create coordinated animations on multiple targets
  35825. */
  35826. export class AnimationGroup implements IDisposable {
  35827. /** The name of the animation group */
  35828. name: string;
  35829. private _scene;
  35830. private _targetedAnimations;
  35831. private _animatables;
  35832. private _from;
  35833. private _to;
  35834. private _isStarted;
  35835. private _isPaused;
  35836. private _speedRatio;
  35837. private _loopAnimation;
  35838. /**
  35839. * Gets or sets the unique id of the node
  35840. */
  35841. uniqueId: number;
  35842. /**
  35843. * This observable will notify when one animation have ended
  35844. */
  35845. onAnimationEndObservable: Observable<TargetedAnimation>;
  35846. /**
  35847. * Observer raised when one animation loops
  35848. */
  35849. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35850. /**
  35851. * Observer raised when all animations have looped
  35852. */
  35853. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35854. /**
  35855. * This observable will notify when all animations have ended.
  35856. */
  35857. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35858. /**
  35859. * This observable will notify when all animations have paused.
  35860. */
  35861. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35862. /**
  35863. * This observable will notify when all animations are playing.
  35864. */
  35865. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35866. /**
  35867. * Gets the first frame
  35868. */
  35869. get from(): number;
  35870. /**
  35871. * Gets the last frame
  35872. */
  35873. get to(): number;
  35874. /**
  35875. * Define if the animations are started
  35876. */
  35877. get isStarted(): boolean;
  35878. /**
  35879. * Gets a value indicating that the current group is playing
  35880. */
  35881. get isPlaying(): boolean;
  35882. /**
  35883. * Gets or sets the speed ratio to use for all animations
  35884. */
  35885. get speedRatio(): number;
  35886. /**
  35887. * Gets or sets the speed ratio to use for all animations
  35888. */
  35889. set speedRatio(value: number);
  35890. /**
  35891. * Gets or sets if all animations should loop or not
  35892. */
  35893. get loopAnimation(): boolean;
  35894. set loopAnimation(value: boolean);
  35895. /**
  35896. * Gets the targeted animations for this animation group
  35897. */
  35898. get targetedAnimations(): Array<TargetedAnimation>;
  35899. /**
  35900. * returning the list of animatables controlled by this animation group.
  35901. */
  35902. get animatables(): Array<Animatable>;
  35903. /**
  35904. * Instantiates a new Animation Group.
  35905. * This helps managing several animations at once.
  35906. * @see http://doc.babylonjs.com/how_to/group
  35907. * @param name Defines the name of the group
  35908. * @param scene Defines the scene the group belongs to
  35909. */
  35910. constructor(
  35911. /** The name of the animation group */
  35912. name: string, scene?: Nullable<Scene>);
  35913. /**
  35914. * Add an animation (with its target) in the group
  35915. * @param animation defines the animation we want to add
  35916. * @param target defines the target of the animation
  35917. * @returns the TargetedAnimation object
  35918. */
  35919. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35920. /**
  35921. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35922. * It can add constant keys at begin or end
  35923. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35924. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35925. * @returns the animation group
  35926. */
  35927. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35928. private _animationLoopCount;
  35929. private _animationLoopFlags;
  35930. private _processLoop;
  35931. /**
  35932. * Start all animations on given targets
  35933. * @param loop defines if animations must loop
  35934. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35935. * @param from defines the from key (optional)
  35936. * @param to defines the to key (optional)
  35937. * @returns the current animation group
  35938. */
  35939. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35940. /**
  35941. * Pause all animations
  35942. * @returns the animation group
  35943. */
  35944. pause(): AnimationGroup;
  35945. /**
  35946. * Play all animations to initial state
  35947. * This function will start() the animations if they were not started or will restart() them if they were paused
  35948. * @param loop defines if animations must loop
  35949. * @returns the animation group
  35950. */
  35951. play(loop?: boolean): AnimationGroup;
  35952. /**
  35953. * Reset all animations to initial state
  35954. * @returns the animation group
  35955. */
  35956. reset(): AnimationGroup;
  35957. /**
  35958. * Restart animations from key 0
  35959. * @returns the animation group
  35960. */
  35961. restart(): AnimationGroup;
  35962. /**
  35963. * Stop all animations
  35964. * @returns the animation group
  35965. */
  35966. stop(): AnimationGroup;
  35967. /**
  35968. * Set animation weight for all animatables
  35969. * @param weight defines the weight to use
  35970. * @return the animationGroup
  35971. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35972. */
  35973. setWeightForAllAnimatables(weight: number): AnimationGroup;
  35974. /**
  35975. * Synchronize and normalize all animatables with a source animatable
  35976. * @param root defines the root animatable to synchronize with
  35977. * @return the animationGroup
  35978. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  35979. */
  35980. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  35981. /**
  35982. * Goes to a specific frame in this animation group
  35983. * @param frame the frame number to go to
  35984. * @return the animationGroup
  35985. */
  35986. goToFrame(frame: number): AnimationGroup;
  35987. /**
  35988. * Dispose all associated resources
  35989. */
  35990. dispose(): void;
  35991. private _checkAnimationGroupEnded;
  35992. /**
  35993. * Clone the current animation group and returns a copy
  35994. * @param newName defines the name of the new group
  35995. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  35996. * @returns the new aniamtion group
  35997. */
  35998. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  35999. /**
  36000. * Serializes the animationGroup to an object
  36001. * @returns Serialized object
  36002. */
  36003. serialize(): any;
  36004. /**
  36005. * Returns a new AnimationGroup object parsed from the source provided.
  36006. * @param parsedAnimationGroup defines the source
  36007. * @param scene defines the scene that will receive the animationGroup
  36008. * @returns a new AnimationGroup
  36009. */
  36010. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36011. /**
  36012. * Returns the string "AnimationGroup"
  36013. * @returns "AnimationGroup"
  36014. */
  36015. getClassName(): string;
  36016. /**
  36017. * Creates a detailled string about the object
  36018. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36019. * @returns a string representing the object
  36020. */
  36021. toString(fullDetails?: boolean): string;
  36022. }
  36023. }
  36024. declare module "babylonjs/scene" {
  36025. import { Nullable } from "babylonjs/types";
  36026. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36027. import { Observable } from "babylonjs/Misc/observable";
  36028. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36029. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36030. import { Geometry } from "babylonjs/Meshes/geometry";
  36031. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36032. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36033. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36034. import { Mesh } from "babylonjs/Meshes/mesh";
  36035. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36036. import { Bone } from "babylonjs/Bones/bone";
  36037. import { Skeleton } from "babylonjs/Bones/skeleton";
  36038. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36039. import { Camera } from "babylonjs/Cameras/camera";
  36040. import { AbstractScene } from "babylonjs/abstractScene";
  36041. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36042. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36043. import { Material } from "babylonjs/Materials/material";
  36044. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36045. import { Effect } from "babylonjs/Materials/effect";
  36046. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36047. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36048. import { Light } from "babylonjs/Lights/light";
  36049. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36050. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36051. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36052. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36053. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36054. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36055. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36056. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36057. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36058. import { Engine } from "babylonjs/Engines/engine";
  36059. import { Node } from "babylonjs/node";
  36060. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36061. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36062. import { WebRequest } from "babylonjs/Misc/webRequest";
  36063. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36064. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36065. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36066. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36067. import { Plane } from "babylonjs/Maths/math.plane";
  36068. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36069. import { Ray } from "babylonjs/Culling/ray";
  36070. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36071. import { Animation } from "babylonjs/Animations/animation";
  36072. import { Animatable } from "babylonjs/Animations/animatable";
  36073. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36074. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36075. import { Collider } from "babylonjs/Collisions/collider";
  36076. /**
  36077. * Define an interface for all classes that will hold resources
  36078. */
  36079. export interface IDisposable {
  36080. /**
  36081. * Releases all held resources
  36082. */
  36083. dispose(): void;
  36084. }
  36085. /** Interface defining initialization parameters for Scene class */
  36086. export interface SceneOptions {
  36087. /**
  36088. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36089. * It will improve performance when the number of geometries becomes important.
  36090. */
  36091. useGeometryUniqueIdsMap?: boolean;
  36092. /**
  36093. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36094. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36095. */
  36096. useMaterialMeshMap?: boolean;
  36097. /**
  36098. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36099. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36100. */
  36101. useClonedMeshMap?: boolean;
  36102. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36103. virtual?: boolean;
  36104. }
  36105. /**
  36106. * Represents a scene to be rendered by the engine.
  36107. * @see http://doc.babylonjs.com/features/scene
  36108. */
  36109. export class Scene extends AbstractScene implements IAnimatable {
  36110. /** The fog is deactivated */
  36111. static readonly FOGMODE_NONE: number;
  36112. /** The fog density is following an exponential function */
  36113. static readonly FOGMODE_EXP: number;
  36114. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36115. static readonly FOGMODE_EXP2: number;
  36116. /** The fog density is following a linear function. */
  36117. static readonly FOGMODE_LINEAR: number;
  36118. /**
  36119. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36120. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36121. */
  36122. static MinDeltaTime: number;
  36123. /**
  36124. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36125. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36126. */
  36127. static MaxDeltaTime: number;
  36128. /**
  36129. * Factory used to create the default material.
  36130. * @param name The name of the material to create
  36131. * @param scene The scene to create the material for
  36132. * @returns The default material
  36133. */
  36134. static DefaultMaterialFactory(scene: Scene): Material;
  36135. /**
  36136. * Factory used to create the a collision coordinator.
  36137. * @returns The collision coordinator
  36138. */
  36139. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36140. /** @hidden */
  36141. _inputManager: InputManager;
  36142. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36143. cameraToUseForPointers: Nullable<Camera>;
  36144. /** @hidden */
  36145. readonly _isScene: boolean;
  36146. /** @hidden */
  36147. _blockEntityCollection: boolean;
  36148. /**
  36149. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36150. */
  36151. autoClear: boolean;
  36152. /**
  36153. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36154. */
  36155. autoClearDepthAndStencil: boolean;
  36156. /**
  36157. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36158. */
  36159. clearColor: Color4;
  36160. /**
  36161. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36162. */
  36163. ambientColor: Color3;
  36164. /**
  36165. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36166. * It should only be one of the following (if not the default embedded one):
  36167. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36168. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36169. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36170. * The material properties need to be setup according to the type of texture in use.
  36171. */
  36172. environmentBRDFTexture: BaseTexture;
  36173. /** @hidden */
  36174. protected _environmentTexture: Nullable<BaseTexture>;
  36175. /**
  36176. * Texture used in all pbr material as the reflection texture.
  36177. * As in the majority of the scene they are the same (exception for multi room and so on),
  36178. * this is easier to reference from here than from all the materials.
  36179. */
  36180. get environmentTexture(): Nullable<BaseTexture>;
  36181. /**
  36182. * Texture used in all pbr material as the reflection texture.
  36183. * As in the majority of the scene they are the same (exception for multi room and so on),
  36184. * this is easier to set here than in all the materials.
  36185. */
  36186. set environmentTexture(value: Nullable<BaseTexture>);
  36187. /** @hidden */
  36188. protected _environmentIntensity: number;
  36189. /**
  36190. * Intensity of the environment in all pbr material.
  36191. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36192. * As in the majority of the scene they are the same (exception for multi room and so on),
  36193. * this is easier to reference from here than from all the materials.
  36194. */
  36195. get environmentIntensity(): number;
  36196. /**
  36197. * Intensity of the environment in all pbr material.
  36198. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36199. * As in the majority of the scene they are the same (exception for multi room and so on),
  36200. * this is easier to set here than in all the materials.
  36201. */
  36202. set environmentIntensity(value: number);
  36203. /** @hidden */
  36204. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36205. /**
  36206. * Default image processing configuration used either in the rendering
  36207. * Forward main pass or through the imageProcessingPostProcess if present.
  36208. * As in the majority of the scene they are the same (exception for multi camera),
  36209. * this is easier to reference from here than from all the materials and post process.
  36210. *
  36211. * No setter as we it is a shared configuration, you can set the values instead.
  36212. */
  36213. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36214. private _forceWireframe;
  36215. /**
  36216. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36217. */
  36218. set forceWireframe(value: boolean);
  36219. get forceWireframe(): boolean;
  36220. private _skipFrustumClipping;
  36221. /**
  36222. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36223. */
  36224. set skipFrustumClipping(value: boolean);
  36225. get skipFrustumClipping(): boolean;
  36226. private _forcePointsCloud;
  36227. /**
  36228. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36229. */
  36230. set forcePointsCloud(value: boolean);
  36231. get forcePointsCloud(): boolean;
  36232. /**
  36233. * Gets or sets the active clipplane 1
  36234. */
  36235. clipPlane: Nullable<Plane>;
  36236. /**
  36237. * Gets or sets the active clipplane 2
  36238. */
  36239. clipPlane2: Nullable<Plane>;
  36240. /**
  36241. * Gets or sets the active clipplane 3
  36242. */
  36243. clipPlane3: Nullable<Plane>;
  36244. /**
  36245. * Gets or sets the active clipplane 4
  36246. */
  36247. clipPlane4: Nullable<Plane>;
  36248. /**
  36249. * Gets or sets the active clipplane 5
  36250. */
  36251. clipPlane5: Nullable<Plane>;
  36252. /**
  36253. * Gets or sets the active clipplane 6
  36254. */
  36255. clipPlane6: Nullable<Plane>;
  36256. /**
  36257. * Gets or sets a boolean indicating if animations are enabled
  36258. */
  36259. animationsEnabled: boolean;
  36260. private _animationPropertiesOverride;
  36261. /**
  36262. * Gets or sets the animation properties override
  36263. */
  36264. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36265. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36266. /**
  36267. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36268. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36269. */
  36270. useConstantAnimationDeltaTime: boolean;
  36271. /**
  36272. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36273. * Please note that it requires to run a ray cast through the scene on every frame
  36274. */
  36275. constantlyUpdateMeshUnderPointer: boolean;
  36276. /**
  36277. * Defines the HTML cursor to use when hovering over interactive elements
  36278. */
  36279. hoverCursor: string;
  36280. /**
  36281. * Defines the HTML default cursor to use (empty by default)
  36282. */
  36283. defaultCursor: string;
  36284. /**
  36285. * Defines whether cursors are handled by the scene.
  36286. */
  36287. doNotHandleCursors: boolean;
  36288. /**
  36289. * This is used to call preventDefault() on pointer down
  36290. * in order to block unwanted artifacts like system double clicks
  36291. */
  36292. preventDefaultOnPointerDown: boolean;
  36293. /**
  36294. * This is used to call preventDefault() on pointer up
  36295. * in order to block unwanted artifacts like system double clicks
  36296. */
  36297. preventDefaultOnPointerUp: boolean;
  36298. /**
  36299. * Gets or sets user defined metadata
  36300. */
  36301. metadata: any;
  36302. /**
  36303. * For internal use only. Please do not use.
  36304. */
  36305. reservedDataStore: any;
  36306. /**
  36307. * Gets the name of the plugin used to load this scene (null by default)
  36308. */
  36309. loadingPluginName: string;
  36310. /**
  36311. * Use this array to add regular expressions used to disable offline support for specific urls
  36312. */
  36313. disableOfflineSupportExceptionRules: RegExp[];
  36314. /**
  36315. * An event triggered when the scene is disposed.
  36316. */
  36317. onDisposeObservable: Observable<Scene>;
  36318. private _onDisposeObserver;
  36319. /** Sets a function to be executed when this scene is disposed. */
  36320. set onDispose(callback: () => void);
  36321. /**
  36322. * An event triggered before rendering the scene (right after animations and physics)
  36323. */
  36324. onBeforeRenderObservable: Observable<Scene>;
  36325. private _onBeforeRenderObserver;
  36326. /** Sets a function to be executed before rendering this scene */
  36327. set beforeRender(callback: Nullable<() => void>);
  36328. /**
  36329. * An event triggered after rendering the scene
  36330. */
  36331. onAfterRenderObservable: Observable<Scene>;
  36332. /**
  36333. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36334. */
  36335. onAfterRenderCameraObservable: Observable<Camera>;
  36336. private _onAfterRenderObserver;
  36337. /** Sets a function to be executed after rendering this scene */
  36338. set afterRender(callback: Nullable<() => void>);
  36339. /**
  36340. * An event triggered before animating the scene
  36341. */
  36342. onBeforeAnimationsObservable: Observable<Scene>;
  36343. /**
  36344. * An event triggered after animations processing
  36345. */
  36346. onAfterAnimationsObservable: Observable<Scene>;
  36347. /**
  36348. * An event triggered before draw calls are ready to be sent
  36349. */
  36350. onBeforeDrawPhaseObservable: Observable<Scene>;
  36351. /**
  36352. * An event triggered after draw calls have been sent
  36353. */
  36354. onAfterDrawPhaseObservable: Observable<Scene>;
  36355. /**
  36356. * An event triggered when the scene is ready
  36357. */
  36358. onReadyObservable: Observable<Scene>;
  36359. /**
  36360. * An event triggered before rendering a camera
  36361. */
  36362. onBeforeCameraRenderObservable: Observable<Camera>;
  36363. private _onBeforeCameraRenderObserver;
  36364. /** Sets a function to be executed before rendering a camera*/
  36365. set beforeCameraRender(callback: () => void);
  36366. /**
  36367. * An event triggered after rendering a camera
  36368. */
  36369. onAfterCameraRenderObservable: Observable<Camera>;
  36370. private _onAfterCameraRenderObserver;
  36371. /** Sets a function to be executed after rendering a camera*/
  36372. set afterCameraRender(callback: () => void);
  36373. /**
  36374. * An event triggered when active meshes evaluation is about to start
  36375. */
  36376. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36377. /**
  36378. * An event triggered when active meshes evaluation is done
  36379. */
  36380. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36381. /**
  36382. * An event triggered when particles rendering is about to start
  36383. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36384. */
  36385. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36386. /**
  36387. * An event triggered when particles rendering is done
  36388. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36389. */
  36390. onAfterParticlesRenderingObservable: Observable<Scene>;
  36391. /**
  36392. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36393. */
  36394. onDataLoadedObservable: Observable<Scene>;
  36395. /**
  36396. * An event triggered when a camera is created
  36397. */
  36398. onNewCameraAddedObservable: Observable<Camera>;
  36399. /**
  36400. * An event triggered when a camera is removed
  36401. */
  36402. onCameraRemovedObservable: Observable<Camera>;
  36403. /**
  36404. * An event triggered when a light is created
  36405. */
  36406. onNewLightAddedObservable: Observable<Light>;
  36407. /**
  36408. * An event triggered when a light is removed
  36409. */
  36410. onLightRemovedObservable: Observable<Light>;
  36411. /**
  36412. * An event triggered when a geometry is created
  36413. */
  36414. onNewGeometryAddedObservable: Observable<Geometry>;
  36415. /**
  36416. * An event triggered when a geometry is removed
  36417. */
  36418. onGeometryRemovedObservable: Observable<Geometry>;
  36419. /**
  36420. * An event triggered when a transform node is created
  36421. */
  36422. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36423. /**
  36424. * An event triggered when a transform node is removed
  36425. */
  36426. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36427. /**
  36428. * An event triggered when a mesh is created
  36429. */
  36430. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36431. /**
  36432. * An event triggered when a mesh is removed
  36433. */
  36434. onMeshRemovedObservable: Observable<AbstractMesh>;
  36435. /**
  36436. * An event triggered when a skeleton is created
  36437. */
  36438. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36439. /**
  36440. * An event triggered when a skeleton is removed
  36441. */
  36442. onSkeletonRemovedObservable: Observable<Skeleton>;
  36443. /**
  36444. * An event triggered when a material is created
  36445. */
  36446. onNewMaterialAddedObservable: Observable<Material>;
  36447. /**
  36448. * An event triggered when a material is removed
  36449. */
  36450. onMaterialRemovedObservable: Observable<Material>;
  36451. /**
  36452. * An event triggered when a texture is created
  36453. */
  36454. onNewTextureAddedObservable: Observable<BaseTexture>;
  36455. /**
  36456. * An event triggered when a texture is removed
  36457. */
  36458. onTextureRemovedObservable: Observable<BaseTexture>;
  36459. /**
  36460. * An event triggered when render targets are about to be rendered
  36461. * Can happen multiple times per frame.
  36462. */
  36463. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36464. /**
  36465. * An event triggered when render targets were rendered.
  36466. * Can happen multiple times per frame.
  36467. */
  36468. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36469. /**
  36470. * An event triggered before calculating deterministic simulation step
  36471. */
  36472. onBeforeStepObservable: Observable<Scene>;
  36473. /**
  36474. * An event triggered after calculating deterministic simulation step
  36475. */
  36476. onAfterStepObservable: Observable<Scene>;
  36477. /**
  36478. * An event triggered when the activeCamera property is updated
  36479. */
  36480. onActiveCameraChanged: Observable<Scene>;
  36481. /**
  36482. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36483. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36484. * 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)
  36485. */
  36486. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36487. /**
  36488. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36489. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36490. * 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)
  36491. */
  36492. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36493. /**
  36494. * This Observable will when a mesh has been imported into the scene.
  36495. */
  36496. onMeshImportedObservable: Observable<AbstractMesh>;
  36497. /**
  36498. * This Observable will when an animation file has been imported into the scene.
  36499. */
  36500. onAnimationFileImportedObservable: Observable<Scene>;
  36501. /**
  36502. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36503. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36504. */
  36505. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36506. /** @hidden */
  36507. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36508. /**
  36509. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36510. */
  36511. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36512. /**
  36513. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36514. */
  36515. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36516. /**
  36517. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36518. */
  36519. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36520. /** Callback called when a pointer move is detected */
  36521. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36522. /** Callback called when a pointer down is detected */
  36523. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36524. /** Callback called when a pointer up is detected */
  36525. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36526. /** Callback called when a pointer pick is detected */
  36527. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36528. /**
  36529. * 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).
  36530. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36531. */
  36532. onPrePointerObservable: Observable<PointerInfoPre>;
  36533. /**
  36534. * Observable event triggered each time an input event is received from the rendering canvas
  36535. */
  36536. onPointerObservable: Observable<PointerInfo>;
  36537. /**
  36538. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36539. */
  36540. get unTranslatedPointer(): Vector2;
  36541. /**
  36542. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36543. */
  36544. static get DragMovementThreshold(): number;
  36545. static set DragMovementThreshold(value: number);
  36546. /**
  36547. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36548. */
  36549. static get LongPressDelay(): number;
  36550. static set LongPressDelay(value: number);
  36551. /**
  36552. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36553. */
  36554. static get DoubleClickDelay(): number;
  36555. static set DoubleClickDelay(value: number);
  36556. /** If you need to check double click without raising a single click at first click, enable this flag */
  36557. static get ExclusiveDoubleClickMode(): boolean;
  36558. static set ExclusiveDoubleClickMode(value: boolean);
  36559. /** @hidden */
  36560. _mirroredCameraPosition: Nullable<Vector3>;
  36561. /**
  36562. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36563. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36564. */
  36565. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36566. /**
  36567. * Observable event triggered each time an keyboard event is received from the hosting window
  36568. */
  36569. onKeyboardObservable: Observable<KeyboardInfo>;
  36570. private _useRightHandedSystem;
  36571. /**
  36572. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36573. */
  36574. set useRightHandedSystem(value: boolean);
  36575. get useRightHandedSystem(): boolean;
  36576. private _timeAccumulator;
  36577. private _currentStepId;
  36578. private _currentInternalStep;
  36579. /**
  36580. * Sets the step Id used by deterministic lock step
  36581. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36582. * @param newStepId defines the step Id
  36583. */
  36584. setStepId(newStepId: number): void;
  36585. /**
  36586. * Gets the step Id used by deterministic lock step
  36587. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36588. * @returns the step Id
  36589. */
  36590. getStepId(): number;
  36591. /**
  36592. * Gets the internal step used by deterministic lock step
  36593. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36594. * @returns the internal step
  36595. */
  36596. getInternalStep(): number;
  36597. private _fogEnabled;
  36598. /**
  36599. * Gets or sets a boolean indicating if fog is enabled on this scene
  36600. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36601. * (Default is true)
  36602. */
  36603. set fogEnabled(value: boolean);
  36604. get fogEnabled(): boolean;
  36605. private _fogMode;
  36606. /**
  36607. * Gets or sets the fog mode to use
  36608. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36609. * | mode | value |
  36610. * | --- | --- |
  36611. * | FOGMODE_NONE | 0 |
  36612. * | FOGMODE_EXP | 1 |
  36613. * | FOGMODE_EXP2 | 2 |
  36614. * | FOGMODE_LINEAR | 3 |
  36615. */
  36616. set fogMode(value: number);
  36617. get fogMode(): number;
  36618. /**
  36619. * Gets or sets the fog color to use
  36620. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36621. * (Default is Color3(0.2, 0.2, 0.3))
  36622. */
  36623. fogColor: Color3;
  36624. /**
  36625. * Gets or sets the fog density to use
  36626. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36627. * (Default is 0.1)
  36628. */
  36629. fogDensity: number;
  36630. /**
  36631. * Gets or sets the fog start distance to use
  36632. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36633. * (Default is 0)
  36634. */
  36635. fogStart: number;
  36636. /**
  36637. * Gets or sets the fog end distance to use
  36638. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36639. * (Default is 1000)
  36640. */
  36641. fogEnd: number;
  36642. private _shadowsEnabled;
  36643. /**
  36644. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36645. */
  36646. set shadowsEnabled(value: boolean);
  36647. get shadowsEnabled(): boolean;
  36648. private _lightsEnabled;
  36649. /**
  36650. * Gets or sets a boolean indicating if lights are enabled on this scene
  36651. */
  36652. set lightsEnabled(value: boolean);
  36653. get lightsEnabled(): boolean;
  36654. /** All of the active cameras added to this scene. */
  36655. activeCameras: Camera[];
  36656. /** @hidden */
  36657. _activeCamera: Nullable<Camera>;
  36658. /** Gets or sets the current active camera */
  36659. get activeCamera(): Nullable<Camera>;
  36660. set activeCamera(value: Nullable<Camera>);
  36661. private _defaultMaterial;
  36662. /** The default material used on meshes when no material is affected */
  36663. get defaultMaterial(): Material;
  36664. /** The default material used on meshes when no material is affected */
  36665. set defaultMaterial(value: Material);
  36666. private _texturesEnabled;
  36667. /**
  36668. * Gets or sets a boolean indicating if textures are enabled on this scene
  36669. */
  36670. set texturesEnabled(value: boolean);
  36671. get texturesEnabled(): boolean;
  36672. /**
  36673. * Gets or sets a boolean indicating if particles are enabled on this scene
  36674. */
  36675. particlesEnabled: boolean;
  36676. /**
  36677. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36678. */
  36679. spritesEnabled: boolean;
  36680. private _skeletonsEnabled;
  36681. /**
  36682. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36683. */
  36684. set skeletonsEnabled(value: boolean);
  36685. get skeletonsEnabled(): boolean;
  36686. /**
  36687. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36688. */
  36689. lensFlaresEnabled: boolean;
  36690. /**
  36691. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36692. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36693. */
  36694. collisionsEnabled: boolean;
  36695. private _collisionCoordinator;
  36696. /** @hidden */
  36697. get collisionCoordinator(): ICollisionCoordinator;
  36698. /**
  36699. * Defines the gravity applied to this scene (used only for collisions)
  36700. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36701. */
  36702. gravity: Vector3;
  36703. /**
  36704. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36705. */
  36706. postProcessesEnabled: boolean;
  36707. /**
  36708. * The list of postprocesses added to the scene
  36709. */
  36710. postProcesses: PostProcess[];
  36711. /**
  36712. * Gets the current postprocess manager
  36713. */
  36714. postProcessManager: PostProcessManager;
  36715. /**
  36716. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36717. */
  36718. renderTargetsEnabled: boolean;
  36719. /**
  36720. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36721. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36722. */
  36723. dumpNextRenderTargets: boolean;
  36724. /**
  36725. * The list of user defined render targets added to the scene
  36726. */
  36727. customRenderTargets: RenderTargetTexture[];
  36728. /**
  36729. * Defines if texture loading must be delayed
  36730. * If true, textures will only be loaded when they need to be rendered
  36731. */
  36732. useDelayedTextureLoading: boolean;
  36733. /**
  36734. * Gets the list of meshes imported to the scene through SceneLoader
  36735. */
  36736. importedMeshesFiles: String[];
  36737. /**
  36738. * Gets or sets a boolean indicating if probes are enabled on this scene
  36739. */
  36740. probesEnabled: boolean;
  36741. /**
  36742. * Gets or sets the current offline provider to use to store scene data
  36743. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36744. */
  36745. offlineProvider: IOfflineProvider;
  36746. /**
  36747. * Gets or sets the action manager associated with the scene
  36748. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36749. */
  36750. actionManager: AbstractActionManager;
  36751. private _meshesForIntersections;
  36752. /**
  36753. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36754. */
  36755. proceduralTexturesEnabled: boolean;
  36756. private _engine;
  36757. private _totalVertices;
  36758. /** @hidden */
  36759. _activeIndices: PerfCounter;
  36760. /** @hidden */
  36761. _activeParticles: PerfCounter;
  36762. /** @hidden */
  36763. _activeBones: PerfCounter;
  36764. private _animationRatio;
  36765. /** @hidden */
  36766. _animationTimeLast: number;
  36767. /** @hidden */
  36768. _animationTime: number;
  36769. /**
  36770. * Gets or sets a general scale for animation speed
  36771. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36772. */
  36773. animationTimeScale: number;
  36774. /** @hidden */
  36775. _cachedMaterial: Nullable<Material>;
  36776. /** @hidden */
  36777. _cachedEffect: Nullable<Effect>;
  36778. /** @hidden */
  36779. _cachedVisibility: Nullable<number>;
  36780. private _renderId;
  36781. private _frameId;
  36782. private _executeWhenReadyTimeoutId;
  36783. private _intermediateRendering;
  36784. private _viewUpdateFlag;
  36785. private _projectionUpdateFlag;
  36786. /** @hidden */
  36787. _toBeDisposed: Nullable<IDisposable>[];
  36788. private _activeRequests;
  36789. /** @hidden */
  36790. _pendingData: any[];
  36791. private _isDisposed;
  36792. /**
  36793. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36794. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36795. */
  36796. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36797. private _activeMeshes;
  36798. private _processedMaterials;
  36799. private _renderTargets;
  36800. /** @hidden */
  36801. _activeParticleSystems: SmartArray<IParticleSystem>;
  36802. private _activeSkeletons;
  36803. private _softwareSkinnedMeshes;
  36804. private _renderingManager;
  36805. /** @hidden */
  36806. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36807. private _transformMatrix;
  36808. private _sceneUbo;
  36809. /** @hidden */
  36810. _viewMatrix: Matrix;
  36811. private _projectionMatrix;
  36812. /** @hidden */
  36813. _forcedViewPosition: Nullable<Vector3>;
  36814. /** @hidden */
  36815. _frustumPlanes: Plane[];
  36816. /**
  36817. * Gets the list of frustum planes (built from the active camera)
  36818. */
  36819. get frustumPlanes(): Plane[];
  36820. /**
  36821. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36822. * This is useful if there are more lights that the maximum simulteanous authorized
  36823. */
  36824. requireLightSorting: boolean;
  36825. /** @hidden */
  36826. readonly useMaterialMeshMap: boolean;
  36827. /** @hidden */
  36828. readonly useClonedMeshMap: boolean;
  36829. private _externalData;
  36830. private _uid;
  36831. /**
  36832. * @hidden
  36833. * Backing store of defined scene components.
  36834. */
  36835. _components: ISceneComponent[];
  36836. /**
  36837. * @hidden
  36838. * Backing store of defined scene components.
  36839. */
  36840. _serializableComponents: ISceneSerializableComponent[];
  36841. /**
  36842. * List of components to register on the next registration step.
  36843. */
  36844. private _transientComponents;
  36845. /**
  36846. * Registers the transient components if needed.
  36847. */
  36848. private _registerTransientComponents;
  36849. /**
  36850. * @hidden
  36851. * Add a component to the scene.
  36852. * Note that the ccomponent could be registered on th next frame if this is called after
  36853. * the register component stage.
  36854. * @param component Defines the component to add to the scene
  36855. */
  36856. _addComponent(component: ISceneComponent): void;
  36857. /**
  36858. * @hidden
  36859. * Gets a component from the scene.
  36860. * @param name defines the name of the component to retrieve
  36861. * @returns the component or null if not present
  36862. */
  36863. _getComponent(name: string): Nullable<ISceneComponent>;
  36864. /**
  36865. * @hidden
  36866. * Defines the actions happening before camera updates.
  36867. */
  36868. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36869. /**
  36870. * @hidden
  36871. * Defines the actions happening before clear the canvas.
  36872. */
  36873. _beforeClearStage: Stage<SimpleStageAction>;
  36874. /**
  36875. * @hidden
  36876. * Defines the actions when collecting render targets for the frame.
  36877. */
  36878. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36879. /**
  36880. * @hidden
  36881. * Defines the actions happening for one camera in the frame.
  36882. */
  36883. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36884. /**
  36885. * @hidden
  36886. * Defines the actions happening during the per mesh ready checks.
  36887. */
  36888. _isReadyForMeshStage: Stage<MeshStageAction>;
  36889. /**
  36890. * @hidden
  36891. * Defines the actions happening before evaluate active mesh checks.
  36892. */
  36893. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36894. /**
  36895. * @hidden
  36896. * Defines the actions happening during the evaluate sub mesh checks.
  36897. */
  36898. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36899. /**
  36900. * @hidden
  36901. * Defines the actions happening during the active mesh stage.
  36902. */
  36903. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36904. /**
  36905. * @hidden
  36906. * Defines the actions happening during the per camera render target step.
  36907. */
  36908. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36909. /**
  36910. * @hidden
  36911. * Defines the actions happening just before the active camera is drawing.
  36912. */
  36913. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36914. /**
  36915. * @hidden
  36916. * Defines the actions happening just before a render target is drawing.
  36917. */
  36918. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36919. /**
  36920. * @hidden
  36921. * Defines the actions happening just before a rendering group is drawing.
  36922. */
  36923. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36924. /**
  36925. * @hidden
  36926. * Defines the actions happening just before a mesh is drawing.
  36927. */
  36928. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36929. /**
  36930. * @hidden
  36931. * Defines the actions happening just after a mesh has been drawn.
  36932. */
  36933. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36934. /**
  36935. * @hidden
  36936. * Defines the actions happening just after a rendering group has been drawn.
  36937. */
  36938. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36939. /**
  36940. * @hidden
  36941. * Defines the actions happening just after the active camera has been drawn.
  36942. */
  36943. _afterCameraDrawStage: Stage<CameraStageAction>;
  36944. /**
  36945. * @hidden
  36946. * Defines the actions happening just after a render target has been drawn.
  36947. */
  36948. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36949. /**
  36950. * @hidden
  36951. * Defines the actions happening just after rendering all cameras and computing intersections.
  36952. */
  36953. _afterRenderStage: Stage<SimpleStageAction>;
  36954. /**
  36955. * @hidden
  36956. * Defines the actions happening when a pointer move event happens.
  36957. */
  36958. _pointerMoveStage: Stage<PointerMoveStageAction>;
  36959. /**
  36960. * @hidden
  36961. * Defines the actions happening when a pointer down event happens.
  36962. */
  36963. _pointerDownStage: Stage<PointerUpDownStageAction>;
  36964. /**
  36965. * @hidden
  36966. * Defines the actions happening when a pointer up event happens.
  36967. */
  36968. _pointerUpStage: Stage<PointerUpDownStageAction>;
  36969. /**
  36970. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  36971. */
  36972. private geometriesByUniqueId;
  36973. /**
  36974. * Creates a new Scene
  36975. * @param engine defines the engine to use to render this scene
  36976. * @param options defines the scene options
  36977. */
  36978. constructor(engine: Engine, options?: SceneOptions);
  36979. /**
  36980. * Gets a string idenfifying the name of the class
  36981. * @returns "Scene" string
  36982. */
  36983. getClassName(): string;
  36984. private _defaultMeshCandidates;
  36985. /**
  36986. * @hidden
  36987. */
  36988. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  36989. private _defaultSubMeshCandidates;
  36990. /**
  36991. * @hidden
  36992. */
  36993. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  36994. /**
  36995. * Sets the default candidate providers for the scene.
  36996. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  36997. * and getCollidingSubMeshCandidates to their default function
  36998. */
  36999. setDefaultCandidateProviders(): void;
  37000. /**
  37001. * Gets the mesh that is currently under the pointer
  37002. */
  37003. get meshUnderPointer(): Nullable<AbstractMesh>;
  37004. /**
  37005. * Gets or sets the current on-screen X position of the pointer
  37006. */
  37007. get pointerX(): number;
  37008. set pointerX(value: number);
  37009. /**
  37010. * Gets or sets the current on-screen Y position of the pointer
  37011. */
  37012. get pointerY(): number;
  37013. set pointerY(value: number);
  37014. /**
  37015. * Gets the cached material (ie. the latest rendered one)
  37016. * @returns the cached material
  37017. */
  37018. getCachedMaterial(): Nullable<Material>;
  37019. /**
  37020. * Gets the cached effect (ie. the latest rendered one)
  37021. * @returns the cached effect
  37022. */
  37023. getCachedEffect(): Nullable<Effect>;
  37024. /**
  37025. * Gets the cached visibility state (ie. the latest rendered one)
  37026. * @returns the cached visibility state
  37027. */
  37028. getCachedVisibility(): Nullable<number>;
  37029. /**
  37030. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37031. * @param material defines the current material
  37032. * @param effect defines the current effect
  37033. * @param visibility defines the current visibility state
  37034. * @returns true if one parameter is not cached
  37035. */
  37036. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37037. /**
  37038. * Gets the engine associated with the scene
  37039. * @returns an Engine
  37040. */
  37041. getEngine(): Engine;
  37042. /**
  37043. * Gets the total number of vertices rendered per frame
  37044. * @returns the total number of vertices rendered per frame
  37045. */
  37046. getTotalVertices(): number;
  37047. /**
  37048. * Gets the performance counter for total vertices
  37049. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37050. */
  37051. get totalVerticesPerfCounter(): PerfCounter;
  37052. /**
  37053. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37054. * @returns the total number of active indices rendered per frame
  37055. */
  37056. getActiveIndices(): number;
  37057. /**
  37058. * Gets the performance counter for active indices
  37059. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37060. */
  37061. get totalActiveIndicesPerfCounter(): PerfCounter;
  37062. /**
  37063. * Gets the total number of active particles rendered per frame
  37064. * @returns the total number of active particles rendered per frame
  37065. */
  37066. getActiveParticles(): number;
  37067. /**
  37068. * Gets the performance counter for active particles
  37069. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37070. */
  37071. get activeParticlesPerfCounter(): PerfCounter;
  37072. /**
  37073. * Gets the total number of active bones rendered per frame
  37074. * @returns the total number of active bones rendered per frame
  37075. */
  37076. getActiveBones(): number;
  37077. /**
  37078. * Gets the performance counter for active bones
  37079. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37080. */
  37081. get activeBonesPerfCounter(): PerfCounter;
  37082. /**
  37083. * Gets the array of active meshes
  37084. * @returns an array of AbstractMesh
  37085. */
  37086. getActiveMeshes(): SmartArray<AbstractMesh>;
  37087. /**
  37088. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37089. * @returns a number
  37090. */
  37091. getAnimationRatio(): number;
  37092. /**
  37093. * Gets an unique Id for the current render phase
  37094. * @returns a number
  37095. */
  37096. getRenderId(): number;
  37097. /**
  37098. * Gets an unique Id for the current frame
  37099. * @returns a number
  37100. */
  37101. getFrameId(): number;
  37102. /** Call this function if you want to manually increment the render Id*/
  37103. incrementRenderId(): void;
  37104. private _createUbo;
  37105. /**
  37106. * Use this method to simulate a pointer move on a mesh
  37107. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37108. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37109. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37110. * @returns the current scene
  37111. */
  37112. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37113. /**
  37114. * Use this method to simulate a pointer down on a mesh
  37115. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37116. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37117. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37118. * @returns the current scene
  37119. */
  37120. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37121. /**
  37122. * Use this method to simulate a pointer up on a mesh
  37123. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37124. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37125. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37126. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37127. * @returns the current scene
  37128. */
  37129. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37130. /**
  37131. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37132. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37133. * @returns true if the pointer was captured
  37134. */
  37135. isPointerCaptured(pointerId?: number): boolean;
  37136. /**
  37137. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37138. * @param attachUp defines if you want to attach events to pointerup
  37139. * @param attachDown defines if you want to attach events to pointerdown
  37140. * @param attachMove defines if you want to attach events to pointermove
  37141. */
  37142. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37143. /** Detaches all event handlers*/
  37144. detachControl(): void;
  37145. /**
  37146. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37147. * Delay loaded resources are not taking in account
  37148. * @return true if all required resources are ready
  37149. */
  37150. isReady(): boolean;
  37151. /** Resets all cached information relative to material (including effect and visibility) */
  37152. resetCachedMaterial(): void;
  37153. /**
  37154. * Registers a function to be called before every frame render
  37155. * @param func defines the function to register
  37156. */
  37157. registerBeforeRender(func: () => void): void;
  37158. /**
  37159. * Unregisters a function called before every frame render
  37160. * @param func defines the function to unregister
  37161. */
  37162. unregisterBeforeRender(func: () => void): void;
  37163. /**
  37164. * Registers a function to be called after every frame render
  37165. * @param func defines the function to register
  37166. */
  37167. registerAfterRender(func: () => void): void;
  37168. /**
  37169. * Unregisters a function called after every frame render
  37170. * @param func defines the function to unregister
  37171. */
  37172. unregisterAfterRender(func: () => void): void;
  37173. private _executeOnceBeforeRender;
  37174. /**
  37175. * The provided function will run before render once and will be disposed afterwards.
  37176. * A timeout delay can be provided so that the function will be executed in N ms.
  37177. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37178. * @param func The function to be executed.
  37179. * @param timeout optional delay in ms
  37180. */
  37181. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37182. /** @hidden */
  37183. _addPendingData(data: any): void;
  37184. /** @hidden */
  37185. _removePendingData(data: any): void;
  37186. /**
  37187. * Returns the number of items waiting to be loaded
  37188. * @returns the number of items waiting to be loaded
  37189. */
  37190. getWaitingItemsCount(): number;
  37191. /**
  37192. * Returns a boolean indicating if the scene is still loading data
  37193. */
  37194. get isLoading(): boolean;
  37195. /**
  37196. * Registers a function to be executed when the scene is ready
  37197. * @param {Function} func - the function to be executed
  37198. */
  37199. executeWhenReady(func: () => void): void;
  37200. /**
  37201. * Returns a promise that resolves when the scene is ready
  37202. * @returns A promise that resolves when the scene is ready
  37203. */
  37204. whenReadyAsync(): Promise<void>;
  37205. /** @hidden */
  37206. _checkIsReady(): void;
  37207. /**
  37208. * Gets all animatable attached to the scene
  37209. */
  37210. get animatables(): Animatable[];
  37211. /**
  37212. * Resets the last animation time frame.
  37213. * Useful to override when animations start running when loading a scene for the first time.
  37214. */
  37215. resetLastAnimationTimeFrame(): void;
  37216. /**
  37217. * Gets the current view matrix
  37218. * @returns a Matrix
  37219. */
  37220. getViewMatrix(): Matrix;
  37221. /**
  37222. * Gets the current projection matrix
  37223. * @returns a Matrix
  37224. */
  37225. getProjectionMatrix(): Matrix;
  37226. /**
  37227. * Gets the current transform matrix
  37228. * @returns a Matrix made of View * Projection
  37229. */
  37230. getTransformMatrix(): Matrix;
  37231. /**
  37232. * Sets the current transform matrix
  37233. * @param viewL defines the View matrix to use
  37234. * @param projectionL defines the Projection matrix to use
  37235. * @param viewR defines the right View matrix to use (if provided)
  37236. * @param projectionR defines the right Projection matrix to use (if provided)
  37237. */
  37238. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37239. /**
  37240. * Gets the uniform buffer used to store scene data
  37241. * @returns a UniformBuffer
  37242. */
  37243. getSceneUniformBuffer(): UniformBuffer;
  37244. /**
  37245. * Gets an unique (relatively to the current scene) Id
  37246. * @returns an unique number for the scene
  37247. */
  37248. getUniqueId(): number;
  37249. /**
  37250. * Add a mesh to the list of scene's meshes
  37251. * @param newMesh defines the mesh to add
  37252. * @param recursive if all child meshes should also be added to the scene
  37253. */
  37254. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37255. /**
  37256. * Remove a mesh for the list of scene's meshes
  37257. * @param toRemove defines the mesh to remove
  37258. * @param recursive if all child meshes should also be removed from the scene
  37259. * @returns the index where the mesh was in the mesh list
  37260. */
  37261. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37262. /**
  37263. * Add a transform node to the list of scene's transform nodes
  37264. * @param newTransformNode defines the transform node to add
  37265. */
  37266. addTransformNode(newTransformNode: TransformNode): void;
  37267. /**
  37268. * Remove a transform node for the list of scene's transform nodes
  37269. * @param toRemove defines the transform node to remove
  37270. * @returns the index where the transform node was in the transform node list
  37271. */
  37272. removeTransformNode(toRemove: TransformNode): number;
  37273. /**
  37274. * Remove a skeleton for the list of scene's skeletons
  37275. * @param toRemove defines the skeleton to remove
  37276. * @returns the index where the skeleton was in the skeleton list
  37277. */
  37278. removeSkeleton(toRemove: Skeleton): number;
  37279. /**
  37280. * Remove a morph target for the list of scene's morph targets
  37281. * @param toRemove defines the morph target to remove
  37282. * @returns the index where the morph target was in the morph target list
  37283. */
  37284. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37285. /**
  37286. * Remove a light for the list of scene's lights
  37287. * @param toRemove defines the light to remove
  37288. * @returns the index where the light was in the light list
  37289. */
  37290. removeLight(toRemove: Light): number;
  37291. /**
  37292. * Remove a camera for the list of scene's cameras
  37293. * @param toRemove defines the camera to remove
  37294. * @returns the index where the camera was in the camera list
  37295. */
  37296. removeCamera(toRemove: Camera): number;
  37297. /**
  37298. * Remove a particle system for the list of scene's particle systems
  37299. * @param toRemove defines the particle system to remove
  37300. * @returns the index where the particle system was in the particle system list
  37301. */
  37302. removeParticleSystem(toRemove: IParticleSystem): number;
  37303. /**
  37304. * Remove a animation for the list of scene's animations
  37305. * @param toRemove defines the animation to remove
  37306. * @returns the index where the animation was in the animation list
  37307. */
  37308. removeAnimation(toRemove: Animation): number;
  37309. /**
  37310. * Will stop the animation of the given target
  37311. * @param target - the target
  37312. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37313. * @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)
  37314. */
  37315. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37316. /**
  37317. * Removes the given animation group from this scene.
  37318. * @param toRemove The animation group to remove
  37319. * @returns The index of the removed animation group
  37320. */
  37321. removeAnimationGroup(toRemove: AnimationGroup): number;
  37322. /**
  37323. * Removes the given multi-material from this scene.
  37324. * @param toRemove The multi-material to remove
  37325. * @returns The index of the removed multi-material
  37326. */
  37327. removeMultiMaterial(toRemove: MultiMaterial): number;
  37328. /**
  37329. * Removes the given material from this scene.
  37330. * @param toRemove The material to remove
  37331. * @returns The index of the removed material
  37332. */
  37333. removeMaterial(toRemove: Material): number;
  37334. /**
  37335. * Removes the given action manager from this scene.
  37336. * @param toRemove The action manager to remove
  37337. * @returns The index of the removed action manager
  37338. */
  37339. removeActionManager(toRemove: AbstractActionManager): number;
  37340. /**
  37341. * Removes the given texture from this scene.
  37342. * @param toRemove The texture to remove
  37343. * @returns The index of the removed texture
  37344. */
  37345. removeTexture(toRemove: BaseTexture): number;
  37346. /**
  37347. * Adds the given light to this scene
  37348. * @param newLight The light to add
  37349. */
  37350. addLight(newLight: Light): void;
  37351. /**
  37352. * Sorts the list list based on light priorities
  37353. */
  37354. sortLightsByPriority(): void;
  37355. /**
  37356. * Adds the given camera to this scene
  37357. * @param newCamera The camera to add
  37358. */
  37359. addCamera(newCamera: Camera): void;
  37360. /**
  37361. * Adds the given skeleton to this scene
  37362. * @param newSkeleton The skeleton to add
  37363. */
  37364. addSkeleton(newSkeleton: Skeleton): void;
  37365. /**
  37366. * Adds the given particle system to this scene
  37367. * @param newParticleSystem The particle system to add
  37368. */
  37369. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37370. /**
  37371. * Adds the given animation to this scene
  37372. * @param newAnimation The animation to add
  37373. */
  37374. addAnimation(newAnimation: Animation): void;
  37375. /**
  37376. * Adds the given animation group to this scene.
  37377. * @param newAnimationGroup The animation group to add
  37378. */
  37379. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37380. /**
  37381. * Adds the given multi-material to this scene
  37382. * @param newMultiMaterial The multi-material to add
  37383. */
  37384. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37385. /**
  37386. * Adds the given material to this scene
  37387. * @param newMaterial The material to add
  37388. */
  37389. addMaterial(newMaterial: Material): void;
  37390. /**
  37391. * Adds the given morph target to this scene
  37392. * @param newMorphTargetManager The morph target to add
  37393. */
  37394. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37395. /**
  37396. * Adds the given geometry to this scene
  37397. * @param newGeometry The geometry to add
  37398. */
  37399. addGeometry(newGeometry: Geometry): void;
  37400. /**
  37401. * Adds the given action manager to this scene
  37402. * @param newActionManager The action manager to add
  37403. */
  37404. addActionManager(newActionManager: AbstractActionManager): void;
  37405. /**
  37406. * Adds the given texture to this scene.
  37407. * @param newTexture The texture to add
  37408. */
  37409. addTexture(newTexture: BaseTexture): void;
  37410. /**
  37411. * Switch active camera
  37412. * @param newCamera defines the new active camera
  37413. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37414. */
  37415. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37416. /**
  37417. * sets the active camera of the scene using its ID
  37418. * @param id defines the camera's ID
  37419. * @return the new active camera or null if none found.
  37420. */
  37421. setActiveCameraByID(id: string): Nullable<Camera>;
  37422. /**
  37423. * sets the active camera of the scene using its name
  37424. * @param name defines the camera's name
  37425. * @returns the new active camera or null if none found.
  37426. */
  37427. setActiveCameraByName(name: string): Nullable<Camera>;
  37428. /**
  37429. * get an animation group using its name
  37430. * @param name defines the material's name
  37431. * @return the animation group or null if none found.
  37432. */
  37433. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37434. /**
  37435. * Get a material using its unique id
  37436. * @param uniqueId defines the material's unique id
  37437. * @return the material or null if none found.
  37438. */
  37439. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37440. /**
  37441. * get a material using its id
  37442. * @param id defines the material's ID
  37443. * @return the material or null if none found.
  37444. */
  37445. getMaterialByID(id: string): Nullable<Material>;
  37446. /**
  37447. * Gets a the last added material using a given id
  37448. * @param id defines the material's ID
  37449. * @return the last material with the given id or null if none found.
  37450. */
  37451. getLastMaterialByID(id: string): Nullable<Material>;
  37452. /**
  37453. * Gets a material using its name
  37454. * @param name defines the material's name
  37455. * @return the material or null if none found.
  37456. */
  37457. getMaterialByName(name: string): Nullable<Material>;
  37458. /**
  37459. * Get a texture using its unique id
  37460. * @param uniqueId defines the texture's unique id
  37461. * @return the texture or null if none found.
  37462. */
  37463. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37464. /**
  37465. * Gets a camera using its id
  37466. * @param id defines the id to look for
  37467. * @returns the camera or null if not found
  37468. */
  37469. getCameraByID(id: string): Nullable<Camera>;
  37470. /**
  37471. * Gets a camera using its unique id
  37472. * @param uniqueId defines the unique id to look for
  37473. * @returns the camera or null if not found
  37474. */
  37475. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37476. /**
  37477. * Gets a camera using its name
  37478. * @param name defines the camera's name
  37479. * @return the camera or null if none found.
  37480. */
  37481. getCameraByName(name: string): Nullable<Camera>;
  37482. /**
  37483. * Gets a bone using its id
  37484. * @param id defines the bone's id
  37485. * @return the bone or null if not found
  37486. */
  37487. getBoneByID(id: string): Nullable<Bone>;
  37488. /**
  37489. * Gets a bone using its id
  37490. * @param name defines the bone's name
  37491. * @return the bone or null if not found
  37492. */
  37493. getBoneByName(name: string): Nullable<Bone>;
  37494. /**
  37495. * Gets a light node using its name
  37496. * @param name defines the the light's name
  37497. * @return the light or null if none found.
  37498. */
  37499. getLightByName(name: string): Nullable<Light>;
  37500. /**
  37501. * Gets a light node using its id
  37502. * @param id defines the light's id
  37503. * @return the light or null if none found.
  37504. */
  37505. getLightByID(id: string): Nullable<Light>;
  37506. /**
  37507. * Gets a light node using its scene-generated unique ID
  37508. * @param uniqueId defines the light's unique id
  37509. * @return the light or null if none found.
  37510. */
  37511. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37512. /**
  37513. * Gets a particle system by id
  37514. * @param id defines the particle system id
  37515. * @return the corresponding system or null if none found
  37516. */
  37517. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37518. /**
  37519. * Gets a geometry using its ID
  37520. * @param id defines the geometry's id
  37521. * @return the geometry or null if none found.
  37522. */
  37523. getGeometryByID(id: string): Nullable<Geometry>;
  37524. private _getGeometryByUniqueID;
  37525. /**
  37526. * Add a new geometry to this scene
  37527. * @param geometry defines the geometry to be added to the scene.
  37528. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37529. * @return a boolean defining if the geometry was added or not
  37530. */
  37531. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37532. /**
  37533. * Removes an existing geometry
  37534. * @param geometry defines the geometry to be removed from the scene
  37535. * @return a boolean defining if the geometry was removed or not
  37536. */
  37537. removeGeometry(geometry: Geometry): boolean;
  37538. /**
  37539. * Gets the list of geometries attached to the scene
  37540. * @returns an array of Geometry
  37541. */
  37542. getGeometries(): Geometry[];
  37543. /**
  37544. * Gets the first added mesh found of a given ID
  37545. * @param id defines the id to search for
  37546. * @return the mesh found or null if not found at all
  37547. */
  37548. getMeshByID(id: string): Nullable<AbstractMesh>;
  37549. /**
  37550. * Gets a list of meshes using their id
  37551. * @param id defines the id to search for
  37552. * @returns a list of meshes
  37553. */
  37554. getMeshesByID(id: string): Array<AbstractMesh>;
  37555. /**
  37556. * Gets the first added transform node found of a given ID
  37557. * @param id defines the id to search for
  37558. * @return the found transform node or null if not found at all.
  37559. */
  37560. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37561. /**
  37562. * Gets a transform node with its auto-generated unique id
  37563. * @param uniqueId efines the unique id to search for
  37564. * @return the found transform node or null if not found at all.
  37565. */
  37566. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37567. /**
  37568. * Gets a list of transform nodes using their id
  37569. * @param id defines the id to search for
  37570. * @returns a list of transform nodes
  37571. */
  37572. getTransformNodesByID(id: string): Array<TransformNode>;
  37573. /**
  37574. * Gets a mesh with its auto-generated unique id
  37575. * @param uniqueId defines the unique id to search for
  37576. * @return the found mesh or null if not found at all.
  37577. */
  37578. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37579. /**
  37580. * Gets a the last added mesh using a given id
  37581. * @param id defines the id to search for
  37582. * @return the found mesh or null if not found at all.
  37583. */
  37584. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37585. /**
  37586. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37587. * @param id defines the id to search for
  37588. * @return the found node or null if not found at all
  37589. */
  37590. getLastEntryByID(id: string): Nullable<Node>;
  37591. /**
  37592. * Gets a node (Mesh, Camera, Light) using a given id
  37593. * @param id defines the id to search for
  37594. * @return the found node or null if not found at all
  37595. */
  37596. getNodeByID(id: string): Nullable<Node>;
  37597. /**
  37598. * Gets a node (Mesh, Camera, Light) using a given name
  37599. * @param name defines the name to search for
  37600. * @return the found node or null if not found at all.
  37601. */
  37602. getNodeByName(name: string): Nullable<Node>;
  37603. /**
  37604. * Gets a mesh using a given name
  37605. * @param name defines the name to search for
  37606. * @return the found mesh or null if not found at all.
  37607. */
  37608. getMeshByName(name: string): Nullable<AbstractMesh>;
  37609. /**
  37610. * Gets a transform node using a given name
  37611. * @param name defines the name to search for
  37612. * @return the found transform node or null if not found at all.
  37613. */
  37614. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37615. /**
  37616. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37617. * @param id defines the id to search for
  37618. * @return the found skeleton or null if not found at all.
  37619. */
  37620. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37621. /**
  37622. * Gets a skeleton using a given auto generated unique id
  37623. * @param uniqueId defines the unique id to search for
  37624. * @return the found skeleton or null if not found at all.
  37625. */
  37626. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37627. /**
  37628. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37629. * @param id defines the id to search for
  37630. * @return the found skeleton or null if not found at all.
  37631. */
  37632. getSkeletonById(id: string): Nullable<Skeleton>;
  37633. /**
  37634. * Gets a skeleton using a given name
  37635. * @param name defines the name to search for
  37636. * @return the found skeleton or null if not found at all.
  37637. */
  37638. getSkeletonByName(name: string): Nullable<Skeleton>;
  37639. /**
  37640. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37641. * @param id defines the id to search for
  37642. * @return the found morph target manager or null if not found at all.
  37643. */
  37644. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37645. /**
  37646. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37647. * @param id defines the id to search for
  37648. * @return the found morph target or null if not found at all.
  37649. */
  37650. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37651. /**
  37652. * Gets a boolean indicating if the given mesh is active
  37653. * @param mesh defines the mesh to look for
  37654. * @returns true if the mesh is in the active list
  37655. */
  37656. isActiveMesh(mesh: AbstractMesh): boolean;
  37657. /**
  37658. * Return a unique id as a string which can serve as an identifier for the scene
  37659. */
  37660. get uid(): string;
  37661. /**
  37662. * Add an externaly attached data from its key.
  37663. * This method call will fail and return false, if such key already exists.
  37664. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37665. * @param key the unique key that identifies the data
  37666. * @param data the data object to associate to the key for this Engine instance
  37667. * @return true if no such key were already present and the data was added successfully, false otherwise
  37668. */
  37669. addExternalData<T>(key: string, data: T): boolean;
  37670. /**
  37671. * Get an externaly attached data from its key
  37672. * @param key the unique key that identifies the data
  37673. * @return the associated data, if present (can be null), or undefined if not present
  37674. */
  37675. getExternalData<T>(key: string): Nullable<T>;
  37676. /**
  37677. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37678. * @param key the unique key that identifies the data
  37679. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37680. * @return the associated data, can be null if the factory returned null.
  37681. */
  37682. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37683. /**
  37684. * Remove an externaly attached data from the Engine instance
  37685. * @param key the unique key that identifies the data
  37686. * @return true if the data was successfully removed, false if it doesn't exist
  37687. */
  37688. removeExternalData(key: string): boolean;
  37689. private _evaluateSubMesh;
  37690. /**
  37691. * Clear the processed materials smart array preventing retention point in material dispose.
  37692. */
  37693. freeProcessedMaterials(): void;
  37694. private _preventFreeActiveMeshesAndRenderingGroups;
  37695. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37696. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37697. * when disposing several meshes in a row or a hierarchy of meshes.
  37698. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37699. */
  37700. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37701. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37702. /**
  37703. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37704. */
  37705. freeActiveMeshes(): void;
  37706. /**
  37707. * Clear the info related to rendering groups preventing retention points during dispose.
  37708. */
  37709. freeRenderingGroups(): void;
  37710. /** @hidden */
  37711. _isInIntermediateRendering(): boolean;
  37712. /**
  37713. * Lambda returning the list of potentially active meshes.
  37714. */
  37715. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37716. /**
  37717. * Lambda returning the list of potentially active sub meshes.
  37718. */
  37719. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37720. /**
  37721. * Lambda returning the list of potentially intersecting sub meshes.
  37722. */
  37723. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37724. /**
  37725. * Lambda returning the list of potentially colliding sub meshes.
  37726. */
  37727. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37728. private _activeMeshesFrozen;
  37729. private _skipEvaluateActiveMeshesCompletely;
  37730. /**
  37731. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37732. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37733. * @returns the current scene
  37734. */
  37735. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37736. /**
  37737. * Use this function to restart evaluating active meshes on every frame
  37738. * @returns the current scene
  37739. */
  37740. unfreezeActiveMeshes(): Scene;
  37741. private _evaluateActiveMeshes;
  37742. private _activeMesh;
  37743. /**
  37744. * Update the transform matrix to update from the current active camera
  37745. * @param force defines a boolean used to force the update even if cache is up to date
  37746. */
  37747. updateTransformMatrix(force?: boolean): void;
  37748. private _bindFrameBuffer;
  37749. /** @hidden */
  37750. _allowPostProcessClearColor: boolean;
  37751. /** @hidden */
  37752. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37753. private _processSubCameras;
  37754. private _checkIntersections;
  37755. /** @hidden */
  37756. _advancePhysicsEngineStep(step: number): void;
  37757. /**
  37758. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37759. */
  37760. getDeterministicFrameTime: () => number;
  37761. /** @hidden */
  37762. _animate(): void;
  37763. /** Execute all animations (for a frame) */
  37764. animate(): void;
  37765. /**
  37766. * Render the scene
  37767. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37768. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37769. */
  37770. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37771. /**
  37772. * Freeze all materials
  37773. * A frozen material will not be updatable but should be faster to render
  37774. */
  37775. freezeMaterials(): void;
  37776. /**
  37777. * Unfreeze all materials
  37778. * A frozen material will not be updatable but should be faster to render
  37779. */
  37780. unfreezeMaterials(): void;
  37781. /**
  37782. * Releases all held ressources
  37783. */
  37784. dispose(): void;
  37785. /**
  37786. * Gets if the scene is already disposed
  37787. */
  37788. get isDisposed(): boolean;
  37789. /**
  37790. * Call this function to reduce memory footprint of the scene.
  37791. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37792. */
  37793. clearCachedVertexData(): void;
  37794. /**
  37795. * This function will remove the local cached buffer data from texture.
  37796. * It will save memory but will prevent the texture from being rebuilt
  37797. */
  37798. cleanCachedTextureBuffer(): void;
  37799. /**
  37800. * Get the world extend vectors with an optional filter
  37801. *
  37802. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37803. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37804. */
  37805. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37806. min: Vector3;
  37807. max: Vector3;
  37808. };
  37809. /**
  37810. * Creates a ray that can be used to pick in the scene
  37811. * @param x defines the x coordinate of the origin (on-screen)
  37812. * @param y defines the y coordinate of the origin (on-screen)
  37813. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37814. * @param camera defines the camera to use for the picking
  37815. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37816. * @returns a Ray
  37817. */
  37818. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37819. /**
  37820. * Creates a ray that can be used to pick in the scene
  37821. * @param x defines the x coordinate of the origin (on-screen)
  37822. * @param y defines the y coordinate of the origin (on-screen)
  37823. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37824. * @param result defines the ray where to store the picking ray
  37825. * @param camera defines the camera to use for the picking
  37826. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37827. * @returns the current scene
  37828. */
  37829. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37830. /**
  37831. * Creates a ray that can be used to pick in the scene
  37832. * @param x defines the x coordinate of the origin (on-screen)
  37833. * @param y defines the y coordinate of the origin (on-screen)
  37834. * @param camera defines the camera to use for the picking
  37835. * @returns a Ray
  37836. */
  37837. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37838. /**
  37839. * Creates a ray that can be used to pick in the scene
  37840. * @param x defines the x coordinate of the origin (on-screen)
  37841. * @param y defines the y coordinate of the origin (on-screen)
  37842. * @param result defines the ray where to store the picking ray
  37843. * @param camera defines the camera to use for the picking
  37844. * @returns the current scene
  37845. */
  37846. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37847. /** Launch a ray to try to pick a mesh in the scene
  37848. * @param x position on screen
  37849. * @param y position on screen
  37850. * @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
  37851. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37852. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37853. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37854. * @returns a PickingInfo
  37855. */
  37856. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37857. /** Use the given ray to pick a mesh in the scene
  37858. * @param ray The ray to use to pick meshes
  37859. * @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
  37860. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37861. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37862. * @returns a PickingInfo
  37863. */
  37864. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37865. /**
  37866. * Launch a ray to try to pick a mesh in the scene
  37867. * @param x X position on screen
  37868. * @param y Y position on screen
  37869. * @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
  37870. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37871. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37872. * @returns an array of PickingInfo
  37873. */
  37874. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37875. /**
  37876. * Launch a ray to try to pick a mesh in the scene
  37877. * @param ray Ray to use
  37878. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  37879. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37880. * @returns an array of PickingInfo
  37881. */
  37882. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37883. /**
  37884. * Force the value of meshUnderPointer
  37885. * @param mesh defines the mesh to use
  37886. */
  37887. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37888. /**
  37889. * Gets the mesh under the pointer
  37890. * @returns a Mesh or null if no mesh is under the pointer
  37891. */
  37892. getPointerOverMesh(): Nullable<AbstractMesh>;
  37893. /** @hidden */
  37894. _rebuildGeometries(): void;
  37895. /** @hidden */
  37896. _rebuildTextures(): void;
  37897. private _getByTags;
  37898. /**
  37899. * Get a list of meshes by tags
  37900. * @param tagsQuery defines the tags query to use
  37901. * @param forEach defines a predicate used to filter results
  37902. * @returns an array of Mesh
  37903. */
  37904. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37905. /**
  37906. * Get a list of cameras by tags
  37907. * @param tagsQuery defines the tags query to use
  37908. * @param forEach defines a predicate used to filter results
  37909. * @returns an array of Camera
  37910. */
  37911. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37912. /**
  37913. * Get a list of lights by tags
  37914. * @param tagsQuery defines the tags query to use
  37915. * @param forEach defines a predicate used to filter results
  37916. * @returns an array of Light
  37917. */
  37918. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37919. /**
  37920. * Get a list of materials by tags
  37921. * @param tagsQuery defines the tags query to use
  37922. * @param forEach defines a predicate used to filter results
  37923. * @returns an array of Material
  37924. */
  37925. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37926. /**
  37927. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37928. * This allowed control for front to back rendering or reversly depending of the special needs.
  37929. *
  37930. * @param renderingGroupId The rendering group id corresponding to its index
  37931. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37932. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37933. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37934. */
  37935. 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;
  37936. /**
  37937. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37938. *
  37939. * @param renderingGroupId The rendering group id corresponding to its index
  37940. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37941. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37942. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37943. */
  37944. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37945. /**
  37946. * Gets the current auto clear configuration for one rendering group of the rendering
  37947. * manager.
  37948. * @param index the rendering group index to get the information for
  37949. * @returns The auto clear setup for the requested rendering group
  37950. */
  37951. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37952. private _blockMaterialDirtyMechanism;
  37953. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37954. get blockMaterialDirtyMechanism(): boolean;
  37955. set blockMaterialDirtyMechanism(value: boolean);
  37956. /**
  37957. * Will flag all materials as dirty to trigger new shader compilation
  37958. * @param flag defines the flag used to specify which material part must be marked as dirty
  37959. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  37960. */
  37961. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  37962. /** @hidden */
  37963. _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;
  37964. /** @hidden */
  37965. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37966. /** @hidden */
  37967. _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;
  37968. /** @hidden */
  37969. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  37970. /** @hidden */
  37971. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  37972. /** @hidden */
  37973. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  37974. }
  37975. }
  37976. declare module "babylonjs/assetContainer" {
  37977. import { AbstractScene } from "babylonjs/abstractScene";
  37978. import { Scene } from "babylonjs/scene";
  37979. import { Mesh } from "babylonjs/Meshes/mesh";
  37980. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37981. import { Skeleton } from "babylonjs/Bones/skeleton";
  37982. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  37983. import { Animatable } from "babylonjs/Animations/animatable";
  37984. import { Nullable } from "babylonjs/types";
  37985. import { Node } from "babylonjs/node";
  37986. /**
  37987. * Set of assets to keep when moving a scene into an asset container.
  37988. */
  37989. export class KeepAssets extends AbstractScene {
  37990. }
  37991. /**
  37992. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  37993. */
  37994. export class InstantiatedEntries {
  37995. /**
  37996. * List of new root nodes (eg. nodes with no parent)
  37997. */
  37998. rootNodes: TransformNode[];
  37999. /**
  38000. * List of new skeletons
  38001. */
  38002. skeletons: Skeleton[];
  38003. /**
  38004. * List of new animation groups
  38005. */
  38006. animationGroups: AnimationGroup[];
  38007. }
  38008. /**
  38009. * Container with a set of assets that can be added or removed from a scene.
  38010. */
  38011. export class AssetContainer extends AbstractScene {
  38012. private _wasAddedToScene;
  38013. /**
  38014. * The scene the AssetContainer belongs to.
  38015. */
  38016. scene: Scene;
  38017. /**
  38018. * Instantiates an AssetContainer.
  38019. * @param scene The scene the AssetContainer belongs to.
  38020. */
  38021. constructor(scene: Scene);
  38022. /**
  38023. * Instantiate or clone all meshes and add the new ones to the scene.
  38024. * Skeletons and animation groups will all be cloned
  38025. * @param nameFunction defines an optional function used to get new names for clones
  38026. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38027. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38028. */
  38029. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38030. /**
  38031. * Adds all the assets from the container to the scene.
  38032. */
  38033. addAllToScene(): void;
  38034. /**
  38035. * Removes all the assets in the container from the scene
  38036. */
  38037. removeAllFromScene(): void;
  38038. /**
  38039. * Disposes all the assets in the container
  38040. */
  38041. dispose(): void;
  38042. private _moveAssets;
  38043. /**
  38044. * Removes all the assets contained in the scene and adds them to the container.
  38045. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38046. */
  38047. moveAllFromScene(keepAssets?: KeepAssets): void;
  38048. /**
  38049. * 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.
  38050. * @returns the root mesh
  38051. */
  38052. createRootMesh(): Mesh;
  38053. /**
  38054. * Merge animations from this asset container into a scene
  38055. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38056. * @param animatables set of animatables to retarget to a node from the scene
  38057. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38058. */
  38059. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38060. }
  38061. }
  38062. declare module "babylonjs/abstractScene" {
  38063. import { Scene } from "babylonjs/scene";
  38064. import { Nullable } from "babylonjs/types";
  38065. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38066. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38067. import { Geometry } from "babylonjs/Meshes/geometry";
  38068. import { Skeleton } from "babylonjs/Bones/skeleton";
  38069. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38070. import { AssetContainer } from "babylonjs/assetContainer";
  38071. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38072. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38073. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38074. import { Material } from "babylonjs/Materials/material";
  38075. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38076. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38077. import { Camera } from "babylonjs/Cameras/camera";
  38078. import { Light } from "babylonjs/Lights/light";
  38079. import { Node } from "babylonjs/node";
  38080. import { Animation } from "babylonjs/Animations/animation";
  38081. /**
  38082. * Defines how the parser contract is defined.
  38083. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38084. */
  38085. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38086. /**
  38087. * Defines how the individual parser contract is defined.
  38088. * These parser can parse an individual asset
  38089. */
  38090. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38091. /**
  38092. * Base class of the scene acting as a container for the different elements composing a scene.
  38093. * This class is dynamically extended by the different components of the scene increasing
  38094. * flexibility and reducing coupling
  38095. */
  38096. export abstract class AbstractScene {
  38097. /**
  38098. * Stores the list of available parsers in the application.
  38099. */
  38100. private static _BabylonFileParsers;
  38101. /**
  38102. * Stores the list of available individual parsers in the application.
  38103. */
  38104. private static _IndividualBabylonFileParsers;
  38105. /**
  38106. * Adds a parser in the list of available ones
  38107. * @param name Defines the name of the parser
  38108. * @param parser Defines the parser to add
  38109. */
  38110. static AddParser(name: string, parser: BabylonFileParser): void;
  38111. /**
  38112. * Gets a general parser from the list of avaialble ones
  38113. * @param name Defines the name of the parser
  38114. * @returns the requested parser or null
  38115. */
  38116. static GetParser(name: string): Nullable<BabylonFileParser>;
  38117. /**
  38118. * Adds n individual parser in the list of available ones
  38119. * @param name Defines the name of the parser
  38120. * @param parser Defines the parser to add
  38121. */
  38122. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38123. /**
  38124. * Gets an individual parser from the list of avaialble ones
  38125. * @param name Defines the name of the parser
  38126. * @returns the requested parser or null
  38127. */
  38128. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38129. /**
  38130. * Parser json data and populate both a scene and its associated container object
  38131. * @param jsonData Defines the data to parse
  38132. * @param scene Defines the scene to parse the data for
  38133. * @param container Defines the container attached to the parsing sequence
  38134. * @param rootUrl Defines the root url of the data
  38135. */
  38136. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38137. /**
  38138. * Gets the list of root nodes (ie. nodes with no parent)
  38139. */
  38140. rootNodes: Node[];
  38141. /** All of the cameras added to this scene
  38142. * @see http://doc.babylonjs.com/babylon101/cameras
  38143. */
  38144. cameras: Camera[];
  38145. /**
  38146. * All of the lights added to this scene
  38147. * @see http://doc.babylonjs.com/babylon101/lights
  38148. */
  38149. lights: Light[];
  38150. /**
  38151. * All of the (abstract) meshes added to this scene
  38152. */
  38153. meshes: AbstractMesh[];
  38154. /**
  38155. * The list of skeletons added to the scene
  38156. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38157. */
  38158. skeletons: Skeleton[];
  38159. /**
  38160. * All of the particle systems added to this scene
  38161. * @see http://doc.babylonjs.com/babylon101/particles
  38162. */
  38163. particleSystems: IParticleSystem[];
  38164. /**
  38165. * Gets a list of Animations associated with the scene
  38166. */
  38167. animations: Animation[];
  38168. /**
  38169. * All of the animation groups added to this scene
  38170. * @see http://doc.babylonjs.com/how_to/group
  38171. */
  38172. animationGroups: AnimationGroup[];
  38173. /**
  38174. * All of the multi-materials added to this scene
  38175. * @see http://doc.babylonjs.com/how_to/multi_materials
  38176. */
  38177. multiMaterials: MultiMaterial[];
  38178. /**
  38179. * All of the materials added to this scene
  38180. * In the context of a Scene, it is not supposed to be modified manually.
  38181. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38182. * Note also that the order of the Material within the array is not significant and might change.
  38183. * @see http://doc.babylonjs.com/babylon101/materials
  38184. */
  38185. materials: Material[];
  38186. /**
  38187. * The list of morph target managers added to the scene
  38188. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38189. */
  38190. morphTargetManagers: MorphTargetManager[];
  38191. /**
  38192. * The list of geometries used in the scene.
  38193. */
  38194. geometries: Geometry[];
  38195. /**
  38196. * All of the tranform nodes added to this scene
  38197. * In the context of a Scene, it is not supposed to be modified manually.
  38198. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38199. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38200. * @see http://doc.babylonjs.com/how_to/transformnode
  38201. */
  38202. transformNodes: TransformNode[];
  38203. /**
  38204. * ActionManagers available on the scene.
  38205. */
  38206. actionManagers: AbstractActionManager[];
  38207. /**
  38208. * Textures to keep.
  38209. */
  38210. textures: BaseTexture[];
  38211. /**
  38212. * Environment texture for the scene
  38213. */
  38214. environmentTexture: Nullable<BaseTexture>;
  38215. /**
  38216. * @returns all meshes, lights, cameras, transformNodes and bones
  38217. */
  38218. getNodes(): Array<Node>;
  38219. }
  38220. }
  38221. declare module "babylonjs/Audio/sound" {
  38222. import { Observable } from "babylonjs/Misc/observable";
  38223. import { Vector3 } from "babylonjs/Maths/math.vector";
  38224. import { Nullable } from "babylonjs/types";
  38225. import { Scene } from "babylonjs/scene";
  38226. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38227. /**
  38228. * Interface used to define options for Sound class
  38229. */
  38230. export interface ISoundOptions {
  38231. /**
  38232. * Does the sound autoplay once loaded.
  38233. */
  38234. autoplay?: boolean;
  38235. /**
  38236. * Does the sound loop after it finishes playing once.
  38237. */
  38238. loop?: boolean;
  38239. /**
  38240. * Sound's volume
  38241. */
  38242. volume?: number;
  38243. /**
  38244. * Is it a spatial sound?
  38245. */
  38246. spatialSound?: boolean;
  38247. /**
  38248. * Maximum distance to hear that sound
  38249. */
  38250. maxDistance?: number;
  38251. /**
  38252. * Uses user defined attenuation function
  38253. */
  38254. useCustomAttenuation?: boolean;
  38255. /**
  38256. * Define the roll off factor of spatial sounds.
  38257. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38258. */
  38259. rolloffFactor?: number;
  38260. /**
  38261. * Define the reference distance the sound should be heard perfectly.
  38262. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38263. */
  38264. refDistance?: number;
  38265. /**
  38266. * Define the distance attenuation model the sound will follow.
  38267. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38268. */
  38269. distanceModel?: string;
  38270. /**
  38271. * Defines the playback speed (1 by default)
  38272. */
  38273. playbackRate?: number;
  38274. /**
  38275. * Defines if the sound is from a streaming source
  38276. */
  38277. streaming?: boolean;
  38278. /**
  38279. * Defines an optional length (in seconds) inside the sound file
  38280. */
  38281. length?: number;
  38282. /**
  38283. * Defines an optional offset (in seconds) inside the sound file
  38284. */
  38285. offset?: number;
  38286. /**
  38287. * If true, URLs will not be required to state the audio file codec to use.
  38288. */
  38289. skipCodecCheck?: boolean;
  38290. }
  38291. /**
  38292. * Defines a sound that can be played in the application.
  38293. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38294. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38295. */
  38296. export class Sound {
  38297. /**
  38298. * The name of the sound in the scene.
  38299. */
  38300. name: string;
  38301. /**
  38302. * Does the sound autoplay once loaded.
  38303. */
  38304. autoplay: boolean;
  38305. /**
  38306. * Does the sound loop after it finishes playing once.
  38307. */
  38308. loop: boolean;
  38309. /**
  38310. * Does the sound use a custom attenuation curve to simulate the falloff
  38311. * happening when the source gets further away from the camera.
  38312. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38313. */
  38314. useCustomAttenuation: boolean;
  38315. /**
  38316. * The sound track id this sound belongs to.
  38317. */
  38318. soundTrackId: number;
  38319. /**
  38320. * Is this sound currently played.
  38321. */
  38322. isPlaying: boolean;
  38323. /**
  38324. * Is this sound currently paused.
  38325. */
  38326. isPaused: boolean;
  38327. /**
  38328. * Does this sound enables spatial sound.
  38329. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38330. */
  38331. spatialSound: boolean;
  38332. /**
  38333. * Define the reference distance the sound should be heard perfectly.
  38334. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38335. */
  38336. refDistance: number;
  38337. /**
  38338. * Define the roll off factor of spatial sounds.
  38339. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38340. */
  38341. rolloffFactor: number;
  38342. /**
  38343. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38344. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38345. */
  38346. maxDistance: number;
  38347. /**
  38348. * Define the distance attenuation model the sound will follow.
  38349. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38350. */
  38351. distanceModel: string;
  38352. /**
  38353. * @hidden
  38354. * Back Compat
  38355. **/
  38356. onended: () => any;
  38357. /**
  38358. * Observable event when the current playing sound finishes.
  38359. */
  38360. onEndedObservable: Observable<Sound>;
  38361. private _panningModel;
  38362. private _playbackRate;
  38363. private _streaming;
  38364. private _startTime;
  38365. private _startOffset;
  38366. private _position;
  38367. /** @hidden */
  38368. _positionInEmitterSpace: boolean;
  38369. private _localDirection;
  38370. private _volume;
  38371. private _isReadyToPlay;
  38372. private _isDirectional;
  38373. private _readyToPlayCallback;
  38374. private _audioBuffer;
  38375. private _soundSource;
  38376. private _streamingSource;
  38377. private _soundPanner;
  38378. private _soundGain;
  38379. private _inputAudioNode;
  38380. private _outputAudioNode;
  38381. private _coneInnerAngle;
  38382. private _coneOuterAngle;
  38383. private _coneOuterGain;
  38384. private _scene;
  38385. private _connectedTransformNode;
  38386. private _customAttenuationFunction;
  38387. private _registerFunc;
  38388. private _isOutputConnected;
  38389. private _htmlAudioElement;
  38390. private _urlType;
  38391. private _length?;
  38392. private _offset?;
  38393. /** @hidden */
  38394. static _SceneComponentInitialization: (scene: Scene) => void;
  38395. /**
  38396. * Create a sound and attach it to a scene
  38397. * @param name Name of your sound
  38398. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38399. * @param scene defines the scene the sound belongs to
  38400. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38401. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38402. */
  38403. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38404. /**
  38405. * Release the sound and its associated resources
  38406. */
  38407. dispose(): void;
  38408. /**
  38409. * Gets if the sounds is ready to be played or not.
  38410. * @returns true if ready, otherwise false
  38411. */
  38412. isReady(): boolean;
  38413. private _soundLoaded;
  38414. /**
  38415. * Sets the data of the sound from an audiobuffer
  38416. * @param audioBuffer The audioBuffer containing the data
  38417. */
  38418. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38419. /**
  38420. * Updates the current sounds options such as maxdistance, loop...
  38421. * @param options A JSON object containing values named as the object properties
  38422. */
  38423. updateOptions(options: ISoundOptions): void;
  38424. private _createSpatialParameters;
  38425. private _updateSpatialParameters;
  38426. /**
  38427. * Switch the panning model to HRTF:
  38428. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38429. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38430. */
  38431. switchPanningModelToHRTF(): void;
  38432. /**
  38433. * Switch the panning model to Equal Power:
  38434. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38435. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38436. */
  38437. switchPanningModelToEqualPower(): void;
  38438. private _switchPanningModel;
  38439. /**
  38440. * Connect this sound to a sound track audio node like gain...
  38441. * @param soundTrackAudioNode the sound track audio node to connect to
  38442. */
  38443. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38444. /**
  38445. * Transform this sound into a directional source
  38446. * @param coneInnerAngle Size of the inner cone in degree
  38447. * @param coneOuterAngle Size of the outer cone in degree
  38448. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38449. */
  38450. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38451. /**
  38452. * Gets or sets the inner angle for the directional cone.
  38453. */
  38454. get directionalConeInnerAngle(): number;
  38455. /**
  38456. * Gets or sets the inner angle for the directional cone.
  38457. */
  38458. set directionalConeInnerAngle(value: number);
  38459. /**
  38460. * Gets or sets the outer angle for the directional cone.
  38461. */
  38462. get directionalConeOuterAngle(): number;
  38463. /**
  38464. * Gets or sets the outer angle for the directional cone.
  38465. */
  38466. set directionalConeOuterAngle(value: number);
  38467. /**
  38468. * Sets the position of the emitter if spatial sound is enabled
  38469. * @param newPosition Defines the new posisiton
  38470. */
  38471. setPosition(newPosition: Vector3): void;
  38472. /**
  38473. * Sets the local direction of the emitter if spatial sound is enabled
  38474. * @param newLocalDirection Defines the new local direction
  38475. */
  38476. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38477. private _updateDirection;
  38478. /** @hidden */
  38479. updateDistanceFromListener(): void;
  38480. /**
  38481. * Sets a new custom attenuation function for the sound.
  38482. * @param callback Defines the function used for the attenuation
  38483. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38484. */
  38485. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38486. /**
  38487. * Play the sound
  38488. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38489. * @param offset (optional) Start the sound at a specific time in seconds
  38490. * @param length (optional) Sound duration (in seconds)
  38491. */
  38492. play(time?: number, offset?: number, length?: number): void;
  38493. private _onended;
  38494. /**
  38495. * Stop the sound
  38496. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38497. */
  38498. stop(time?: number): void;
  38499. /**
  38500. * Put the sound in pause
  38501. */
  38502. pause(): void;
  38503. /**
  38504. * Sets a dedicated volume for this sounds
  38505. * @param newVolume Define the new volume of the sound
  38506. * @param time Define time for gradual change to new volume
  38507. */
  38508. setVolume(newVolume: number, time?: number): void;
  38509. /**
  38510. * Set the sound play back rate
  38511. * @param newPlaybackRate Define the playback rate the sound should be played at
  38512. */
  38513. setPlaybackRate(newPlaybackRate: number): void;
  38514. /**
  38515. * Gets the volume of the sound.
  38516. * @returns the volume of the sound
  38517. */
  38518. getVolume(): number;
  38519. /**
  38520. * Attach the sound to a dedicated mesh
  38521. * @param transformNode The transform node to connect the sound with
  38522. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38523. */
  38524. attachToMesh(transformNode: TransformNode): void;
  38525. /**
  38526. * Detach the sound from the previously attached mesh
  38527. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38528. */
  38529. detachFromMesh(): void;
  38530. private _onRegisterAfterWorldMatrixUpdate;
  38531. /**
  38532. * Clone the current sound in the scene.
  38533. * @returns the new sound clone
  38534. */
  38535. clone(): Nullable<Sound>;
  38536. /**
  38537. * Gets the current underlying audio buffer containing the data
  38538. * @returns the audio buffer
  38539. */
  38540. getAudioBuffer(): Nullable<AudioBuffer>;
  38541. /**
  38542. * Serializes the Sound in a JSON representation
  38543. * @returns the JSON representation of the sound
  38544. */
  38545. serialize(): any;
  38546. /**
  38547. * Parse a JSON representation of a sound to innstantiate in a given scene
  38548. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38549. * @param scene Define the scene the new parsed sound should be created in
  38550. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38551. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38552. * @returns the newly parsed sound
  38553. */
  38554. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38555. }
  38556. }
  38557. declare module "babylonjs/Actions/directAudioActions" {
  38558. import { Action } from "babylonjs/Actions/action";
  38559. import { Condition } from "babylonjs/Actions/condition";
  38560. import { Sound } from "babylonjs/Audio/sound";
  38561. /**
  38562. * This defines an action helpful to play a defined sound on a triggered action.
  38563. */
  38564. export class PlaySoundAction extends Action {
  38565. private _sound;
  38566. /**
  38567. * Instantiate the action
  38568. * @param triggerOptions defines the trigger options
  38569. * @param sound defines the sound to play
  38570. * @param condition defines the trigger related conditions
  38571. */
  38572. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38573. /** @hidden */
  38574. _prepare(): void;
  38575. /**
  38576. * Execute the action and play the sound.
  38577. */
  38578. execute(): void;
  38579. /**
  38580. * Serializes the actions and its related information.
  38581. * @param parent defines the object to serialize in
  38582. * @returns the serialized object
  38583. */
  38584. serialize(parent: any): any;
  38585. }
  38586. /**
  38587. * This defines an action helpful to stop a defined sound on a triggered action.
  38588. */
  38589. export class StopSoundAction extends Action {
  38590. private _sound;
  38591. /**
  38592. * Instantiate the action
  38593. * @param triggerOptions defines the trigger options
  38594. * @param sound defines the sound to stop
  38595. * @param condition defines the trigger related conditions
  38596. */
  38597. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38598. /** @hidden */
  38599. _prepare(): void;
  38600. /**
  38601. * Execute the action and stop the sound.
  38602. */
  38603. execute(): void;
  38604. /**
  38605. * Serializes the actions and its related information.
  38606. * @param parent defines the object to serialize in
  38607. * @returns the serialized object
  38608. */
  38609. serialize(parent: any): any;
  38610. }
  38611. }
  38612. declare module "babylonjs/Actions/interpolateValueAction" {
  38613. import { Action } from "babylonjs/Actions/action";
  38614. import { Condition } from "babylonjs/Actions/condition";
  38615. import { Observable } from "babylonjs/Misc/observable";
  38616. /**
  38617. * This defines an action responsible to change the value of a property
  38618. * by interpolating between its current value and the newly set one once triggered.
  38619. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38620. */
  38621. export class InterpolateValueAction extends Action {
  38622. /**
  38623. * Defines the path of the property where the value should be interpolated
  38624. */
  38625. propertyPath: string;
  38626. /**
  38627. * Defines the target value at the end of the interpolation.
  38628. */
  38629. value: any;
  38630. /**
  38631. * Defines the time it will take for the property to interpolate to the value.
  38632. */
  38633. duration: number;
  38634. /**
  38635. * Defines if the other scene animations should be stopped when the action has been triggered
  38636. */
  38637. stopOtherAnimations?: boolean;
  38638. /**
  38639. * Defines a callback raised once the interpolation animation has been done.
  38640. */
  38641. onInterpolationDone?: () => void;
  38642. /**
  38643. * Observable triggered once the interpolation animation has been done.
  38644. */
  38645. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38646. private _target;
  38647. private _effectiveTarget;
  38648. private _property;
  38649. /**
  38650. * Instantiate the action
  38651. * @param triggerOptions defines the trigger options
  38652. * @param target defines the object containing the value to interpolate
  38653. * @param propertyPath defines the path to the property in the target object
  38654. * @param value defines the target value at the end of the interpolation
  38655. * @param duration deines the time it will take for the property to interpolate to the value.
  38656. * @param condition defines the trigger related conditions
  38657. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38658. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38659. */
  38660. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38661. /** @hidden */
  38662. _prepare(): void;
  38663. /**
  38664. * Execute the action starts the value interpolation.
  38665. */
  38666. execute(): void;
  38667. /**
  38668. * Serializes the actions and its related information.
  38669. * @param parent defines the object to serialize in
  38670. * @returns the serialized object
  38671. */
  38672. serialize(parent: any): any;
  38673. }
  38674. }
  38675. declare module "babylonjs/Actions/index" {
  38676. export * from "babylonjs/Actions/abstractActionManager";
  38677. export * from "babylonjs/Actions/action";
  38678. export * from "babylonjs/Actions/actionEvent";
  38679. export * from "babylonjs/Actions/actionManager";
  38680. export * from "babylonjs/Actions/condition";
  38681. export * from "babylonjs/Actions/directActions";
  38682. export * from "babylonjs/Actions/directAudioActions";
  38683. export * from "babylonjs/Actions/interpolateValueAction";
  38684. }
  38685. declare module "babylonjs/Animations/index" {
  38686. export * from "babylonjs/Animations/animatable";
  38687. export * from "babylonjs/Animations/animation";
  38688. export * from "babylonjs/Animations/animationGroup";
  38689. export * from "babylonjs/Animations/animationPropertiesOverride";
  38690. export * from "babylonjs/Animations/easing";
  38691. export * from "babylonjs/Animations/runtimeAnimation";
  38692. export * from "babylonjs/Animations/animationEvent";
  38693. export * from "babylonjs/Animations/animationGroup";
  38694. export * from "babylonjs/Animations/animationKey";
  38695. export * from "babylonjs/Animations/animationRange";
  38696. export * from "babylonjs/Animations/animatable.interface";
  38697. }
  38698. declare module "babylonjs/Audio/soundTrack" {
  38699. import { Sound } from "babylonjs/Audio/sound";
  38700. import { Analyser } from "babylonjs/Audio/analyser";
  38701. import { Scene } from "babylonjs/scene";
  38702. /**
  38703. * Options allowed during the creation of a sound track.
  38704. */
  38705. export interface ISoundTrackOptions {
  38706. /**
  38707. * The volume the sound track should take during creation
  38708. */
  38709. volume?: number;
  38710. /**
  38711. * Define if the sound track is the main sound track of the scene
  38712. */
  38713. mainTrack?: boolean;
  38714. }
  38715. /**
  38716. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38717. * It will be also used in a future release to apply effects on a specific track.
  38718. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38719. */
  38720. export class SoundTrack {
  38721. /**
  38722. * The unique identifier of the sound track in the scene.
  38723. */
  38724. id: number;
  38725. /**
  38726. * The list of sounds included in the sound track.
  38727. */
  38728. soundCollection: Array<Sound>;
  38729. private _outputAudioNode;
  38730. private _scene;
  38731. private _connectedAnalyser;
  38732. private _options;
  38733. private _isInitialized;
  38734. /**
  38735. * Creates a new sound track.
  38736. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38737. * @param scene Define the scene the sound track belongs to
  38738. * @param options
  38739. */
  38740. constructor(scene: Scene, options?: ISoundTrackOptions);
  38741. private _initializeSoundTrackAudioGraph;
  38742. /**
  38743. * Release the sound track and its associated resources
  38744. */
  38745. dispose(): void;
  38746. /**
  38747. * Adds a sound to this sound track
  38748. * @param sound define the cound to add
  38749. * @ignoreNaming
  38750. */
  38751. AddSound(sound: Sound): void;
  38752. /**
  38753. * Removes a sound to this sound track
  38754. * @param sound define the cound to remove
  38755. * @ignoreNaming
  38756. */
  38757. RemoveSound(sound: Sound): void;
  38758. /**
  38759. * Set a global volume for the full sound track.
  38760. * @param newVolume Define the new volume of the sound track
  38761. */
  38762. setVolume(newVolume: number): void;
  38763. /**
  38764. * Switch the panning model to HRTF:
  38765. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38766. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38767. */
  38768. switchPanningModelToHRTF(): void;
  38769. /**
  38770. * Switch the panning model to Equal Power:
  38771. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38772. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38773. */
  38774. switchPanningModelToEqualPower(): void;
  38775. /**
  38776. * Connect the sound track to an audio analyser allowing some amazing
  38777. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38779. * @param analyser The analyser to connect to the engine
  38780. */
  38781. connectToAnalyser(analyser: Analyser): void;
  38782. }
  38783. }
  38784. declare module "babylonjs/Audio/audioSceneComponent" {
  38785. import { Sound } from "babylonjs/Audio/sound";
  38786. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38787. import { Nullable } from "babylonjs/types";
  38788. import { Vector3 } from "babylonjs/Maths/math.vector";
  38789. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38790. import { Scene } from "babylonjs/scene";
  38791. import { AbstractScene } from "babylonjs/abstractScene";
  38792. import "babylonjs/Audio/audioEngine";
  38793. module "babylonjs/abstractScene" {
  38794. interface AbstractScene {
  38795. /**
  38796. * The list of sounds used in the scene.
  38797. */
  38798. sounds: Nullable<Array<Sound>>;
  38799. }
  38800. }
  38801. module "babylonjs/scene" {
  38802. interface Scene {
  38803. /**
  38804. * @hidden
  38805. * Backing field
  38806. */
  38807. _mainSoundTrack: SoundTrack;
  38808. /**
  38809. * The main sound track played by the scene.
  38810. * It cotains your primary collection of sounds.
  38811. */
  38812. mainSoundTrack: SoundTrack;
  38813. /**
  38814. * The list of sound tracks added to the scene
  38815. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38816. */
  38817. soundTracks: Nullable<Array<SoundTrack>>;
  38818. /**
  38819. * Gets a sound using a given name
  38820. * @param name defines the name to search for
  38821. * @return the found sound or null if not found at all.
  38822. */
  38823. getSoundByName(name: string): Nullable<Sound>;
  38824. /**
  38825. * Gets or sets if audio support is enabled
  38826. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38827. */
  38828. audioEnabled: boolean;
  38829. /**
  38830. * Gets or sets if audio will be output to headphones
  38831. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38832. */
  38833. headphone: boolean;
  38834. /**
  38835. * Gets or sets custom audio listener position provider
  38836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38837. */
  38838. audioListenerPositionProvider: Nullable<() => Vector3>;
  38839. /**
  38840. * Gets or sets a refresh rate when using 3D audio positioning
  38841. */
  38842. audioPositioningRefreshRate: number;
  38843. }
  38844. }
  38845. /**
  38846. * Defines the sound scene component responsible to manage any sounds
  38847. * in a given scene.
  38848. */
  38849. export class AudioSceneComponent implements ISceneSerializableComponent {
  38850. /**
  38851. * The component name helpfull to identify the component in the list of scene components.
  38852. */
  38853. readonly name: string;
  38854. /**
  38855. * The scene the component belongs to.
  38856. */
  38857. scene: Scene;
  38858. private _audioEnabled;
  38859. /**
  38860. * Gets whether audio is enabled or not.
  38861. * Please use related enable/disable method to switch state.
  38862. */
  38863. get audioEnabled(): boolean;
  38864. private _headphone;
  38865. /**
  38866. * Gets whether audio is outputing to headphone or not.
  38867. * Please use the according Switch methods to change output.
  38868. */
  38869. get headphone(): boolean;
  38870. /**
  38871. * Gets or sets a refresh rate when using 3D audio positioning
  38872. */
  38873. audioPositioningRefreshRate: number;
  38874. private _audioListenerPositionProvider;
  38875. /**
  38876. * Gets the current audio listener position provider
  38877. */
  38878. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38879. /**
  38880. * Sets a custom listener position for all sounds in the scene
  38881. * By default, this is the position of the first active camera
  38882. */
  38883. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38884. /**
  38885. * Creates a new instance of the component for the given scene
  38886. * @param scene Defines the scene to register the component in
  38887. */
  38888. constructor(scene: Scene);
  38889. /**
  38890. * Registers the component in a given scene
  38891. */
  38892. register(): void;
  38893. /**
  38894. * Rebuilds the elements related to this component in case of
  38895. * context lost for instance.
  38896. */
  38897. rebuild(): void;
  38898. /**
  38899. * Serializes the component data to the specified json object
  38900. * @param serializationObject The object to serialize to
  38901. */
  38902. serialize(serializationObject: any): void;
  38903. /**
  38904. * Adds all the elements from the container to the scene
  38905. * @param container the container holding the elements
  38906. */
  38907. addFromContainer(container: AbstractScene): void;
  38908. /**
  38909. * Removes all the elements in the container from the scene
  38910. * @param container contains the elements to remove
  38911. * @param dispose if the removed element should be disposed (default: false)
  38912. */
  38913. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38914. /**
  38915. * Disposes the component and the associated ressources.
  38916. */
  38917. dispose(): void;
  38918. /**
  38919. * Disables audio in the associated scene.
  38920. */
  38921. disableAudio(): void;
  38922. /**
  38923. * Enables audio in the associated scene.
  38924. */
  38925. enableAudio(): void;
  38926. /**
  38927. * Switch audio to headphone output.
  38928. */
  38929. switchAudioModeForHeadphones(): void;
  38930. /**
  38931. * Switch audio to normal speakers.
  38932. */
  38933. switchAudioModeForNormalSpeakers(): void;
  38934. private _cachedCameraDirection;
  38935. private _cachedCameraPosition;
  38936. private _lastCheck;
  38937. private _afterRender;
  38938. }
  38939. }
  38940. declare module "babylonjs/Audio/weightedsound" {
  38941. import { Sound } from "babylonjs/Audio/sound";
  38942. /**
  38943. * Wraps one or more Sound objects and selects one with random weight for playback.
  38944. */
  38945. export class WeightedSound {
  38946. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38947. loop: boolean;
  38948. private _coneInnerAngle;
  38949. private _coneOuterAngle;
  38950. private _volume;
  38951. /** A Sound is currently playing. */
  38952. isPlaying: boolean;
  38953. /** A Sound is currently paused. */
  38954. isPaused: boolean;
  38955. private _sounds;
  38956. private _weights;
  38957. private _currentIndex?;
  38958. /**
  38959. * Creates a new WeightedSound from the list of sounds given.
  38960. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  38961. * @param sounds Array of Sounds that will be selected from.
  38962. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  38963. */
  38964. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  38965. /**
  38966. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  38967. */
  38968. get directionalConeInnerAngle(): number;
  38969. /**
  38970. * The size of cone in degress for a directional sound in which there will be no attenuation.
  38971. */
  38972. set directionalConeInnerAngle(value: number);
  38973. /**
  38974. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38975. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38976. */
  38977. get directionalConeOuterAngle(): number;
  38978. /**
  38979. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  38980. * Listener angles between innerAngle and outerAngle will falloff linearly.
  38981. */
  38982. set directionalConeOuterAngle(value: number);
  38983. /**
  38984. * Playback volume.
  38985. */
  38986. get volume(): number;
  38987. /**
  38988. * Playback volume.
  38989. */
  38990. set volume(value: number);
  38991. private _onended;
  38992. /**
  38993. * Suspend playback
  38994. */
  38995. pause(): void;
  38996. /**
  38997. * Stop playback
  38998. */
  38999. stop(): void;
  39000. /**
  39001. * Start playback.
  39002. * @param startOffset Position the clip head at a specific time in seconds.
  39003. */
  39004. play(startOffset?: number): void;
  39005. }
  39006. }
  39007. declare module "babylonjs/Audio/index" {
  39008. export * from "babylonjs/Audio/analyser";
  39009. export * from "babylonjs/Audio/audioEngine";
  39010. export * from "babylonjs/Audio/audioSceneComponent";
  39011. export * from "babylonjs/Audio/sound";
  39012. export * from "babylonjs/Audio/soundTrack";
  39013. export * from "babylonjs/Audio/weightedsound";
  39014. }
  39015. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39016. import { Behavior } from "babylonjs/Behaviors/behavior";
  39017. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39018. import { BackEase } from "babylonjs/Animations/easing";
  39019. /**
  39020. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39021. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39022. */
  39023. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39024. /**
  39025. * Gets the name of the behavior.
  39026. */
  39027. get name(): string;
  39028. /**
  39029. * The easing function used by animations
  39030. */
  39031. static EasingFunction: BackEase;
  39032. /**
  39033. * The easing mode used by animations
  39034. */
  39035. static EasingMode: number;
  39036. /**
  39037. * The duration of the animation, in milliseconds
  39038. */
  39039. transitionDuration: number;
  39040. /**
  39041. * Length of the distance animated by the transition when lower radius is reached
  39042. */
  39043. lowerRadiusTransitionRange: number;
  39044. /**
  39045. * Length of the distance animated by the transition when upper radius is reached
  39046. */
  39047. upperRadiusTransitionRange: number;
  39048. private _autoTransitionRange;
  39049. /**
  39050. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39051. */
  39052. get autoTransitionRange(): boolean;
  39053. /**
  39054. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39055. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39056. */
  39057. set autoTransitionRange(value: boolean);
  39058. private _attachedCamera;
  39059. private _onAfterCheckInputsObserver;
  39060. private _onMeshTargetChangedObserver;
  39061. /**
  39062. * Initializes the behavior.
  39063. */
  39064. init(): void;
  39065. /**
  39066. * Attaches the behavior to its arc rotate camera.
  39067. * @param camera Defines the camera to attach the behavior to
  39068. */
  39069. attach(camera: ArcRotateCamera): void;
  39070. /**
  39071. * Detaches the behavior from its current arc rotate camera.
  39072. */
  39073. detach(): void;
  39074. private _radiusIsAnimating;
  39075. private _radiusBounceTransition;
  39076. private _animatables;
  39077. private _cachedWheelPrecision;
  39078. /**
  39079. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39080. * @param radiusLimit The limit to check against.
  39081. * @return Bool to indicate if at limit.
  39082. */
  39083. private _isRadiusAtLimit;
  39084. /**
  39085. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39086. * @param radiusDelta The delta by which to animate to. Can be negative.
  39087. */
  39088. private _applyBoundRadiusAnimation;
  39089. /**
  39090. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39091. */
  39092. protected _clearAnimationLocks(): void;
  39093. /**
  39094. * Stops and removes all animations that have been applied to the camera
  39095. */
  39096. stopAllAnimations(): void;
  39097. }
  39098. }
  39099. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39100. import { Behavior } from "babylonjs/Behaviors/behavior";
  39101. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39102. import { ExponentialEase } from "babylonjs/Animations/easing";
  39103. import { Nullable } from "babylonjs/types";
  39104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39105. import { Vector3 } from "babylonjs/Maths/math.vector";
  39106. /**
  39107. * 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.
  39108. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39109. */
  39110. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39111. /**
  39112. * Gets the name of the behavior.
  39113. */
  39114. get name(): string;
  39115. private _mode;
  39116. private _radiusScale;
  39117. private _positionScale;
  39118. private _defaultElevation;
  39119. private _elevationReturnTime;
  39120. private _elevationReturnWaitTime;
  39121. private _zoomStopsAnimation;
  39122. private _framingTime;
  39123. /**
  39124. * The easing function used by animations
  39125. */
  39126. static EasingFunction: ExponentialEase;
  39127. /**
  39128. * The easing mode used by animations
  39129. */
  39130. static EasingMode: number;
  39131. /**
  39132. * Sets the current mode used by the behavior
  39133. */
  39134. set mode(mode: number);
  39135. /**
  39136. * Gets current mode used by the behavior.
  39137. */
  39138. get mode(): number;
  39139. /**
  39140. * Sets the scale applied to the radius (1 by default)
  39141. */
  39142. set radiusScale(radius: number);
  39143. /**
  39144. * Gets the scale applied to the radius
  39145. */
  39146. get radiusScale(): number;
  39147. /**
  39148. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39149. */
  39150. set positionScale(scale: number);
  39151. /**
  39152. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39153. */
  39154. get positionScale(): number;
  39155. /**
  39156. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39157. * behaviour is triggered, in radians.
  39158. */
  39159. set defaultElevation(elevation: number);
  39160. /**
  39161. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39162. * behaviour is triggered, in radians.
  39163. */
  39164. get defaultElevation(): number;
  39165. /**
  39166. * Sets the time (in milliseconds) taken to return to the default beta position.
  39167. * Negative value indicates camera should not return to default.
  39168. */
  39169. set elevationReturnTime(speed: number);
  39170. /**
  39171. * Gets the time (in milliseconds) taken to return to the default beta position.
  39172. * Negative value indicates camera should not return to default.
  39173. */
  39174. get elevationReturnTime(): number;
  39175. /**
  39176. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39177. */
  39178. set elevationReturnWaitTime(time: number);
  39179. /**
  39180. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39181. */
  39182. get elevationReturnWaitTime(): number;
  39183. /**
  39184. * Sets the flag that indicates if user zooming should stop animation.
  39185. */
  39186. set zoomStopsAnimation(flag: boolean);
  39187. /**
  39188. * Gets the flag that indicates if user zooming should stop animation.
  39189. */
  39190. get zoomStopsAnimation(): boolean;
  39191. /**
  39192. * Sets the transition time when framing the mesh, in milliseconds
  39193. */
  39194. set framingTime(time: number);
  39195. /**
  39196. * Gets the transition time when framing the mesh, in milliseconds
  39197. */
  39198. get framingTime(): number;
  39199. /**
  39200. * Define if the behavior should automatically change the configured
  39201. * camera limits and sensibilities.
  39202. */
  39203. autoCorrectCameraLimitsAndSensibility: boolean;
  39204. private _onPrePointerObservableObserver;
  39205. private _onAfterCheckInputsObserver;
  39206. private _onMeshTargetChangedObserver;
  39207. private _attachedCamera;
  39208. private _isPointerDown;
  39209. private _lastInteractionTime;
  39210. /**
  39211. * Initializes the behavior.
  39212. */
  39213. init(): void;
  39214. /**
  39215. * Attaches the behavior to its arc rotate camera.
  39216. * @param camera Defines the camera to attach the behavior to
  39217. */
  39218. attach(camera: ArcRotateCamera): void;
  39219. /**
  39220. * Detaches the behavior from its current arc rotate camera.
  39221. */
  39222. detach(): void;
  39223. private _animatables;
  39224. private _betaIsAnimating;
  39225. private _betaTransition;
  39226. private _radiusTransition;
  39227. private _vectorTransition;
  39228. /**
  39229. * Targets the given mesh and updates zoom level accordingly.
  39230. * @param mesh The mesh to target.
  39231. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39232. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39233. */
  39234. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39235. /**
  39236. * Targets the given mesh with its children and updates zoom level accordingly.
  39237. * @param mesh The mesh to target.
  39238. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39239. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39240. */
  39241. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39242. /**
  39243. * Targets the given meshes with their children and updates zoom level accordingly.
  39244. * @param meshes The mesh to target.
  39245. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39246. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39247. */
  39248. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39249. /**
  39250. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39251. * @param minimumWorld Determines the smaller position of the bounding box extend
  39252. * @param maximumWorld Determines the bigger position of the bounding box extend
  39253. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39254. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39255. */
  39256. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39257. /**
  39258. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39259. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39260. * frustum width.
  39261. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39262. * to fully enclose the mesh in the viewing frustum.
  39263. */
  39264. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39265. /**
  39266. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39267. * is automatically returned to its default position (expected to be above ground plane).
  39268. */
  39269. private _maintainCameraAboveGround;
  39270. /**
  39271. * Returns the frustum slope based on the canvas ratio and camera FOV
  39272. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39273. */
  39274. private _getFrustumSlope;
  39275. /**
  39276. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39277. */
  39278. private _clearAnimationLocks;
  39279. /**
  39280. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39281. */
  39282. private _applyUserInteraction;
  39283. /**
  39284. * Stops and removes all animations that have been applied to the camera
  39285. */
  39286. stopAllAnimations(): void;
  39287. /**
  39288. * Gets a value indicating if the user is moving the camera
  39289. */
  39290. get isUserIsMoving(): boolean;
  39291. /**
  39292. * The camera can move all the way towards the mesh.
  39293. */
  39294. static IgnoreBoundsSizeMode: number;
  39295. /**
  39296. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39297. */
  39298. static FitFrustumSidesMode: number;
  39299. }
  39300. }
  39301. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39302. import { Nullable } from "babylonjs/types";
  39303. import { Camera } from "babylonjs/Cameras/camera";
  39304. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39305. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39306. /**
  39307. * Base class for Camera Pointer Inputs.
  39308. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39309. * for example usage.
  39310. */
  39311. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39312. /**
  39313. * Defines the camera the input is attached to.
  39314. */
  39315. abstract camera: Camera;
  39316. /**
  39317. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39318. */
  39319. protected _altKey: boolean;
  39320. protected _ctrlKey: boolean;
  39321. protected _metaKey: boolean;
  39322. protected _shiftKey: boolean;
  39323. /**
  39324. * Which mouse buttons were pressed at time of last mouse event.
  39325. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39326. */
  39327. protected _buttonsPressed: number;
  39328. /**
  39329. * Defines the buttons associated with the input to handle camera move.
  39330. */
  39331. buttons: number[];
  39332. /**
  39333. * Attach the input controls to a specific dom element to get the input from.
  39334. * @param element Defines the element the controls should be listened from
  39335. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39336. */
  39337. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39338. /**
  39339. * Detach the current controls from the specified dom element.
  39340. * @param element Defines the element to stop listening the inputs from
  39341. */
  39342. detachControl(element: Nullable<HTMLElement>): void;
  39343. /**
  39344. * Gets the class name of the current input.
  39345. * @returns the class name
  39346. */
  39347. getClassName(): string;
  39348. /**
  39349. * Get the friendly name associated with the input class.
  39350. * @returns the input friendly name
  39351. */
  39352. getSimpleName(): string;
  39353. /**
  39354. * Called on pointer POINTERDOUBLETAP event.
  39355. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39356. */
  39357. protected onDoubleTap(type: string): void;
  39358. /**
  39359. * Called on pointer POINTERMOVE event if only a single touch is active.
  39360. * Override this method to provide functionality.
  39361. */
  39362. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39363. /**
  39364. * Called on pointer POINTERMOVE event if multiple touches are active.
  39365. * Override this method to provide functionality.
  39366. */
  39367. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39368. /**
  39369. * Called on JS contextmenu event.
  39370. * Override this method to provide functionality.
  39371. */
  39372. protected onContextMenu(evt: PointerEvent): void;
  39373. /**
  39374. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39375. * press.
  39376. * Override this method to provide functionality.
  39377. */
  39378. protected onButtonDown(evt: PointerEvent): void;
  39379. /**
  39380. * Called each time a new POINTERUP event occurs. Ie, for each button
  39381. * release.
  39382. * Override this method to provide functionality.
  39383. */
  39384. protected onButtonUp(evt: PointerEvent): void;
  39385. /**
  39386. * Called when window becomes inactive.
  39387. * Override this method to provide functionality.
  39388. */
  39389. protected onLostFocus(): void;
  39390. private _pointerInput;
  39391. private _observer;
  39392. private _onLostFocus;
  39393. private pointA;
  39394. private pointB;
  39395. }
  39396. }
  39397. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39398. import { Nullable } from "babylonjs/types";
  39399. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39400. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39401. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39402. /**
  39403. * Manage the pointers inputs to control an arc rotate camera.
  39404. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39405. */
  39406. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39407. /**
  39408. * Defines the camera the input is attached to.
  39409. */
  39410. camera: ArcRotateCamera;
  39411. /**
  39412. * Gets the class name of the current input.
  39413. * @returns the class name
  39414. */
  39415. getClassName(): string;
  39416. /**
  39417. * Defines the buttons associated with the input to handle camera move.
  39418. */
  39419. buttons: number[];
  39420. /**
  39421. * Defines the pointer angular sensibility along the X axis or how fast is
  39422. * the camera rotating.
  39423. */
  39424. angularSensibilityX: number;
  39425. /**
  39426. * Defines the pointer angular sensibility along the Y axis or how fast is
  39427. * the camera rotating.
  39428. */
  39429. angularSensibilityY: number;
  39430. /**
  39431. * Defines the pointer pinch precision or how fast is the camera zooming.
  39432. */
  39433. pinchPrecision: number;
  39434. /**
  39435. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39436. * from 0.
  39437. * It defines the percentage of current camera.radius to use as delta when
  39438. * pinch zoom is used.
  39439. */
  39440. pinchDeltaPercentage: number;
  39441. /**
  39442. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39443. * that any object in the plane at the camera's target point will scale
  39444. * perfectly with finger motion.
  39445. * Overrides pinchDeltaPercentage and pinchPrecision.
  39446. */
  39447. useNaturalPinchZoom: boolean;
  39448. /**
  39449. * Defines the pointer panning sensibility or how fast is the camera moving.
  39450. */
  39451. panningSensibility: number;
  39452. /**
  39453. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39454. */
  39455. multiTouchPanning: boolean;
  39456. /**
  39457. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39458. * zoom (pinch) through multitouch.
  39459. */
  39460. multiTouchPanAndZoom: boolean;
  39461. /**
  39462. * Revers pinch action direction.
  39463. */
  39464. pinchInwards: boolean;
  39465. private _isPanClick;
  39466. private _twoFingerActivityCount;
  39467. private _isPinching;
  39468. /**
  39469. * Called on pointer POINTERMOVE event if only a single touch is active.
  39470. */
  39471. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39472. /**
  39473. * Called on pointer POINTERDOUBLETAP event.
  39474. */
  39475. protected onDoubleTap(type: string): void;
  39476. /**
  39477. * Called on pointer POINTERMOVE event if multiple touches are active.
  39478. */
  39479. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39480. /**
  39481. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39482. * press.
  39483. */
  39484. protected onButtonDown(evt: PointerEvent): void;
  39485. /**
  39486. * Called each time a new POINTERUP event occurs. Ie, for each button
  39487. * release.
  39488. */
  39489. protected onButtonUp(evt: PointerEvent): void;
  39490. /**
  39491. * Called when window becomes inactive.
  39492. */
  39493. protected onLostFocus(): void;
  39494. }
  39495. }
  39496. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39497. import { Nullable } from "babylonjs/types";
  39498. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39499. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39500. /**
  39501. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39502. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39503. */
  39504. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39505. /**
  39506. * Defines the camera the input is attached to.
  39507. */
  39508. camera: ArcRotateCamera;
  39509. /**
  39510. * Defines the list of key codes associated with the up action (increase alpha)
  39511. */
  39512. keysUp: number[];
  39513. /**
  39514. * Defines the list of key codes associated with the down action (decrease alpha)
  39515. */
  39516. keysDown: number[];
  39517. /**
  39518. * Defines the list of key codes associated with the left action (increase beta)
  39519. */
  39520. keysLeft: number[];
  39521. /**
  39522. * Defines the list of key codes associated with the right action (decrease beta)
  39523. */
  39524. keysRight: number[];
  39525. /**
  39526. * Defines the list of key codes associated with the reset action.
  39527. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39528. */
  39529. keysReset: number[];
  39530. /**
  39531. * Defines the panning sensibility of the inputs.
  39532. * (How fast is the camera panning)
  39533. */
  39534. panningSensibility: number;
  39535. /**
  39536. * Defines the zooming sensibility of the inputs.
  39537. * (How fast is the camera zooming)
  39538. */
  39539. zoomingSensibility: number;
  39540. /**
  39541. * Defines whether maintaining the alt key down switch the movement mode from
  39542. * orientation to zoom.
  39543. */
  39544. useAltToZoom: boolean;
  39545. /**
  39546. * Rotation speed of the camera
  39547. */
  39548. angularSpeed: number;
  39549. private _keys;
  39550. private _ctrlPressed;
  39551. private _altPressed;
  39552. private _onCanvasBlurObserver;
  39553. private _onKeyboardObserver;
  39554. private _engine;
  39555. private _scene;
  39556. /**
  39557. * Attach the input controls to a specific dom element to get the input from.
  39558. * @param element Defines the element the controls should be listened from
  39559. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39560. */
  39561. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39562. /**
  39563. * Detach the current controls from the specified dom element.
  39564. * @param element Defines the element to stop listening the inputs from
  39565. */
  39566. detachControl(element: Nullable<HTMLElement>): void;
  39567. /**
  39568. * Update the current camera state depending on the inputs that have been used this frame.
  39569. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39570. */
  39571. checkInputs(): void;
  39572. /**
  39573. * Gets the class name of the current intput.
  39574. * @returns the class name
  39575. */
  39576. getClassName(): string;
  39577. /**
  39578. * Get the friendly name associated with the input class.
  39579. * @returns the input friendly name
  39580. */
  39581. getSimpleName(): string;
  39582. }
  39583. }
  39584. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39585. import { Nullable } from "babylonjs/types";
  39586. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39587. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39588. /**
  39589. * Manage the mouse wheel inputs to control an arc rotate camera.
  39590. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39591. */
  39592. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39593. /**
  39594. * Defines the camera the input is attached to.
  39595. */
  39596. camera: ArcRotateCamera;
  39597. /**
  39598. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39599. */
  39600. wheelPrecision: number;
  39601. /**
  39602. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39603. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39604. */
  39605. wheelDeltaPercentage: number;
  39606. private _wheel;
  39607. private _observer;
  39608. private computeDeltaFromMouseWheelLegacyEvent;
  39609. /**
  39610. * Attach the input controls to a specific dom element to get the input from.
  39611. * @param element Defines the element the controls should be listened from
  39612. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39613. */
  39614. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39615. /**
  39616. * Detach the current controls from the specified dom element.
  39617. * @param element Defines the element to stop listening the inputs from
  39618. */
  39619. detachControl(element: Nullable<HTMLElement>): void;
  39620. /**
  39621. * Gets the class name of the current intput.
  39622. * @returns the class name
  39623. */
  39624. getClassName(): string;
  39625. /**
  39626. * Get the friendly name associated with the input class.
  39627. * @returns the input friendly name
  39628. */
  39629. getSimpleName(): string;
  39630. }
  39631. }
  39632. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39633. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39634. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39635. /**
  39636. * Default Inputs manager for the ArcRotateCamera.
  39637. * It groups all the default supported inputs for ease of use.
  39638. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39639. */
  39640. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39641. /**
  39642. * Instantiates a new ArcRotateCameraInputsManager.
  39643. * @param camera Defines the camera the inputs belong to
  39644. */
  39645. constructor(camera: ArcRotateCamera);
  39646. /**
  39647. * Add mouse wheel input support to the input manager.
  39648. * @returns the current input manager
  39649. */
  39650. addMouseWheel(): ArcRotateCameraInputsManager;
  39651. /**
  39652. * Add pointers input support to the input manager.
  39653. * @returns the current input manager
  39654. */
  39655. addPointers(): ArcRotateCameraInputsManager;
  39656. /**
  39657. * Add keyboard input support to the input manager.
  39658. * @returns the current input manager
  39659. */
  39660. addKeyboard(): ArcRotateCameraInputsManager;
  39661. }
  39662. }
  39663. declare module "babylonjs/Cameras/arcRotateCamera" {
  39664. import { Observable } from "babylonjs/Misc/observable";
  39665. import { Nullable } from "babylonjs/types";
  39666. import { Scene } from "babylonjs/scene";
  39667. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39668. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39669. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39670. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39671. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39672. import { Camera } from "babylonjs/Cameras/camera";
  39673. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39674. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39675. import { Collider } from "babylonjs/Collisions/collider";
  39676. /**
  39677. * This represents an orbital type of camera.
  39678. *
  39679. * 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.
  39680. * 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.
  39681. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39682. */
  39683. export class ArcRotateCamera extends TargetCamera {
  39684. /**
  39685. * Defines the rotation angle of the camera along the longitudinal axis.
  39686. */
  39687. alpha: number;
  39688. /**
  39689. * Defines the rotation angle of the camera along the latitudinal axis.
  39690. */
  39691. beta: number;
  39692. /**
  39693. * Defines the radius of the camera from it s target point.
  39694. */
  39695. radius: number;
  39696. protected _target: Vector3;
  39697. protected _targetHost: Nullable<AbstractMesh>;
  39698. /**
  39699. * Defines the target point of the camera.
  39700. * The camera looks towards it form the radius distance.
  39701. */
  39702. get target(): Vector3;
  39703. set target(value: Vector3);
  39704. /**
  39705. * Define the current local position of the camera in the scene
  39706. */
  39707. get position(): Vector3;
  39708. set position(newPosition: Vector3);
  39709. protected _upVector: Vector3;
  39710. protected _upToYMatrix: Matrix;
  39711. protected _YToUpMatrix: Matrix;
  39712. /**
  39713. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39714. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39715. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39716. */
  39717. set upVector(vec: Vector3);
  39718. get upVector(): Vector3;
  39719. /**
  39720. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39721. */
  39722. setMatUp(): void;
  39723. /**
  39724. * Current inertia value on the longitudinal axis.
  39725. * The bigger this number the longer it will take for the camera to stop.
  39726. */
  39727. inertialAlphaOffset: number;
  39728. /**
  39729. * Current inertia value on the latitudinal axis.
  39730. * The bigger this number the longer it will take for the camera to stop.
  39731. */
  39732. inertialBetaOffset: number;
  39733. /**
  39734. * Current inertia value on the radius axis.
  39735. * The bigger this number the longer it will take for the camera to stop.
  39736. */
  39737. inertialRadiusOffset: number;
  39738. /**
  39739. * Minimum allowed angle on the longitudinal axis.
  39740. * This can help limiting how the Camera is able to move in the scene.
  39741. */
  39742. lowerAlphaLimit: Nullable<number>;
  39743. /**
  39744. * Maximum allowed angle on the longitudinal axis.
  39745. * This can help limiting how the Camera is able to move in the scene.
  39746. */
  39747. upperAlphaLimit: Nullable<number>;
  39748. /**
  39749. * Minimum allowed angle on the latitudinal axis.
  39750. * This can help limiting how the Camera is able to move in the scene.
  39751. */
  39752. lowerBetaLimit: number;
  39753. /**
  39754. * Maximum allowed angle on the latitudinal axis.
  39755. * This can help limiting how the Camera is able to move in the scene.
  39756. */
  39757. upperBetaLimit: number;
  39758. /**
  39759. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39760. * This can help limiting how the Camera is able to move in the scene.
  39761. */
  39762. lowerRadiusLimit: Nullable<number>;
  39763. /**
  39764. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39765. * This can help limiting how the Camera is able to move in the scene.
  39766. */
  39767. upperRadiusLimit: Nullable<number>;
  39768. /**
  39769. * Defines the current inertia value used during panning of the camera along the X axis.
  39770. */
  39771. inertialPanningX: number;
  39772. /**
  39773. * Defines the current inertia value used during panning of the camera along the Y axis.
  39774. */
  39775. inertialPanningY: number;
  39776. /**
  39777. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39778. * Basically if your fingers moves away from more than this distance you will be considered
  39779. * in pinch mode.
  39780. */
  39781. pinchToPanMaxDistance: number;
  39782. /**
  39783. * Defines the maximum distance the camera can pan.
  39784. * This could help keeping the cammera always in your scene.
  39785. */
  39786. panningDistanceLimit: Nullable<number>;
  39787. /**
  39788. * Defines the target of the camera before paning.
  39789. */
  39790. panningOriginTarget: Vector3;
  39791. /**
  39792. * Defines the value of the inertia used during panning.
  39793. * 0 would mean stop inertia and one would mean no decelleration at all.
  39794. */
  39795. panningInertia: number;
  39796. /**
  39797. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39798. */
  39799. get angularSensibilityX(): number;
  39800. set angularSensibilityX(value: number);
  39801. /**
  39802. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39803. */
  39804. get angularSensibilityY(): number;
  39805. set angularSensibilityY(value: number);
  39806. /**
  39807. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39808. */
  39809. get pinchPrecision(): number;
  39810. set pinchPrecision(value: number);
  39811. /**
  39812. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39813. * It will be used instead of pinchDeltaPrecision if different from 0.
  39814. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39815. */
  39816. get pinchDeltaPercentage(): number;
  39817. set pinchDeltaPercentage(value: number);
  39818. /**
  39819. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39820. * and pinch delta percentage.
  39821. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39822. * that any object in the plane at the camera's target point will scale
  39823. * perfectly with finger motion.
  39824. */
  39825. get useNaturalPinchZoom(): boolean;
  39826. set useNaturalPinchZoom(value: boolean);
  39827. /**
  39828. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39829. */
  39830. get panningSensibility(): number;
  39831. set panningSensibility(value: number);
  39832. /**
  39833. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39834. */
  39835. get keysUp(): number[];
  39836. set keysUp(value: number[]);
  39837. /**
  39838. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39839. */
  39840. get keysDown(): number[];
  39841. set keysDown(value: number[]);
  39842. /**
  39843. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39844. */
  39845. get keysLeft(): number[];
  39846. set keysLeft(value: number[]);
  39847. /**
  39848. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39849. */
  39850. get keysRight(): number[];
  39851. set keysRight(value: number[]);
  39852. /**
  39853. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39854. */
  39855. get wheelPrecision(): number;
  39856. set wheelPrecision(value: number);
  39857. /**
  39858. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39859. * It will be used instead of pinchDeltaPrecision if different from 0.
  39860. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39861. */
  39862. get wheelDeltaPercentage(): number;
  39863. set wheelDeltaPercentage(value: number);
  39864. /**
  39865. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39866. */
  39867. zoomOnFactor: number;
  39868. /**
  39869. * Defines a screen offset for the camera position.
  39870. */
  39871. targetScreenOffset: Vector2;
  39872. /**
  39873. * Allows the camera to be completely reversed.
  39874. * If false the camera can not arrive upside down.
  39875. */
  39876. allowUpsideDown: boolean;
  39877. /**
  39878. * Define if double tap/click is used to restore the previously saved state of the camera.
  39879. */
  39880. useInputToRestoreState: boolean;
  39881. /** @hidden */
  39882. _viewMatrix: Matrix;
  39883. /** @hidden */
  39884. _useCtrlForPanning: boolean;
  39885. /** @hidden */
  39886. _panningMouseButton: number;
  39887. /**
  39888. * Defines the input associated to the camera.
  39889. */
  39890. inputs: ArcRotateCameraInputsManager;
  39891. /** @hidden */
  39892. _reset: () => void;
  39893. /**
  39894. * Defines the allowed panning axis.
  39895. */
  39896. panningAxis: Vector3;
  39897. protected _localDirection: Vector3;
  39898. protected _transformedDirection: Vector3;
  39899. private _bouncingBehavior;
  39900. /**
  39901. * Gets the bouncing behavior of the camera if it has been enabled.
  39902. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39903. */
  39904. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39905. /**
  39906. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39907. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39908. */
  39909. get useBouncingBehavior(): boolean;
  39910. set useBouncingBehavior(value: boolean);
  39911. private _framingBehavior;
  39912. /**
  39913. * Gets the framing behavior of the camera if it has been enabled.
  39914. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39915. */
  39916. get framingBehavior(): Nullable<FramingBehavior>;
  39917. /**
  39918. * Defines if the framing behavior of the camera is enabled on the camera.
  39919. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39920. */
  39921. get useFramingBehavior(): boolean;
  39922. set useFramingBehavior(value: boolean);
  39923. private _autoRotationBehavior;
  39924. /**
  39925. * Gets the auto rotation behavior of the camera if it has been enabled.
  39926. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39927. */
  39928. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39929. /**
  39930. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39931. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39932. */
  39933. get useAutoRotationBehavior(): boolean;
  39934. set useAutoRotationBehavior(value: boolean);
  39935. /**
  39936. * Observable triggered when the mesh target has been changed on the camera.
  39937. */
  39938. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39939. /**
  39940. * Event raised when the camera is colliding with a mesh.
  39941. */
  39942. onCollide: (collidedMesh: AbstractMesh) => void;
  39943. /**
  39944. * Defines whether the camera should check collision with the objects oh the scene.
  39945. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39946. */
  39947. checkCollisions: boolean;
  39948. /**
  39949. * Defines the collision radius of the camera.
  39950. * This simulates a sphere around the camera.
  39951. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39952. */
  39953. collisionRadius: Vector3;
  39954. protected _collider: Collider;
  39955. protected _previousPosition: Vector3;
  39956. protected _collisionVelocity: Vector3;
  39957. protected _newPosition: Vector3;
  39958. protected _previousAlpha: number;
  39959. protected _previousBeta: number;
  39960. protected _previousRadius: number;
  39961. protected _collisionTriggered: boolean;
  39962. protected _targetBoundingCenter: Nullable<Vector3>;
  39963. private _computationVector;
  39964. /**
  39965. * Instantiates a new ArcRotateCamera in a given scene
  39966. * @param name Defines the name of the camera
  39967. * @param alpha Defines the camera rotation along the logitudinal axis
  39968. * @param beta Defines the camera rotation along the latitudinal axis
  39969. * @param radius Defines the camera distance from its target
  39970. * @param target Defines the camera target
  39971. * @param scene Defines the scene the camera belongs to
  39972. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  39973. */
  39974. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  39975. /** @hidden */
  39976. _initCache(): void;
  39977. /** @hidden */
  39978. _updateCache(ignoreParentClass?: boolean): void;
  39979. protected _getTargetPosition(): Vector3;
  39980. private _storedAlpha;
  39981. private _storedBeta;
  39982. private _storedRadius;
  39983. private _storedTarget;
  39984. private _storedTargetScreenOffset;
  39985. /**
  39986. * Stores the current state of the camera (alpha, beta, radius and target)
  39987. * @returns the camera itself
  39988. */
  39989. storeState(): Camera;
  39990. /**
  39991. * @hidden
  39992. * Restored camera state. You must call storeState() first
  39993. */
  39994. _restoreStateValues(): boolean;
  39995. /** @hidden */
  39996. _isSynchronizedViewMatrix(): boolean;
  39997. /**
  39998. * Attached controls to the current camera.
  39999. * @param element Defines the element the controls should be listened from
  40000. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40001. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40002. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40003. */
  40004. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40005. /**
  40006. * Detach the current controls from the camera.
  40007. * The camera will stop reacting to inputs.
  40008. * @param element Defines the element to stop listening the inputs from
  40009. */
  40010. detachControl(element: HTMLElement): void;
  40011. /** @hidden */
  40012. _checkInputs(): void;
  40013. protected _checkLimits(): void;
  40014. /**
  40015. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40016. */
  40017. rebuildAnglesAndRadius(): void;
  40018. /**
  40019. * Use a position to define the current camera related information like alpha, beta and radius
  40020. * @param position Defines the position to set the camera at
  40021. */
  40022. setPosition(position: Vector3): void;
  40023. /**
  40024. * Defines the target the camera should look at.
  40025. * This will automatically adapt alpha beta and radius to fit within the new target.
  40026. * @param target Defines the new target as a Vector or a mesh
  40027. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40028. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40029. */
  40030. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40031. /** @hidden */
  40032. _getViewMatrix(): Matrix;
  40033. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40034. /**
  40035. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40036. * @param meshes Defines the mesh to zoom on
  40037. * @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)
  40038. */
  40039. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40040. /**
  40041. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40042. * The target will be changed but the radius
  40043. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40044. * @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)
  40045. */
  40046. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40047. min: Vector3;
  40048. max: Vector3;
  40049. distance: number;
  40050. }, doNotUpdateMaxZ?: boolean): void;
  40051. /**
  40052. * @override
  40053. * Override Camera.createRigCamera
  40054. */
  40055. createRigCamera(name: string, cameraIndex: number): Camera;
  40056. /**
  40057. * @hidden
  40058. * @override
  40059. * Override Camera._updateRigCameras
  40060. */
  40061. _updateRigCameras(): void;
  40062. /**
  40063. * Destroy the camera and release the current resources hold by it.
  40064. */
  40065. dispose(): void;
  40066. /**
  40067. * Gets the current object class name.
  40068. * @return the class name
  40069. */
  40070. getClassName(): string;
  40071. }
  40072. }
  40073. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40074. import { Behavior } from "babylonjs/Behaviors/behavior";
  40075. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40076. /**
  40077. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40078. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40079. */
  40080. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40081. /**
  40082. * Gets the name of the behavior.
  40083. */
  40084. get name(): string;
  40085. private _zoomStopsAnimation;
  40086. private _idleRotationSpeed;
  40087. private _idleRotationWaitTime;
  40088. private _idleRotationSpinupTime;
  40089. /**
  40090. * Sets the flag that indicates if user zooming should stop animation.
  40091. */
  40092. set zoomStopsAnimation(flag: boolean);
  40093. /**
  40094. * Gets the flag that indicates if user zooming should stop animation.
  40095. */
  40096. get zoomStopsAnimation(): boolean;
  40097. /**
  40098. * Sets the default speed at which the camera rotates around the model.
  40099. */
  40100. set idleRotationSpeed(speed: number);
  40101. /**
  40102. * Gets the default speed at which the camera rotates around the model.
  40103. */
  40104. get idleRotationSpeed(): number;
  40105. /**
  40106. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40107. */
  40108. set idleRotationWaitTime(time: number);
  40109. /**
  40110. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40111. */
  40112. get idleRotationWaitTime(): number;
  40113. /**
  40114. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40115. */
  40116. set idleRotationSpinupTime(time: number);
  40117. /**
  40118. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40119. */
  40120. get idleRotationSpinupTime(): number;
  40121. /**
  40122. * Gets a value indicating if the camera is currently rotating because of this behavior
  40123. */
  40124. get rotationInProgress(): boolean;
  40125. private _onPrePointerObservableObserver;
  40126. private _onAfterCheckInputsObserver;
  40127. private _attachedCamera;
  40128. private _isPointerDown;
  40129. private _lastFrameTime;
  40130. private _lastInteractionTime;
  40131. private _cameraRotationSpeed;
  40132. /**
  40133. * Initializes the behavior.
  40134. */
  40135. init(): void;
  40136. /**
  40137. * Attaches the behavior to its arc rotate camera.
  40138. * @param camera Defines the camera to attach the behavior to
  40139. */
  40140. attach(camera: ArcRotateCamera): void;
  40141. /**
  40142. * Detaches the behavior from its current arc rotate camera.
  40143. */
  40144. detach(): void;
  40145. /**
  40146. * Returns true if user is scrolling.
  40147. * @return true if user is scrolling.
  40148. */
  40149. private _userIsZooming;
  40150. private _lastFrameRadius;
  40151. private _shouldAnimationStopForInteraction;
  40152. /**
  40153. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40154. */
  40155. private _applyUserInteraction;
  40156. private _userIsMoving;
  40157. }
  40158. }
  40159. declare module "babylonjs/Behaviors/Cameras/index" {
  40160. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40161. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40162. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40163. }
  40164. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40165. import { Mesh } from "babylonjs/Meshes/mesh";
  40166. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40167. import { Behavior } from "babylonjs/Behaviors/behavior";
  40168. /**
  40169. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40170. */
  40171. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40172. private ui;
  40173. /**
  40174. * The name of the behavior
  40175. */
  40176. name: string;
  40177. /**
  40178. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40179. */
  40180. distanceAwayFromFace: number;
  40181. /**
  40182. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40183. */
  40184. distanceAwayFromBottomOfFace: number;
  40185. private _faceVectors;
  40186. private _target;
  40187. private _scene;
  40188. private _onRenderObserver;
  40189. private _tmpMatrix;
  40190. private _tmpVector;
  40191. /**
  40192. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40193. * @param ui The transform node that should be attched to the mesh
  40194. */
  40195. constructor(ui: TransformNode);
  40196. /**
  40197. * Initializes the behavior
  40198. */
  40199. init(): void;
  40200. private _closestFace;
  40201. private _zeroVector;
  40202. private _lookAtTmpMatrix;
  40203. private _lookAtToRef;
  40204. /**
  40205. * Attaches the AttachToBoxBehavior to the passed in mesh
  40206. * @param target The mesh that the specified node will be attached to
  40207. */
  40208. attach(target: Mesh): void;
  40209. /**
  40210. * Detaches the behavior from the mesh
  40211. */
  40212. detach(): void;
  40213. }
  40214. }
  40215. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40216. import { Behavior } from "babylonjs/Behaviors/behavior";
  40217. import { Mesh } from "babylonjs/Meshes/mesh";
  40218. /**
  40219. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40220. */
  40221. export class FadeInOutBehavior implements Behavior<Mesh> {
  40222. /**
  40223. * Time in milliseconds to delay before fading in (Default: 0)
  40224. */
  40225. delay: number;
  40226. /**
  40227. * Time in milliseconds for the mesh to fade in (Default: 300)
  40228. */
  40229. fadeInTime: number;
  40230. private _millisecondsPerFrame;
  40231. private _hovered;
  40232. private _hoverValue;
  40233. private _ownerNode;
  40234. /**
  40235. * Instatiates the FadeInOutBehavior
  40236. */
  40237. constructor();
  40238. /**
  40239. * The name of the behavior
  40240. */
  40241. get name(): string;
  40242. /**
  40243. * Initializes the behavior
  40244. */
  40245. init(): void;
  40246. /**
  40247. * Attaches the fade behavior on the passed in mesh
  40248. * @param ownerNode The mesh that will be faded in/out once attached
  40249. */
  40250. attach(ownerNode: Mesh): void;
  40251. /**
  40252. * Detaches the behavior from the mesh
  40253. */
  40254. detach(): void;
  40255. /**
  40256. * Triggers the mesh to begin fading in or out
  40257. * @param value if the object should fade in or out (true to fade in)
  40258. */
  40259. fadeIn(value: boolean): void;
  40260. private _update;
  40261. private _setAllVisibility;
  40262. }
  40263. }
  40264. declare module "babylonjs/Misc/pivotTools" {
  40265. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40266. /**
  40267. * Class containing a set of static utilities functions for managing Pivots
  40268. * @hidden
  40269. */
  40270. export class PivotTools {
  40271. private static _PivotCached;
  40272. private static _OldPivotPoint;
  40273. private static _PivotTranslation;
  40274. private static _PivotTmpVector;
  40275. /** @hidden */
  40276. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40277. /** @hidden */
  40278. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40279. }
  40280. }
  40281. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40282. import { Scene } from "babylonjs/scene";
  40283. import { Vector4 } from "babylonjs/Maths/math.vector";
  40284. import { Mesh } from "babylonjs/Meshes/mesh";
  40285. import { Nullable } from "babylonjs/types";
  40286. import { Plane } from "babylonjs/Maths/math.plane";
  40287. /**
  40288. * Class containing static functions to help procedurally build meshes
  40289. */
  40290. export class PlaneBuilder {
  40291. /**
  40292. * Creates a plane mesh
  40293. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40294. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40295. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40297. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40299. * @param name defines the name of the mesh
  40300. * @param options defines the options used to create the mesh
  40301. * @param scene defines the hosting scene
  40302. * @returns the plane mesh
  40303. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40304. */
  40305. static CreatePlane(name: string, options: {
  40306. size?: number;
  40307. width?: number;
  40308. height?: number;
  40309. sideOrientation?: number;
  40310. frontUVs?: Vector4;
  40311. backUVs?: Vector4;
  40312. updatable?: boolean;
  40313. sourcePlane?: Plane;
  40314. }, scene?: Nullable<Scene>): Mesh;
  40315. }
  40316. }
  40317. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40318. import { Behavior } from "babylonjs/Behaviors/behavior";
  40319. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40320. import { Observable } from "babylonjs/Misc/observable";
  40321. import { Vector3 } from "babylonjs/Maths/math.vector";
  40322. import { Ray } from "babylonjs/Culling/ray";
  40323. import "babylonjs/Meshes/Builders/planeBuilder";
  40324. /**
  40325. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40326. */
  40327. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40328. private static _AnyMouseID;
  40329. /**
  40330. * Abstract mesh the behavior is set on
  40331. */
  40332. attachedNode: AbstractMesh;
  40333. private _dragPlane;
  40334. private _scene;
  40335. private _pointerObserver;
  40336. private _beforeRenderObserver;
  40337. private static _planeScene;
  40338. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40339. /**
  40340. * 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)
  40341. */
  40342. maxDragAngle: number;
  40343. /**
  40344. * @hidden
  40345. */
  40346. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40347. /**
  40348. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40349. */
  40350. currentDraggingPointerID: number;
  40351. /**
  40352. * The last position where the pointer hit the drag plane in world space
  40353. */
  40354. lastDragPosition: Vector3;
  40355. /**
  40356. * If the behavior is currently in a dragging state
  40357. */
  40358. dragging: boolean;
  40359. /**
  40360. * 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)
  40361. */
  40362. dragDeltaRatio: number;
  40363. /**
  40364. * If the drag plane orientation should be updated during the dragging (Default: true)
  40365. */
  40366. updateDragPlane: boolean;
  40367. private _debugMode;
  40368. private _moving;
  40369. /**
  40370. * Fires each time the attached mesh is dragged with the pointer
  40371. * * delta between last drag position and current drag position in world space
  40372. * * dragDistance along the drag axis
  40373. * * dragPlaneNormal normal of the current drag plane used during the drag
  40374. * * dragPlanePoint in world space where the drag intersects the drag plane
  40375. */
  40376. onDragObservable: Observable<{
  40377. delta: Vector3;
  40378. dragPlanePoint: Vector3;
  40379. dragPlaneNormal: Vector3;
  40380. dragDistance: number;
  40381. pointerId: number;
  40382. }>;
  40383. /**
  40384. * Fires each time a drag begins (eg. mouse down on mesh)
  40385. */
  40386. onDragStartObservable: Observable<{
  40387. dragPlanePoint: Vector3;
  40388. pointerId: number;
  40389. }>;
  40390. /**
  40391. * Fires each time a drag ends (eg. mouse release after drag)
  40392. */
  40393. onDragEndObservable: Observable<{
  40394. dragPlanePoint: Vector3;
  40395. pointerId: number;
  40396. }>;
  40397. /**
  40398. * If the attached mesh should be moved when dragged
  40399. */
  40400. moveAttached: boolean;
  40401. /**
  40402. * If the drag behavior will react to drag events (Default: true)
  40403. */
  40404. enabled: boolean;
  40405. /**
  40406. * If pointer events should start and release the drag (Default: true)
  40407. */
  40408. startAndReleaseDragOnPointerEvents: boolean;
  40409. /**
  40410. * If camera controls should be detached during the drag
  40411. */
  40412. detachCameraControls: boolean;
  40413. /**
  40414. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40415. */
  40416. useObjectOrientationForDragging: boolean;
  40417. private _options;
  40418. /**
  40419. * Gets the options used by the behavior
  40420. */
  40421. get options(): {
  40422. dragAxis?: Vector3;
  40423. dragPlaneNormal?: Vector3;
  40424. };
  40425. /**
  40426. * Sets the options used by the behavior
  40427. */
  40428. set options(options: {
  40429. dragAxis?: Vector3;
  40430. dragPlaneNormal?: Vector3;
  40431. });
  40432. /**
  40433. * Creates a pointer drag behavior that can be attached to a mesh
  40434. * @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)
  40435. */
  40436. constructor(options?: {
  40437. dragAxis?: Vector3;
  40438. dragPlaneNormal?: Vector3;
  40439. });
  40440. /**
  40441. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40442. */
  40443. validateDrag: (targetPosition: Vector3) => boolean;
  40444. /**
  40445. * The name of the behavior
  40446. */
  40447. get name(): string;
  40448. /**
  40449. * Initializes the behavior
  40450. */
  40451. init(): void;
  40452. private _tmpVector;
  40453. private _alternatePickedPoint;
  40454. private _worldDragAxis;
  40455. private _targetPosition;
  40456. private _attachedElement;
  40457. /**
  40458. * Attaches the drag behavior the passed in mesh
  40459. * @param ownerNode The mesh that will be dragged around once attached
  40460. * @param predicate Predicate to use for pick filtering
  40461. */
  40462. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40463. /**
  40464. * Force relase the drag action by code.
  40465. */
  40466. releaseDrag(): void;
  40467. private _startDragRay;
  40468. private _lastPointerRay;
  40469. /**
  40470. * Simulates the start of a pointer drag event on the behavior
  40471. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40472. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40473. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40474. */
  40475. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40476. private _startDrag;
  40477. private _dragDelta;
  40478. private _moveDrag;
  40479. private _pickWithRayOnDragPlane;
  40480. private _pointA;
  40481. private _pointB;
  40482. private _pointC;
  40483. private _lineA;
  40484. private _lineB;
  40485. private _localAxis;
  40486. private _lookAt;
  40487. private _updateDragPlanePosition;
  40488. /**
  40489. * Detaches the behavior from the mesh
  40490. */
  40491. detach(): void;
  40492. }
  40493. }
  40494. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40495. import { Mesh } from "babylonjs/Meshes/mesh";
  40496. import { Behavior } from "babylonjs/Behaviors/behavior";
  40497. /**
  40498. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40499. */
  40500. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40501. private _dragBehaviorA;
  40502. private _dragBehaviorB;
  40503. private _startDistance;
  40504. private _initialScale;
  40505. private _targetScale;
  40506. private _ownerNode;
  40507. private _sceneRenderObserver;
  40508. /**
  40509. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40510. */
  40511. constructor();
  40512. /**
  40513. * The name of the behavior
  40514. */
  40515. get name(): string;
  40516. /**
  40517. * Initializes the behavior
  40518. */
  40519. init(): void;
  40520. private _getCurrentDistance;
  40521. /**
  40522. * Attaches the scale behavior the passed in mesh
  40523. * @param ownerNode The mesh that will be scaled around once attached
  40524. */
  40525. attach(ownerNode: Mesh): void;
  40526. /**
  40527. * Detaches the behavior from the mesh
  40528. */
  40529. detach(): void;
  40530. }
  40531. }
  40532. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40533. import { Behavior } from "babylonjs/Behaviors/behavior";
  40534. import { Mesh } from "babylonjs/Meshes/mesh";
  40535. import { Observable } from "babylonjs/Misc/observable";
  40536. /**
  40537. * 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
  40538. */
  40539. export class SixDofDragBehavior implements Behavior<Mesh> {
  40540. private static _virtualScene;
  40541. private _ownerNode;
  40542. private _sceneRenderObserver;
  40543. private _scene;
  40544. private _targetPosition;
  40545. private _virtualOriginMesh;
  40546. private _virtualDragMesh;
  40547. private _pointerObserver;
  40548. private _moving;
  40549. private _startingOrientation;
  40550. /**
  40551. * 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)
  40552. */
  40553. private zDragFactor;
  40554. /**
  40555. * If the object should rotate to face the drag origin
  40556. */
  40557. rotateDraggedObject: boolean;
  40558. /**
  40559. * If the behavior is currently in a dragging state
  40560. */
  40561. dragging: boolean;
  40562. /**
  40563. * 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)
  40564. */
  40565. dragDeltaRatio: number;
  40566. /**
  40567. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40568. */
  40569. currentDraggingPointerID: number;
  40570. /**
  40571. * If camera controls should be detached during the drag
  40572. */
  40573. detachCameraControls: boolean;
  40574. /**
  40575. * Fires each time a drag starts
  40576. */
  40577. onDragStartObservable: Observable<{}>;
  40578. /**
  40579. * Fires each time a drag ends (eg. mouse release after drag)
  40580. */
  40581. onDragEndObservable: Observable<{}>;
  40582. /**
  40583. * 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
  40584. */
  40585. constructor();
  40586. /**
  40587. * The name of the behavior
  40588. */
  40589. get name(): string;
  40590. /**
  40591. * Initializes the behavior
  40592. */
  40593. init(): void;
  40594. /**
  40595. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40596. */
  40597. private get _pointerCamera();
  40598. /**
  40599. * Attaches the scale behavior the passed in mesh
  40600. * @param ownerNode The mesh that will be scaled around once attached
  40601. */
  40602. attach(ownerNode: Mesh): void;
  40603. /**
  40604. * Detaches the behavior from the mesh
  40605. */
  40606. detach(): void;
  40607. }
  40608. }
  40609. declare module "babylonjs/Behaviors/Meshes/index" {
  40610. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40611. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40612. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40613. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40614. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40615. }
  40616. declare module "babylonjs/Behaviors/index" {
  40617. export * from "babylonjs/Behaviors/behavior";
  40618. export * from "babylonjs/Behaviors/Cameras/index";
  40619. export * from "babylonjs/Behaviors/Meshes/index";
  40620. }
  40621. declare module "babylonjs/Bones/boneIKController" {
  40622. import { Bone } from "babylonjs/Bones/bone";
  40623. import { Vector3 } from "babylonjs/Maths/math.vector";
  40624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40625. import { Nullable } from "babylonjs/types";
  40626. /**
  40627. * Class used to apply inverse kinematics to bones
  40628. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40629. */
  40630. export class BoneIKController {
  40631. private static _tmpVecs;
  40632. private static _tmpQuat;
  40633. private static _tmpMats;
  40634. /**
  40635. * Gets or sets the target mesh
  40636. */
  40637. targetMesh: AbstractMesh;
  40638. /** Gets or sets the mesh used as pole */
  40639. poleTargetMesh: AbstractMesh;
  40640. /**
  40641. * Gets or sets the bone used as pole
  40642. */
  40643. poleTargetBone: Nullable<Bone>;
  40644. /**
  40645. * Gets or sets the target position
  40646. */
  40647. targetPosition: Vector3;
  40648. /**
  40649. * Gets or sets the pole target position
  40650. */
  40651. poleTargetPosition: Vector3;
  40652. /**
  40653. * Gets or sets the pole target local offset
  40654. */
  40655. poleTargetLocalOffset: Vector3;
  40656. /**
  40657. * Gets or sets the pole angle
  40658. */
  40659. poleAngle: number;
  40660. /**
  40661. * Gets or sets the mesh associated with the controller
  40662. */
  40663. mesh: AbstractMesh;
  40664. /**
  40665. * 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)
  40666. */
  40667. slerpAmount: number;
  40668. private _bone1Quat;
  40669. private _bone1Mat;
  40670. private _bone2Ang;
  40671. private _bone1;
  40672. private _bone2;
  40673. private _bone1Length;
  40674. private _bone2Length;
  40675. private _maxAngle;
  40676. private _maxReach;
  40677. private _rightHandedSystem;
  40678. private _bendAxis;
  40679. private _slerping;
  40680. private _adjustRoll;
  40681. /**
  40682. * Gets or sets maximum allowed angle
  40683. */
  40684. get maxAngle(): number;
  40685. set maxAngle(value: number);
  40686. /**
  40687. * Creates a new BoneIKController
  40688. * @param mesh defines the mesh to control
  40689. * @param bone defines the bone to control
  40690. * @param options defines options to set up the controller
  40691. */
  40692. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40693. targetMesh?: AbstractMesh;
  40694. poleTargetMesh?: AbstractMesh;
  40695. poleTargetBone?: Bone;
  40696. poleTargetLocalOffset?: Vector3;
  40697. poleAngle?: number;
  40698. bendAxis?: Vector3;
  40699. maxAngle?: number;
  40700. slerpAmount?: number;
  40701. });
  40702. private _setMaxAngle;
  40703. /**
  40704. * Force the controller to update the bones
  40705. */
  40706. update(): void;
  40707. }
  40708. }
  40709. declare module "babylonjs/Bones/boneLookController" {
  40710. import { Vector3 } from "babylonjs/Maths/math.vector";
  40711. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40712. import { Bone } from "babylonjs/Bones/bone";
  40713. import { Space } from "babylonjs/Maths/math.axis";
  40714. /**
  40715. * Class used to make a bone look toward a point in space
  40716. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40717. */
  40718. export class BoneLookController {
  40719. private static _tmpVecs;
  40720. private static _tmpQuat;
  40721. private static _tmpMats;
  40722. /**
  40723. * The target Vector3 that the bone will look at
  40724. */
  40725. target: Vector3;
  40726. /**
  40727. * The mesh that the bone is attached to
  40728. */
  40729. mesh: AbstractMesh;
  40730. /**
  40731. * The bone that will be looking to the target
  40732. */
  40733. bone: Bone;
  40734. /**
  40735. * The up axis of the coordinate system that is used when the bone is rotated
  40736. */
  40737. upAxis: Vector3;
  40738. /**
  40739. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40740. */
  40741. upAxisSpace: Space;
  40742. /**
  40743. * Used to make an adjustment to the yaw of the bone
  40744. */
  40745. adjustYaw: number;
  40746. /**
  40747. * Used to make an adjustment to the pitch of the bone
  40748. */
  40749. adjustPitch: number;
  40750. /**
  40751. * Used to make an adjustment to the roll of the bone
  40752. */
  40753. adjustRoll: number;
  40754. /**
  40755. * 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)
  40756. */
  40757. slerpAmount: number;
  40758. private _minYaw;
  40759. private _maxYaw;
  40760. private _minPitch;
  40761. private _maxPitch;
  40762. private _minYawSin;
  40763. private _minYawCos;
  40764. private _maxYawSin;
  40765. private _maxYawCos;
  40766. private _midYawConstraint;
  40767. private _minPitchTan;
  40768. private _maxPitchTan;
  40769. private _boneQuat;
  40770. private _slerping;
  40771. private _transformYawPitch;
  40772. private _transformYawPitchInv;
  40773. private _firstFrameSkipped;
  40774. private _yawRange;
  40775. private _fowardAxis;
  40776. /**
  40777. * Gets or sets the minimum yaw angle that the bone can look to
  40778. */
  40779. get minYaw(): number;
  40780. set minYaw(value: number);
  40781. /**
  40782. * Gets or sets the maximum yaw angle that the bone can look to
  40783. */
  40784. get maxYaw(): number;
  40785. set maxYaw(value: number);
  40786. /**
  40787. * Gets or sets the minimum pitch angle that the bone can look to
  40788. */
  40789. get minPitch(): number;
  40790. set minPitch(value: number);
  40791. /**
  40792. * Gets or sets the maximum pitch angle that the bone can look to
  40793. */
  40794. get maxPitch(): number;
  40795. set maxPitch(value: number);
  40796. /**
  40797. * Create a BoneLookController
  40798. * @param mesh the mesh that the bone belongs to
  40799. * @param bone the bone that will be looking to the target
  40800. * @param target the target Vector3 to look at
  40801. * @param options optional settings:
  40802. * * maxYaw: the maximum angle the bone will yaw to
  40803. * * minYaw: the minimum angle the bone will yaw to
  40804. * * maxPitch: the maximum angle the bone will pitch to
  40805. * * minPitch: the minimum angle the bone will yaw to
  40806. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40807. * * upAxis: the up axis of the coordinate system
  40808. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40809. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40810. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40811. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40812. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40813. * * adjustRoll: used to make an adjustment to the roll of the bone
  40814. **/
  40815. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40816. maxYaw?: number;
  40817. minYaw?: number;
  40818. maxPitch?: number;
  40819. minPitch?: number;
  40820. slerpAmount?: number;
  40821. upAxis?: Vector3;
  40822. upAxisSpace?: Space;
  40823. yawAxis?: Vector3;
  40824. pitchAxis?: Vector3;
  40825. adjustYaw?: number;
  40826. adjustPitch?: number;
  40827. adjustRoll?: number;
  40828. });
  40829. /**
  40830. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40831. */
  40832. update(): void;
  40833. private _getAngleDiff;
  40834. private _getAngleBetween;
  40835. private _isAngleBetween;
  40836. }
  40837. }
  40838. declare module "babylonjs/Bones/index" {
  40839. export * from "babylonjs/Bones/bone";
  40840. export * from "babylonjs/Bones/boneIKController";
  40841. export * from "babylonjs/Bones/boneLookController";
  40842. export * from "babylonjs/Bones/skeleton";
  40843. }
  40844. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40845. import { Nullable } from "babylonjs/types";
  40846. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40847. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40848. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40849. /**
  40850. * Manage the gamepad inputs to control an arc rotate camera.
  40851. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40852. */
  40853. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40854. /**
  40855. * Defines the camera the input is attached to.
  40856. */
  40857. camera: ArcRotateCamera;
  40858. /**
  40859. * Defines the gamepad the input is gathering event from.
  40860. */
  40861. gamepad: Nullable<Gamepad>;
  40862. /**
  40863. * Defines the gamepad rotation sensiblity.
  40864. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40865. */
  40866. gamepadRotationSensibility: number;
  40867. /**
  40868. * Defines the gamepad move sensiblity.
  40869. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40870. */
  40871. gamepadMoveSensibility: number;
  40872. private _yAxisScale;
  40873. /**
  40874. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40875. */
  40876. get invertYAxis(): boolean;
  40877. set invertYAxis(value: boolean);
  40878. private _onGamepadConnectedObserver;
  40879. private _onGamepadDisconnectedObserver;
  40880. /**
  40881. * Attach the input controls to a specific dom element to get the input from.
  40882. * @param element Defines the element the controls should be listened from
  40883. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40884. */
  40885. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40886. /**
  40887. * Detach the current controls from the specified dom element.
  40888. * @param element Defines the element to stop listening the inputs from
  40889. */
  40890. detachControl(element: Nullable<HTMLElement>): void;
  40891. /**
  40892. * Update the current camera state depending on the inputs that have been used this frame.
  40893. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40894. */
  40895. checkInputs(): void;
  40896. /**
  40897. * Gets the class name of the current intput.
  40898. * @returns the class name
  40899. */
  40900. getClassName(): string;
  40901. /**
  40902. * Get the friendly name associated with the input class.
  40903. * @returns the input friendly name
  40904. */
  40905. getSimpleName(): string;
  40906. }
  40907. }
  40908. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40909. import { Nullable } from "babylonjs/types";
  40910. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40911. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40912. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40913. interface ArcRotateCameraInputsManager {
  40914. /**
  40915. * Add orientation input support to the input manager.
  40916. * @returns the current input manager
  40917. */
  40918. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40919. }
  40920. }
  40921. /**
  40922. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40923. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40924. */
  40925. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40926. /**
  40927. * Defines the camera the input is attached to.
  40928. */
  40929. camera: ArcRotateCamera;
  40930. /**
  40931. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40932. */
  40933. alphaCorrection: number;
  40934. /**
  40935. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40936. */
  40937. gammaCorrection: number;
  40938. private _alpha;
  40939. private _gamma;
  40940. private _dirty;
  40941. private _deviceOrientationHandler;
  40942. /**
  40943. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40944. */
  40945. constructor();
  40946. /**
  40947. * Attach the input controls to a specific dom element to get the input from.
  40948. * @param element Defines the element the controls should be listened from
  40949. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40950. */
  40951. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40952. /** @hidden */
  40953. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40954. /**
  40955. * Update the current camera state depending on the inputs that have been used this frame.
  40956. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40957. */
  40958. checkInputs(): void;
  40959. /**
  40960. * Detach the current controls from the specified dom element.
  40961. * @param element Defines the element to stop listening the inputs from
  40962. */
  40963. detachControl(element: Nullable<HTMLElement>): void;
  40964. /**
  40965. * Gets the class name of the current intput.
  40966. * @returns the class name
  40967. */
  40968. getClassName(): string;
  40969. /**
  40970. * Get the friendly name associated with the input class.
  40971. * @returns the input friendly name
  40972. */
  40973. getSimpleName(): string;
  40974. }
  40975. }
  40976. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  40977. import { Nullable } from "babylonjs/types";
  40978. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40979. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  40980. /**
  40981. * Listen to mouse events to control the camera.
  40982. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40983. */
  40984. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  40985. /**
  40986. * Defines the camera the input is attached to.
  40987. */
  40988. camera: FlyCamera;
  40989. /**
  40990. * Defines if touch is enabled. (Default is true.)
  40991. */
  40992. touchEnabled: boolean;
  40993. /**
  40994. * Defines the buttons associated with the input to handle camera rotation.
  40995. */
  40996. buttons: number[];
  40997. /**
  40998. * Assign buttons for Yaw control.
  40999. */
  41000. buttonsYaw: number[];
  41001. /**
  41002. * Assign buttons for Pitch control.
  41003. */
  41004. buttonsPitch: number[];
  41005. /**
  41006. * Assign buttons for Roll control.
  41007. */
  41008. buttonsRoll: number[];
  41009. /**
  41010. * Detect if any button is being pressed while mouse is moved.
  41011. * -1 = Mouse locked.
  41012. * 0 = Left button.
  41013. * 1 = Middle Button.
  41014. * 2 = Right Button.
  41015. */
  41016. activeButton: number;
  41017. /**
  41018. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41019. * Higher values reduce its sensitivity.
  41020. */
  41021. angularSensibility: number;
  41022. private _mousemoveCallback;
  41023. private _observer;
  41024. private _rollObserver;
  41025. private previousPosition;
  41026. private noPreventDefault;
  41027. private element;
  41028. /**
  41029. * Listen to mouse events to control the camera.
  41030. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41031. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41032. */
  41033. constructor(touchEnabled?: boolean);
  41034. /**
  41035. * Attach the mouse control to the HTML DOM element.
  41036. * @param element Defines the element that listens to the input events.
  41037. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41038. */
  41039. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41040. /**
  41041. * Detach the current controls from the specified dom element.
  41042. * @param element Defines the element to stop listening the inputs from
  41043. */
  41044. detachControl(element: Nullable<HTMLElement>): void;
  41045. /**
  41046. * Gets the class name of the current input.
  41047. * @returns the class name.
  41048. */
  41049. getClassName(): string;
  41050. /**
  41051. * Get the friendly name associated with the input class.
  41052. * @returns the input's friendly name.
  41053. */
  41054. getSimpleName(): string;
  41055. private _pointerInput;
  41056. private _onMouseMove;
  41057. /**
  41058. * Rotate camera by mouse offset.
  41059. */
  41060. private rotateCamera;
  41061. }
  41062. }
  41063. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41064. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41065. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41066. /**
  41067. * Default Inputs manager for the FlyCamera.
  41068. * It groups all the default supported inputs for ease of use.
  41069. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41070. */
  41071. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41072. /**
  41073. * Instantiates a new FlyCameraInputsManager.
  41074. * @param camera Defines the camera the inputs belong to.
  41075. */
  41076. constructor(camera: FlyCamera);
  41077. /**
  41078. * Add keyboard input support to the input manager.
  41079. * @returns the new FlyCameraKeyboardMoveInput().
  41080. */
  41081. addKeyboard(): FlyCameraInputsManager;
  41082. /**
  41083. * Add mouse input support to the input manager.
  41084. * @param touchEnabled Enable touch screen support.
  41085. * @returns the new FlyCameraMouseInput().
  41086. */
  41087. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41088. }
  41089. }
  41090. declare module "babylonjs/Cameras/flyCamera" {
  41091. import { Scene } from "babylonjs/scene";
  41092. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41094. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41095. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41096. /**
  41097. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41098. * such as in a 3D Space Shooter or a Flight Simulator.
  41099. */
  41100. export class FlyCamera extends TargetCamera {
  41101. /**
  41102. * Define the collision ellipsoid of the camera.
  41103. * This is helpful for simulating a camera body, like a player's body.
  41104. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41105. */
  41106. ellipsoid: Vector3;
  41107. /**
  41108. * Define an offset for the position of the ellipsoid around the camera.
  41109. * This can be helpful if the camera is attached away from the player's body center,
  41110. * such as at its head.
  41111. */
  41112. ellipsoidOffset: Vector3;
  41113. /**
  41114. * Enable or disable collisions of the camera with the rest of the scene objects.
  41115. */
  41116. checkCollisions: boolean;
  41117. /**
  41118. * Enable or disable gravity on the camera.
  41119. */
  41120. applyGravity: boolean;
  41121. /**
  41122. * Define the current direction the camera is moving to.
  41123. */
  41124. cameraDirection: Vector3;
  41125. /**
  41126. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41127. * This overrides and empties cameraRotation.
  41128. */
  41129. rotationQuaternion: Quaternion;
  41130. /**
  41131. * Track Roll to maintain the wanted Rolling when looking around.
  41132. */
  41133. _trackRoll: number;
  41134. /**
  41135. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41136. */
  41137. rollCorrect: number;
  41138. /**
  41139. * Mimic a banked turn, Rolling the camera when Yawing.
  41140. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41141. */
  41142. bankedTurn: boolean;
  41143. /**
  41144. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41145. */
  41146. bankedTurnLimit: number;
  41147. /**
  41148. * Value of 0 disables the banked Roll.
  41149. * Value of 1 is equal to the Yaw angle in radians.
  41150. */
  41151. bankedTurnMultiplier: number;
  41152. /**
  41153. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41154. */
  41155. inputs: FlyCameraInputsManager;
  41156. /**
  41157. * Gets the input sensibility for mouse input.
  41158. * Higher values reduce sensitivity.
  41159. */
  41160. get angularSensibility(): number;
  41161. /**
  41162. * Sets the input sensibility for a mouse input.
  41163. * Higher values reduce sensitivity.
  41164. */
  41165. set angularSensibility(value: number);
  41166. /**
  41167. * Get the keys for camera movement forward.
  41168. */
  41169. get keysForward(): number[];
  41170. /**
  41171. * Set the keys for camera movement forward.
  41172. */
  41173. set keysForward(value: number[]);
  41174. /**
  41175. * Get the keys for camera movement backward.
  41176. */
  41177. get keysBackward(): number[];
  41178. set keysBackward(value: number[]);
  41179. /**
  41180. * Get the keys for camera movement up.
  41181. */
  41182. get keysUp(): number[];
  41183. /**
  41184. * Set the keys for camera movement up.
  41185. */
  41186. set keysUp(value: number[]);
  41187. /**
  41188. * Get the keys for camera movement down.
  41189. */
  41190. get keysDown(): number[];
  41191. /**
  41192. * Set the keys for camera movement down.
  41193. */
  41194. set keysDown(value: number[]);
  41195. /**
  41196. * Get the keys for camera movement left.
  41197. */
  41198. get keysLeft(): number[];
  41199. /**
  41200. * Set the keys for camera movement left.
  41201. */
  41202. set keysLeft(value: number[]);
  41203. /**
  41204. * Set the keys for camera movement right.
  41205. */
  41206. get keysRight(): number[];
  41207. /**
  41208. * Set the keys for camera movement right.
  41209. */
  41210. set keysRight(value: number[]);
  41211. /**
  41212. * Event raised when the camera collides with a mesh in the scene.
  41213. */
  41214. onCollide: (collidedMesh: AbstractMesh) => void;
  41215. private _collider;
  41216. private _needMoveForGravity;
  41217. private _oldPosition;
  41218. private _diffPosition;
  41219. private _newPosition;
  41220. /** @hidden */
  41221. _localDirection: Vector3;
  41222. /** @hidden */
  41223. _transformedDirection: Vector3;
  41224. /**
  41225. * Instantiates a FlyCamera.
  41226. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41227. * such as in a 3D Space Shooter or a Flight Simulator.
  41228. * @param name Define the name of the camera in the scene.
  41229. * @param position Define the starting position of the camera in the scene.
  41230. * @param scene Define the scene the camera belongs to.
  41231. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41232. */
  41233. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41234. /**
  41235. * Attach a control to the HTML DOM element.
  41236. * @param element Defines the element that listens to the input events.
  41237. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41238. */
  41239. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41240. /**
  41241. * Detach a control from the HTML DOM element.
  41242. * The camera will stop reacting to that input.
  41243. * @param element Defines the element that listens to the input events.
  41244. */
  41245. detachControl(element: HTMLElement): void;
  41246. private _collisionMask;
  41247. /**
  41248. * Get the mask that the camera ignores in collision events.
  41249. */
  41250. get collisionMask(): number;
  41251. /**
  41252. * Set the mask that the camera ignores in collision events.
  41253. */
  41254. set collisionMask(mask: number);
  41255. /** @hidden */
  41256. _collideWithWorld(displacement: Vector3): void;
  41257. /** @hidden */
  41258. private _onCollisionPositionChange;
  41259. /** @hidden */
  41260. _checkInputs(): void;
  41261. /** @hidden */
  41262. _decideIfNeedsToMove(): boolean;
  41263. /** @hidden */
  41264. _updatePosition(): void;
  41265. /**
  41266. * Restore the Roll to its target value at the rate specified.
  41267. * @param rate - Higher means slower restoring.
  41268. * @hidden
  41269. */
  41270. restoreRoll(rate: number): void;
  41271. /**
  41272. * Destroy the camera and release the current resources held by it.
  41273. */
  41274. dispose(): void;
  41275. /**
  41276. * Get the current object class name.
  41277. * @returns the class name.
  41278. */
  41279. getClassName(): string;
  41280. }
  41281. }
  41282. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41283. import { Nullable } from "babylonjs/types";
  41284. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41285. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41286. /**
  41287. * Listen to keyboard events to control the camera.
  41288. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41289. */
  41290. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41291. /**
  41292. * Defines the camera the input is attached to.
  41293. */
  41294. camera: FlyCamera;
  41295. /**
  41296. * The list of keyboard keys used to control the forward move of the camera.
  41297. */
  41298. keysForward: number[];
  41299. /**
  41300. * The list of keyboard keys used to control the backward move of the camera.
  41301. */
  41302. keysBackward: number[];
  41303. /**
  41304. * The list of keyboard keys used to control the forward move of the camera.
  41305. */
  41306. keysUp: number[];
  41307. /**
  41308. * The list of keyboard keys used to control the backward move of the camera.
  41309. */
  41310. keysDown: number[];
  41311. /**
  41312. * The list of keyboard keys used to control the right strafe move of the camera.
  41313. */
  41314. keysRight: number[];
  41315. /**
  41316. * The list of keyboard keys used to control the left strafe move of the camera.
  41317. */
  41318. keysLeft: number[];
  41319. private _keys;
  41320. private _onCanvasBlurObserver;
  41321. private _onKeyboardObserver;
  41322. private _engine;
  41323. private _scene;
  41324. /**
  41325. * Attach the input controls to a specific dom element to get the input from.
  41326. * @param element Defines the element the controls should be listened from
  41327. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41328. */
  41329. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41330. /**
  41331. * Detach the current controls from the specified dom element.
  41332. * @param element Defines the element to stop listening the inputs from
  41333. */
  41334. detachControl(element: Nullable<HTMLElement>): void;
  41335. /**
  41336. * Gets the class name of the current intput.
  41337. * @returns the class name
  41338. */
  41339. getClassName(): string;
  41340. /** @hidden */
  41341. _onLostFocus(e: FocusEvent): void;
  41342. /**
  41343. * Get the friendly name associated with the input class.
  41344. * @returns the input friendly name
  41345. */
  41346. getSimpleName(): string;
  41347. /**
  41348. * Update the current camera state depending on the inputs that have been used this frame.
  41349. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41350. */
  41351. checkInputs(): void;
  41352. }
  41353. }
  41354. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41355. import { Nullable } from "babylonjs/types";
  41356. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41357. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41358. /**
  41359. * Manage the mouse wheel inputs to control a follow camera.
  41360. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41361. */
  41362. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41363. /**
  41364. * Defines the camera the input is attached to.
  41365. */
  41366. camera: FollowCamera;
  41367. /**
  41368. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41369. */
  41370. axisControlRadius: boolean;
  41371. /**
  41372. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41373. */
  41374. axisControlHeight: boolean;
  41375. /**
  41376. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41377. */
  41378. axisControlRotation: boolean;
  41379. /**
  41380. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41381. * relation to mouseWheel events.
  41382. */
  41383. wheelPrecision: number;
  41384. /**
  41385. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41386. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41387. */
  41388. wheelDeltaPercentage: number;
  41389. private _wheel;
  41390. private _observer;
  41391. /**
  41392. * Attach the input controls to a specific dom element to get the input from.
  41393. * @param element Defines the element the controls should be listened from
  41394. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41395. */
  41396. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41397. /**
  41398. * Detach the current controls from the specified dom element.
  41399. * @param element Defines the element to stop listening the inputs from
  41400. */
  41401. detachControl(element: Nullable<HTMLElement>): void;
  41402. /**
  41403. * Gets the class name of the current intput.
  41404. * @returns the class name
  41405. */
  41406. getClassName(): string;
  41407. /**
  41408. * Get the friendly name associated with the input class.
  41409. * @returns the input friendly name
  41410. */
  41411. getSimpleName(): string;
  41412. }
  41413. }
  41414. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41415. import { Nullable } from "babylonjs/types";
  41416. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41417. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41418. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41419. /**
  41420. * Manage the pointers inputs to control an follow camera.
  41421. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41422. */
  41423. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41424. /**
  41425. * Defines the camera the input is attached to.
  41426. */
  41427. camera: FollowCamera;
  41428. /**
  41429. * Gets the class name of the current input.
  41430. * @returns the class name
  41431. */
  41432. getClassName(): string;
  41433. /**
  41434. * Defines the pointer angular sensibility along the X axis or how fast is
  41435. * the camera rotating.
  41436. * A negative number will reverse the axis direction.
  41437. */
  41438. angularSensibilityX: number;
  41439. /**
  41440. * Defines the pointer angular sensibility along the Y axis or how fast is
  41441. * the camera rotating.
  41442. * A negative number will reverse the axis direction.
  41443. */
  41444. angularSensibilityY: number;
  41445. /**
  41446. * Defines the pointer pinch precision or how fast is the camera zooming.
  41447. * A negative number will reverse the axis direction.
  41448. */
  41449. pinchPrecision: number;
  41450. /**
  41451. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41452. * from 0.
  41453. * It defines the percentage of current camera.radius to use as delta when
  41454. * pinch zoom is used.
  41455. */
  41456. pinchDeltaPercentage: number;
  41457. /**
  41458. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41459. */
  41460. axisXControlRadius: boolean;
  41461. /**
  41462. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41463. */
  41464. axisXControlHeight: boolean;
  41465. /**
  41466. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41467. */
  41468. axisXControlRotation: boolean;
  41469. /**
  41470. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41471. */
  41472. axisYControlRadius: boolean;
  41473. /**
  41474. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41475. */
  41476. axisYControlHeight: boolean;
  41477. /**
  41478. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41479. */
  41480. axisYControlRotation: boolean;
  41481. /**
  41482. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41483. */
  41484. axisPinchControlRadius: boolean;
  41485. /**
  41486. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41487. */
  41488. axisPinchControlHeight: boolean;
  41489. /**
  41490. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41491. */
  41492. axisPinchControlRotation: boolean;
  41493. /**
  41494. * Log error messages if basic misconfiguration has occurred.
  41495. */
  41496. warningEnable: boolean;
  41497. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41498. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41499. private _warningCounter;
  41500. private _warning;
  41501. }
  41502. }
  41503. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41504. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41505. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41506. /**
  41507. * Default Inputs manager for the FollowCamera.
  41508. * It groups all the default supported inputs for ease of use.
  41509. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41510. */
  41511. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41512. /**
  41513. * Instantiates a new FollowCameraInputsManager.
  41514. * @param camera Defines the camera the inputs belong to
  41515. */
  41516. constructor(camera: FollowCamera);
  41517. /**
  41518. * Add keyboard input support to the input manager.
  41519. * @returns the current input manager
  41520. */
  41521. addKeyboard(): FollowCameraInputsManager;
  41522. /**
  41523. * Add mouse wheel input support to the input manager.
  41524. * @returns the current input manager
  41525. */
  41526. addMouseWheel(): FollowCameraInputsManager;
  41527. /**
  41528. * Add pointers input support to the input manager.
  41529. * @returns the current input manager
  41530. */
  41531. addPointers(): FollowCameraInputsManager;
  41532. /**
  41533. * Add orientation input support to the input manager.
  41534. * @returns the current input manager
  41535. */
  41536. addVRDeviceOrientation(): FollowCameraInputsManager;
  41537. }
  41538. }
  41539. declare module "babylonjs/Cameras/followCamera" {
  41540. import { Nullable } from "babylonjs/types";
  41541. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41542. import { Scene } from "babylonjs/scene";
  41543. import { Vector3 } from "babylonjs/Maths/math.vector";
  41544. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41545. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41546. /**
  41547. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41548. * an arc rotate version arcFollowCamera are available.
  41549. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41550. */
  41551. export class FollowCamera extends TargetCamera {
  41552. /**
  41553. * Distance the follow camera should follow an object at
  41554. */
  41555. radius: number;
  41556. /**
  41557. * Minimum allowed distance of the camera to the axis of rotation
  41558. * (The camera can not get closer).
  41559. * This can help limiting how the Camera is able to move in the scene.
  41560. */
  41561. lowerRadiusLimit: Nullable<number>;
  41562. /**
  41563. * Maximum allowed distance of the camera to the axis of rotation
  41564. * (The camera can not get further).
  41565. * This can help limiting how the Camera is able to move in the scene.
  41566. */
  41567. upperRadiusLimit: Nullable<number>;
  41568. /**
  41569. * Define a rotation offset between the camera and the object it follows
  41570. */
  41571. rotationOffset: number;
  41572. /**
  41573. * Minimum allowed angle to camera position relative to target object.
  41574. * This can help limiting how the Camera is able to move in the scene.
  41575. */
  41576. lowerRotationOffsetLimit: Nullable<number>;
  41577. /**
  41578. * Maximum allowed angle to camera position relative to target object.
  41579. * This can help limiting how the Camera is able to move in the scene.
  41580. */
  41581. upperRotationOffsetLimit: Nullable<number>;
  41582. /**
  41583. * Define a height offset between the camera and the object it follows.
  41584. * It can help following an object from the top (like a car chaing a plane)
  41585. */
  41586. heightOffset: number;
  41587. /**
  41588. * Minimum allowed height of camera position relative to target object.
  41589. * This can help limiting how the Camera is able to move in the scene.
  41590. */
  41591. lowerHeightOffsetLimit: Nullable<number>;
  41592. /**
  41593. * Maximum allowed height of camera position relative to target object.
  41594. * This can help limiting how the Camera is able to move in the scene.
  41595. */
  41596. upperHeightOffsetLimit: Nullable<number>;
  41597. /**
  41598. * Define how fast the camera can accelerate to follow it s target.
  41599. */
  41600. cameraAcceleration: number;
  41601. /**
  41602. * Define the speed limit of the camera following an object.
  41603. */
  41604. maxCameraSpeed: number;
  41605. /**
  41606. * Define the target of the camera.
  41607. */
  41608. lockedTarget: Nullable<AbstractMesh>;
  41609. /**
  41610. * Defines the input associated with the camera.
  41611. */
  41612. inputs: FollowCameraInputsManager;
  41613. /**
  41614. * Instantiates the follow camera.
  41615. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41616. * @param name Define the name of the camera in the scene
  41617. * @param position Define the position of the camera
  41618. * @param scene Define the scene the camera belong to
  41619. * @param lockedTarget Define the target of the camera
  41620. */
  41621. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41622. private _follow;
  41623. /**
  41624. * Attached controls to the current camera.
  41625. * @param element Defines the element the controls should be listened from
  41626. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41627. */
  41628. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41629. /**
  41630. * Detach the current controls from the camera.
  41631. * The camera will stop reacting to inputs.
  41632. * @param element Defines the element to stop listening the inputs from
  41633. */
  41634. detachControl(element: HTMLElement): void;
  41635. /** @hidden */
  41636. _checkInputs(): void;
  41637. private _checkLimits;
  41638. /**
  41639. * Gets the camera class name.
  41640. * @returns the class name
  41641. */
  41642. getClassName(): string;
  41643. }
  41644. /**
  41645. * Arc Rotate version of the follow camera.
  41646. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41647. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41648. */
  41649. export class ArcFollowCamera extends TargetCamera {
  41650. /** The longitudinal angle of the camera */
  41651. alpha: number;
  41652. /** The latitudinal angle of the camera */
  41653. beta: number;
  41654. /** The radius of the camera from its target */
  41655. radius: number;
  41656. /** Define the camera target (the messh it should follow) */
  41657. target: Nullable<AbstractMesh>;
  41658. private _cartesianCoordinates;
  41659. /**
  41660. * Instantiates a new ArcFollowCamera
  41661. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41662. * @param name Define the name of the camera
  41663. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41664. * @param beta Define the rotation angle of the camera around the elevation axis
  41665. * @param radius Define the radius of the camera from its target point
  41666. * @param target Define the target of the camera
  41667. * @param scene Define the scene the camera belongs to
  41668. */
  41669. constructor(name: string,
  41670. /** The longitudinal angle of the camera */
  41671. alpha: number,
  41672. /** The latitudinal angle of the camera */
  41673. beta: number,
  41674. /** The radius of the camera from its target */
  41675. radius: number,
  41676. /** Define the camera target (the messh it should follow) */
  41677. target: Nullable<AbstractMesh>, scene: Scene);
  41678. private _follow;
  41679. /** @hidden */
  41680. _checkInputs(): void;
  41681. /**
  41682. * Returns the class name of the object.
  41683. * It is mostly used internally for serialization purposes.
  41684. */
  41685. getClassName(): string;
  41686. }
  41687. }
  41688. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41689. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41690. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41691. import { Nullable } from "babylonjs/types";
  41692. /**
  41693. * Manage the keyboard inputs to control the movement of a follow camera.
  41694. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41695. */
  41696. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41697. /**
  41698. * Defines the camera the input is attached to.
  41699. */
  41700. camera: FollowCamera;
  41701. /**
  41702. * Defines the list of key codes associated with the up action (increase heightOffset)
  41703. */
  41704. keysHeightOffsetIncr: number[];
  41705. /**
  41706. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41707. */
  41708. keysHeightOffsetDecr: number[];
  41709. /**
  41710. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41711. */
  41712. keysHeightOffsetModifierAlt: boolean;
  41713. /**
  41714. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41715. */
  41716. keysHeightOffsetModifierCtrl: boolean;
  41717. /**
  41718. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41719. */
  41720. keysHeightOffsetModifierShift: boolean;
  41721. /**
  41722. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41723. */
  41724. keysRotationOffsetIncr: number[];
  41725. /**
  41726. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41727. */
  41728. keysRotationOffsetDecr: number[];
  41729. /**
  41730. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41731. */
  41732. keysRotationOffsetModifierAlt: boolean;
  41733. /**
  41734. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41735. */
  41736. keysRotationOffsetModifierCtrl: boolean;
  41737. /**
  41738. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41739. */
  41740. keysRotationOffsetModifierShift: boolean;
  41741. /**
  41742. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41743. */
  41744. keysRadiusIncr: number[];
  41745. /**
  41746. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41747. */
  41748. keysRadiusDecr: number[];
  41749. /**
  41750. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41751. */
  41752. keysRadiusModifierAlt: boolean;
  41753. /**
  41754. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41755. */
  41756. keysRadiusModifierCtrl: boolean;
  41757. /**
  41758. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41759. */
  41760. keysRadiusModifierShift: boolean;
  41761. /**
  41762. * Defines the rate of change of heightOffset.
  41763. */
  41764. heightSensibility: number;
  41765. /**
  41766. * Defines the rate of change of rotationOffset.
  41767. */
  41768. rotationSensibility: number;
  41769. /**
  41770. * Defines the rate of change of radius.
  41771. */
  41772. radiusSensibility: number;
  41773. private _keys;
  41774. private _ctrlPressed;
  41775. private _altPressed;
  41776. private _shiftPressed;
  41777. private _onCanvasBlurObserver;
  41778. private _onKeyboardObserver;
  41779. private _engine;
  41780. private _scene;
  41781. /**
  41782. * Attach the input controls to a specific dom element to get the input from.
  41783. * @param element Defines the element the controls should be listened from
  41784. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41785. */
  41786. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41787. /**
  41788. * Detach the current controls from the specified dom element.
  41789. * @param element Defines the element to stop listening the inputs from
  41790. */
  41791. detachControl(element: Nullable<HTMLElement>): void;
  41792. /**
  41793. * Update the current camera state depending on the inputs that have been used this frame.
  41794. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41795. */
  41796. checkInputs(): void;
  41797. /**
  41798. * Gets the class name of the current input.
  41799. * @returns the class name
  41800. */
  41801. getClassName(): string;
  41802. /**
  41803. * Get the friendly name associated with the input class.
  41804. * @returns the input friendly name
  41805. */
  41806. getSimpleName(): string;
  41807. /**
  41808. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41809. * allow modification of the heightOffset value.
  41810. */
  41811. private _modifierHeightOffset;
  41812. /**
  41813. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41814. * allow modification of the rotationOffset value.
  41815. */
  41816. private _modifierRotationOffset;
  41817. /**
  41818. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41819. * allow modification of the radius value.
  41820. */
  41821. private _modifierRadius;
  41822. }
  41823. }
  41824. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41825. import { Nullable } from "babylonjs/types";
  41826. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41827. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41828. import { Observable } from "babylonjs/Misc/observable";
  41829. module "babylonjs/Cameras/freeCameraInputsManager" {
  41830. interface FreeCameraInputsManager {
  41831. /**
  41832. * @hidden
  41833. */
  41834. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41835. /**
  41836. * Add orientation input support to the input manager.
  41837. * @returns the current input manager
  41838. */
  41839. addDeviceOrientation(): FreeCameraInputsManager;
  41840. }
  41841. }
  41842. /**
  41843. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41844. * Screen rotation is taken into account.
  41845. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41846. */
  41847. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41848. private _camera;
  41849. private _screenOrientationAngle;
  41850. private _constantTranform;
  41851. private _screenQuaternion;
  41852. private _alpha;
  41853. private _beta;
  41854. private _gamma;
  41855. /**
  41856. * Can be used to detect if a device orientation sensor is available on a device
  41857. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41858. * @returns a promise that will resolve on orientation change
  41859. */
  41860. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41861. /**
  41862. * @hidden
  41863. */
  41864. _onDeviceOrientationChangedObservable: Observable<void>;
  41865. /**
  41866. * Instantiates a new input
  41867. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41868. */
  41869. constructor();
  41870. /**
  41871. * Define the camera controlled by the input.
  41872. */
  41873. get camera(): FreeCamera;
  41874. set camera(camera: FreeCamera);
  41875. /**
  41876. * Attach the input controls to a specific dom element to get the input from.
  41877. * @param element Defines the element the controls should be listened from
  41878. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41879. */
  41880. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41881. private _orientationChanged;
  41882. private _deviceOrientation;
  41883. /**
  41884. * Detach the current controls from the specified dom element.
  41885. * @param element Defines the element to stop listening the inputs from
  41886. */
  41887. detachControl(element: Nullable<HTMLElement>): void;
  41888. /**
  41889. * Update the current camera state depending on the inputs that have been used this frame.
  41890. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41891. */
  41892. checkInputs(): void;
  41893. /**
  41894. * Gets the class name of the current intput.
  41895. * @returns the class name
  41896. */
  41897. getClassName(): string;
  41898. /**
  41899. * Get the friendly name associated with the input class.
  41900. * @returns the input friendly name
  41901. */
  41902. getSimpleName(): string;
  41903. }
  41904. }
  41905. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41906. import { Nullable } from "babylonjs/types";
  41907. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41908. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41909. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41910. /**
  41911. * Manage the gamepad inputs to control a free camera.
  41912. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41913. */
  41914. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41915. /**
  41916. * Define the camera the input is attached to.
  41917. */
  41918. camera: FreeCamera;
  41919. /**
  41920. * Define the Gamepad controlling the input
  41921. */
  41922. gamepad: Nullable<Gamepad>;
  41923. /**
  41924. * Defines the gamepad rotation sensiblity.
  41925. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41926. */
  41927. gamepadAngularSensibility: number;
  41928. /**
  41929. * Defines the gamepad move sensiblity.
  41930. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41931. */
  41932. gamepadMoveSensibility: number;
  41933. private _yAxisScale;
  41934. /**
  41935. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41936. */
  41937. get invertYAxis(): boolean;
  41938. set invertYAxis(value: boolean);
  41939. private _onGamepadConnectedObserver;
  41940. private _onGamepadDisconnectedObserver;
  41941. private _cameraTransform;
  41942. private _deltaTransform;
  41943. private _vector3;
  41944. private _vector2;
  41945. /**
  41946. * Attach the input controls to a specific dom element to get the input from.
  41947. * @param element Defines the element the controls should be listened from
  41948. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41949. */
  41950. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41951. /**
  41952. * Detach the current controls from the specified dom element.
  41953. * @param element Defines the element to stop listening the inputs from
  41954. */
  41955. detachControl(element: Nullable<HTMLElement>): void;
  41956. /**
  41957. * Update the current camera state depending on the inputs that have been used this frame.
  41958. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41959. */
  41960. checkInputs(): void;
  41961. /**
  41962. * Gets the class name of the current intput.
  41963. * @returns the class name
  41964. */
  41965. getClassName(): string;
  41966. /**
  41967. * Get the friendly name associated with the input class.
  41968. * @returns the input friendly name
  41969. */
  41970. getSimpleName(): string;
  41971. }
  41972. }
  41973. declare module "babylonjs/Misc/virtualJoystick" {
  41974. import { Nullable } from "babylonjs/types";
  41975. import { Vector3 } from "babylonjs/Maths/math.vector";
  41976. /**
  41977. * Defines the potential axis of a Joystick
  41978. */
  41979. export enum JoystickAxis {
  41980. /** X axis */
  41981. X = 0,
  41982. /** Y axis */
  41983. Y = 1,
  41984. /** Z axis */
  41985. Z = 2
  41986. }
  41987. /**
  41988. * Class used to define virtual joystick (used in touch mode)
  41989. */
  41990. export class VirtualJoystick {
  41991. /**
  41992. * Gets or sets a boolean indicating that left and right values must be inverted
  41993. */
  41994. reverseLeftRight: boolean;
  41995. /**
  41996. * Gets or sets a boolean indicating that up and down values must be inverted
  41997. */
  41998. reverseUpDown: boolean;
  41999. /**
  42000. * Gets the offset value for the position (ie. the change of the position value)
  42001. */
  42002. deltaPosition: Vector3;
  42003. /**
  42004. * Gets a boolean indicating if the virtual joystick was pressed
  42005. */
  42006. pressed: boolean;
  42007. /**
  42008. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42009. */
  42010. static Canvas: Nullable<HTMLCanvasElement>;
  42011. private static _globalJoystickIndex;
  42012. private static vjCanvasContext;
  42013. private static vjCanvasWidth;
  42014. private static vjCanvasHeight;
  42015. private static halfWidth;
  42016. private _action;
  42017. private _axisTargetedByLeftAndRight;
  42018. private _axisTargetedByUpAndDown;
  42019. private _joystickSensibility;
  42020. private _inversedSensibility;
  42021. private _joystickPointerID;
  42022. private _joystickColor;
  42023. private _joystickPointerPos;
  42024. private _joystickPreviousPointerPos;
  42025. private _joystickPointerStartPos;
  42026. private _deltaJoystickVector;
  42027. private _leftJoystick;
  42028. private _touches;
  42029. private _onPointerDownHandlerRef;
  42030. private _onPointerMoveHandlerRef;
  42031. private _onPointerUpHandlerRef;
  42032. private _onResize;
  42033. /**
  42034. * Creates a new virtual joystick
  42035. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42036. */
  42037. constructor(leftJoystick?: boolean);
  42038. /**
  42039. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42040. * @param newJoystickSensibility defines the new sensibility
  42041. */
  42042. setJoystickSensibility(newJoystickSensibility: number): void;
  42043. private _onPointerDown;
  42044. private _onPointerMove;
  42045. private _onPointerUp;
  42046. /**
  42047. * Change the color of the virtual joystick
  42048. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42049. */
  42050. setJoystickColor(newColor: string): void;
  42051. /**
  42052. * Defines a callback to call when the joystick is touched
  42053. * @param action defines the callback
  42054. */
  42055. setActionOnTouch(action: () => any): void;
  42056. /**
  42057. * Defines which axis you'd like to control for left & right
  42058. * @param axis defines the axis to use
  42059. */
  42060. setAxisForLeftRight(axis: JoystickAxis): void;
  42061. /**
  42062. * Defines which axis you'd like to control for up & down
  42063. * @param axis defines the axis to use
  42064. */
  42065. setAxisForUpDown(axis: JoystickAxis): void;
  42066. private _drawVirtualJoystick;
  42067. /**
  42068. * Release internal HTML canvas
  42069. */
  42070. releaseCanvas(): void;
  42071. }
  42072. }
  42073. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42074. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42075. import { Nullable } from "babylonjs/types";
  42076. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42077. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42078. module "babylonjs/Cameras/freeCameraInputsManager" {
  42079. interface FreeCameraInputsManager {
  42080. /**
  42081. * Add virtual joystick input support to the input manager.
  42082. * @returns the current input manager
  42083. */
  42084. addVirtualJoystick(): FreeCameraInputsManager;
  42085. }
  42086. }
  42087. /**
  42088. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42089. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42090. */
  42091. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42092. /**
  42093. * Defines the camera the input is attached to.
  42094. */
  42095. camera: FreeCamera;
  42096. private _leftjoystick;
  42097. private _rightjoystick;
  42098. /**
  42099. * Gets the left stick of the virtual joystick.
  42100. * @returns The virtual Joystick
  42101. */
  42102. getLeftJoystick(): VirtualJoystick;
  42103. /**
  42104. * Gets the right stick of the virtual joystick.
  42105. * @returns The virtual Joystick
  42106. */
  42107. getRightJoystick(): VirtualJoystick;
  42108. /**
  42109. * Update the current camera state depending on the inputs that have been used this frame.
  42110. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42111. */
  42112. checkInputs(): void;
  42113. /**
  42114. * Attach the input controls to a specific dom element to get the input from.
  42115. * @param element Defines the element the controls should be listened from
  42116. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42117. */
  42118. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42119. /**
  42120. * Detach the current controls from the specified dom element.
  42121. * @param element Defines the element to stop listening the inputs from
  42122. */
  42123. detachControl(element: Nullable<HTMLElement>): void;
  42124. /**
  42125. * Gets the class name of the current intput.
  42126. * @returns the class name
  42127. */
  42128. getClassName(): string;
  42129. /**
  42130. * Get the friendly name associated with the input class.
  42131. * @returns the input friendly name
  42132. */
  42133. getSimpleName(): string;
  42134. }
  42135. }
  42136. declare module "babylonjs/Cameras/Inputs/index" {
  42137. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42138. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42139. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42140. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42141. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42142. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42143. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42144. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42145. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42146. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42147. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42148. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42149. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42150. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42151. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42152. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42153. }
  42154. declare module "babylonjs/Cameras/touchCamera" {
  42155. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42156. import { Scene } from "babylonjs/scene";
  42157. import { Vector3 } from "babylonjs/Maths/math.vector";
  42158. /**
  42159. * This represents a FPS type of camera controlled by touch.
  42160. * This is like a universal camera minus the Gamepad controls.
  42161. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42162. */
  42163. export class TouchCamera extends FreeCamera {
  42164. /**
  42165. * Defines the touch sensibility for rotation.
  42166. * The higher the faster.
  42167. */
  42168. get touchAngularSensibility(): number;
  42169. set touchAngularSensibility(value: number);
  42170. /**
  42171. * Defines the touch sensibility for move.
  42172. * The higher the faster.
  42173. */
  42174. get touchMoveSensibility(): number;
  42175. set touchMoveSensibility(value: number);
  42176. /**
  42177. * Instantiates a new touch camera.
  42178. * This represents a FPS type of camera controlled by touch.
  42179. * This is like a universal camera minus the Gamepad controls.
  42180. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42181. * @param name Define the name of the camera in the scene
  42182. * @param position Define the start position of the camera in the scene
  42183. * @param scene Define the scene the camera belongs to
  42184. */
  42185. constructor(name: string, position: Vector3, scene: Scene);
  42186. /**
  42187. * Gets the current object class name.
  42188. * @return the class name
  42189. */
  42190. getClassName(): string;
  42191. /** @hidden */
  42192. _setupInputs(): void;
  42193. }
  42194. }
  42195. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42196. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42197. import { Scene } from "babylonjs/scene";
  42198. import { Vector3 } from "babylonjs/Maths/math.vector";
  42199. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42200. import { Axis } from "babylonjs/Maths/math.axis";
  42201. /**
  42202. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42203. * being tilted forward or back and left or right.
  42204. */
  42205. export class DeviceOrientationCamera extends FreeCamera {
  42206. private _initialQuaternion;
  42207. private _quaternionCache;
  42208. private _tmpDragQuaternion;
  42209. private _disablePointerInputWhenUsingDeviceOrientation;
  42210. /**
  42211. * Creates a new device orientation camera
  42212. * @param name The name of the camera
  42213. * @param position The start position camera
  42214. * @param scene The scene the camera belongs to
  42215. */
  42216. constructor(name: string, position: Vector3, scene: Scene);
  42217. /**
  42218. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42219. */
  42220. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42221. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42222. private _dragFactor;
  42223. /**
  42224. * Enabled turning on the y axis when the orientation sensor is active
  42225. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42226. */
  42227. enableHorizontalDragging(dragFactor?: number): void;
  42228. /**
  42229. * Gets the current instance class name ("DeviceOrientationCamera").
  42230. * This helps avoiding instanceof at run time.
  42231. * @returns the class name
  42232. */
  42233. getClassName(): string;
  42234. /**
  42235. * @hidden
  42236. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42237. */
  42238. _checkInputs(): void;
  42239. /**
  42240. * Reset the camera to its default orientation on the specified axis only.
  42241. * @param axis The axis to reset
  42242. */
  42243. resetToCurrentRotation(axis?: Axis): void;
  42244. }
  42245. }
  42246. declare module "babylonjs/Gamepads/xboxGamepad" {
  42247. import { Observable } from "babylonjs/Misc/observable";
  42248. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42249. /**
  42250. * Defines supported buttons for XBox360 compatible gamepads
  42251. */
  42252. export enum Xbox360Button {
  42253. /** A */
  42254. A = 0,
  42255. /** B */
  42256. B = 1,
  42257. /** X */
  42258. X = 2,
  42259. /** Y */
  42260. Y = 3,
  42261. /** Start */
  42262. Start = 4,
  42263. /** Back */
  42264. Back = 5,
  42265. /** Left button */
  42266. LB = 6,
  42267. /** Right button */
  42268. RB = 7,
  42269. /** Left stick */
  42270. LeftStick = 8,
  42271. /** Right stick */
  42272. RightStick = 9
  42273. }
  42274. /** Defines values for XBox360 DPad */
  42275. export enum Xbox360Dpad {
  42276. /** Up */
  42277. Up = 0,
  42278. /** Down */
  42279. Down = 1,
  42280. /** Left */
  42281. Left = 2,
  42282. /** Right */
  42283. Right = 3
  42284. }
  42285. /**
  42286. * Defines a XBox360 gamepad
  42287. */
  42288. export class Xbox360Pad extends Gamepad {
  42289. private _leftTrigger;
  42290. private _rightTrigger;
  42291. private _onlefttriggerchanged;
  42292. private _onrighttriggerchanged;
  42293. private _onbuttondown;
  42294. private _onbuttonup;
  42295. private _ondpaddown;
  42296. private _ondpadup;
  42297. /** Observable raised when a button is pressed */
  42298. onButtonDownObservable: Observable<Xbox360Button>;
  42299. /** Observable raised when a button is released */
  42300. onButtonUpObservable: Observable<Xbox360Button>;
  42301. /** Observable raised when a pad is pressed */
  42302. onPadDownObservable: Observable<Xbox360Dpad>;
  42303. /** Observable raised when a pad is released */
  42304. onPadUpObservable: Observable<Xbox360Dpad>;
  42305. private _buttonA;
  42306. private _buttonB;
  42307. private _buttonX;
  42308. private _buttonY;
  42309. private _buttonBack;
  42310. private _buttonStart;
  42311. private _buttonLB;
  42312. private _buttonRB;
  42313. private _buttonLeftStick;
  42314. private _buttonRightStick;
  42315. private _dPadUp;
  42316. private _dPadDown;
  42317. private _dPadLeft;
  42318. private _dPadRight;
  42319. private _isXboxOnePad;
  42320. /**
  42321. * Creates a new XBox360 gamepad object
  42322. * @param id defines the id of this gamepad
  42323. * @param index defines its index
  42324. * @param gamepad defines the internal HTML gamepad object
  42325. * @param xboxOne defines if it is a XBox One gamepad
  42326. */
  42327. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42328. /**
  42329. * Defines the callback to call when left trigger is pressed
  42330. * @param callback defines the callback to use
  42331. */
  42332. onlefttriggerchanged(callback: (value: number) => void): void;
  42333. /**
  42334. * Defines the callback to call when right trigger is pressed
  42335. * @param callback defines the callback to use
  42336. */
  42337. onrighttriggerchanged(callback: (value: number) => void): void;
  42338. /**
  42339. * Gets the left trigger value
  42340. */
  42341. get leftTrigger(): number;
  42342. /**
  42343. * Sets the left trigger value
  42344. */
  42345. set leftTrigger(newValue: number);
  42346. /**
  42347. * Gets the right trigger value
  42348. */
  42349. get rightTrigger(): number;
  42350. /**
  42351. * Sets the right trigger value
  42352. */
  42353. set rightTrigger(newValue: number);
  42354. /**
  42355. * Defines the callback to call when a button is pressed
  42356. * @param callback defines the callback to use
  42357. */
  42358. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42359. /**
  42360. * Defines the callback to call when a button is released
  42361. * @param callback defines the callback to use
  42362. */
  42363. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42364. /**
  42365. * Defines the callback to call when a pad is pressed
  42366. * @param callback defines the callback to use
  42367. */
  42368. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42369. /**
  42370. * Defines the callback to call when a pad is released
  42371. * @param callback defines the callback to use
  42372. */
  42373. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42374. private _setButtonValue;
  42375. private _setDPadValue;
  42376. /**
  42377. * Gets the value of the `A` button
  42378. */
  42379. get buttonA(): number;
  42380. /**
  42381. * Sets the value of the `A` button
  42382. */
  42383. set buttonA(value: number);
  42384. /**
  42385. * Gets the value of the `B` button
  42386. */
  42387. get buttonB(): number;
  42388. /**
  42389. * Sets the value of the `B` button
  42390. */
  42391. set buttonB(value: number);
  42392. /**
  42393. * Gets the value of the `X` button
  42394. */
  42395. get buttonX(): number;
  42396. /**
  42397. * Sets the value of the `X` button
  42398. */
  42399. set buttonX(value: number);
  42400. /**
  42401. * Gets the value of the `Y` button
  42402. */
  42403. get buttonY(): number;
  42404. /**
  42405. * Sets the value of the `Y` button
  42406. */
  42407. set buttonY(value: number);
  42408. /**
  42409. * Gets the value of the `Start` button
  42410. */
  42411. get buttonStart(): number;
  42412. /**
  42413. * Sets the value of the `Start` button
  42414. */
  42415. set buttonStart(value: number);
  42416. /**
  42417. * Gets the value of the `Back` button
  42418. */
  42419. get buttonBack(): number;
  42420. /**
  42421. * Sets the value of the `Back` button
  42422. */
  42423. set buttonBack(value: number);
  42424. /**
  42425. * Gets the value of the `Left` button
  42426. */
  42427. get buttonLB(): number;
  42428. /**
  42429. * Sets the value of the `Left` button
  42430. */
  42431. set buttonLB(value: number);
  42432. /**
  42433. * Gets the value of the `Right` button
  42434. */
  42435. get buttonRB(): number;
  42436. /**
  42437. * Sets the value of the `Right` button
  42438. */
  42439. set buttonRB(value: number);
  42440. /**
  42441. * Gets the value of the Left joystick
  42442. */
  42443. get buttonLeftStick(): number;
  42444. /**
  42445. * Sets the value of the Left joystick
  42446. */
  42447. set buttonLeftStick(value: number);
  42448. /**
  42449. * Gets the value of the Right joystick
  42450. */
  42451. get buttonRightStick(): number;
  42452. /**
  42453. * Sets the value of the Right joystick
  42454. */
  42455. set buttonRightStick(value: number);
  42456. /**
  42457. * Gets the value of D-pad up
  42458. */
  42459. get dPadUp(): number;
  42460. /**
  42461. * Sets the value of D-pad up
  42462. */
  42463. set dPadUp(value: number);
  42464. /**
  42465. * Gets the value of D-pad down
  42466. */
  42467. get dPadDown(): number;
  42468. /**
  42469. * Sets the value of D-pad down
  42470. */
  42471. set dPadDown(value: number);
  42472. /**
  42473. * Gets the value of D-pad left
  42474. */
  42475. get dPadLeft(): number;
  42476. /**
  42477. * Sets the value of D-pad left
  42478. */
  42479. set dPadLeft(value: number);
  42480. /**
  42481. * Gets the value of D-pad right
  42482. */
  42483. get dPadRight(): number;
  42484. /**
  42485. * Sets the value of D-pad right
  42486. */
  42487. set dPadRight(value: number);
  42488. /**
  42489. * Force the gamepad to synchronize with device values
  42490. */
  42491. update(): void;
  42492. /**
  42493. * Disposes the gamepad
  42494. */
  42495. dispose(): void;
  42496. }
  42497. }
  42498. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42499. import { Observable } from "babylonjs/Misc/observable";
  42500. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42501. /**
  42502. * Defines supported buttons for DualShock compatible gamepads
  42503. */
  42504. export enum DualShockButton {
  42505. /** Cross */
  42506. Cross = 0,
  42507. /** Circle */
  42508. Circle = 1,
  42509. /** Square */
  42510. Square = 2,
  42511. /** Triangle */
  42512. Triangle = 3,
  42513. /** Options */
  42514. Options = 4,
  42515. /** Share */
  42516. Share = 5,
  42517. /** L1 */
  42518. L1 = 6,
  42519. /** R1 */
  42520. R1 = 7,
  42521. /** Left stick */
  42522. LeftStick = 8,
  42523. /** Right stick */
  42524. RightStick = 9
  42525. }
  42526. /** Defines values for DualShock DPad */
  42527. export enum DualShockDpad {
  42528. /** Up */
  42529. Up = 0,
  42530. /** Down */
  42531. Down = 1,
  42532. /** Left */
  42533. Left = 2,
  42534. /** Right */
  42535. Right = 3
  42536. }
  42537. /**
  42538. * Defines a DualShock gamepad
  42539. */
  42540. export class DualShockPad extends Gamepad {
  42541. private _leftTrigger;
  42542. private _rightTrigger;
  42543. private _onlefttriggerchanged;
  42544. private _onrighttriggerchanged;
  42545. private _onbuttondown;
  42546. private _onbuttonup;
  42547. private _ondpaddown;
  42548. private _ondpadup;
  42549. /** Observable raised when a button is pressed */
  42550. onButtonDownObservable: Observable<DualShockButton>;
  42551. /** Observable raised when a button is released */
  42552. onButtonUpObservable: Observable<DualShockButton>;
  42553. /** Observable raised when a pad is pressed */
  42554. onPadDownObservable: Observable<DualShockDpad>;
  42555. /** Observable raised when a pad is released */
  42556. onPadUpObservable: Observable<DualShockDpad>;
  42557. private _buttonCross;
  42558. private _buttonCircle;
  42559. private _buttonSquare;
  42560. private _buttonTriangle;
  42561. private _buttonShare;
  42562. private _buttonOptions;
  42563. private _buttonL1;
  42564. private _buttonR1;
  42565. private _buttonLeftStick;
  42566. private _buttonRightStick;
  42567. private _dPadUp;
  42568. private _dPadDown;
  42569. private _dPadLeft;
  42570. private _dPadRight;
  42571. /**
  42572. * Creates a new DualShock gamepad object
  42573. * @param id defines the id of this gamepad
  42574. * @param index defines its index
  42575. * @param gamepad defines the internal HTML gamepad object
  42576. */
  42577. constructor(id: string, index: number, gamepad: any);
  42578. /**
  42579. * Defines the callback to call when left trigger is pressed
  42580. * @param callback defines the callback to use
  42581. */
  42582. onlefttriggerchanged(callback: (value: number) => void): void;
  42583. /**
  42584. * Defines the callback to call when right trigger is pressed
  42585. * @param callback defines the callback to use
  42586. */
  42587. onrighttriggerchanged(callback: (value: number) => void): void;
  42588. /**
  42589. * Gets the left trigger value
  42590. */
  42591. get leftTrigger(): number;
  42592. /**
  42593. * Sets the left trigger value
  42594. */
  42595. set leftTrigger(newValue: number);
  42596. /**
  42597. * Gets the right trigger value
  42598. */
  42599. get rightTrigger(): number;
  42600. /**
  42601. * Sets the right trigger value
  42602. */
  42603. set rightTrigger(newValue: number);
  42604. /**
  42605. * Defines the callback to call when a button is pressed
  42606. * @param callback defines the callback to use
  42607. */
  42608. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42609. /**
  42610. * Defines the callback to call when a button is released
  42611. * @param callback defines the callback to use
  42612. */
  42613. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42614. /**
  42615. * Defines the callback to call when a pad is pressed
  42616. * @param callback defines the callback to use
  42617. */
  42618. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42619. /**
  42620. * Defines the callback to call when a pad is released
  42621. * @param callback defines the callback to use
  42622. */
  42623. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42624. private _setButtonValue;
  42625. private _setDPadValue;
  42626. /**
  42627. * Gets the value of the `Cross` button
  42628. */
  42629. get buttonCross(): number;
  42630. /**
  42631. * Sets the value of the `Cross` button
  42632. */
  42633. set buttonCross(value: number);
  42634. /**
  42635. * Gets the value of the `Circle` button
  42636. */
  42637. get buttonCircle(): number;
  42638. /**
  42639. * Sets the value of the `Circle` button
  42640. */
  42641. set buttonCircle(value: number);
  42642. /**
  42643. * Gets the value of the `Square` button
  42644. */
  42645. get buttonSquare(): number;
  42646. /**
  42647. * Sets the value of the `Square` button
  42648. */
  42649. set buttonSquare(value: number);
  42650. /**
  42651. * Gets the value of the `Triangle` button
  42652. */
  42653. get buttonTriangle(): number;
  42654. /**
  42655. * Sets the value of the `Triangle` button
  42656. */
  42657. set buttonTriangle(value: number);
  42658. /**
  42659. * Gets the value of the `Options` button
  42660. */
  42661. get buttonOptions(): number;
  42662. /**
  42663. * Sets the value of the `Options` button
  42664. */
  42665. set buttonOptions(value: number);
  42666. /**
  42667. * Gets the value of the `Share` button
  42668. */
  42669. get buttonShare(): number;
  42670. /**
  42671. * Sets the value of the `Share` button
  42672. */
  42673. set buttonShare(value: number);
  42674. /**
  42675. * Gets the value of the `L1` button
  42676. */
  42677. get buttonL1(): number;
  42678. /**
  42679. * Sets the value of the `L1` button
  42680. */
  42681. set buttonL1(value: number);
  42682. /**
  42683. * Gets the value of the `R1` button
  42684. */
  42685. get buttonR1(): number;
  42686. /**
  42687. * Sets the value of the `R1` button
  42688. */
  42689. set buttonR1(value: number);
  42690. /**
  42691. * Gets the value of the Left joystick
  42692. */
  42693. get buttonLeftStick(): number;
  42694. /**
  42695. * Sets the value of the Left joystick
  42696. */
  42697. set buttonLeftStick(value: number);
  42698. /**
  42699. * Gets the value of the Right joystick
  42700. */
  42701. get buttonRightStick(): number;
  42702. /**
  42703. * Sets the value of the Right joystick
  42704. */
  42705. set buttonRightStick(value: number);
  42706. /**
  42707. * Gets the value of D-pad up
  42708. */
  42709. get dPadUp(): number;
  42710. /**
  42711. * Sets the value of D-pad up
  42712. */
  42713. set dPadUp(value: number);
  42714. /**
  42715. * Gets the value of D-pad down
  42716. */
  42717. get dPadDown(): number;
  42718. /**
  42719. * Sets the value of D-pad down
  42720. */
  42721. set dPadDown(value: number);
  42722. /**
  42723. * Gets the value of D-pad left
  42724. */
  42725. get dPadLeft(): number;
  42726. /**
  42727. * Sets the value of D-pad left
  42728. */
  42729. set dPadLeft(value: number);
  42730. /**
  42731. * Gets the value of D-pad right
  42732. */
  42733. get dPadRight(): number;
  42734. /**
  42735. * Sets the value of D-pad right
  42736. */
  42737. set dPadRight(value: number);
  42738. /**
  42739. * Force the gamepad to synchronize with device values
  42740. */
  42741. update(): void;
  42742. /**
  42743. * Disposes the gamepad
  42744. */
  42745. dispose(): void;
  42746. }
  42747. }
  42748. declare module "babylonjs/Gamepads/gamepadManager" {
  42749. import { Observable } from "babylonjs/Misc/observable";
  42750. import { Nullable } from "babylonjs/types";
  42751. import { Scene } from "babylonjs/scene";
  42752. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42753. /**
  42754. * Manager for handling gamepads
  42755. */
  42756. export class GamepadManager {
  42757. private _scene?;
  42758. private _babylonGamepads;
  42759. private _oneGamepadConnected;
  42760. /** @hidden */
  42761. _isMonitoring: boolean;
  42762. private _gamepadEventSupported;
  42763. private _gamepadSupport?;
  42764. /**
  42765. * observable to be triggered when the gamepad controller has been connected
  42766. */
  42767. onGamepadConnectedObservable: Observable<Gamepad>;
  42768. /**
  42769. * observable to be triggered when the gamepad controller has been disconnected
  42770. */
  42771. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42772. private _onGamepadConnectedEvent;
  42773. private _onGamepadDisconnectedEvent;
  42774. /**
  42775. * Initializes the gamepad manager
  42776. * @param _scene BabylonJS scene
  42777. */
  42778. constructor(_scene?: Scene | undefined);
  42779. /**
  42780. * The gamepads in the game pad manager
  42781. */
  42782. get gamepads(): Gamepad[];
  42783. /**
  42784. * Get the gamepad controllers based on type
  42785. * @param type The type of gamepad controller
  42786. * @returns Nullable gamepad
  42787. */
  42788. getGamepadByType(type?: number): Nullable<Gamepad>;
  42789. /**
  42790. * Disposes the gamepad manager
  42791. */
  42792. dispose(): void;
  42793. private _addNewGamepad;
  42794. private _startMonitoringGamepads;
  42795. private _stopMonitoringGamepads;
  42796. /** @hidden */
  42797. _checkGamepadsStatus(): void;
  42798. private _updateGamepadObjects;
  42799. }
  42800. }
  42801. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42802. import { Nullable } from "babylonjs/types";
  42803. import { Scene } from "babylonjs/scene";
  42804. import { ISceneComponent } from "babylonjs/sceneComponent";
  42805. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42806. module "babylonjs/scene" {
  42807. interface Scene {
  42808. /** @hidden */
  42809. _gamepadManager: Nullable<GamepadManager>;
  42810. /**
  42811. * Gets the gamepad manager associated with the scene
  42812. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42813. */
  42814. gamepadManager: GamepadManager;
  42815. }
  42816. }
  42817. module "babylonjs/Cameras/freeCameraInputsManager" {
  42818. /**
  42819. * Interface representing a free camera inputs manager
  42820. */
  42821. interface FreeCameraInputsManager {
  42822. /**
  42823. * Adds gamepad input support to the FreeCameraInputsManager.
  42824. * @returns the FreeCameraInputsManager
  42825. */
  42826. addGamepad(): FreeCameraInputsManager;
  42827. }
  42828. }
  42829. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42830. /**
  42831. * Interface representing an arc rotate camera inputs manager
  42832. */
  42833. interface ArcRotateCameraInputsManager {
  42834. /**
  42835. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42836. * @returns the camera inputs manager
  42837. */
  42838. addGamepad(): ArcRotateCameraInputsManager;
  42839. }
  42840. }
  42841. /**
  42842. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42843. */
  42844. export class GamepadSystemSceneComponent implements ISceneComponent {
  42845. /**
  42846. * The component name helpfull to identify the component in the list of scene components.
  42847. */
  42848. readonly name: string;
  42849. /**
  42850. * The scene the component belongs to.
  42851. */
  42852. scene: Scene;
  42853. /**
  42854. * Creates a new instance of the component for the given scene
  42855. * @param scene Defines the scene to register the component in
  42856. */
  42857. constructor(scene: Scene);
  42858. /**
  42859. * Registers the component in a given scene
  42860. */
  42861. register(): void;
  42862. /**
  42863. * Rebuilds the elements related to this component in case of
  42864. * context lost for instance.
  42865. */
  42866. rebuild(): void;
  42867. /**
  42868. * Disposes the component and the associated ressources
  42869. */
  42870. dispose(): void;
  42871. private _beforeCameraUpdate;
  42872. }
  42873. }
  42874. declare module "babylonjs/Cameras/universalCamera" {
  42875. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42876. import { Scene } from "babylonjs/scene";
  42877. import { Vector3 } from "babylonjs/Maths/math.vector";
  42878. import "babylonjs/Gamepads/gamepadSceneComponent";
  42879. /**
  42880. * 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,
  42881. * which still works and will still be found in many Playgrounds.
  42882. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42883. */
  42884. export class UniversalCamera extends TouchCamera {
  42885. /**
  42886. * Defines the gamepad rotation sensiblity.
  42887. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42888. */
  42889. get gamepadAngularSensibility(): number;
  42890. set gamepadAngularSensibility(value: number);
  42891. /**
  42892. * Defines the gamepad move sensiblity.
  42893. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42894. */
  42895. get gamepadMoveSensibility(): number;
  42896. set gamepadMoveSensibility(value: number);
  42897. /**
  42898. * 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,
  42899. * which still works and will still be found in many Playgrounds.
  42900. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42901. * @param name Define the name of the camera in the scene
  42902. * @param position Define the start position of the camera in the scene
  42903. * @param scene Define the scene the camera belongs to
  42904. */
  42905. constructor(name: string, position: Vector3, scene: Scene);
  42906. /**
  42907. * Gets the current object class name.
  42908. * @return the class name
  42909. */
  42910. getClassName(): string;
  42911. }
  42912. }
  42913. declare module "babylonjs/Cameras/gamepadCamera" {
  42914. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42915. import { Scene } from "babylonjs/scene";
  42916. import { Vector3 } from "babylonjs/Maths/math.vector";
  42917. /**
  42918. * This represents a FPS type of camera. This is only here for back compat purpose.
  42919. * Please use the UniversalCamera instead as both are identical.
  42920. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42921. */
  42922. export class GamepadCamera extends UniversalCamera {
  42923. /**
  42924. * Instantiates a new Gamepad Camera
  42925. * This represents a FPS type of camera. This is only here for back compat purpose.
  42926. * Please use the UniversalCamera instead as both are identical.
  42927. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42928. * @param name Define the name of the camera in the scene
  42929. * @param position Define the start position of the camera in the scene
  42930. * @param scene Define the scene the camera belongs to
  42931. */
  42932. constructor(name: string, position: Vector3, scene: Scene);
  42933. /**
  42934. * Gets the current object class name.
  42935. * @return the class name
  42936. */
  42937. getClassName(): string;
  42938. }
  42939. }
  42940. declare module "babylonjs/Shaders/pass.fragment" {
  42941. /** @hidden */
  42942. export var passPixelShader: {
  42943. name: string;
  42944. shader: string;
  42945. };
  42946. }
  42947. declare module "babylonjs/Shaders/passCube.fragment" {
  42948. /** @hidden */
  42949. export var passCubePixelShader: {
  42950. name: string;
  42951. shader: string;
  42952. };
  42953. }
  42954. declare module "babylonjs/PostProcesses/passPostProcess" {
  42955. import { Nullable } from "babylonjs/types";
  42956. import { Camera } from "babylonjs/Cameras/camera";
  42957. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42958. import { Engine } from "babylonjs/Engines/engine";
  42959. import "babylonjs/Shaders/pass.fragment";
  42960. import "babylonjs/Shaders/passCube.fragment";
  42961. /**
  42962. * PassPostProcess which produces an output the same as it's input
  42963. */
  42964. export class PassPostProcess extends PostProcess {
  42965. /**
  42966. * Creates the PassPostProcess
  42967. * @param name The name of the effect.
  42968. * @param options The required width/height ratio to downsize to before computing the render pass.
  42969. * @param camera The camera to apply the render pass to.
  42970. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  42971. * @param engine The engine which the post process will be applied. (default: current engine)
  42972. * @param reusable If the post process can be reused on the same frame. (default: false)
  42973. * @param textureType The type of texture to be used when performing the post processing.
  42974. * @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)
  42975. */
  42976. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  42977. }
  42978. /**
  42979. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  42980. */
  42981. export class PassCubePostProcess extends PostProcess {
  42982. private _face;
  42983. /**
  42984. * Gets or sets the cube face to display.
  42985. * * 0 is +X
  42986. * * 1 is -X
  42987. * * 2 is +Y
  42988. * * 3 is -Y
  42989. * * 4 is +Z
  42990. * * 5 is -Z
  42991. */
  42992. get face(): number;
  42993. set face(value: number);
  42994. /**
  42995. * Creates the PassCubePostProcess
  42996. * @param name The name of the effect.
  42997. * @param options The required width/height ratio to downsize to before computing the render pass.
  42998. * @param camera The camera to apply the render pass to.
  42999. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43000. * @param engine The engine which the post process will be applied. (default: current engine)
  43001. * @param reusable If the post process can be reused on the same frame. (default: false)
  43002. * @param textureType The type of texture to be used when performing the post processing.
  43003. * @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)
  43004. */
  43005. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43006. }
  43007. }
  43008. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43009. /** @hidden */
  43010. export var anaglyphPixelShader: {
  43011. name: string;
  43012. shader: string;
  43013. };
  43014. }
  43015. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43016. import { Engine } from "babylonjs/Engines/engine";
  43017. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43018. import { Camera } from "babylonjs/Cameras/camera";
  43019. import "babylonjs/Shaders/anaglyph.fragment";
  43020. /**
  43021. * Postprocess used to generate anaglyphic rendering
  43022. */
  43023. export class AnaglyphPostProcess extends PostProcess {
  43024. private _passedProcess;
  43025. /**
  43026. * Creates a new AnaglyphPostProcess
  43027. * @param name defines postprocess name
  43028. * @param options defines creation options or target ratio scale
  43029. * @param rigCameras defines cameras using this postprocess
  43030. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43031. * @param engine defines hosting engine
  43032. * @param reusable defines if the postprocess will be reused multiple times per frame
  43033. */
  43034. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43035. }
  43036. }
  43037. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43038. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43039. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43040. import { Scene } from "babylonjs/scene";
  43041. import { Vector3 } from "babylonjs/Maths/math.vector";
  43042. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43043. /**
  43044. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43045. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43046. */
  43047. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43048. /**
  43049. * Creates a new AnaglyphArcRotateCamera
  43050. * @param name defines camera name
  43051. * @param alpha defines alpha angle (in radians)
  43052. * @param beta defines beta angle (in radians)
  43053. * @param radius defines radius
  43054. * @param target defines camera target
  43055. * @param interaxialDistance defines distance between each color axis
  43056. * @param scene defines the hosting scene
  43057. */
  43058. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43059. /**
  43060. * Gets camera class name
  43061. * @returns AnaglyphArcRotateCamera
  43062. */
  43063. getClassName(): string;
  43064. }
  43065. }
  43066. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43067. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43068. import { Scene } from "babylonjs/scene";
  43069. import { Vector3 } from "babylonjs/Maths/math.vector";
  43070. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43071. /**
  43072. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43073. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43074. */
  43075. export class AnaglyphFreeCamera extends FreeCamera {
  43076. /**
  43077. * Creates a new AnaglyphFreeCamera
  43078. * @param name defines camera name
  43079. * @param position defines initial position
  43080. * @param interaxialDistance defines distance between each color axis
  43081. * @param scene defines the hosting scene
  43082. */
  43083. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43084. /**
  43085. * Gets camera class name
  43086. * @returns AnaglyphFreeCamera
  43087. */
  43088. getClassName(): string;
  43089. }
  43090. }
  43091. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43092. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43093. import { Scene } from "babylonjs/scene";
  43094. import { Vector3 } from "babylonjs/Maths/math.vector";
  43095. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43096. /**
  43097. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43098. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43099. */
  43100. export class AnaglyphGamepadCamera extends GamepadCamera {
  43101. /**
  43102. * Creates a new AnaglyphGamepadCamera
  43103. * @param name defines camera name
  43104. * @param position defines initial position
  43105. * @param interaxialDistance defines distance between each color axis
  43106. * @param scene defines the hosting scene
  43107. */
  43108. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43109. /**
  43110. * Gets camera class name
  43111. * @returns AnaglyphGamepadCamera
  43112. */
  43113. getClassName(): string;
  43114. }
  43115. }
  43116. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43117. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43118. import { Scene } from "babylonjs/scene";
  43119. import { Vector3 } from "babylonjs/Maths/math.vector";
  43120. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43121. /**
  43122. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43123. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43124. */
  43125. export class AnaglyphUniversalCamera extends UniversalCamera {
  43126. /**
  43127. * Creates a new AnaglyphUniversalCamera
  43128. * @param name defines camera name
  43129. * @param position defines initial position
  43130. * @param interaxialDistance defines distance between each color axis
  43131. * @param scene defines the hosting scene
  43132. */
  43133. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43134. /**
  43135. * Gets camera class name
  43136. * @returns AnaglyphUniversalCamera
  43137. */
  43138. getClassName(): string;
  43139. }
  43140. }
  43141. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43142. /** @hidden */
  43143. export var stereoscopicInterlacePixelShader: {
  43144. name: string;
  43145. shader: string;
  43146. };
  43147. }
  43148. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43149. import { Camera } from "babylonjs/Cameras/camera";
  43150. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43151. import { Engine } from "babylonjs/Engines/engine";
  43152. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43153. /**
  43154. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43155. */
  43156. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43157. private _stepSize;
  43158. private _passedProcess;
  43159. /**
  43160. * Initializes a StereoscopicInterlacePostProcessI
  43161. * @param name The name of the effect.
  43162. * @param rigCameras The rig cameras to be appled to the post process
  43163. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43164. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43165. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43166. * @param engine The engine which the post process will be applied. (default: current engine)
  43167. * @param reusable If the post process can be reused on the same frame. (default: false)
  43168. */
  43169. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43170. }
  43171. /**
  43172. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43173. */
  43174. export class StereoscopicInterlacePostProcess extends PostProcess {
  43175. private _stepSize;
  43176. private _passedProcess;
  43177. /**
  43178. * Initializes a StereoscopicInterlacePostProcess
  43179. * @param name The name of the effect.
  43180. * @param rigCameras The rig cameras to be appled to the post process
  43181. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43182. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43183. * @param engine The engine which the post process will be applied. (default: current engine)
  43184. * @param reusable If the post process can be reused on the same frame. (default: false)
  43185. */
  43186. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43187. }
  43188. }
  43189. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43190. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43191. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43192. import { Scene } from "babylonjs/scene";
  43193. import { Vector3 } from "babylonjs/Maths/math.vector";
  43194. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43195. /**
  43196. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43197. * @see http://doc.babylonjs.com/features/cameras
  43198. */
  43199. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43200. /**
  43201. * Creates a new StereoscopicArcRotateCamera
  43202. * @param name defines camera name
  43203. * @param alpha defines alpha angle (in radians)
  43204. * @param beta defines beta angle (in radians)
  43205. * @param radius defines radius
  43206. * @param target defines camera target
  43207. * @param interaxialDistance defines distance between each color axis
  43208. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43209. * @param scene defines the hosting scene
  43210. */
  43211. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43212. /**
  43213. * Gets camera class name
  43214. * @returns StereoscopicArcRotateCamera
  43215. */
  43216. getClassName(): string;
  43217. }
  43218. }
  43219. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43220. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43221. import { Scene } from "babylonjs/scene";
  43222. import { Vector3 } from "babylonjs/Maths/math.vector";
  43223. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43224. /**
  43225. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43226. * @see http://doc.babylonjs.com/features/cameras
  43227. */
  43228. export class StereoscopicFreeCamera extends FreeCamera {
  43229. /**
  43230. * Creates a new StereoscopicFreeCamera
  43231. * @param name defines camera name
  43232. * @param position defines initial position
  43233. * @param interaxialDistance defines distance between each color axis
  43234. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43235. * @param scene defines the hosting scene
  43236. */
  43237. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43238. /**
  43239. * Gets camera class name
  43240. * @returns StereoscopicFreeCamera
  43241. */
  43242. getClassName(): string;
  43243. }
  43244. }
  43245. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43246. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43247. import { Scene } from "babylonjs/scene";
  43248. import { Vector3 } from "babylonjs/Maths/math.vector";
  43249. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43250. /**
  43251. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43252. * @see http://doc.babylonjs.com/features/cameras
  43253. */
  43254. export class StereoscopicGamepadCamera extends GamepadCamera {
  43255. /**
  43256. * Creates a new StereoscopicGamepadCamera
  43257. * @param name defines camera name
  43258. * @param position defines initial position
  43259. * @param interaxialDistance defines distance between each color axis
  43260. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43261. * @param scene defines the hosting scene
  43262. */
  43263. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43264. /**
  43265. * Gets camera class name
  43266. * @returns StereoscopicGamepadCamera
  43267. */
  43268. getClassName(): string;
  43269. }
  43270. }
  43271. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43272. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43273. import { Scene } from "babylonjs/scene";
  43274. import { Vector3 } from "babylonjs/Maths/math.vector";
  43275. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43276. /**
  43277. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43278. * @see http://doc.babylonjs.com/features/cameras
  43279. */
  43280. export class StereoscopicUniversalCamera extends UniversalCamera {
  43281. /**
  43282. * Creates a new StereoscopicUniversalCamera
  43283. * @param name defines camera name
  43284. * @param position defines initial position
  43285. * @param interaxialDistance defines distance between each color axis
  43286. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43287. * @param scene defines the hosting scene
  43288. */
  43289. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43290. /**
  43291. * Gets camera class name
  43292. * @returns StereoscopicUniversalCamera
  43293. */
  43294. getClassName(): string;
  43295. }
  43296. }
  43297. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43298. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43299. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43300. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43301. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43302. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43303. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43304. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43305. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43306. }
  43307. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43308. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43309. import { Scene } from "babylonjs/scene";
  43310. import { Vector3 } from "babylonjs/Maths/math.vector";
  43311. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43312. /**
  43313. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43314. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43315. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43316. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43317. */
  43318. export class VirtualJoysticksCamera extends FreeCamera {
  43319. /**
  43320. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43321. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43322. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43323. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43324. * @param name Define the name of the camera in the scene
  43325. * @param position Define the start position of the camera in the scene
  43326. * @param scene Define the scene the camera belongs to
  43327. */
  43328. constructor(name: string, position: Vector3, scene: Scene);
  43329. /**
  43330. * Gets the current object class name.
  43331. * @return the class name
  43332. */
  43333. getClassName(): string;
  43334. }
  43335. }
  43336. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43337. import { Matrix } from "babylonjs/Maths/math.vector";
  43338. /**
  43339. * This represents all the required metrics to create a VR camera.
  43340. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43341. */
  43342. export class VRCameraMetrics {
  43343. /**
  43344. * Define the horizontal resolution off the screen.
  43345. */
  43346. hResolution: number;
  43347. /**
  43348. * Define the vertical resolution off the screen.
  43349. */
  43350. vResolution: number;
  43351. /**
  43352. * Define the horizontal screen size.
  43353. */
  43354. hScreenSize: number;
  43355. /**
  43356. * Define the vertical screen size.
  43357. */
  43358. vScreenSize: number;
  43359. /**
  43360. * Define the vertical screen center position.
  43361. */
  43362. vScreenCenter: number;
  43363. /**
  43364. * Define the distance of the eyes to the screen.
  43365. */
  43366. eyeToScreenDistance: number;
  43367. /**
  43368. * Define the distance between both lenses
  43369. */
  43370. lensSeparationDistance: number;
  43371. /**
  43372. * Define the distance between both viewer's eyes.
  43373. */
  43374. interpupillaryDistance: number;
  43375. /**
  43376. * Define the distortion factor of the VR postprocess.
  43377. * Please, touch with care.
  43378. */
  43379. distortionK: number[];
  43380. /**
  43381. * Define the chromatic aberration correction factors for the VR post process.
  43382. */
  43383. chromaAbCorrection: number[];
  43384. /**
  43385. * Define the scale factor of the post process.
  43386. * The smaller the better but the slower.
  43387. */
  43388. postProcessScaleFactor: number;
  43389. /**
  43390. * Define an offset for the lens center.
  43391. */
  43392. lensCenterOffset: number;
  43393. /**
  43394. * Define if the current vr camera should compensate the distortion of the lense or not.
  43395. */
  43396. compensateDistortion: boolean;
  43397. /**
  43398. * Defines if multiview should be enabled when rendering (Default: false)
  43399. */
  43400. multiviewEnabled: boolean;
  43401. /**
  43402. * Gets the rendering aspect ratio based on the provided resolutions.
  43403. */
  43404. get aspectRatio(): number;
  43405. /**
  43406. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43407. */
  43408. get aspectRatioFov(): number;
  43409. /**
  43410. * @hidden
  43411. */
  43412. get leftHMatrix(): Matrix;
  43413. /**
  43414. * @hidden
  43415. */
  43416. get rightHMatrix(): Matrix;
  43417. /**
  43418. * @hidden
  43419. */
  43420. get leftPreViewMatrix(): Matrix;
  43421. /**
  43422. * @hidden
  43423. */
  43424. get rightPreViewMatrix(): Matrix;
  43425. /**
  43426. * Get the default VRMetrics based on the most generic setup.
  43427. * @returns the default vr metrics
  43428. */
  43429. static GetDefault(): VRCameraMetrics;
  43430. }
  43431. }
  43432. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43433. /** @hidden */
  43434. export var vrDistortionCorrectionPixelShader: {
  43435. name: string;
  43436. shader: string;
  43437. };
  43438. }
  43439. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43440. import { Camera } from "babylonjs/Cameras/camera";
  43441. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43442. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43443. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43444. /**
  43445. * VRDistortionCorrectionPostProcess used for mobile VR
  43446. */
  43447. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43448. private _isRightEye;
  43449. private _distortionFactors;
  43450. private _postProcessScaleFactor;
  43451. private _lensCenterOffset;
  43452. private _scaleIn;
  43453. private _scaleFactor;
  43454. private _lensCenter;
  43455. /**
  43456. * Initializes the VRDistortionCorrectionPostProcess
  43457. * @param name The name of the effect.
  43458. * @param camera The camera to apply the render pass to.
  43459. * @param isRightEye If this is for the right eye distortion
  43460. * @param vrMetrics All the required metrics for the VR camera
  43461. */
  43462. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43463. }
  43464. }
  43465. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43466. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43467. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43468. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43469. import { Scene } from "babylonjs/scene";
  43470. import { Vector3 } from "babylonjs/Maths/math.vector";
  43471. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43472. import "babylonjs/Cameras/RigModes/vrRigMode";
  43473. /**
  43474. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43475. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43476. */
  43477. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43478. /**
  43479. * Creates a new VRDeviceOrientationArcRotateCamera
  43480. * @param name defines camera name
  43481. * @param alpha defines the camera rotation along the logitudinal axis
  43482. * @param beta defines the camera rotation along the latitudinal axis
  43483. * @param radius defines the camera distance from its target
  43484. * @param target defines the camera target
  43485. * @param scene defines the scene the camera belongs to
  43486. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43487. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43488. */
  43489. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43490. /**
  43491. * Gets camera class name
  43492. * @returns VRDeviceOrientationArcRotateCamera
  43493. */
  43494. getClassName(): string;
  43495. }
  43496. }
  43497. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43498. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43499. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43500. import { Scene } from "babylonjs/scene";
  43501. import { Vector3 } from "babylonjs/Maths/math.vector";
  43502. import "babylonjs/Cameras/RigModes/vrRigMode";
  43503. /**
  43504. * Camera used to simulate VR rendering (based on FreeCamera)
  43505. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43506. */
  43507. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43508. /**
  43509. * Creates a new VRDeviceOrientationFreeCamera
  43510. * @param name defines camera name
  43511. * @param position defines the start position of the camera
  43512. * @param scene defines the scene the camera belongs to
  43513. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43514. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43515. */
  43516. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43517. /**
  43518. * Gets camera class name
  43519. * @returns VRDeviceOrientationFreeCamera
  43520. */
  43521. getClassName(): string;
  43522. }
  43523. }
  43524. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43525. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43526. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43527. import { Scene } from "babylonjs/scene";
  43528. import { Vector3 } from "babylonjs/Maths/math.vector";
  43529. import "babylonjs/Gamepads/gamepadSceneComponent";
  43530. /**
  43531. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43532. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43533. */
  43534. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43535. /**
  43536. * Creates a new VRDeviceOrientationGamepadCamera
  43537. * @param name defines camera name
  43538. * @param position defines the start position of the camera
  43539. * @param scene defines the scene the camera belongs to
  43540. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43541. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43542. */
  43543. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43544. /**
  43545. * Gets camera class name
  43546. * @returns VRDeviceOrientationGamepadCamera
  43547. */
  43548. getClassName(): string;
  43549. }
  43550. }
  43551. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43552. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43553. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43554. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43555. /** @hidden */
  43556. export var imageProcessingPixelShader: {
  43557. name: string;
  43558. shader: string;
  43559. };
  43560. }
  43561. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43562. import { Nullable } from "babylonjs/types";
  43563. import { Color4 } from "babylonjs/Maths/math.color";
  43564. import { Camera } from "babylonjs/Cameras/camera";
  43565. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43566. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43567. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43568. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43569. import { Engine } from "babylonjs/Engines/engine";
  43570. import "babylonjs/Shaders/imageProcessing.fragment";
  43571. import "babylonjs/Shaders/postprocess.vertex";
  43572. /**
  43573. * ImageProcessingPostProcess
  43574. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43575. */
  43576. export class ImageProcessingPostProcess extends PostProcess {
  43577. /**
  43578. * Default configuration related to image processing available in the PBR Material.
  43579. */
  43580. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43581. /**
  43582. * Gets the image processing configuration used either in this material.
  43583. */
  43584. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43585. /**
  43586. * Sets the Default image processing configuration used either in the this material.
  43587. *
  43588. * If sets to null, the scene one is in use.
  43589. */
  43590. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43591. /**
  43592. * Keep track of the image processing observer to allow dispose and replace.
  43593. */
  43594. private _imageProcessingObserver;
  43595. /**
  43596. * Attaches a new image processing configuration to the PBR Material.
  43597. * @param configuration
  43598. */
  43599. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43600. /**
  43601. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43602. */
  43603. get colorCurves(): Nullable<ColorCurves>;
  43604. /**
  43605. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43606. */
  43607. set colorCurves(value: Nullable<ColorCurves>);
  43608. /**
  43609. * Gets wether the color curves effect is enabled.
  43610. */
  43611. get colorCurvesEnabled(): boolean;
  43612. /**
  43613. * Sets wether the color curves effect is enabled.
  43614. */
  43615. set colorCurvesEnabled(value: boolean);
  43616. /**
  43617. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43618. */
  43619. get colorGradingTexture(): Nullable<BaseTexture>;
  43620. /**
  43621. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43622. */
  43623. set colorGradingTexture(value: Nullable<BaseTexture>);
  43624. /**
  43625. * Gets wether the color grading effect is enabled.
  43626. */
  43627. get colorGradingEnabled(): boolean;
  43628. /**
  43629. * Gets wether the color grading effect is enabled.
  43630. */
  43631. set colorGradingEnabled(value: boolean);
  43632. /**
  43633. * Gets exposure used in the effect.
  43634. */
  43635. get exposure(): number;
  43636. /**
  43637. * Sets exposure used in the effect.
  43638. */
  43639. set exposure(value: number);
  43640. /**
  43641. * Gets wether tonemapping is enabled or not.
  43642. */
  43643. get toneMappingEnabled(): boolean;
  43644. /**
  43645. * Sets wether tonemapping is enabled or not
  43646. */
  43647. set toneMappingEnabled(value: boolean);
  43648. /**
  43649. * Gets the type of tone mapping effect.
  43650. */
  43651. get toneMappingType(): number;
  43652. /**
  43653. * Sets the type of tone mapping effect.
  43654. */
  43655. set toneMappingType(value: number);
  43656. /**
  43657. * Gets contrast used in the effect.
  43658. */
  43659. get contrast(): number;
  43660. /**
  43661. * Sets contrast used in the effect.
  43662. */
  43663. set contrast(value: number);
  43664. /**
  43665. * Gets Vignette stretch size.
  43666. */
  43667. get vignetteStretch(): number;
  43668. /**
  43669. * Sets Vignette stretch size.
  43670. */
  43671. set vignetteStretch(value: number);
  43672. /**
  43673. * Gets Vignette centre X Offset.
  43674. */
  43675. get vignetteCentreX(): number;
  43676. /**
  43677. * Sets Vignette centre X Offset.
  43678. */
  43679. set vignetteCentreX(value: number);
  43680. /**
  43681. * Gets Vignette centre Y Offset.
  43682. */
  43683. get vignetteCentreY(): number;
  43684. /**
  43685. * Sets Vignette centre Y Offset.
  43686. */
  43687. set vignetteCentreY(value: number);
  43688. /**
  43689. * Gets Vignette weight or intensity of the vignette effect.
  43690. */
  43691. get vignetteWeight(): number;
  43692. /**
  43693. * Sets Vignette weight or intensity of the vignette effect.
  43694. */
  43695. set vignetteWeight(value: number);
  43696. /**
  43697. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43698. * if vignetteEnabled is set to true.
  43699. */
  43700. get vignetteColor(): Color4;
  43701. /**
  43702. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43703. * if vignetteEnabled is set to true.
  43704. */
  43705. set vignetteColor(value: Color4);
  43706. /**
  43707. * Gets Camera field of view used by the Vignette effect.
  43708. */
  43709. get vignetteCameraFov(): number;
  43710. /**
  43711. * Sets Camera field of view used by the Vignette effect.
  43712. */
  43713. set vignetteCameraFov(value: number);
  43714. /**
  43715. * Gets the vignette blend mode allowing different kind of effect.
  43716. */
  43717. get vignetteBlendMode(): number;
  43718. /**
  43719. * Sets the vignette blend mode allowing different kind of effect.
  43720. */
  43721. set vignetteBlendMode(value: number);
  43722. /**
  43723. * Gets wether the vignette effect is enabled.
  43724. */
  43725. get vignetteEnabled(): boolean;
  43726. /**
  43727. * Sets wether the vignette effect is enabled.
  43728. */
  43729. set vignetteEnabled(value: boolean);
  43730. private _fromLinearSpace;
  43731. /**
  43732. * Gets wether the input of the processing is in Gamma or Linear Space.
  43733. */
  43734. get fromLinearSpace(): boolean;
  43735. /**
  43736. * Sets wether the input of the processing is in Gamma or Linear Space.
  43737. */
  43738. set fromLinearSpace(value: boolean);
  43739. /**
  43740. * Defines cache preventing GC.
  43741. */
  43742. private _defines;
  43743. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43744. /**
  43745. * "ImageProcessingPostProcess"
  43746. * @returns "ImageProcessingPostProcess"
  43747. */
  43748. getClassName(): string;
  43749. protected _updateParameters(): void;
  43750. dispose(camera?: Camera): void;
  43751. }
  43752. }
  43753. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43754. import { Scene } from "babylonjs/scene";
  43755. import { Color3 } from "babylonjs/Maths/math.color";
  43756. import { Mesh } from "babylonjs/Meshes/mesh";
  43757. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43758. import { Nullable } from "babylonjs/types";
  43759. /**
  43760. * Class containing static functions to help procedurally build meshes
  43761. */
  43762. export class GroundBuilder {
  43763. /**
  43764. * Creates a ground mesh
  43765. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43766. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43768. * @param name defines the name of the mesh
  43769. * @param options defines the options used to create the mesh
  43770. * @param scene defines the hosting scene
  43771. * @returns the ground mesh
  43772. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43773. */
  43774. static CreateGround(name: string, options: {
  43775. width?: number;
  43776. height?: number;
  43777. subdivisions?: number;
  43778. subdivisionsX?: number;
  43779. subdivisionsY?: number;
  43780. updatable?: boolean;
  43781. }, scene: any): Mesh;
  43782. /**
  43783. * Creates a tiled ground mesh
  43784. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43785. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43786. * * 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
  43787. * * 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
  43788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43789. * @param name defines the name of the mesh
  43790. * @param options defines the options used to create the mesh
  43791. * @param scene defines the hosting scene
  43792. * @returns the tiled ground mesh
  43793. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43794. */
  43795. static CreateTiledGround(name: string, options: {
  43796. xmin: number;
  43797. zmin: number;
  43798. xmax: number;
  43799. zmax: number;
  43800. subdivisions?: {
  43801. w: number;
  43802. h: number;
  43803. };
  43804. precision?: {
  43805. w: number;
  43806. h: number;
  43807. };
  43808. updatable?: boolean;
  43809. }, scene?: Nullable<Scene>): Mesh;
  43810. /**
  43811. * Creates a ground mesh from a height map
  43812. * * The parameter `url` sets the URL of the height map image resource.
  43813. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43814. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43815. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43816. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43817. * * 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.
  43818. * * 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).
  43819. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43821. * @param name defines the name of the mesh
  43822. * @param url defines the url to the height map
  43823. * @param options defines the options used to create the mesh
  43824. * @param scene defines the hosting scene
  43825. * @returns the ground mesh
  43826. * @see https://doc.babylonjs.com/babylon101/height_map
  43827. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43828. */
  43829. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43830. width?: number;
  43831. height?: number;
  43832. subdivisions?: number;
  43833. minHeight?: number;
  43834. maxHeight?: number;
  43835. colorFilter?: Color3;
  43836. alphaFilter?: number;
  43837. updatable?: boolean;
  43838. onReady?: (mesh: GroundMesh) => void;
  43839. }, scene?: Nullable<Scene>): GroundMesh;
  43840. }
  43841. }
  43842. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43843. import { Vector4 } from "babylonjs/Maths/math.vector";
  43844. import { Mesh } from "babylonjs/Meshes/mesh";
  43845. /**
  43846. * Class containing static functions to help procedurally build meshes
  43847. */
  43848. export class TorusBuilder {
  43849. /**
  43850. * Creates a torus mesh
  43851. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43852. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43853. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43854. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43855. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43856. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43857. * @param name defines the name of the mesh
  43858. * @param options defines the options used to create the mesh
  43859. * @param scene defines the hosting scene
  43860. * @returns the torus mesh
  43861. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43862. */
  43863. static CreateTorus(name: string, options: {
  43864. diameter?: number;
  43865. thickness?: number;
  43866. tessellation?: number;
  43867. updatable?: boolean;
  43868. sideOrientation?: number;
  43869. frontUVs?: Vector4;
  43870. backUVs?: Vector4;
  43871. }, scene: any): Mesh;
  43872. }
  43873. }
  43874. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43875. import { Vector4 } from "babylonjs/Maths/math.vector";
  43876. import { Color4 } from "babylonjs/Maths/math.color";
  43877. import { Mesh } from "babylonjs/Meshes/mesh";
  43878. /**
  43879. * Class containing static functions to help procedurally build meshes
  43880. */
  43881. export class CylinderBuilder {
  43882. /**
  43883. * Creates a cylinder or a cone mesh
  43884. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43885. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43886. * * 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.
  43887. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43888. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43889. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43890. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43891. * * 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).
  43892. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43893. * * 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).
  43894. * * 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
  43895. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43896. * * 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
  43897. * * 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.
  43898. * * If `enclose` is false, a ring surface is one element.
  43899. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43900. * * 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
  43901. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43902. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43903. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43904. * @param name defines the name of the mesh
  43905. * @param options defines the options used to create the mesh
  43906. * @param scene defines the hosting scene
  43907. * @returns the cylinder mesh
  43908. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43909. */
  43910. static CreateCylinder(name: string, options: {
  43911. height?: number;
  43912. diameterTop?: number;
  43913. diameterBottom?: number;
  43914. diameter?: number;
  43915. tessellation?: number;
  43916. subdivisions?: number;
  43917. arc?: number;
  43918. faceColors?: Color4[];
  43919. faceUV?: Vector4[];
  43920. updatable?: boolean;
  43921. hasRings?: boolean;
  43922. enclose?: boolean;
  43923. cap?: number;
  43924. sideOrientation?: number;
  43925. frontUVs?: Vector4;
  43926. backUVs?: Vector4;
  43927. }, scene: any): Mesh;
  43928. }
  43929. }
  43930. declare module "babylonjs/XR/webXRTypes" {
  43931. import { Nullable } from "babylonjs/types";
  43932. import { IDisposable } from "babylonjs/scene";
  43933. /**
  43934. * States of the webXR experience
  43935. */
  43936. export enum WebXRState {
  43937. /**
  43938. * Transitioning to being in XR mode
  43939. */
  43940. ENTERING_XR = 0,
  43941. /**
  43942. * Transitioning to non XR mode
  43943. */
  43944. EXITING_XR = 1,
  43945. /**
  43946. * In XR mode and presenting
  43947. */
  43948. IN_XR = 2,
  43949. /**
  43950. * Not entered XR mode
  43951. */
  43952. NOT_IN_XR = 3
  43953. }
  43954. /**
  43955. * Abstraction of the XR render target
  43956. */
  43957. export interface WebXRRenderTarget extends IDisposable {
  43958. /**
  43959. * xrpresent context of the canvas which can be used to display/mirror xr content
  43960. */
  43961. canvasContext: WebGLRenderingContext;
  43962. /**
  43963. * xr layer for the canvas
  43964. */
  43965. xrLayer: Nullable<XRWebGLLayer>;
  43966. /**
  43967. * Initializes the xr layer for the session
  43968. * @param xrSession xr session
  43969. * @returns a promise that will resolve once the XR Layer has been created
  43970. */
  43971. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  43972. }
  43973. }
  43974. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  43975. import { Nullable } from "babylonjs/types";
  43976. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  43977. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  43978. /**
  43979. * COnfiguration object for WebXR output canvas
  43980. */
  43981. export class WebXRManagedOutputCanvasOptions {
  43982. /**
  43983. * An optional canvas in case you wish to create it yourself and provide it here.
  43984. * If not provided, a new canvas will be created
  43985. */
  43986. canvasElement?: HTMLCanvasElement;
  43987. /**
  43988. * Options for this XR Layer output
  43989. */
  43990. canvasOptions?: XRWebGLLayerOptions;
  43991. /**
  43992. * CSS styling for a newly created canvas (if not provided)
  43993. */
  43994. newCanvasCssStyle?: string;
  43995. /**
  43996. * Get the default values of the configuration object
  43997. * @returns default values of this configuration object
  43998. */
  43999. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44000. }
  44001. /**
  44002. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44003. */
  44004. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44005. private _options;
  44006. private _canvas;
  44007. private _engine;
  44008. /**
  44009. * Rendering context of the canvas which can be used to display/mirror xr content
  44010. */
  44011. canvasContext: WebGLRenderingContext;
  44012. /**
  44013. * xr layer for the canvas
  44014. */
  44015. xrLayer: Nullable<XRWebGLLayer>;
  44016. /**
  44017. * Initializes the canvas to be added/removed upon entering/exiting xr
  44018. * @param _xrSessionManager The XR Session manager
  44019. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44020. */
  44021. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44022. /**
  44023. * Disposes of the object
  44024. */
  44025. dispose(): void;
  44026. /**
  44027. * Initializes the xr layer for the session
  44028. * @param xrSession xr session
  44029. * @returns a promise that will resolve once the XR Layer has been created
  44030. */
  44031. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44032. private _addCanvas;
  44033. private _removeCanvas;
  44034. private _setManagedOutputCanvas;
  44035. }
  44036. }
  44037. declare module "babylonjs/XR/webXRSessionManager" {
  44038. import { Observable } from "babylonjs/Misc/observable";
  44039. import { Nullable } from "babylonjs/types";
  44040. import { IDisposable, Scene } from "babylonjs/scene";
  44041. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44042. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44043. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44044. /**
  44045. * Manages an XRSession to work with Babylon's engine
  44046. * @see https://doc.babylonjs.com/how_to/webxr
  44047. */
  44048. export class WebXRSessionManager implements IDisposable {
  44049. /** The scene which the session should be created for */
  44050. scene: Scene;
  44051. private _referenceSpace;
  44052. private _rttProvider;
  44053. private _sessionEnded;
  44054. private _xrNavigator;
  44055. private baseLayer;
  44056. /**
  44057. * The base reference space from which the session started. good if you want to reset your
  44058. * reference space
  44059. */
  44060. baseReferenceSpace: XRReferenceSpace;
  44061. /**
  44062. * Current XR frame
  44063. */
  44064. currentFrame: Nullable<XRFrame>;
  44065. /** WebXR timestamp updated every frame */
  44066. currentTimestamp: number;
  44067. /**
  44068. * Used just in case of a failure to initialize an immersive session.
  44069. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44070. */
  44071. defaultHeightCompensation: number;
  44072. /**
  44073. * Fires every time a new xrFrame arrives which can be used to update the camera
  44074. */
  44075. onXRFrameObservable: Observable<XRFrame>;
  44076. /**
  44077. * Fires when the reference space changed
  44078. */
  44079. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44080. /**
  44081. * Fires when the xr session is ended either by the device or manually done
  44082. */
  44083. onXRSessionEnded: Observable<any>;
  44084. /**
  44085. * Fires when the xr session is ended either by the device or manually done
  44086. */
  44087. onXRSessionInit: Observable<XRSession>;
  44088. /**
  44089. * Underlying xr session
  44090. */
  44091. session: XRSession;
  44092. /**
  44093. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44094. * or get the offset the player is currently at.
  44095. */
  44096. viewerReferenceSpace: XRReferenceSpace;
  44097. /**
  44098. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44099. * @param scene The scene which the session should be created for
  44100. */
  44101. constructor(
  44102. /** The scene which the session should be created for */
  44103. scene: Scene);
  44104. /**
  44105. * The current reference space used in this session. This reference space can constantly change!
  44106. * It is mainly used to offset the camera's position.
  44107. */
  44108. get referenceSpace(): XRReferenceSpace;
  44109. /**
  44110. * Set a new reference space and triggers the observable
  44111. */
  44112. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44113. /**
  44114. * Disposes of the session manager
  44115. */
  44116. dispose(): void;
  44117. /**
  44118. * Stops the xrSession and restores the render loop
  44119. * @returns Promise which resolves after it exits XR
  44120. */
  44121. exitXRAsync(): Promise<void>;
  44122. /**
  44123. * Gets the correct render target texture to be rendered this frame for this eye
  44124. * @param eye the eye for which to get the render target
  44125. * @returns the render target for the specified eye
  44126. */
  44127. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44128. /**
  44129. * Creates a WebXRRenderTarget object for the XR session
  44130. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44131. * @param options optional options to provide when creating a new render target
  44132. * @returns a WebXR render target to which the session can render
  44133. */
  44134. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44135. /**
  44136. * Initializes the manager
  44137. * After initialization enterXR can be called to start an XR session
  44138. * @returns Promise which resolves after it is initialized
  44139. */
  44140. initializeAsync(): Promise<void>;
  44141. /**
  44142. * Initializes an xr session
  44143. * @param xrSessionMode mode to initialize
  44144. * @param xrSessionInit defines optional and required values to pass to the session builder
  44145. * @returns a promise which will resolve once the session has been initialized
  44146. */
  44147. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44148. /**
  44149. * Checks if a session would be supported for the creation options specified
  44150. * @param sessionMode session mode to check if supported eg. immersive-vr
  44151. * @returns A Promise that resolves to true if supported and false if not
  44152. */
  44153. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44154. /**
  44155. * Resets the reference space to the one started the session
  44156. */
  44157. resetReferenceSpace(): void;
  44158. /**
  44159. * Starts rendering to the xr layer
  44160. */
  44161. runXRRenderLoop(): void;
  44162. /**
  44163. * Sets the reference space on the xr session
  44164. * @param referenceSpaceType space to set
  44165. * @returns a promise that will resolve once the reference space has been set
  44166. */
  44167. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44168. /**
  44169. * Updates the render state of the session
  44170. * @param state state to set
  44171. * @returns a promise that resolves once the render state has been updated
  44172. */
  44173. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44174. /**
  44175. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44176. * @param sessionMode defines the session to test
  44177. * @returns a promise with boolean as final value
  44178. */
  44179. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44180. private _createRenderTargetTexture;
  44181. }
  44182. }
  44183. declare module "babylonjs/XR/webXRCamera" {
  44184. import { Scene } from "babylonjs/scene";
  44185. import { Camera } from "babylonjs/Cameras/camera";
  44186. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44187. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44188. /**
  44189. * WebXR Camera which holds the views for the xrSession
  44190. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44191. */
  44192. export class WebXRCamera extends FreeCamera {
  44193. private _xrSessionManager;
  44194. private _firstFrame;
  44195. private _referenceQuaternion;
  44196. private _referencedPosition;
  44197. private _xrInvPositionCache;
  44198. private _xrInvQuaternionCache;
  44199. /**
  44200. * Should position compensation execute on first frame.
  44201. * This is used when copying the position from a native (non XR) camera
  44202. */
  44203. compensateOnFirstFrame: boolean;
  44204. /**
  44205. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44206. * @param name the name of the camera
  44207. * @param scene the scene to add the camera to
  44208. * @param _xrSessionManager a constructed xr session manager
  44209. */
  44210. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44211. /**
  44212. * Return the user's height, unrelated to the current ground.
  44213. * This will be the y position of this camera, when ground level is 0.
  44214. */
  44215. get realWorldHeight(): number;
  44216. /** @hidden */
  44217. _updateForDualEyeDebugging(): void;
  44218. /**
  44219. * Sets this camera's transformation based on a non-vr camera
  44220. * @param otherCamera the non-vr camera to copy the transformation from
  44221. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44222. */
  44223. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44224. private _updateFromXRSession;
  44225. private _updateNumberOfRigCameras;
  44226. private _updateReferenceSpace;
  44227. private _updateReferenceSpaceOffset;
  44228. }
  44229. }
  44230. declare module "babylonjs/XR/webXRFeaturesManager" {
  44231. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44232. import { IDisposable } from "babylonjs/scene";
  44233. /**
  44234. * Defining the interface required for a (webxr) feature
  44235. */
  44236. export interface IWebXRFeature extends IDisposable {
  44237. /**
  44238. * Is this feature attached
  44239. */
  44240. attached: boolean;
  44241. /**
  44242. * Should auto-attach be disabled?
  44243. */
  44244. disableAutoAttach: boolean;
  44245. /**
  44246. * Attach the feature to the session
  44247. * Will usually be called by the features manager
  44248. *
  44249. * @param force should attachment be forced (even when already attached)
  44250. * @returns true if successful.
  44251. */
  44252. attach(force?: boolean): boolean;
  44253. /**
  44254. * Detach the feature from the session
  44255. * Will usually be called by the features manager
  44256. *
  44257. * @returns true if successful.
  44258. */
  44259. detach(): boolean;
  44260. }
  44261. /**
  44262. * A list of the currently available features without referencing them
  44263. */
  44264. export class WebXRFeatureName {
  44265. /**
  44266. * The name of the anchor system feature
  44267. */
  44268. static ANCHOR_SYSTEM: string;
  44269. /**
  44270. * The name of the background remover feature
  44271. */
  44272. static BACKGROUND_REMOVER: string;
  44273. /**
  44274. * The name of the hit test feature
  44275. */
  44276. static HIT_TEST: string;
  44277. /**
  44278. * physics impostors for xr controllers feature
  44279. */
  44280. static PHYSICS_CONTROLLERS: string;
  44281. /**
  44282. * The name of the plane detection feature
  44283. */
  44284. static PLANE_DETECTION: string;
  44285. /**
  44286. * The name of the pointer selection feature
  44287. */
  44288. static POINTER_SELECTION: string;
  44289. /**
  44290. * The name of the teleportation feature
  44291. */
  44292. static TELEPORTATION: string;
  44293. }
  44294. /**
  44295. * Defining the constructor of a feature. Used to register the modules.
  44296. */
  44297. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44298. /**
  44299. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44300. * It is mainly used in AR sessions.
  44301. *
  44302. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44303. */
  44304. export class WebXRFeaturesManager implements IDisposable {
  44305. private _xrSessionManager;
  44306. private static readonly _AvailableFeatures;
  44307. private _features;
  44308. /**
  44309. * constructs a new features manages.
  44310. *
  44311. * @param _xrSessionManager an instance of WebXRSessionManager
  44312. */
  44313. constructor(_xrSessionManager: WebXRSessionManager);
  44314. /**
  44315. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44316. * Mainly used internally.
  44317. *
  44318. * @param featureName the name of the feature to register
  44319. * @param constructorFunction the function used to construct the module
  44320. * @param version the (babylon) version of the module
  44321. * @param stable is that a stable version of this module
  44322. */
  44323. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44324. /**
  44325. * Returns a constructor of a specific feature.
  44326. *
  44327. * @param featureName the name of the feature to construct
  44328. * @param version the version of the feature to load
  44329. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44330. * @param options optional options provided to the module.
  44331. * @returns a function that, when called, will return a new instance of this feature
  44332. */
  44333. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44334. /**
  44335. * Can be used to return the list of features currently registered
  44336. *
  44337. * @returns an Array of available features
  44338. */
  44339. static GetAvailableFeatures(): string[];
  44340. /**
  44341. * Gets the versions available for a specific feature
  44342. * @param featureName the name of the feature
  44343. * @returns an array with the available versions
  44344. */
  44345. static GetAvailableVersions(featureName: string): string[];
  44346. /**
  44347. * Return the latest unstable version of this feature
  44348. * @param featureName the name of the feature to search
  44349. * @returns the version number. if not found will return -1
  44350. */
  44351. static GetLatestVersionOfFeature(featureName: string): number;
  44352. /**
  44353. * Return the latest stable version of this feature
  44354. * @param featureName the name of the feature to search
  44355. * @returns the version number. if not found will return -1
  44356. */
  44357. static GetStableVersionOfFeature(featureName: string): number;
  44358. /**
  44359. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44360. * Can be used during a session to start a feature
  44361. * @param featureName the name of feature to attach
  44362. */
  44363. attachFeature(featureName: string): void;
  44364. /**
  44365. * Can be used inside a session or when the session ends to detach a specific feature
  44366. * @param featureName the name of the feature to detach
  44367. */
  44368. detachFeature(featureName: string): void;
  44369. /**
  44370. * Used to disable an already-enabled feature
  44371. * The feature will be disposed and will be recreated once enabled.
  44372. * @param featureName the feature to disable
  44373. * @returns true if disable was successful
  44374. */
  44375. disableFeature(featureName: string | {
  44376. Name: string;
  44377. }): boolean;
  44378. /**
  44379. * dispose this features manager
  44380. */
  44381. dispose(): void;
  44382. /**
  44383. * 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.
  44384. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  44385. *
  44386. * @param featureName the name of the feature to load or the class of the feature
  44387. * @param version optional version to load. if not provided the latest version will be enabled
  44388. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44389. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44390. * @returns a new constructed feature or throws an error if feature not found.
  44391. */
  44392. enableFeature(featureName: string | {
  44393. Name: string;
  44394. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44395. /**
  44396. * get the implementation of an enabled feature.
  44397. * @param featureName the name of the feature to load
  44398. * @returns the feature class, if found
  44399. */
  44400. getEnabledFeature(featureName: string): IWebXRFeature;
  44401. /**
  44402. * Get the list of enabled features
  44403. * @returns an array of enabled features
  44404. */
  44405. getEnabledFeatures(): string[];
  44406. }
  44407. }
  44408. declare module "babylonjs/XR/webXRExperienceHelper" {
  44409. import { Observable } from "babylonjs/Misc/observable";
  44410. import { IDisposable, Scene } from "babylonjs/scene";
  44411. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44412. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44413. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44414. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44415. /**
  44416. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  44417. * @see https://doc.babylonjs.com/how_to/webxr
  44418. */
  44419. export class WebXRExperienceHelper implements IDisposable {
  44420. private scene;
  44421. private _nonVRCamera;
  44422. private _originalSceneAutoClear;
  44423. private _supported;
  44424. /**
  44425. * Camera used to render xr content
  44426. */
  44427. camera: WebXRCamera;
  44428. /** A features manager for this xr session */
  44429. featuresManager: WebXRFeaturesManager;
  44430. /**
  44431. * Observers registered here will be triggered after the camera's initial transformation is set
  44432. * This can be used to set a different ground level or an extra rotation.
  44433. *
  44434. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44435. * to the position set after this observable is done executing.
  44436. */
  44437. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44438. /**
  44439. * Fires when the state of the experience helper has changed
  44440. */
  44441. onStateChangedObservable: Observable<WebXRState>;
  44442. /** Session manager used to keep track of xr session */
  44443. sessionManager: WebXRSessionManager;
  44444. /**
  44445. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44446. */
  44447. state: WebXRState;
  44448. /**
  44449. * Creates a WebXRExperienceHelper
  44450. * @param scene The scene the helper should be created in
  44451. */
  44452. private constructor();
  44453. /**
  44454. * Creates the experience helper
  44455. * @param scene the scene to attach the experience helper to
  44456. * @returns a promise for the experience helper
  44457. */
  44458. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44459. /**
  44460. * Disposes of the experience helper
  44461. */
  44462. dispose(): void;
  44463. /**
  44464. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44465. * @param sessionMode options for the XR session
  44466. * @param referenceSpaceType frame of reference of the XR session
  44467. * @param renderTarget the output canvas that will be used to enter XR mode
  44468. * @returns promise that resolves after xr mode has entered
  44469. */
  44470. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44471. /**
  44472. * Exits XR mode and returns the scene to its original state
  44473. * @returns promise that resolves after xr mode has exited
  44474. */
  44475. exitXRAsync(): Promise<void>;
  44476. private _nonXRToXRCamera;
  44477. private _setState;
  44478. }
  44479. }
  44480. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44481. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44482. import { Observable } from "babylonjs/Misc/observable";
  44483. import { IDisposable } from "babylonjs/scene";
  44484. /**
  44485. * X-Y values for axes in WebXR
  44486. */
  44487. export interface IWebXRMotionControllerAxesValue {
  44488. /**
  44489. * The value of the x axis
  44490. */
  44491. x: number;
  44492. /**
  44493. * The value of the y-axis
  44494. */
  44495. y: number;
  44496. }
  44497. /**
  44498. * changed / previous values for the values of this component
  44499. */
  44500. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44501. /**
  44502. * current (this frame) value
  44503. */
  44504. current: T;
  44505. /**
  44506. * previous (last change) value
  44507. */
  44508. previous: T;
  44509. }
  44510. /**
  44511. * Represents changes in the component between current frame and last values recorded
  44512. */
  44513. export interface IWebXRMotionControllerComponentChanges {
  44514. /**
  44515. * will be populated with previous and current values if axes changed
  44516. */
  44517. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44518. /**
  44519. * will be populated with previous and current values if pressed changed
  44520. */
  44521. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44522. /**
  44523. * will be populated with previous and current values if touched changed
  44524. */
  44525. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44526. /**
  44527. * will be populated with previous and current values if value changed
  44528. */
  44529. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44530. }
  44531. /**
  44532. * This class represents a single component (for example button or thumbstick) of a motion controller
  44533. */
  44534. export class WebXRControllerComponent implements IDisposable {
  44535. /**
  44536. * the id of this component
  44537. */
  44538. id: string;
  44539. /**
  44540. * the type of the component
  44541. */
  44542. type: MotionControllerComponentType;
  44543. private _buttonIndex;
  44544. private _axesIndices;
  44545. private _axes;
  44546. private _changes;
  44547. private _currentValue;
  44548. private _hasChanges;
  44549. private _pressed;
  44550. private _touched;
  44551. /**
  44552. * button component type
  44553. */
  44554. static BUTTON_TYPE: MotionControllerComponentType;
  44555. /**
  44556. * squeeze component type
  44557. */
  44558. static SQUEEZE_TYPE: MotionControllerComponentType;
  44559. /**
  44560. * Thumbstick component type
  44561. */
  44562. static THUMBSTICK_TYPE: MotionControllerComponentType;
  44563. /**
  44564. * Touchpad component type
  44565. */
  44566. static TOUCHPAD_TYPE: MotionControllerComponentType;
  44567. /**
  44568. * trigger component type
  44569. */
  44570. static TRIGGER_TYPE: MotionControllerComponentType;
  44571. /**
  44572. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44573. * the axes data changes
  44574. */
  44575. onAxisValueChangedObservable: Observable<{
  44576. x: number;
  44577. y: number;
  44578. }>;
  44579. /**
  44580. * Observers registered here will be triggered when the state of a button changes
  44581. * State change is either pressed / touched / value
  44582. */
  44583. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  44584. /**
  44585. * Creates a new component for a motion controller.
  44586. * It is created by the motion controller itself
  44587. *
  44588. * @param id the id of this component
  44589. * @param type the type of the component
  44590. * @param _buttonIndex index in the buttons array of the gamepad
  44591. * @param _axesIndices indices of the values in the axes array of the gamepad
  44592. */
  44593. constructor(
  44594. /**
  44595. * the id of this component
  44596. */
  44597. id: string,
  44598. /**
  44599. * the type of the component
  44600. */
  44601. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44602. /**
  44603. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44604. */
  44605. get axes(): IWebXRMotionControllerAxesValue;
  44606. /**
  44607. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44608. */
  44609. get changes(): IWebXRMotionControllerComponentChanges;
  44610. /**
  44611. * Return whether or not the component changed the last frame
  44612. */
  44613. get hasChanges(): boolean;
  44614. /**
  44615. * is the button currently pressed
  44616. */
  44617. get pressed(): boolean;
  44618. /**
  44619. * is the button currently touched
  44620. */
  44621. get touched(): boolean;
  44622. /**
  44623. * Get the current value of this component
  44624. */
  44625. get value(): number;
  44626. /**
  44627. * Dispose this component
  44628. */
  44629. dispose(): void;
  44630. /**
  44631. * Are there axes correlating to this component
  44632. * @return true is axes data is available
  44633. */
  44634. isAxes(): boolean;
  44635. /**
  44636. * Is this component a button (hence - pressable)
  44637. * @returns true if can be pressed
  44638. */
  44639. isButton(): boolean;
  44640. /**
  44641. * update this component using the gamepad object it is in. Called on every frame
  44642. * @param nativeController the native gamepad controller object
  44643. */
  44644. update(nativeController: IMinimalMotionControllerObject): void;
  44645. }
  44646. }
  44647. declare module "babylonjs/Loading/sceneLoader" {
  44648. import { Observable } from "babylonjs/Misc/observable";
  44649. import { Nullable } from "babylonjs/types";
  44650. import { Scene } from "babylonjs/scene";
  44651. import { Engine } from "babylonjs/Engines/engine";
  44652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44653. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44654. import { AssetContainer } from "babylonjs/assetContainer";
  44655. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44656. import { Skeleton } from "babylonjs/Bones/skeleton";
  44657. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44658. import { WebRequest } from "babylonjs/Misc/webRequest";
  44659. /**
  44660. * Class used to represent data loading progression
  44661. */
  44662. export class SceneLoaderProgressEvent {
  44663. /** defines if data length to load can be evaluated */
  44664. readonly lengthComputable: boolean;
  44665. /** defines the loaded data length */
  44666. readonly loaded: number;
  44667. /** defines the data length to load */
  44668. readonly total: number;
  44669. /**
  44670. * Create a new progress event
  44671. * @param lengthComputable defines if data length to load can be evaluated
  44672. * @param loaded defines the loaded data length
  44673. * @param total defines the data length to load
  44674. */
  44675. constructor(
  44676. /** defines if data length to load can be evaluated */
  44677. lengthComputable: boolean,
  44678. /** defines the loaded data length */
  44679. loaded: number,
  44680. /** defines the data length to load */
  44681. total: number);
  44682. /**
  44683. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44684. * @param event defines the source event
  44685. * @returns a new SceneLoaderProgressEvent
  44686. */
  44687. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44688. }
  44689. /**
  44690. * Interface used by SceneLoader plugins to define supported file extensions
  44691. */
  44692. export interface ISceneLoaderPluginExtensions {
  44693. /**
  44694. * Defines the list of supported extensions
  44695. */
  44696. [extension: string]: {
  44697. isBinary: boolean;
  44698. };
  44699. }
  44700. /**
  44701. * Interface used by SceneLoader plugin factory
  44702. */
  44703. export interface ISceneLoaderPluginFactory {
  44704. /**
  44705. * Defines the name of the factory
  44706. */
  44707. name: string;
  44708. /**
  44709. * Function called to create a new plugin
  44710. * @return the new plugin
  44711. */
  44712. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44713. /**
  44714. * The callback that returns true if the data can be directly loaded.
  44715. * @param data string containing the file data
  44716. * @returns if the data can be loaded directly
  44717. */
  44718. canDirectLoad?(data: string): boolean;
  44719. }
  44720. /**
  44721. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44722. */
  44723. export interface ISceneLoaderPluginBase {
  44724. /**
  44725. * The friendly name of this plugin.
  44726. */
  44727. name: string;
  44728. /**
  44729. * The file extensions supported by this plugin.
  44730. */
  44731. extensions: string | ISceneLoaderPluginExtensions;
  44732. /**
  44733. * The callback called when loading from a url.
  44734. * @param scene scene loading this url
  44735. * @param url url to load
  44736. * @param onSuccess callback called when the file successfully loads
  44737. * @param onProgress callback called while file is loading (if the server supports this mode)
  44738. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44739. * @param onError callback called when the file fails to load
  44740. * @returns a file request object
  44741. */
  44742. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44743. /**
  44744. * The callback called when loading from a file object.
  44745. * @param scene scene loading this file
  44746. * @param file defines the file to load
  44747. * @param onSuccess defines the callback to call when data is loaded
  44748. * @param onProgress defines the callback to call during loading process
  44749. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44750. * @param onError defines the callback to call when an error occurs
  44751. * @returns a file request object
  44752. */
  44753. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44754. /**
  44755. * The callback that returns true if the data can be directly loaded.
  44756. * @param data string containing the file data
  44757. * @returns if the data can be loaded directly
  44758. */
  44759. canDirectLoad?(data: string): boolean;
  44760. /**
  44761. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44762. * @param scene scene loading this data
  44763. * @param data string containing the data
  44764. * @returns data to pass to the plugin
  44765. */
  44766. directLoad?(scene: Scene, data: string): any;
  44767. /**
  44768. * The callback that allows custom handling of the root url based on the response url.
  44769. * @param rootUrl the original root url
  44770. * @param responseURL the response url if available
  44771. * @returns the new root url
  44772. */
  44773. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44774. }
  44775. /**
  44776. * Interface used to define a SceneLoader plugin
  44777. */
  44778. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44779. /**
  44780. * Import meshes into a scene.
  44781. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44782. * @param scene The scene to import into
  44783. * @param data The data to import
  44784. * @param rootUrl The root url for scene and resources
  44785. * @param meshes The meshes array to import into
  44786. * @param particleSystems The particle systems array to import into
  44787. * @param skeletons The skeletons array to import into
  44788. * @param onError The callback when import fails
  44789. * @returns True if successful or false otherwise
  44790. */
  44791. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44792. /**
  44793. * Load into a scene.
  44794. * @param scene The scene to load into
  44795. * @param data The data to import
  44796. * @param rootUrl The root url for scene and resources
  44797. * @param onError The callback when import fails
  44798. * @returns True if successful or false otherwise
  44799. */
  44800. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44801. /**
  44802. * Load into an asset container.
  44803. * @param scene The scene to load into
  44804. * @param data The data to import
  44805. * @param rootUrl The root url for scene and resources
  44806. * @param onError The callback when import fails
  44807. * @returns The loaded asset container
  44808. */
  44809. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44810. }
  44811. /**
  44812. * Interface used to define an async SceneLoader plugin
  44813. */
  44814. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44815. /**
  44816. * Import meshes into a scene.
  44817. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44818. * @param scene The scene to import into
  44819. * @param data The data to import
  44820. * @param rootUrl The root url for scene and resources
  44821. * @param onProgress The callback when the load progresses
  44822. * @param fileName Defines the name of the file to load
  44823. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44824. */
  44825. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44826. meshes: AbstractMesh[];
  44827. particleSystems: IParticleSystem[];
  44828. skeletons: Skeleton[];
  44829. animationGroups: AnimationGroup[];
  44830. }>;
  44831. /**
  44832. * Load into a scene.
  44833. * @param scene The scene to load into
  44834. * @param data The data to import
  44835. * @param rootUrl The root url for scene and resources
  44836. * @param onProgress The callback when the load progresses
  44837. * @param fileName Defines the name of the file to load
  44838. * @returns Nothing
  44839. */
  44840. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44841. /**
  44842. * Load into an asset container.
  44843. * @param scene The scene to load into
  44844. * @param data The data to import
  44845. * @param rootUrl The root url for scene and resources
  44846. * @param onProgress The callback when the load progresses
  44847. * @param fileName Defines the name of the file to load
  44848. * @returns The loaded asset container
  44849. */
  44850. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44851. }
  44852. /**
  44853. * Mode that determines how to handle old animation groups before loading new ones.
  44854. */
  44855. export enum SceneLoaderAnimationGroupLoadingMode {
  44856. /**
  44857. * Reset all old animations to initial state then dispose them.
  44858. */
  44859. Clean = 0,
  44860. /**
  44861. * Stop all old animations.
  44862. */
  44863. Stop = 1,
  44864. /**
  44865. * Restart old animations from first frame.
  44866. */
  44867. Sync = 2,
  44868. /**
  44869. * Old animations remains untouched.
  44870. */
  44871. NoSync = 3
  44872. }
  44873. /**
  44874. * Class used to load scene from various file formats using registered plugins
  44875. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44876. */
  44877. export class SceneLoader {
  44878. /**
  44879. * No logging while loading
  44880. */
  44881. static readonly NO_LOGGING: number;
  44882. /**
  44883. * Minimal logging while loading
  44884. */
  44885. static readonly MINIMAL_LOGGING: number;
  44886. /**
  44887. * Summary logging while loading
  44888. */
  44889. static readonly SUMMARY_LOGGING: number;
  44890. /**
  44891. * Detailled logging while loading
  44892. */
  44893. static readonly DETAILED_LOGGING: number;
  44894. /**
  44895. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44896. */
  44897. static get ForceFullSceneLoadingForIncremental(): boolean;
  44898. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44899. /**
  44900. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44901. */
  44902. static get ShowLoadingScreen(): boolean;
  44903. static set ShowLoadingScreen(value: boolean);
  44904. /**
  44905. * Defines the current logging level (while loading the scene)
  44906. * @ignorenaming
  44907. */
  44908. static get loggingLevel(): number;
  44909. static set loggingLevel(value: number);
  44910. /**
  44911. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44912. */
  44913. static get CleanBoneMatrixWeights(): boolean;
  44914. static set CleanBoneMatrixWeights(value: boolean);
  44915. /**
  44916. * Event raised when a plugin is used to load a scene
  44917. */
  44918. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44919. private static _registeredPlugins;
  44920. private static _getDefaultPlugin;
  44921. private static _getPluginForExtension;
  44922. private static _getPluginForDirectLoad;
  44923. private static _getPluginForFilename;
  44924. private static _getDirectLoad;
  44925. private static _loadData;
  44926. private static _getFileInfo;
  44927. /**
  44928. * Gets a plugin that can load the given extension
  44929. * @param extension defines the extension to load
  44930. * @returns a plugin or null if none works
  44931. */
  44932. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44933. /**
  44934. * Gets a boolean indicating that the given extension can be loaded
  44935. * @param extension defines the extension to load
  44936. * @returns true if the extension is supported
  44937. */
  44938. static IsPluginForExtensionAvailable(extension: string): boolean;
  44939. /**
  44940. * Adds a new plugin to the list of registered plugins
  44941. * @param plugin defines the plugin to add
  44942. */
  44943. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44944. /**
  44945. * Import meshes into a scene
  44946. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44947. * @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)
  44948. * @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)
  44949. * @param scene the instance of BABYLON.Scene to append to
  44950. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44951. * @param onProgress a callback with a progress event for each file being loaded
  44952. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44953. * @param pluginExtension the extension used to determine the plugin
  44954. * @returns The loaded plugin
  44955. */
  44956. 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>;
  44957. /**
  44958. * Import meshes into a scene
  44959. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44960. * @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)
  44961. * @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)
  44962. * @param scene the instance of BABYLON.Scene to append to
  44963. * @param onProgress a callback with a progress event for each file being loaded
  44964. * @param pluginExtension the extension used to determine the plugin
  44965. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  44966. */
  44967. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  44968. meshes: AbstractMesh[];
  44969. particleSystems: IParticleSystem[];
  44970. skeletons: Skeleton[];
  44971. animationGroups: AnimationGroup[];
  44972. }>;
  44973. /**
  44974. * Load a scene
  44975. * @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)
  44976. * @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)
  44977. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44978. * @param onSuccess a callback with the scene when import succeeds
  44979. * @param onProgress a callback with a progress event for each file being loaded
  44980. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  44981. * @param pluginExtension the extension used to determine the plugin
  44982. * @returns The loaded plugin
  44983. */
  44984. 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>;
  44985. /**
  44986. * Load a scene
  44987. * @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)
  44988. * @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)
  44989. * @param engine is the instance of BABYLON.Engine to use to create the scene
  44990. * @param onProgress a callback with a progress event for each file being loaded
  44991. * @param pluginExtension the extension used to determine the plugin
  44992. * @returns The loaded scene
  44993. */
  44994. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  44995. /**
  44996. * Append a scene
  44997. * @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)
  44998. * @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)
  44999. * @param scene is the instance of BABYLON.Scene to append to
  45000. * @param onSuccess a callback with the scene when import succeeds
  45001. * @param onProgress a callback with a progress event for each file being loaded
  45002. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45003. * @param pluginExtension the extension used to determine the plugin
  45004. * @returns The loaded plugin
  45005. */
  45006. 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>;
  45007. /**
  45008. * Append a scene
  45009. * @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)
  45010. * @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)
  45011. * @param scene is the instance of BABYLON.Scene to append to
  45012. * @param onProgress a callback with a progress event for each file being loaded
  45013. * @param pluginExtension the extension used to determine the plugin
  45014. * @returns The given scene
  45015. */
  45016. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45017. /**
  45018. * Load a scene into an asset container
  45019. * @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)
  45020. * @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)
  45021. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45022. * @param onSuccess a callback with the scene when import succeeds
  45023. * @param onProgress a callback with a progress event for each file being loaded
  45024. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45025. * @param pluginExtension the extension used to determine the plugin
  45026. * @returns The loaded plugin
  45027. */
  45028. 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>;
  45029. /**
  45030. * Load a scene into an asset container
  45031. * @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)
  45032. * @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)
  45033. * @param scene is the instance of Scene to append to
  45034. * @param onProgress a callback with a progress event for each file being loaded
  45035. * @param pluginExtension the extension used to determine the plugin
  45036. * @returns The loaded asset container
  45037. */
  45038. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45039. /**
  45040. * Import animations from a file into a scene
  45041. * @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)
  45042. * @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)
  45043. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45044. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45045. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45046. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45047. * @param onSuccess a callback with the scene when import succeeds
  45048. * @param onProgress a callback with a progress event for each file being loaded
  45049. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45050. */
  45051. 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;
  45052. /**
  45053. * Import animations from a file into a scene
  45054. * @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)
  45055. * @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)
  45056. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45057. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45058. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45059. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45060. * @param onSuccess a callback with the scene when import succeeds
  45061. * @param onProgress a callback with a progress event for each file being loaded
  45062. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45063. * @returns the updated scene with imported animations
  45064. */
  45065. 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>;
  45066. }
  45067. }
  45068. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45069. import { IDisposable, Scene } from "babylonjs/scene";
  45070. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45071. import { Observable } from "babylonjs/Misc/observable";
  45072. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45073. import { Nullable } from "babylonjs/types";
  45074. /**
  45075. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45076. */
  45077. export type MotionControllerHandness = "none" | "left" | "right";
  45078. /**
  45079. * The type of components available in motion controllers.
  45080. * This is not the name of the component.
  45081. */
  45082. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45083. /**
  45084. * The state of a controller component
  45085. */
  45086. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45087. /**
  45088. * The schema of motion controller layout.
  45089. * No object will be initialized using this interface
  45090. * This is used just to define the profile.
  45091. */
  45092. export interface IMotionControllerLayout {
  45093. /**
  45094. * Path to load the assets. Usually relative to the base path
  45095. */
  45096. assetPath: string;
  45097. /**
  45098. * Available components (unsorted)
  45099. */
  45100. components: {
  45101. /**
  45102. * A map of component Ids
  45103. */
  45104. [componentId: string]: {
  45105. /**
  45106. * The type of input the component outputs
  45107. */
  45108. type: MotionControllerComponentType;
  45109. /**
  45110. * The indices of this component in the gamepad object
  45111. */
  45112. gamepadIndices: {
  45113. /**
  45114. * Index of button
  45115. */
  45116. button?: number;
  45117. /**
  45118. * If available, index of x-axis
  45119. */
  45120. xAxis?: number;
  45121. /**
  45122. * If available, index of y-axis
  45123. */
  45124. yAxis?: number;
  45125. };
  45126. /**
  45127. * The mesh's root node name
  45128. */
  45129. rootNodeName: string;
  45130. /**
  45131. * Animation definitions for this model
  45132. */
  45133. visualResponses: {
  45134. [stateKey: string]: {
  45135. /**
  45136. * What property will be animated
  45137. */
  45138. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45139. /**
  45140. * What states influence this visual response
  45141. */
  45142. states: MotionControllerComponentStateType[];
  45143. /**
  45144. * Type of animation - movement or visibility
  45145. */
  45146. valueNodeProperty: "transform" | "visibility";
  45147. /**
  45148. * Base node name to move. Its position will be calculated according to the min and max nodes
  45149. */
  45150. valueNodeName?: string;
  45151. /**
  45152. * Minimum movement node
  45153. */
  45154. minNodeName?: string;
  45155. /**
  45156. * Max movement node
  45157. */
  45158. maxNodeName?: string;
  45159. };
  45160. };
  45161. /**
  45162. * If touch enabled, what is the name of node to display user feedback
  45163. */
  45164. touchPointNodeName?: string;
  45165. };
  45166. };
  45167. /**
  45168. * Is it xr standard mapping or not
  45169. */
  45170. gamepadMapping: "" | "xr-standard";
  45171. /**
  45172. * Base root node of this entire model
  45173. */
  45174. rootNodeName: string;
  45175. /**
  45176. * Defines the main button component id
  45177. */
  45178. selectComponentId: string;
  45179. }
  45180. /**
  45181. * A definition for the layout map in the input profile
  45182. */
  45183. export interface IMotionControllerLayoutMap {
  45184. /**
  45185. * Layouts with handness type as a key
  45186. */
  45187. [handness: string]: IMotionControllerLayout;
  45188. }
  45189. /**
  45190. * The XR Input profile schema
  45191. * Profiles can be found here:
  45192. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45193. */
  45194. export interface IMotionControllerProfile {
  45195. /**
  45196. * fallback profiles for this profileId
  45197. */
  45198. fallbackProfileIds: string[];
  45199. /**
  45200. * The layout map, with handness as key
  45201. */
  45202. layouts: IMotionControllerLayoutMap;
  45203. /**
  45204. * The id of this profile
  45205. * correlates to the profile(s) in the xrInput.profiles array
  45206. */
  45207. profileId: string;
  45208. }
  45209. /**
  45210. * A helper-interface for the 3 meshes needed for controller button animation
  45211. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45212. */
  45213. export interface IMotionControllerButtonMeshMap {
  45214. /**
  45215. * the mesh that defines the pressed value mesh position.
  45216. * This is used to find the max-position of this button
  45217. */
  45218. pressedMesh: AbstractMesh;
  45219. /**
  45220. * the mesh that defines the unpressed value mesh position.
  45221. * This is used to find the min (or initial) position of this button
  45222. */
  45223. unpressedMesh: AbstractMesh;
  45224. /**
  45225. * The mesh that will be changed when value changes
  45226. */
  45227. valueMesh: AbstractMesh;
  45228. }
  45229. /**
  45230. * A helper-interface for the 3 meshes needed for controller axis animation.
  45231. * This will be expanded when touchpad animations are fully supported
  45232. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45233. */
  45234. export interface IMotionControllerMeshMap {
  45235. /**
  45236. * the mesh that defines the maximum value mesh position.
  45237. */
  45238. maxMesh?: AbstractMesh;
  45239. /**
  45240. * the mesh that defines the minimum value mesh position.
  45241. */
  45242. minMesh?: AbstractMesh;
  45243. /**
  45244. * The mesh that will be changed when axis value changes
  45245. */
  45246. valueMesh: AbstractMesh;
  45247. }
  45248. /**
  45249. * The elements needed for change-detection of the gamepad objects in motion controllers
  45250. */
  45251. export interface IMinimalMotionControllerObject {
  45252. /**
  45253. * Available axes of this controller
  45254. */
  45255. axes: number[];
  45256. /**
  45257. * An array of available buttons
  45258. */
  45259. buttons: Array<{
  45260. /**
  45261. * Value of the button/trigger
  45262. */
  45263. value: number;
  45264. /**
  45265. * If the button/trigger is currently touched
  45266. */
  45267. touched: boolean;
  45268. /**
  45269. * If the button/trigger is currently pressed
  45270. */
  45271. pressed: boolean;
  45272. }>;
  45273. }
  45274. /**
  45275. * An Abstract Motion controller
  45276. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45277. * Each component has an observable to check for changes in value and state
  45278. */
  45279. export abstract class WebXRAbstractMotionController implements IDisposable {
  45280. protected scene: Scene;
  45281. protected layout: IMotionControllerLayout;
  45282. /**
  45283. * The gamepad object correlating to this controller
  45284. */
  45285. gamepadObject: IMinimalMotionControllerObject;
  45286. /**
  45287. * handness (left/right/none) of this controller
  45288. */
  45289. handness: MotionControllerHandness;
  45290. private _initComponent;
  45291. private _modelReady;
  45292. /**
  45293. * A map of components (WebXRControllerComponent) in this motion controller
  45294. * Components have a ComponentType and can also have both button and axis definitions
  45295. */
  45296. readonly components: {
  45297. [id: string]: WebXRControllerComponent;
  45298. };
  45299. /**
  45300. * Disable the model's animation. Can be set at any time.
  45301. */
  45302. disableAnimation: boolean;
  45303. /**
  45304. * Observers registered here will be triggered when the model of this controller is done loading
  45305. */
  45306. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45307. /**
  45308. * The profile id of this motion controller
  45309. */
  45310. abstract profileId: string;
  45311. /**
  45312. * The root mesh of the model. It is null if the model was not yet initialized
  45313. */
  45314. rootMesh: Nullable<AbstractMesh>;
  45315. /**
  45316. * constructs a new abstract motion controller
  45317. * @param scene the scene to which the model of the controller will be added
  45318. * @param layout The profile layout to load
  45319. * @param gamepadObject The gamepad object correlating to this controller
  45320. * @param handness handness (left/right/none) of this controller
  45321. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45322. */
  45323. constructor(scene: Scene, layout: IMotionControllerLayout,
  45324. /**
  45325. * The gamepad object correlating to this controller
  45326. */
  45327. gamepadObject: IMinimalMotionControllerObject,
  45328. /**
  45329. * handness (left/right/none) of this controller
  45330. */
  45331. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45332. /**
  45333. * Dispose this controller, the model mesh and all its components
  45334. */
  45335. dispose(): void;
  45336. /**
  45337. * Returns all components of specific type
  45338. * @param type the type to search for
  45339. * @return an array of components with this type
  45340. */
  45341. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45342. /**
  45343. * get a component based an its component id as defined in layout.components
  45344. * @param id the id of the component
  45345. * @returns the component correlates to the id or undefined if not found
  45346. */
  45347. getComponent(id: string): WebXRControllerComponent;
  45348. /**
  45349. * Get the list of components available in this motion controller
  45350. * @returns an array of strings correlating to available components
  45351. */
  45352. getComponentIds(): string[];
  45353. /**
  45354. * Get the first component of specific type
  45355. * @param type type of component to find
  45356. * @return a controller component or null if not found
  45357. */
  45358. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45359. /**
  45360. * Get the main (Select) component of this controller as defined in the layout
  45361. * @returns the main component of this controller
  45362. */
  45363. getMainComponent(): WebXRControllerComponent;
  45364. /**
  45365. * Loads the model correlating to this controller
  45366. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45367. * @returns A promise fulfilled with the result of the model loading
  45368. */
  45369. loadModel(): Promise<boolean>;
  45370. /**
  45371. * Update this model using the current XRFrame
  45372. * @param xrFrame the current xr frame to use and update the model
  45373. */
  45374. updateFromXRFrame(xrFrame: XRFrame): void;
  45375. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45376. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45377. /**
  45378. * Moves the axis on the controller mesh based on its current state
  45379. * @param axis the index of the axis
  45380. * @param axisValue the value of the axis which determines the meshes new position
  45381. * @hidden
  45382. */
  45383. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45384. /**
  45385. * Update the model itself with the current frame data
  45386. * @param xrFrame the frame to use for updating the model mesh
  45387. */
  45388. protected updateModel(xrFrame: XRFrame): void;
  45389. /**
  45390. * Get the filename and path for this controller's model
  45391. * @returns a map of filename and path
  45392. */
  45393. protected abstract _getFilenameAndPath(): {
  45394. filename: string;
  45395. path: string;
  45396. };
  45397. /**
  45398. * This function is called before the mesh is loaded. It checks for loading constraints.
  45399. * For example, this function can check if the GLB loader is available
  45400. * If this function returns false, the generic controller will be loaded instead
  45401. * @returns Is the client ready to load the mesh
  45402. */
  45403. protected abstract _getModelLoadingConstraints(): boolean;
  45404. /**
  45405. * This function will be called after the model was successfully loaded and can be used
  45406. * for mesh transformations before it is available for the user
  45407. * @param meshes the loaded meshes
  45408. */
  45409. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45410. /**
  45411. * Set the root mesh for this controller. Important for the WebXR controller class
  45412. * @param meshes the loaded meshes
  45413. */
  45414. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45415. /**
  45416. * A function executed each frame that updates the mesh (if needed)
  45417. * @param xrFrame the current xrFrame
  45418. */
  45419. protected abstract _updateModel(xrFrame: XRFrame): void;
  45420. private _getGenericFilenameAndPath;
  45421. private _getGenericParentMesh;
  45422. }
  45423. }
  45424. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45425. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45427. import { Scene } from "babylonjs/scene";
  45428. /**
  45429. * A generic trigger-only motion controller for WebXR
  45430. */
  45431. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45432. /**
  45433. * Static version of the profile id of this controller
  45434. */
  45435. static ProfileId: string;
  45436. profileId: string;
  45437. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45438. protected _getFilenameAndPath(): {
  45439. filename: string;
  45440. path: string;
  45441. };
  45442. protected _getModelLoadingConstraints(): boolean;
  45443. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45444. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45445. protected _updateModel(): void;
  45446. }
  45447. }
  45448. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45449. import { Vector4 } from "babylonjs/Maths/math.vector";
  45450. import { Mesh } from "babylonjs/Meshes/mesh";
  45451. import { Scene } from "babylonjs/scene";
  45452. import { Nullable } from "babylonjs/types";
  45453. /**
  45454. * Class containing static functions to help procedurally build meshes
  45455. */
  45456. export class SphereBuilder {
  45457. /**
  45458. * Creates a sphere mesh
  45459. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45460. * * 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`)
  45461. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45462. * * 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
  45463. * * 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)
  45464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45465. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45467. * @param name defines the name of the mesh
  45468. * @param options defines the options used to create the mesh
  45469. * @param scene defines the hosting scene
  45470. * @returns the sphere mesh
  45471. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45472. */
  45473. static CreateSphere(name: string, options: {
  45474. segments?: number;
  45475. diameter?: number;
  45476. diameterX?: number;
  45477. diameterY?: number;
  45478. diameterZ?: number;
  45479. arc?: number;
  45480. slice?: number;
  45481. sideOrientation?: number;
  45482. frontUVs?: Vector4;
  45483. backUVs?: Vector4;
  45484. updatable?: boolean;
  45485. }, scene?: Nullable<Scene>): Mesh;
  45486. }
  45487. }
  45488. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45489. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45490. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45491. import { Scene } from "babylonjs/scene";
  45492. /**
  45493. * A profiled motion controller has its profile loaded from an online repository.
  45494. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45495. */
  45496. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45497. private _repositoryUrl;
  45498. private _buttonMeshMapping;
  45499. private _touchDots;
  45500. /**
  45501. * The profile ID of this controller. Will be populated when the controller initializes.
  45502. */
  45503. profileId: string;
  45504. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45505. dispose(): void;
  45506. protected _getFilenameAndPath(): {
  45507. filename: string;
  45508. path: string;
  45509. };
  45510. protected _getModelLoadingConstraints(): boolean;
  45511. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45512. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45513. protected _updateModel(_xrFrame: XRFrame): void;
  45514. }
  45515. }
  45516. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45517. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45518. import { Scene } from "babylonjs/scene";
  45519. /**
  45520. * A construction function type to create a new controller based on an xrInput object
  45521. */
  45522. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45523. /**
  45524. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45525. *
  45526. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45527. * it should be replaced with auto-loaded controllers.
  45528. *
  45529. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45530. */
  45531. export class WebXRMotionControllerManager {
  45532. private static _AvailableControllers;
  45533. private static _Fallbacks;
  45534. private static _ProfileLoadingPromises;
  45535. private static _ProfilesList;
  45536. /**
  45537. * The base URL of the online controller repository. Can be changed at any time.
  45538. */
  45539. static BaseRepositoryUrl: string;
  45540. /**
  45541. * Which repository gets priority - local or online
  45542. */
  45543. static PrioritizeOnlineRepository: boolean;
  45544. /**
  45545. * Use the online repository, or use only locally-defined controllers
  45546. */
  45547. static UseOnlineRepository: boolean;
  45548. /**
  45549. * Clear the cache used for profile loading and reload when requested again
  45550. */
  45551. static ClearProfilesCache(): void;
  45552. /**
  45553. * Register the default fallbacks.
  45554. * This function is called automatically when this file is imported.
  45555. */
  45556. static DefaultFallbacks(): void;
  45557. /**
  45558. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45559. * @param profileId the profile to which a fallback needs to be found
  45560. * @return an array with corresponding fallback profiles
  45561. */
  45562. static FindFallbackWithProfileId(profileId: string): string[];
  45563. /**
  45564. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45565. * The order of search:
  45566. *
  45567. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45568. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45569. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45570. * 4) return the generic trigger controller if none were found
  45571. *
  45572. * @param xrInput the xrInput to which a new controller is initialized
  45573. * @param scene the scene to which the model will be added
  45574. * @param forceProfile force a certain profile for this controller
  45575. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  45576. */
  45577. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  45578. /**
  45579. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45580. *
  45581. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45582. *
  45583. * @param type the profile type to register
  45584. * @param constructFunction the function to be called when loading this profile
  45585. */
  45586. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45587. /**
  45588. * Register a fallback to a specific profile.
  45589. * @param profileId the profileId that will receive the fallbacks
  45590. * @param fallbacks A list of fallback profiles
  45591. */
  45592. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45593. /**
  45594. * Will update the list of profiles available in the repository
  45595. * @return a promise that resolves to a map of profiles available online
  45596. */
  45597. static UpdateProfilesList(): Promise<{
  45598. [profile: string]: string;
  45599. }>;
  45600. private static _LoadProfileFromRepository;
  45601. private static _LoadProfilesFromAvailableControllers;
  45602. }
  45603. }
  45604. declare module "babylonjs/XR/webXRInputSource" {
  45605. import { Observable } from "babylonjs/Misc/observable";
  45606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45607. import { Ray } from "babylonjs/Culling/ray";
  45608. import { Scene } from "babylonjs/scene";
  45609. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45610. /**
  45611. * Configuration options for the WebXR controller creation
  45612. */
  45613. export interface IWebXRControllerOptions {
  45614. /**
  45615. * Should the controller mesh be animated when a user interacts with it
  45616. * The pressed buttons / thumbstick and touchpad animations will be disabled
  45617. */
  45618. disableMotionControllerAnimation?: boolean;
  45619. /**
  45620. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  45621. */
  45622. doNotLoadControllerMesh?: boolean;
  45623. /**
  45624. * Force a specific controller type for this controller.
  45625. * This can be used when creating your own profile or when testing different controllers
  45626. */
  45627. forceControllerProfile?: string;
  45628. }
  45629. /**
  45630. * Represents an XR controller
  45631. */
  45632. export class WebXRInputSource {
  45633. private _scene;
  45634. /** The underlying input source for the controller */
  45635. inputSource: XRInputSource;
  45636. private _options;
  45637. private _tmpQuaternion;
  45638. private _tmpVector;
  45639. private _uniqueId;
  45640. /**
  45641. * 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
  45642. */
  45643. grip?: AbstractMesh;
  45644. /**
  45645. * If available, this is the gamepad object related to this controller.
  45646. * Using this object it is possible to get click events and trackpad changes of the
  45647. * webxr controller that is currently being used.
  45648. */
  45649. motionController?: WebXRAbstractMotionController;
  45650. /**
  45651. * Event that fires when the controller is removed/disposed.
  45652. * The object provided as event data is this controller, after associated assets were disposed.
  45653. * uniqueId is still available.
  45654. */
  45655. onDisposeObservable: Observable<WebXRInputSource>;
  45656. /**
  45657. * Will be triggered when the mesh associated with the motion controller is done loading.
  45658. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  45659. * A shortened version of controller -> motion controller -> on mesh loaded.
  45660. */
  45661. onMeshLoadedObservable: Observable<AbstractMesh>;
  45662. /**
  45663. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  45664. */
  45665. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  45666. /**
  45667. * Pointer which can be used to select objects or attach a visible laser to
  45668. */
  45669. pointer: AbstractMesh;
  45670. /**
  45671. * Creates the controller
  45672. * @see https://doc.babylonjs.com/how_to/webxr
  45673. * @param _scene the scene which the controller should be associated to
  45674. * @param inputSource the underlying input source for the controller
  45675. * @param _options options for this controller creation
  45676. */
  45677. constructor(_scene: Scene,
  45678. /** The underlying input source for the controller */
  45679. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45680. /**
  45681. * Get this controllers unique id
  45682. */
  45683. get uniqueId(): string;
  45684. /**
  45685. * Disposes of the object
  45686. */
  45687. dispose(): void;
  45688. /**
  45689. * Gets a world space ray coming from the pointer or grip
  45690. * @param result the resulting ray
  45691. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  45692. */
  45693. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  45694. /**
  45695. * Updates the controller pose based on the given XRFrame
  45696. * @param xrFrame xr frame to update the pose with
  45697. * @param referenceSpace reference space to use
  45698. */
  45699. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45700. }
  45701. }
  45702. declare module "babylonjs/XR/webXRInput" {
  45703. import { Observable } from "babylonjs/Misc/observable";
  45704. import { IDisposable } from "babylonjs/scene";
  45705. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45706. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45707. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45708. /**
  45709. * The schema for initialization options of the XR Input class
  45710. */
  45711. export interface IWebXRInputOptions {
  45712. /**
  45713. * If set to true no model will be automatically loaded
  45714. */
  45715. doNotLoadControllerMeshes?: boolean;
  45716. /**
  45717. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45718. * If not found, the xr input profile data will be used.
  45719. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45720. */
  45721. forceInputProfile?: string;
  45722. /**
  45723. * Do not send a request to the controller repository to load the profile.
  45724. *
  45725. * Instead, use the controllers available in babylon itself.
  45726. */
  45727. disableOnlineControllerRepository?: boolean;
  45728. /**
  45729. * A custom URL for the controllers repository
  45730. */
  45731. customControllersRepositoryURL?: string;
  45732. /**
  45733. * Should the controller model's components not move according to the user input
  45734. */
  45735. disableControllerAnimation?: boolean;
  45736. }
  45737. /**
  45738. * XR input used to track XR inputs such as controllers/rays
  45739. */
  45740. export class WebXRInput implements IDisposable {
  45741. /**
  45742. * the xr session manager for this session
  45743. */
  45744. xrSessionManager: WebXRSessionManager;
  45745. /**
  45746. * the WebXR camera for this session. Mainly used for teleportation
  45747. */
  45748. xrCamera: WebXRCamera;
  45749. private readonly options;
  45750. /**
  45751. * XR controllers being tracked
  45752. */
  45753. controllers: Array<WebXRInputSource>;
  45754. private _frameObserver;
  45755. private _sessionEndedObserver;
  45756. private _sessionInitObserver;
  45757. /**
  45758. * Event when a controller has been connected/added
  45759. */
  45760. onControllerAddedObservable: Observable<WebXRInputSource>;
  45761. /**
  45762. * Event when a controller has been removed/disconnected
  45763. */
  45764. onControllerRemovedObservable: Observable<WebXRInputSource>;
  45765. /**
  45766. * Initializes the WebXRInput
  45767. * @param xrSessionManager the xr session manager for this session
  45768. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45769. * @param options = initialization options for this xr input
  45770. */
  45771. constructor(
  45772. /**
  45773. * the xr session manager for this session
  45774. */
  45775. xrSessionManager: WebXRSessionManager,
  45776. /**
  45777. * the WebXR camera for this session. Mainly used for teleportation
  45778. */
  45779. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45780. private _onInputSourcesChange;
  45781. private _addAndRemoveControllers;
  45782. /**
  45783. * Disposes of the object
  45784. */
  45785. dispose(): void;
  45786. }
  45787. }
  45788. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  45789. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  45790. import { Observable, EventState } from "babylonjs/Misc/observable";
  45791. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45792. /**
  45793. * This is the base class for all WebXR features.
  45794. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  45795. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  45796. */
  45797. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  45798. protected _xrSessionManager: WebXRSessionManager;
  45799. private _attached;
  45800. private _removeOnDetach;
  45801. /**
  45802. * Should auto-attach be disabled?
  45803. */
  45804. disableAutoAttach: boolean;
  45805. /**
  45806. * Construct a new (abstract) WebXR feature
  45807. * @param _xrSessionManager the xr session manager for this feature
  45808. */
  45809. constructor(_xrSessionManager: WebXRSessionManager);
  45810. /**
  45811. * Is this feature attached
  45812. */
  45813. get attached(): boolean;
  45814. /**
  45815. * attach this feature
  45816. *
  45817. * @param force should attachment be forced (even when already attached)
  45818. * @returns true if successful, false is failed or already attached
  45819. */
  45820. attach(force?: boolean): boolean;
  45821. /**
  45822. * detach this feature.
  45823. *
  45824. * @returns true if successful, false if failed or already detached
  45825. */
  45826. detach(): boolean;
  45827. /**
  45828. * Dispose this feature and all of the resources attached
  45829. */
  45830. dispose(): void;
  45831. /**
  45832. * This is used to register callbacks that will automatically be removed when detach is called.
  45833. * @param observable the observable to which the observer will be attached
  45834. * @param callback the callback to register
  45835. */
  45836. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  45837. /**
  45838. * Code in this function will be executed on each xrFrame received from the browser.
  45839. * This function will not execute after the feature is detached.
  45840. * @param _xrFrame the current frame
  45841. */
  45842. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  45843. }
  45844. }
  45845. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45846. import { IDisposable, Scene } from "babylonjs/scene";
  45847. import { Nullable } from "babylonjs/types";
  45848. import { Observable } from "babylonjs/Misc/observable";
  45849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45850. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45851. import { Camera } from "babylonjs/Cameras/camera";
  45852. /**
  45853. * Renders a layer on top of an existing scene
  45854. */
  45855. export class UtilityLayerRenderer implements IDisposable {
  45856. /** the original scene that will be rendered on top of */
  45857. originalScene: Scene;
  45858. private _pointerCaptures;
  45859. private _lastPointerEvents;
  45860. private static _DefaultUtilityLayer;
  45861. private static _DefaultKeepDepthUtilityLayer;
  45862. private _sharedGizmoLight;
  45863. private _renderCamera;
  45864. /**
  45865. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45866. * @returns the camera that is used when rendering the utility layer
  45867. */
  45868. getRenderCamera(): Camera;
  45869. /**
  45870. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45871. * @param cam the camera that should be used when rendering the utility layer
  45872. */
  45873. setRenderCamera(cam: Nullable<Camera>): void;
  45874. /**
  45875. * @hidden
  45876. * Light which used by gizmos to get light shading
  45877. */
  45878. _getSharedGizmoLight(): HemisphericLight;
  45879. /**
  45880. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45881. */
  45882. pickUtilitySceneFirst: boolean;
  45883. /**
  45884. * 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)
  45885. */
  45886. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  45887. /**
  45888. * 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)
  45889. */
  45890. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  45891. /**
  45892. * The scene that is rendered on top of the original scene
  45893. */
  45894. utilityLayerScene: Scene;
  45895. /**
  45896. * If the utility layer should automatically be rendered on top of existing scene
  45897. */
  45898. shouldRender: boolean;
  45899. /**
  45900. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45901. */
  45902. onlyCheckPointerDownEvents: boolean;
  45903. /**
  45904. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45905. */
  45906. processAllEvents: boolean;
  45907. /**
  45908. * Observable raised when the pointer move from the utility layer scene to the main scene
  45909. */
  45910. onPointerOutObservable: Observable<number>;
  45911. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45912. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45913. private _afterRenderObserver;
  45914. private _sceneDisposeObserver;
  45915. private _originalPointerObserver;
  45916. /**
  45917. * Instantiates a UtilityLayerRenderer
  45918. * @param originalScene the original scene that will be rendered on top of
  45919. * @param handleEvents boolean indicating if the utility layer should handle events
  45920. */
  45921. constructor(
  45922. /** the original scene that will be rendered on top of */
  45923. originalScene: Scene, handleEvents?: boolean);
  45924. private _notifyObservers;
  45925. /**
  45926. * Renders the utility layers scene on top of the original scene
  45927. */
  45928. render(): void;
  45929. /**
  45930. * Disposes of the renderer
  45931. */
  45932. dispose(): void;
  45933. private _updateCamera;
  45934. }
  45935. }
  45936. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  45937. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45938. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45939. import { WebXRInput } from "babylonjs/XR/webXRInput";
  45940. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45941. import { Scene } from "babylonjs/scene";
  45942. import { Nullable } from "babylonjs/types";
  45943. import { Color3 } from "babylonjs/Maths/math.color";
  45944. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  45945. /**
  45946. * Options interface for the pointer selection module
  45947. */
  45948. export interface IWebXRControllerPointerSelectionOptions {
  45949. /**
  45950. * if provided, this scene will be used to render meshes.
  45951. */
  45952. customUtilityLayerScene?: Scene;
  45953. /**
  45954. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  45955. * If not disabled, the last picked point will be used to execute a pointer up event
  45956. * If disabled, pointer up event will be triggered right after the pointer down event.
  45957. * Used in screen and gaze target ray mode only
  45958. */
  45959. disablePointerUpOnTouchOut: boolean;
  45960. /**
  45961. * For gaze mode (time to select instead of press)
  45962. */
  45963. forceGazeMode: boolean;
  45964. /**
  45965. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  45966. * to start a new countdown to the pointer down event.
  45967. * Defaults to 1.
  45968. */
  45969. gazeModePointerMovedFactor?: number;
  45970. /**
  45971. * Different button type to use instead of the main component
  45972. */
  45973. overrideButtonId?: string;
  45974. /**
  45975. * use this rendering group id for the meshes (optional)
  45976. */
  45977. renderingGroupId?: number;
  45978. /**
  45979. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  45980. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  45981. * 3000 means 3 seconds between pointing at something and selecting it
  45982. */
  45983. timeToSelect?: number;
  45984. /**
  45985. * Should meshes created here be added to a utility layer or the main scene
  45986. */
  45987. useUtilityLayer?: boolean;
  45988. /**
  45989. * the xr input to use with this pointer selection
  45990. */
  45991. xrInput: WebXRInput;
  45992. }
  45993. /**
  45994. * A module that will enable pointer selection for motion controllers of XR Input Sources
  45995. */
  45996. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  45997. private readonly _options;
  45998. private static _idCounter;
  45999. private _attachController;
  46000. private _controllers;
  46001. private _scene;
  46002. private _tmpVectorForPickCompare;
  46003. /**
  46004. * The module's name
  46005. */
  46006. static readonly Name: string;
  46007. /**
  46008. * The (Babylon) version of this module.
  46009. * This is an integer representing the implementation version.
  46010. * This number does not correspond to the WebXR specs version
  46011. */
  46012. static readonly Version: number;
  46013. /**
  46014. * Disable lighting on the laser pointer (so it will always be visible)
  46015. */
  46016. disablePointerLighting: boolean;
  46017. /**
  46018. * Disable lighting on the selection mesh (so it will always be visible)
  46019. */
  46020. disableSelectionMeshLighting: boolean;
  46021. /**
  46022. * Should the laser pointer be displayed
  46023. */
  46024. displayLaserPointer: boolean;
  46025. /**
  46026. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46027. */
  46028. displaySelectionMesh: boolean;
  46029. /**
  46030. * This color will be set to the laser pointer when selection is triggered
  46031. */
  46032. laserPointerPickedColor: Color3;
  46033. /**
  46034. * Default color of the laser pointer
  46035. */
  46036. lasterPointerDefaultColor: Color3;
  46037. /**
  46038. * default color of the selection ring
  46039. */
  46040. selectionMeshDefaultColor: Color3;
  46041. /**
  46042. * This color will be applied to the selection ring when selection is triggered
  46043. */
  46044. selectionMeshPickedColor: Color3;
  46045. /**
  46046. * constructs a new background remover module
  46047. * @param _xrSessionManager the session manager for this module
  46048. * @param _options read-only options to be used in this module
  46049. */
  46050. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46051. /**
  46052. * attach this feature
  46053. * Will usually be called by the features manager
  46054. *
  46055. * @returns true if successful.
  46056. */
  46057. attach(): boolean;
  46058. /**
  46059. * detach this feature.
  46060. * Will usually be called by the features manager
  46061. *
  46062. * @returns true if successful.
  46063. */
  46064. detach(): boolean;
  46065. /**
  46066. * Will get the mesh under a specific pointer.
  46067. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46068. * @param controllerId the controllerId to check
  46069. * @returns The mesh under pointer or null if no mesh is under the pointer
  46070. */
  46071. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46072. /**
  46073. * Get the xr controller that correlates to the pointer id in the pointer event
  46074. *
  46075. * @param id the pointer id to search for
  46076. * @returns the controller that correlates to this id or null if not found
  46077. */
  46078. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46079. protected _onXRFrame(_xrFrame: XRFrame): void;
  46080. private _attachGazeMode;
  46081. private _attachScreenRayMode;
  46082. private _attachTrackedPointerRayMode;
  46083. private _convertNormalToDirectionOfRay;
  46084. private _detachController;
  46085. private _generateNewMeshPair;
  46086. private _pickingMoved;
  46087. private _updatePointerDistance;
  46088. }
  46089. }
  46090. declare module "babylonjs/XR/webXREnterExitUI" {
  46091. import { Nullable } from "babylonjs/types";
  46092. import { Observable } from "babylonjs/Misc/observable";
  46093. import { IDisposable, Scene } from "babylonjs/scene";
  46094. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46095. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46096. /**
  46097. * Button which can be used to enter a different mode of XR
  46098. */
  46099. export class WebXREnterExitUIButton {
  46100. /** button element */
  46101. element: HTMLElement;
  46102. /** XR initialization options for the button */
  46103. sessionMode: XRSessionMode;
  46104. /** Reference space type */
  46105. referenceSpaceType: XRReferenceSpaceType;
  46106. /**
  46107. * Creates a WebXREnterExitUIButton
  46108. * @param element button element
  46109. * @param sessionMode XR initialization session mode
  46110. * @param referenceSpaceType the type of reference space to be used
  46111. */
  46112. constructor(
  46113. /** button element */
  46114. element: HTMLElement,
  46115. /** XR initialization options for the button */
  46116. sessionMode: XRSessionMode,
  46117. /** Reference space type */
  46118. referenceSpaceType: XRReferenceSpaceType);
  46119. /**
  46120. * Extendable function which can be used to update the button's visuals when the state changes
  46121. * @param activeButton the current active button in the UI
  46122. */
  46123. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46124. }
  46125. /**
  46126. * Options to create the webXR UI
  46127. */
  46128. export class WebXREnterExitUIOptions {
  46129. /**
  46130. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46131. */
  46132. customButtons?: Array<WebXREnterExitUIButton>;
  46133. /**
  46134. * A reference space type to use when creating the default button.
  46135. * Default is local-floor
  46136. */
  46137. referenceSpaceType?: XRReferenceSpaceType;
  46138. /**
  46139. * Context to enter xr with
  46140. */
  46141. renderTarget?: Nullable<WebXRRenderTarget>;
  46142. /**
  46143. * A session mode to use when creating the default button.
  46144. * Default is immersive-vr
  46145. */
  46146. sessionMode?: XRSessionMode;
  46147. }
  46148. /**
  46149. * UI to allow the user to enter/exit XR mode
  46150. */
  46151. export class WebXREnterExitUI implements IDisposable {
  46152. private scene;
  46153. /** version of the options passed to this UI */
  46154. options: WebXREnterExitUIOptions;
  46155. private _activeButton;
  46156. private _buttons;
  46157. private _overlay;
  46158. /**
  46159. * Fired every time the active button is changed.
  46160. *
  46161. * When xr is entered via a button that launches xr that button will be the callback parameter
  46162. *
  46163. * When exiting xr the callback parameter will be null)
  46164. */
  46165. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46166. /**
  46167. *
  46168. * @param scene babylon scene object to use
  46169. * @param options (read-only) version of the options passed to this UI
  46170. */
  46171. private constructor();
  46172. /**
  46173. * Creates UI to allow the user to enter/exit XR mode
  46174. * @param scene the scene to add the ui to
  46175. * @param helper the xr experience helper to enter/exit xr with
  46176. * @param options options to configure the UI
  46177. * @returns the created ui
  46178. */
  46179. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46180. /**
  46181. * Disposes of the XR UI component
  46182. */
  46183. dispose(): void;
  46184. private _updateButtons;
  46185. }
  46186. }
  46187. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46188. import { Vector3 } from "babylonjs/Maths/math.vector";
  46189. import { Color4 } from "babylonjs/Maths/math.color";
  46190. import { Nullable } from "babylonjs/types";
  46191. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46192. import { Scene } from "babylonjs/scene";
  46193. /**
  46194. * Class containing static functions to help procedurally build meshes
  46195. */
  46196. export class LinesBuilder {
  46197. /**
  46198. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46199. * * 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
  46200. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46201. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46202. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46203. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46204. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46205. * * 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
  46206. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46207. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46208. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46209. * @param name defines the name of the new line system
  46210. * @param options defines the options used to create the line system
  46211. * @param scene defines the hosting scene
  46212. * @returns a new line system mesh
  46213. */
  46214. static CreateLineSystem(name: string, options: {
  46215. lines: Vector3[][];
  46216. updatable?: boolean;
  46217. instance?: Nullable<LinesMesh>;
  46218. colors?: Nullable<Color4[][]>;
  46219. useVertexAlpha?: boolean;
  46220. }, scene: Nullable<Scene>): LinesMesh;
  46221. /**
  46222. * Creates a line mesh
  46223. * 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
  46224. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46225. * * The parameter `points` is an array successive Vector3
  46226. * * 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
  46227. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46228. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46229. * * When updating an instance, remember that only point positions can change, not the number of points
  46230. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46231. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46232. * @param name defines the name of the new line system
  46233. * @param options defines the options used to create the line system
  46234. * @param scene defines the hosting scene
  46235. * @returns a new line mesh
  46236. */
  46237. static CreateLines(name: string, options: {
  46238. points: Vector3[];
  46239. updatable?: boolean;
  46240. instance?: Nullable<LinesMesh>;
  46241. colors?: Color4[];
  46242. useVertexAlpha?: boolean;
  46243. }, scene?: Nullable<Scene>): LinesMesh;
  46244. /**
  46245. * Creates a dashed line mesh
  46246. * * 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
  46247. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46248. * * The parameter `points` is an array successive Vector3
  46249. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46250. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46251. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46252. * * 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
  46253. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46254. * * When updating an instance, remember that only point positions can change, not the number of points
  46255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46256. * @param name defines the name of the mesh
  46257. * @param options defines the options used to create the mesh
  46258. * @param scene defines the hosting scene
  46259. * @returns the dashed line mesh
  46260. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46261. */
  46262. static CreateDashedLines(name: string, options: {
  46263. points: Vector3[];
  46264. dashSize?: number;
  46265. gapSize?: number;
  46266. dashNb?: number;
  46267. updatable?: boolean;
  46268. instance?: LinesMesh;
  46269. useVertexAlpha?: boolean;
  46270. }, scene?: Nullable<Scene>): LinesMesh;
  46271. }
  46272. }
  46273. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46274. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46275. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46276. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46278. import { Vector3 } from "babylonjs/Maths/math.vector";
  46279. import { Material } from "babylonjs/Materials/material";
  46280. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46281. import { Scene } from "babylonjs/scene";
  46282. /**
  46283. * The options container for the teleportation module
  46284. */
  46285. export interface IWebXRTeleportationOptions {
  46286. /**
  46287. * if provided, this scene will be used to render meshes.
  46288. */
  46289. customUtilityLayerScene?: Scene;
  46290. /**
  46291. * Values to configure the default target mesh
  46292. */
  46293. defaultTargetMeshOptions?: {
  46294. /**
  46295. * Fill color of the teleportation area
  46296. */
  46297. teleportationFillColor?: string;
  46298. /**
  46299. * Border color for the teleportation area
  46300. */
  46301. teleportationBorderColor?: string;
  46302. /**
  46303. * Disable the mesh's animation sequence
  46304. */
  46305. disableAnimation?: boolean;
  46306. /**
  46307. * Disable lighting on the material or the ring and arrow
  46308. */
  46309. disableLighting?: boolean;
  46310. /**
  46311. * Override the default material of the torus and arrow
  46312. */
  46313. torusArrowMaterial?: Material;
  46314. };
  46315. /**
  46316. * A list of meshes to use as floor meshes.
  46317. * Meshes can be added and removed after initializing the feature using the
  46318. * addFloorMesh and removeFloorMesh functions
  46319. * If empty, rotation will still work
  46320. */
  46321. floorMeshes?: AbstractMesh[];
  46322. /**
  46323. * use this rendering group id for the meshes (optional)
  46324. */
  46325. renderingGroupId?: number;
  46326. /**
  46327. * Should teleportation move only to snap points
  46328. */
  46329. snapPointsOnly?: boolean;
  46330. /**
  46331. * An array of points to which the teleportation will snap to.
  46332. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46333. */
  46334. snapPositions?: Vector3[];
  46335. /**
  46336. * How close should the teleportation ray be in order to snap to position.
  46337. * Default to 0.8 units (meters)
  46338. */
  46339. snapToPositionRadius?: number;
  46340. /**
  46341. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46342. * If you want to support rotation, make sure your mesh has a direction indicator.
  46343. *
  46344. * When left untouched, the default mesh will be initialized.
  46345. */
  46346. teleportationTargetMesh?: AbstractMesh;
  46347. /**
  46348. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  46349. */
  46350. timeToTeleport?: number;
  46351. /**
  46352. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  46353. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  46354. */
  46355. useMainComponentOnly?: boolean;
  46356. /**
  46357. * Should meshes created here be added to a utility layer or the main scene
  46358. */
  46359. useUtilityLayer?: boolean;
  46360. /**
  46361. * Babylon XR Input class for controller
  46362. */
  46363. xrInput: WebXRInput;
  46364. }
  46365. /**
  46366. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  46367. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  46368. * the input of the attached controllers.
  46369. */
  46370. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46371. private _options;
  46372. private _controllers;
  46373. private _currentTeleportationControllerId;
  46374. private _floorMeshes;
  46375. private _quadraticBezierCurve;
  46376. private _selectionFeature;
  46377. private _snapToPositions;
  46378. private _snappedToPoint;
  46379. private _teleportationRingMaterial?;
  46380. private _tmpRay;
  46381. private _tmpVector;
  46382. /**
  46383. * The module's name
  46384. */
  46385. static readonly Name: string;
  46386. /**
  46387. * The (Babylon) version of this module.
  46388. * This is an integer representing the implementation version.
  46389. * This number does not correspond to the webxr specs version
  46390. */
  46391. static readonly Version: number;
  46392. /**
  46393. * Is movement backwards enabled
  46394. */
  46395. backwardsMovementEnabled: boolean;
  46396. /**
  46397. * Distance to travel when moving backwards
  46398. */
  46399. backwardsTeleportationDistance: number;
  46400. /**
  46401. * The distance from the user to the inspection point in the direction of the controller
  46402. * A higher number will allow the user to move further
  46403. * defaults to 5 (meters, in xr units)
  46404. */
  46405. parabolicCheckRadius: number;
  46406. /**
  46407. * Should the module support parabolic ray on top of direct ray
  46408. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46409. * Very helpful when moving between floors / different heights
  46410. */
  46411. parabolicRayEnabled: boolean;
  46412. /**
  46413. * How much rotation should be applied when rotating right and left
  46414. */
  46415. rotationAngle: number;
  46416. /**
  46417. * Is rotation enabled when moving forward?
  46418. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46419. */
  46420. rotationEnabled: boolean;
  46421. /**
  46422. * constructs a new anchor system
  46423. * @param _xrSessionManager an instance of WebXRSessionManager
  46424. * @param _options configuration object for this feature
  46425. */
  46426. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46427. /**
  46428. * Get the snapPointsOnly flag
  46429. */
  46430. get snapPointsOnly(): boolean;
  46431. /**
  46432. * Sets the snapPointsOnly flag
  46433. * @param snapToPoints should teleportation be exclusively to snap points
  46434. */
  46435. set snapPointsOnly(snapToPoints: boolean);
  46436. /**
  46437. * Add a new mesh to the floor meshes array
  46438. * @param mesh the mesh to use as floor mesh
  46439. */
  46440. addFloorMesh(mesh: AbstractMesh): void;
  46441. /**
  46442. * Add a new snap-to point to fix teleportation to this position
  46443. * @param newSnapPoint The new Snap-To point
  46444. */
  46445. addSnapPoint(newSnapPoint: Vector3): void;
  46446. attach(): boolean;
  46447. detach(): boolean;
  46448. dispose(): void;
  46449. /**
  46450. * Remove a mesh from the floor meshes array
  46451. * @param mesh the mesh to remove
  46452. */
  46453. removeFloorMesh(mesh: AbstractMesh): void;
  46454. /**
  46455. * Remove a mesh from the floor meshes array using its name
  46456. * @param name the mesh name to remove
  46457. */
  46458. removeFloorMeshByName(name: string): void;
  46459. /**
  46460. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  46461. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  46462. * @returns was the point found and removed or not
  46463. */
  46464. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  46465. /**
  46466. * This function sets a selection feature that will be disabled when
  46467. * the forward ray is shown and will be reattached when hidden.
  46468. * This is used to remove the selection rays when moving.
  46469. * @param selectionFeature the feature to disable when forward movement is enabled
  46470. */
  46471. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46472. protected _onXRFrame(_xrFrame: XRFrame): void;
  46473. private _attachController;
  46474. private _createDefaultTargetMesh;
  46475. private _detachController;
  46476. private _findClosestSnapPointWithRadius;
  46477. private _setTargetMeshPosition;
  46478. private _setTargetMeshVisibility;
  46479. private _showParabolicPath;
  46480. private _teleportForward;
  46481. }
  46482. }
  46483. declare module "babylonjs/XR/webXRDefaultExperience" {
  46484. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46485. import { Scene } from "babylonjs/scene";
  46486. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46487. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46488. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46489. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46490. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46491. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46492. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46493. /**
  46494. * Options for the default xr helper
  46495. */
  46496. export class WebXRDefaultExperienceOptions {
  46497. /**
  46498. * Enable or disable default UI to enter XR
  46499. */
  46500. disableDefaultUI?: boolean;
  46501. /**
  46502. * Should teleportation not initialize. defaults to false.
  46503. */
  46504. disableTeleportation?: boolean;
  46505. /**
  46506. * Floor meshes that will be used for teleport
  46507. */
  46508. floorMeshes?: Array<AbstractMesh>;
  46509. /**
  46510. * If set to true, the first frame will not be used to reset position
  46511. * The first frame is mainly used when copying transformation from the old camera
  46512. * Mainly used in AR
  46513. */
  46514. ignoreNativeCameraTransformation?: boolean;
  46515. /**
  46516. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46517. */
  46518. inputOptions?: IWebXRInputOptions;
  46519. /**
  46520. * optional configuration for the output canvas
  46521. */
  46522. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46523. /**
  46524. * optional UI options. This can be used among other to change session mode and reference space type
  46525. */
  46526. uiOptions?: WebXREnterExitUIOptions;
  46527. /**
  46528. * When loading teleportation and pointer select, use stable versions instead of latest.
  46529. */
  46530. useStablePlugins?: boolean;
  46531. }
  46532. /**
  46533. * Default experience which provides a similar setup to the previous webVRExperience
  46534. */
  46535. export class WebXRDefaultExperience {
  46536. /**
  46537. * Base experience
  46538. */
  46539. baseExperience: WebXRExperienceHelper;
  46540. /**
  46541. * Enables ui for entering/exiting xr
  46542. */
  46543. enterExitUI: WebXREnterExitUI;
  46544. /**
  46545. * Input experience extension
  46546. */
  46547. input: WebXRInput;
  46548. /**
  46549. * Enables laser pointer and selection
  46550. */
  46551. pointerSelection: WebXRControllerPointerSelection;
  46552. /**
  46553. * Default target xr should render to
  46554. */
  46555. renderTarget: WebXRRenderTarget;
  46556. /**
  46557. * Enables teleportation
  46558. */
  46559. teleportation: WebXRMotionControllerTeleportation;
  46560. private constructor();
  46561. /**
  46562. * Creates the default xr experience
  46563. * @param scene scene
  46564. * @param options options for basic configuration
  46565. * @returns resulting WebXRDefaultExperience
  46566. */
  46567. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46568. /**
  46569. * DIsposes of the experience helper
  46570. */
  46571. dispose(): void;
  46572. }
  46573. }
  46574. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46575. import { Observable } from "babylonjs/Misc/observable";
  46576. import { Nullable } from "babylonjs/types";
  46577. import { Camera } from "babylonjs/Cameras/camera";
  46578. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46579. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46580. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46581. import { Scene } from "babylonjs/scene";
  46582. import { Vector3 } from "babylonjs/Maths/math.vector";
  46583. import { Color3 } from "babylonjs/Maths/math.color";
  46584. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46586. import { Mesh } from "babylonjs/Meshes/mesh";
  46587. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46588. import { EasingFunction } from "babylonjs/Animations/easing";
  46589. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46590. import "babylonjs/Meshes/Builders/groundBuilder";
  46591. import "babylonjs/Meshes/Builders/torusBuilder";
  46592. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46593. import "babylonjs/Gamepads/gamepadSceneComponent";
  46594. import "babylonjs/Animations/animatable";
  46595. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  46596. /**
  46597. * Options to modify the vr teleportation behavior.
  46598. */
  46599. export interface VRTeleportationOptions {
  46600. /**
  46601. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46602. */
  46603. floorMeshName?: string;
  46604. /**
  46605. * A list of meshes to be used as the teleportation floor. (default: empty)
  46606. */
  46607. floorMeshes?: Mesh[];
  46608. /**
  46609. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46610. */
  46611. teleportationMode?: number;
  46612. /**
  46613. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46614. */
  46615. teleportationTime?: number;
  46616. /**
  46617. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46618. */
  46619. teleportationSpeed?: number;
  46620. /**
  46621. * The easing function used in the animation or null for Linear. (default CircleEase)
  46622. */
  46623. easingFunction?: EasingFunction;
  46624. }
  46625. /**
  46626. * Options to modify the vr experience helper's behavior.
  46627. */
  46628. export interface VRExperienceHelperOptions extends WebVROptions {
  46629. /**
  46630. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46631. */
  46632. createDeviceOrientationCamera?: boolean;
  46633. /**
  46634. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46635. */
  46636. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46637. /**
  46638. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46639. */
  46640. laserToggle?: boolean;
  46641. /**
  46642. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46643. */
  46644. floorMeshes?: Mesh[];
  46645. /**
  46646. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46647. */
  46648. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46649. /**
  46650. * Defines if WebXR should be used instead of WebVR (if available)
  46651. */
  46652. useXR?: boolean;
  46653. }
  46654. /**
  46655. * Event containing information after VR has been entered
  46656. */
  46657. export class OnAfterEnteringVRObservableEvent {
  46658. /**
  46659. * If entering vr was successful
  46660. */
  46661. success: boolean;
  46662. }
  46663. /**
  46664. * Helps to quickly add VR support to an existing scene.
  46665. * See http://doc.babylonjs.com/how_to/webvr_helper
  46666. */
  46667. export class VRExperienceHelper {
  46668. /** Options to modify the vr experience helper's behavior. */
  46669. webVROptions: VRExperienceHelperOptions;
  46670. private _scene;
  46671. private _position;
  46672. private _btnVR;
  46673. private _btnVRDisplayed;
  46674. private _webVRsupported;
  46675. private _webVRready;
  46676. private _webVRrequesting;
  46677. private _webVRpresenting;
  46678. private _hasEnteredVR;
  46679. private _fullscreenVRpresenting;
  46680. private _inputElement;
  46681. private _webVRCamera;
  46682. private _vrDeviceOrientationCamera;
  46683. private _deviceOrientationCamera;
  46684. private _existingCamera;
  46685. private _onKeyDown;
  46686. private _onVrDisplayPresentChange;
  46687. private _onVRDisplayChanged;
  46688. private _onVRRequestPresentStart;
  46689. private _onVRRequestPresentComplete;
  46690. /**
  46691. * 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)
  46692. */
  46693. enableGazeEvenWhenNoPointerLock: boolean;
  46694. /**
  46695. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46696. */
  46697. exitVROnDoubleTap: boolean;
  46698. /**
  46699. * Observable raised right before entering VR.
  46700. */
  46701. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46702. /**
  46703. * Observable raised when entering VR has completed.
  46704. */
  46705. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46706. /**
  46707. * Observable raised when exiting VR.
  46708. */
  46709. onExitingVRObservable: Observable<VRExperienceHelper>;
  46710. /**
  46711. * Observable raised when controller mesh is loaded.
  46712. */
  46713. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46714. /** Return this.onEnteringVRObservable
  46715. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46716. */
  46717. get onEnteringVR(): Observable<VRExperienceHelper>;
  46718. /** Return this.onExitingVRObservable
  46719. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46720. */
  46721. get onExitingVR(): Observable<VRExperienceHelper>;
  46722. /** Return this.onControllerMeshLoadedObservable
  46723. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46724. */
  46725. get onControllerMeshLoaded(): Observable<WebVRController>;
  46726. private _rayLength;
  46727. private _useCustomVRButton;
  46728. private _teleportationRequested;
  46729. private _teleportActive;
  46730. private _floorMeshName;
  46731. private _floorMeshesCollection;
  46732. private _teleportationMode;
  46733. private _teleportationTime;
  46734. private _teleportationSpeed;
  46735. private _teleportationEasing;
  46736. private _rotationAllowed;
  46737. private _teleportBackwardsVector;
  46738. private _teleportationTarget;
  46739. private _isDefaultTeleportationTarget;
  46740. private _postProcessMove;
  46741. private _teleportationFillColor;
  46742. private _teleportationBorderColor;
  46743. private _rotationAngle;
  46744. private _haloCenter;
  46745. private _cameraGazer;
  46746. private _padSensibilityUp;
  46747. private _padSensibilityDown;
  46748. private _leftController;
  46749. private _rightController;
  46750. private _gazeColor;
  46751. private _laserColor;
  46752. private _pickedLaserColor;
  46753. private _pickedGazeColor;
  46754. /**
  46755. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46756. */
  46757. onNewMeshSelected: Observable<AbstractMesh>;
  46758. /**
  46759. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46760. * This observable will provide the mesh and the controller used to select the mesh
  46761. */
  46762. onMeshSelectedWithController: Observable<{
  46763. mesh: AbstractMesh;
  46764. controller: WebVRController;
  46765. }>;
  46766. /**
  46767. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46768. */
  46769. onNewMeshPicked: Observable<PickingInfo>;
  46770. private _circleEase;
  46771. /**
  46772. * Observable raised before camera teleportation
  46773. */
  46774. onBeforeCameraTeleport: Observable<Vector3>;
  46775. /**
  46776. * Observable raised after camera teleportation
  46777. */
  46778. onAfterCameraTeleport: Observable<Vector3>;
  46779. /**
  46780. * Observable raised when current selected mesh gets unselected
  46781. */
  46782. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46783. private _raySelectionPredicate;
  46784. /**
  46785. * To be optionaly changed by user to define custom ray selection
  46786. */
  46787. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46788. /**
  46789. * To be optionaly changed by user to define custom selection logic (after ray selection)
  46790. */
  46791. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46792. /**
  46793. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  46794. */
  46795. teleportationEnabled: boolean;
  46796. private _defaultHeight;
  46797. private _teleportationInitialized;
  46798. private _interactionsEnabled;
  46799. private _interactionsRequested;
  46800. private _displayGaze;
  46801. private _displayLaserPointer;
  46802. /**
  46803. * The mesh used to display where the user is going to teleport.
  46804. */
  46805. get teleportationTarget(): Mesh;
  46806. /**
  46807. * Sets the mesh to be used to display where the user is going to teleport.
  46808. */
  46809. set teleportationTarget(value: Mesh);
  46810. /**
  46811. * 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
  46812. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  46813. * See http://doc.babylonjs.com/resources/baking_transformations
  46814. */
  46815. get gazeTrackerMesh(): Mesh;
  46816. set gazeTrackerMesh(value: Mesh);
  46817. /**
  46818. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  46819. */
  46820. updateGazeTrackerScale: boolean;
  46821. /**
  46822. * If the gaze trackers color should be updated when selecting meshes
  46823. */
  46824. updateGazeTrackerColor: boolean;
  46825. /**
  46826. * If the controller laser color should be updated when selecting meshes
  46827. */
  46828. updateControllerLaserColor: boolean;
  46829. /**
  46830. * The gaze tracking mesh corresponding to the left controller
  46831. */
  46832. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  46833. /**
  46834. * The gaze tracking mesh corresponding to the right controller
  46835. */
  46836. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  46837. /**
  46838. * If the ray of the gaze should be displayed.
  46839. */
  46840. get displayGaze(): boolean;
  46841. /**
  46842. * Sets if the ray of the gaze should be displayed.
  46843. */
  46844. set displayGaze(value: boolean);
  46845. /**
  46846. * If the ray of the LaserPointer should be displayed.
  46847. */
  46848. get displayLaserPointer(): boolean;
  46849. /**
  46850. * Sets if the ray of the LaserPointer should be displayed.
  46851. */
  46852. set displayLaserPointer(value: boolean);
  46853. /**
  46854. * The deviceOrientationCamera used as the camera when not in VR.
  46855. */
  46856. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  46857. /**
  46858. * Based on the current WebVR support, returns the current VR camera used.
  46859. */
  46860. get currentVRCamera(): Nullable<Camera>;
  46861. /**
  46862. * The webVRCamera which is used when in VR.
  46863. */
  46864. get webVRCamera(): WebVRFreeCamera;
  46865. /**
  46866. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  46867. */
  46868. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  46869. /**
  46870. * The html button that is used to trigger entering into VR.
  46871. */
  46872. get vrButton(): Nullable<HTMLButtonElement>;
  46873. private get _teleportationRequestInitiated();
  46874. /**
  46875. * Defines whether or not Pointer lock should be requested when switching to
  46876. * full screen.
  46877. */
  46878. requestPointerLockOnFullScreen: boolean;
  46879. /**
  46880. * If asking to force XR, this will be populated with the default xr experience
  46881. */
  46882. xr: WebXRDefaultExperience;
  46883. /**
  46884. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  46885. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  46886. */
  46887. xrTestDone: boolean;
  46888. /**
  46889. * Instantiates a VRExperienceHelper.
  46890. * Helps to quickly add VR support to an existing scene.
  46891. * @param scene The scene the VRExperienceHelper belongs to.
  46892. * @param webVROptions Options to modify the vr experience helper's behavior.
  46893. */
  46894. constructor(scene: Scene,
  46895. /** Options to modify the vr experience helper's behavior. */
  46896. webVROptions?: VRExperienceHelperOptions);
  46897. private completeVRInit;
  46898. private _onDefaultMeshLoaded;
  46899. private _onResize;
  46900. private _onFullscreenChange;
  46901. /**
  46902. * Gets a value indicating if we are currently in VR mode.
  46903. */
  46904. get isInVRMode(): boolean;
  46905. private onVrDisplayPresentChange;
  46906. private onVRDisplayChanged;
  46907. private moveButtonToBottomRight;
  46908. private displayVRButton;
  46909. private updateButtonVisibility;
  46910. private _cachedAngularSensibility;
  46911. /**
  46912. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  46913. * Otherwise, will use the fullscreen API.
  46914. */
  46915. enterVR(): void;
  46916. /**
  46917. * Attempt to exit VR, or fullscreen.
  46918. */
  46919. exitVR(): void;
  46920. /**
  46921. * The position of the vr experience helper.
  46922. */
  46923. get position(): Vector3;
  46924. /**
  46925. * Sets the position of the vr experience helper.
  46926. */
  46927. set position(value: Vector3);
  46928. /**
  46929. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  46930. */
  46931. enableInteractions(): void;
  46932. private get _noControllerIsActive();
  46933. private beforeRender;
  46934. private _isTeleportationFloor;
  46935. /**
  46936. * Adds a floor mesh to be used for teleportation.
  46937. * @param floorMesh the mesh to be used for teleportation.
  46938. */
  46939. addFloorMesh(floorMesh: Mesh): void;
  46940. /**
  46941. * Removes a floor mesh from being used for teleportation.
  46942. * @param floorMesh the mesh to be removed.
  46943. */
  46944. removeFloorMesh(floorMesh: Mesh): void;
  46945. /**
  46946. * Enables interactions and teleportation using the VR controllers and gaze.
  46947. * @param vrTeleportationOptions options to modify teleportation behavior.
  46948. */
  46949. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  46950. private _onNewGamepadConnected;
  46951. private _tryEnableInteractionOnController;
  46952. private _onNewGamepadDisconnected;
  46953. private _enableInteractionOnController;
  46954. private _checkTeleportWithRay;
  46955. private _checkRotate;
  46956. private _checkTeleportBackwards;
  46957. private _enableTeleportationOnController;
  46958. private _createTeleportationCircles;
  46959. private _displayTeleportationTarget;
  46960. private _hideTeleportationTarget;
  46961. private _rotateCamera;
  46962. private _moveTeleportationSelectorTo;
  46963. private _workingVector;
  46964. private _workingQuaternion;
  46965. private _workingMatrix;
  46966. /**
  46967. * Time Constant Teleportation Mode
  46968. */
  46969. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  46970. /**
  46971. * Speed Constant Teleportation Mode
  46972. */
  46973. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  46974. /**
  46975. * Teleports the users feet to the desired location
  46976. * @param location The location where the user's feet should be placed
  46977. */
  46978. teleportCamera(location: Vector3): void;
  46979. private _convertNormalToDirectionOfRay;
  46980. private _castRayAndSelectObject;
  46981. private _notifySelectedMeshUnselected;
  46982. /**
  46983. * Permanently set new colors for the laser pointer
  46984. * @param color the new laser color
  46985. * @param pickedColor the new laser color when picked mesh detected
  46986. */
  46987. setLaserColor(color: Color3, pickedColor?: Color3): void;
  46988. /**
  46989. * Set lighting enabled / disabled on the laser pointer of both controllers
  46990. * @param enabled should the lighting be enabled on the laser pointer
  46991. */
  46992. setLaserLightingState(enabled?: boolean): void;
  46993. /**
  46994. * Permanently set new colors for the gaze pointer
  46995. * @param color the new gaze color
  46996. * @param pickedColor the new gaze color when picked mesh detected
  46997. */
  46998. setGazeColor(color: Color3, pickedColor?: Color3): void;
  46999. /**
  47000. * Sets the color of the laser ray from the vr controllers.
  47001. * @param color new color for the ray.
  47002. */
  47003. changeLaserColor(color: Color3): void;
  47004. /**
  47005. * Sets the color of the ray from the vr headsets gaze.
  47006. * @param color new color for the ray.
  47007. */
  47008. changeGazeColor(color: Color3): void;
  47009. /**
  47010. * Exits VR and disposes of the vr experience helper
  47011. */
  47012. dispose(): void;
  47013. /**
  47014. * Gets the name of the VRExperienceHelper class
  47015. * @returns "VRExperienceHelper"
  47016. */
  47017. getClassName(): string;
  47018. }
  47019. }
  47020. declare module "babylonjs/Cameras/VR/index" {
  47021. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47022. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47023. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47024. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47025. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47026. export * from "babylonjs/Cameras/VR/webVRCamera";
  47027. }
  47028. declare module "babylonjs/Cameras/RigModes/index" {
  47029. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47030. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47031. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47032. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47033. }
  47034. declare module "babylonjs/Cameras/index" {
  47035. export * from "babylonjs/Cameras/Inputs/index";
  47036. export * from "babylonjs/Cameras/cameraInputsManager";
  47037. export * from "babylonjs/Cameras/camera";
  47038. export * from "babylonjs/Cameras/targetCamera";
  47039. export * from "babylonjs/Cameras/freeCamera";
  47040. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47041. export * from "babylonjs/Cameras/touchCamera";
  47042. export * from "babylonjs/Cameras/arcRotateCamera";
  47043. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47044. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47045. export * from "babylonjs/Cameras/flyCamera";
  47046. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47047. export * from "babylonjs/Cameras/followCamera";
  47048. export * from "babylonjs/Cameras/followCameraInputsManager";
  47049. export * from "babylonjs/Cameras/gamepadCamera";
  47050. export * from "babylonjs/Cameras/Stereoscopic/index";
  47051. export * from "babylonjs/Cameras/universalCamera";
  47052. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47053. export * from "babylonjs/Cameras/VR/index";
  47054. export * from "babylonjs/Cameras/RigModes/index";
  47055. }
  47056. declare module "babylonjs/Collisions/index" {
  47057. export * from "babylonjs/Collisions/collider";
  47058. export * from "babylonjs/Collisions/collisionCoordinator";
  47059. export * from "babylonjs/Collisions/pickingInfo";
  47060. export * from "babylonjs/Collisions/intersectionInfo";
  47061. export * from "babylonjs/Collisions/meshCollisionData";
  47062. }
  47063. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47064. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47065. import { Vector3 } from "babylonjs/Maths/math.vector";
  47066. import { Ray } from "babylonjs/Culling/ray";
  47067. import { Plane } from "babylonjs/Maths/math.plane";
  47068. /**
  47069. * Contains an array of blocks representing the octree
  47070. */
  47071. export interface IOctreeContainer<T> {
  47072. /**
  47073. * Blocks within the octree
  47074. */
  47075. blocks: Array<OctreeBlock<T>>;
  47076. }
  47077. /**
  47078. * Class used to store a cell in an octree
  47079. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47080. */
  47081. export class OctreeBlock<T> {
  47082. /**
  47083. * Gets the content of the current block
  47084. */
  47085. entries: T[];
  47086. /**
  47087. * Gets the list of block children
  47088. */
  47089. blocks: Array<OctreeBlock<T>>;
  47090. private _depth;
  47091. private _maxDepth;
  47092. private _capacity;
  47093. private _minPoint;
  47094. private _maxPoint;
  47095. private _boundingVectors;
  47096. private _creationFunc;
  47097. /**
  47098. * Creates a new block
  47099. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47100. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47101. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47102. * @param depth defines the current depth of this block in the octree
  47103. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47104. * @param creationFunc defines a callback to call when an element is added to the block
  47105. */
  47106. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47107. /**
  47108. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47109. */
  47110. get capacity(): number;
  47111. /**
  47112. * Gets the minimum vector (in world space) of the block's bounding box
  47113. */
  47114. get minPoint(): Vector3;
  47115. /**
  47116. * Gets the maximum vector (in world space) of the block's bounding box
  47117. */
  47118. get maxPoint(): Vector3;
  47119. /**
  47120. * Add a new element to this block
  47121. * @param entry defines the element to add
  47122. */
  47123. addEntry(entry: T): void;
  47124. /**
  47125. * Remove an element from this block
  47126. * @param entry defines the element to remove
  47127. */
  47128. removeEntry(entry: T): void;
  47129. /**
  47130. * Add an array of elements to this block
  47131. * @param entries defines the array of elements to add
  47132. */
  47133. addEntries(entries: T[]): void;
  47134. /**
  47135. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47136. * @param frustumPlanes defines the frustum planes to test
  47137. * @param selection defines the array to store current content if selection is positive
  47138. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47139. */
  47140. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47141. /**
  47142. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47143. * @param sphereCenter defines the bounding sphere center
  47144. * @param sphereRadius defines the bounding sphere radius
  47145. * @param selection defines the array to store current content if selection is positive
  47146. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47147. */
  47148. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47149. /**
  47150. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47151. * @param ray defines the ray to test with
  47152. * @param selection defines the array to store current content if selection is positive
  47153. */
  47154. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47155. /**
  47156. * Subdivide the content into child blocks (this block will then be empty)
  47157. */
  47158. createInnerBlocks(): void;
  47159. /**
  47160. * @hidden
  47161. */
  47162. 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;
  47163. }
  47164. }
  47165. declare module "babylonjs/Culling/Octrees/octree" {
  47166. import { SmartArray } from "babylonjs/Misc/smartArray";
  47167. import { Vector3 } from "babylonjs/Maths/math.vector";
  47168. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47169. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47170. import { Ray } from "babylonjs/Culling/ray";
  47171. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47172. import { Plane } from "babylonjs/Maths/math.plane";
  47173. /**
  47174. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47175. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47176. */
  47177. export class Octree<T> {
  47178. /** 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.) */
  47179. maxDepth: number;
  47180. /**
  47181. * Blocks within the octree containing objects
  47182. */
  47183. blocks: Array<OctreeBlock<T>>;
  47184. /**
  47185. * Content stored in the octree
  47186. */
  47187. dynamicContent: T[];
  47188. private _maxBlockCapacity;
  47189. private _selectionContent;
  47190. private _creationFunc;
  47191. /**
  47192. * Creates a octree
  47193. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47194. * @param creationFunc function to be used to instatiate the octree
  47195. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47196. * @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.)
  47197. */
  47198. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47199. /** 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.) */
  47200. maxDepth?: number);
  47201. /**
  47202. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47203. * @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);
  47204. * @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);
  47205. * @param entries meshes to be added to the octree blocks
  47206. */
  47207. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47208. /**
  47209. * Adds a mesh to the octree
  47210. * @param entry Mesh to add to the octree
  47211. */
  47212. addMesh(entry: T): void;
  47213. /**
  47214. * Remove an element from the octree
  47215. * @param entry defines the element to remove
  47216. */
  47217. removeMesh(entry: T): void;
  47218. /**
  47219. * Selects an array of meshes within the frustum
  47220. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47221. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47222. * @returns array of meshes within the frustum
  47223. */
  47224. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47225. /**
  47226. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47227. * @param sphereCenter defines the bounding sphere center
  47228. * @param sphereRadius defines the bounding sphere radius
  47229. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47230. * @returns an array of objects that intersect the sphere
  47231. */
  47232. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47233. /**
  47234. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47235. * @param ray defines the ray to test with
  47236. * @returns array of intersected objects
  47237. */
  47238. intersectsRay(ray: Ray): SmartArray<T>;
  47239. /**
  47240. * Adds a mesh into the octree block if it intersects the block
  47241. */
  47242. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47243. /**
  47244. * Adds a submesh into the octree block if it intersects the block
  47245. */
  47246. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47247. }
  47248. }
  47249. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47250. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47251. import { Scene } from "babylonjs/scene";
  47252. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47253. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47254. import { Ray } from "babylonjs/Culling/ray";
  47255. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47256. import { Collider } from "babylonjs/Collisions/collider";
  47257. module "babylonjs/scene" {
  47258. interface Scene {
  47259. /**
  47260. * @hidden
  47261. * Backing Filed
  47262. */
  47263. _selectionOctree: Octree<AbstractMesh>;
  47264. /**
  47265. * Gets the octree used to boost mesh selection (picking)
  47266. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47267. */
  47268. selectionOctree: Octree<AbstractMesh>;
  47269. /**
  47270. * Creates or updates the octree used to boost selection (picking)
  47271. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47272. * @param maxCapacity defines the maximum capacity per leaf
  47273. * @param maxDepth defines the maximum depth of the octree
  47274. * @returns an octree of AbstractMesh
  47275. */
  47276. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47277. }
  47278. }
  47279. module "babylonjs/Meshes/abstractMesh" {
  47280. interface AbstractMesh {
  47281. /**
  47282. * @hidden
  47283. * Backing Field
  47284. */
  47285. _submeshesOctree: Octree<SubMesh>;
  47286. /**
  47287. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47288. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47289. * @param maxCapacity defines the maximum size of each block (64 by default)
  47290. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47291. * @returns the new octree
  47292. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47293. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47294. */
  47295. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47296. }
  47297. }
  47298. /**
  47299. * Defines the octree scene component responsible to manage any octrees
  47300. * in a given scene.
  47301. */
  47302. export class OctreeSceneComponent {
  47303. /**
  47304. * The component name help to identify the component in the list of scene components.
  47305. */
  47306. readonly name: string;
  47307. /**
  47308. * The scene the component belongs to.
  47309. */
  47310. scene: Scene;
  47311. /**
  47312. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47313. */
  47314. readonly checksIsEnabled: boolean;
  47315. /**
  47316. * Creates a new instance of the component for the given scene
  47317. * @param scene Defines the scene to register the component in
  47318. */
  47319. constructor(scene: Scene);
  47320. /**
  47321. * Registers the component in a given scene
  47322. */
  47323. register(): void;
  47324. /**
  47325. * Return the list of active meshes
  47326. * @returns the list of active meshes
  47327. */
  47328. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47329. /**
  47330. * Return the list of active sub meshes
  47331. * @param mesh The mesh to get the candidates sub meshes from
  47332. * @returns the list of active sub meshes
  47333. */
  47334. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47335. private _tempRay;
  47336. /**
  47337. * Return the list of sub meshes intersecting with a given local ray
  47338. * @param mesh defines the mesh to find the submesh for
  47339. * @param localRay defines the ray in local space
  47340. * @returns the list of intersecting sub meshes
  47341. */
  47342. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47343. /**
  47344. * Return the list of sub meshes colliding with a collider
  47345. * @param mesh defines the mesh to find the submesh for
  47346. * @param collider defines the collider to evaluate the collision against
  47347. * @returns the list of colliding sub meshes
  47348. */
  47349. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47350. /**
  47351. * Rebuilds the elements related to this component in case of
  47352. * context lost for instance.
  47353. */
  47354. rebuild(): void;
  47355. /**
  47356. * Disposes the component and the associated ressources.
  47357. */
  47358. dispose(): void;
  47359. }
  47360. }
  47361. declare module "babylonjs/Culling/Octrees/index" {
  47362. export * from "babylonjs/Culling/Octrees/octree";
  47363. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47364. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47365. }
  47366. declare module "babylonjs/Culling/index" {
  47367. export * from "babylonjs/Culling/boundingBox";
  47368. export * from "babylonjs/Culling/boundingInfo";
  47369. export * from "babylonjs/Culling/boundingSphere";
  47370. export * from "babylonjs/Culling/Octrees/index";
  47371. export * from "babylonjs/Culling/ray";
  47372. }
  47373. declare module "babylonjs/Gizmos/gizmo" {
  47374. import { Nullable } from "babylonjs/types";
  47375. import { IDisposable } from "babylonjs/scene";
  47376. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47377. import { Mesh } from "babylonjs/Meshes/mesh";
  47378. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47379. /**
  47380. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47381. */
  47382. export class Gizmo implements IDisposable {
  47383. /** The utility layer the gizmo will be added to */
  47384. gizmoLayer: UtilityLayerRenderer;
  47385. /**
  47386. * The root mesh of the gizmo
  47387. */
  47388. _rootMesh: Mesh;
  47389. private _attachedMesh;
  47390. /**
  47391. * Ratio for the scale of the gizmo (Default: 1)
  47392. */
  47393. scaleRatio: number;
  47394. /**
  47395. * If a custom mesh has been set (Default: false)
  47396. */
  47397. protected _customMeshSet: boolean;
  47398. /**
  47399. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47400. * * When set, interactions will be enabled
  47401. */
  47402. get attachedMesh(): Nullable<AbstractMesh>;
  47403. set attachedMesh(value: Nullable<AbstractMesh>);
  47404. /**
  47405. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47406. * @param mesh The mesh to replace the default mesh of the gizmo
  47407. */
  47408. setCustomMesh(mesh: Mesh): void;
  47409. /**
  47410. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47411. */
  47412. updateGizmoRotationToMatchAttachedMesh: boolean;
  47413. /**
  47414. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47415. */
  47416. updateGizmoPositionToMatchAttachedMesh: boolean;
  47417. /**
  47418. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47419. */
  47420. updateScale: boolean;
  47421. protected _interactionsEnabled: boolean;
  47422. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47423. private _beforeRenderObserver;
  47424. private _tempVector;
  47425. /**
  47426. * Creates a gizmo
  47427. * @param gizmoLayer The utility layer the gizmo will be added to
  47428. */
  47429. constructor(
  47430. /** The utility layer the gizmo will be added to */
  47431. gizmoLayer?: UtilityLayerRenderer);
  47432. /**
  47433. * Updates the gizmo to match the attached mesh's position/rotation
  47434. */
  47435. protected _update(): void;
  47436. /**
  47437. * Disposes of the gizmo
  47438. */
  47439. dispose(): void;
  47440. }
  47441. }
  47442. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47443. import { Observable } from "babylonjs/Misc/observable";
  47444. import { Nullable } from "babylonjs/types";
  47445. import { Vector3 } from "babylonjs/Maths/math.vector";
  47446. import { Color3 } from "babylonjs/Maths/math.color";
  47447. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47448. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47449. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47450. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47451. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47452. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47453. import { Scene } from "babylonjs/scene";
  47454. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47455. /**
  47456. * Single plane drag gizmo
  47457. */
  47458. export class PlaneDragGizmo extends Gizmo {
  47459. /**
  47460. * Drag behavior responsible for the gizmos dragging interactions
  47461. */
  47462. dragBehavior: PointerDragBehavior;
  47463. private _pointerObserver;
  47464. /**
  47465. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47466. */
  47467. snapDistance: number;
  47468. /**
  47469. * Event that fires each time the gizmo snaps to a new location.
  47470. * * snapDistance is the the change in distance
  47471. */
  47472. onSnapObservable: Observable<{
  47473. snapDistance: number;
  47474. }>;
  47475. private _plane;
  47476. private _coloredMaterial;
  47477. private _hoverMaterial;
  47478. private _isEnabled;
  47479. private _parent;
  47480. /** @hidden */
  47481. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47482. /** @hidden */
  47483. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47484. /**
  47485. * Creates a PlaneDragGizmo
  47486. * @param gizmoLayer The utility layer the gizmo will be added to
  47487. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47488. * @param color The color of the gizmo
  47489. */
  47490. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47491. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47492. /**
  47493. * If the gizmo is enabled
  47494. */
  47495. set isEnabled(value: boolean);
  47496. get isEnabled(): boolean;
  47497. /**
  47498. * Disposes of the gizmo
  47499. */
  47500. dispose(): void;
  47501. }
  47502. }
  47503. declare module "babylonjs/Gizmos/positionGizmo" {
  47504. import { Observable } from "babylonjs/Misc/observable";
  47505. import { Nullable } from "babylonjs/types";
  47506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47507. import { Mesh } from "babylonjs/Meshes/mesh";
  47508. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47509. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47510. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47511. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47512. /**
  47513. * Gizmo that enables dragging a mesh along 3 axis
  47514. */
  47515. export class PositionGizmo extends Gizmo {
  47516. /**
  47517. * Internal gizmo used for interactions on the x axis
  47518. */
  47519. xGizmo: AxisDragGizmo;
  47520. /**
  47521. * Internal gizmo used for interactions on the y axis
  47522. */
  47523. yGizmo: AxisDragGizmo;
  47524. /**
  47525. * Internal gizmo used for interactions on the z axis
  47526. */
  47527. zGizmo: AxisDragGizmo;
  47528. /**
  47529. * Internal gizmo used for interactions on the yz plane
  47530. */
  47531. xPlaneGizmo: PlaneDragGizmo;
  47532. /**
  47533. * Internal gizmo used for interactions on the xz plane
  47534. */
  47535. yPlaneGizmo: PlaneDragGizmo;
  47536. /**
  47537. * Internal gizmo used for interactions on the xy plane
  47538. */
  47539. zPlaneGizmo: PlaneDragGizmo;
  47540. /**
  47541. * private variables
  47542. */
  47543. private _meshAttached;
  47544. private _updateGizmoRotationToMatchAttachedMesh;
  47545. private _snapDistance;
  47546. private _scaleRatio;
  47547. /** Fires an event when any of it's sub gizmos are dragged */
  47548. onDragStartObservable: Observable<unknown>;
  47549. /** Fires an event when any of it's sub gizmos are released from dragging */
  47550. onDragEndObservable: Observable<unknown>;
  47551. /**
  47552. * If set to true, planar drag is enabled
  47553. */
  47554. private _planarGizmoEnabled;
  47555. get attachedMesh(): Nullable<AbstractMesh>;
  47556. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47557. /**
  47558. * Creates a PositionGizmo
  47559. * @param gizmoLayer The utility layer the gizmo will be added to
  47560. */
  47561. constructor(gizmoLayer?: UtilityLayerRenderer);
  47562. /**
  47563. * If the planar drag gizmo is enabled
  47564. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47565. */
  47566. set planarGizmoEnabled(value: boolean);
  47567. get planarGizmoEnabled(): boolean;
  47568. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47569. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47570. /**
  47571. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47572. */
  47573. set snapDistance(value: number);
  47574. get snapDistance(): number;
  47575. /**
  47576. * Ratio for the scale of the gizmo (Default: 1)
  47577. */
  47578. set scaleRatio(value: number);
  47579. get scaleRatio(): number;
  47580. /**
  47581. * Disposes of the gizmo
  47582. */
  47583. dispose(): void;
  47584. /**
  47585. * CustomMeshes are not supported by this gizmo
  47586. * @param mesh The mesh to replace the default mesh of the gizmo
  47587. */
  47588. setCustomMesh(mesh: Mesh): void;
  47589. }
  47590. }
  47591. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47592. import { Observable } from "babylonjs/Misc/observable";
  47593. import { Nullable } from "babylonjs/types";
  47594. import { Vector3 } from "babylonjs/Maths/math.vector";
  47595. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47597. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47598. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47599. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47600. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47601. import { Scene } from "babylonjs/scene";
  47602. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47603. import { Color3 } from "babylonjs/Maths/math.color";
  47604. /**
  47605. * Single axis drag gizmo
  47606. */
  47607. export class AxisDragGizmo extends Gizmo {
  47608. /**
  47609. * Drag behavior responsible for the gizmos dragging interactions
  47610. */
  47611. dragBehavior: PointerDragBehavior;
  47612. private _pointerObserver;
  47613. /**
  47614. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47615. */
  47616. snapDistance: number;
  47617. /**
  47618. * Event that fires each time the gizmo snaps to a new location.
  47619. * * snapDistance is the the change in distance
  47620. */
  47621. onSnapObservable: Observable<{
  47622. snapDistance: number;
  47623. }>;
  47624. private _isEnabled;
  47625. private _parent;
  47626. private _arrow;
  47627. private _coloredMaterial;
  47628. private _hoverMaterial;
  47629. /** @hidden */
  47630. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47631. /** @hidden */
  47632. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47633. /**
  47634. * Creates an AxisDragGizmo
  47635. * @param gizmoLayer The utility layer the gizmo will be added to
  47636. * @param dragAxis The axis which the gizmo will be able to drag on
  47637. * @param color The color of the gizmo
  47638. */
  47639. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47640. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47641. /**
  47642. * If the gizmo is enabled
  47643. */
  47644. set isEnabled(value: boolean);
  47645. get isEnabled(): boolean;
  47646. /**
  47647. * Disposes of the gizmo
  47648. */
  47649. dispose(): void;
  47650. }
  47651. }
  47652. declare module "babylonjs/Debug/axesViewer" {
  47653. import { Vector3 } from "babylonjs/Maths/math.vector";
  47654. import { Nullable } from "babylonjs/types";
  47655. import { Scene } from "babylonjs/scene";
  47656. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47657. /**
  47658. * The Axes viewer will show 3 axes in a specific point in space
  47659. */
  47660. export class AxesViewer {
  47661. private _xAxis;
  47662. private _yAxis;
  47663. private _zAxis;
  47664. private _scaleLinesFactor;
  47665. private _instanced;
  47666. /**
  47667. * Gets the hosting scene
  47668. */
  47669. scene: Scene;
  47670. /**
  47671. * Gets or sets a number used to scale line length
  47672. */
  47673. scaleLines: number;
  47674. /** Gets the node hierarchy used to render x-axis */
  47675. get xAxis(): TransformNode;
  47676. /** Gets the node hierarchy used to render y-axis */
  47677. get yAxis(): TransformNode;
  47678. /** Gets the node hierarchy used to render z-axis */
  47679. get zAxis(): TransformNode;
  47680. /**
  47681. * Creates a new AxesViewer
  47682. * @param scene defines the hosting scene
  47683. * @param scaleLines defines a number used to scale line length (1 by default)
  47684. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47685. * @param xAxis defines the node hierarchy used to render the x-axis
  47686. * @param yAxis defines the node hierarchy used to render the y-axis
  47687. * @param zAxis defines the node hierarchy used to render the z-axis
  47688. */
  47689. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47690. /**
  47691. * Force the viewer to update
  47692. * @param position defines the position of the viewer
  47693. * @param xaxis defines the x axis of the viewer
  47694. * @param yaxis defines the y axis of the viewer
  47695. * @param zaxis defines the z axis of the viewer
  47696. */
  47697. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47698. /**
  47699. * Creates an instance of this axes viewer.
  47700. * @returns a new axes viewer with instanced meshes
  47701. */
  47702. createInstance(): AxesViewer;
  47703. /** Releases resources */
  47704. dispose(): void;
  47705. private static _SetRenderingGroupId;
  47706. }
  47707. }
  47708. declare module "babylonjs/Debug/boneAxesViewer" {
  47709. import { Nullable } from "babylonjs/types";
  47710. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47711. import { Vector3 } from "babylonjs/Maths/math.vector";
  47712. import { Mesh } from "babylonjs/Meshes/mesh";
  47713. import { Bone } from "babylonjs/Bones/bone";
  47714. import { Scene } from "babylonjs/scene";
  47715. /**
  47716. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47717. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47718. */
  47719. export class BoneAxesViewer extends AxesViewer {
  47720. /**
  47721. * Gets or sets the target mesh where to display the axes viewer
  47722. */
  47723. mesh: Nullable<Mesh>;
  47724. /**
  47725. * Gets or sets the target bone where to display the axes viewer
  47726. */
  47727. bone: Nullable<Bone>;
  47728. /** Gets current position */
  47729. pos: Vector3;
  47730. /** Gets direction of X axis */
  47731. xaxis: Vector3;
  47732. /** Gets direction of Y axis */
  47733. yaxis: Vector3;
  47734. /** Gets direction of Z axis */
  47735. zaxis: Vector3;
  47736. /**
  47737. * Creates a new BoneAxesViewer
  47738. * @param scene defines the hosting scene
  47739. * @param bone defines the target bone
  47740. * @param mesh defines the target mesh
  47741. * @param scaleLines defines a scaling factor for line length (1 by default)
  47742. */
  47743. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47744. /**
  47745. * Force the viewer to update
  47746. */
  47747. update(): void;
  47748. /** Releases resources */
  47749. dispose(): void;
  47750. }
  47751. }
  47752. declare module "babylonjs/Debug/debugLayer" {
  47753. import { Scene } from "babylonjs/scene";
  47754. /**
  47755. * Interface used to define scene explorer extensibility option
  47756. */
  47757. export interface IExplorerExtensibilityOption {
  47758. /**
  47759. * Define the option label
  47760. */
  47761. label: string;
  47762. /**
  47763. * Defines the action to execute on click
  47764. */
  47765. action: (entity: any) => void;
  47766. }
  47767. /**
  47768. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47769. */
  47770. export interface IExplorerExtensibilityGroup {
  47771. /**
  47772. * Defines a predicate to test if a given type mut be extended
  47773. */
  47774. predicate: (entity: any) => boolean;
  47775. /**
  47776. * Gets the list of options added to a type
  47777. */
  47778. entries: IExplorerExtensibilityOption[];
  47779. }
  47780. /**
  47781. * Interface used to define the options to use to create the Inspector
  47782. */
  47783. export interface IInspectorOptions {
  47784. /**
  47785. * Display in overlay mode (default: false)
  47786. */
  47787. overlay?: boolean;
  47788. /**
  47789. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47790. */
  47791. globalRoot?: HTMLElement;
  47792. /**
  47793. * Display the Scene explorer
  47794. */
  47795. showExplorer?: boolean;
  47796. /**
  47797. * Display the property inspector
  47798. */
  47799. showInspector?: boolean;
  47800. /**
  47801. * Display in embed mode (both panes on the right)
  47802. */
  47803. embedMode?: boolean;
  47804. /**
  47805. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47806. */
  47807. handleResize?: boolean;
  47808. /**
  47809. * Allow the panes to popup (default: true)
  47810. */
  47811. enablePopup?: boolean;
  47812. /**
  47813. * Allow the panes to be closed by users (default: true)
  47814. */
  47815. enableClose?: boolean;
  47816. /**
  47817. * Optional list of extensibility entries
  47818. */
  47819. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47820. /**
  47821. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47822. */
  47823. inspectorURL?: string;
  47824. /**
  47825. * Optional initial tab (default to DebugLayerTab.Properties)
  47826. */
  47827. initialTab?: DebugLayerTab;
  47828. }
  47829. module "babylonjs/scene" {
  47830. interface Scene {
  47831. /**
  47832. * @hidden
  47833. * Backing field
  47834. */
  47835. _debugLayer: DebugLayer;
  47836. /**
  47837. * Gets the debug layer (aka Inspector) associated with the scene
  47838. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47839. */
  47840. debugLayer: DebugLayer;
  47841. }
  47842. }
  47843. /**
  47844. * Enum of inspector action tab
  47845. */
  47846. export enum DebugLayerTab {
  47847. /**
  47848. * Properties tag (default)
  47849. */
  47850. Properties = 0,
  47851. /**
  47852. * Debug tab
  47853. */
  47854. Debug = 1,
  47855. /**
  47856. * Statistics tab
  47857. */
  47858. Statistics = 2,
  47859. /**
  47860. * Tools tab
  47861. */
  47862. Tools = 3,
  47863. /**
  47864. * Settings tab
  47865. */
  47866. Settings = 4
  47867. }
  47868. /**
  47869. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47870. * what is happening in your scene
  47871. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47872. */
  47873. export class DebugLayer {
  47874. /**
  47875. * Define the url to get the inspector script from.
  47876. * By default it uses the babylonjs CDN.
  47877. * @ignoreNaming
  47878. */
  47879. static InspectorURL: string;
  47880. private _scene;
  47881. private BJSINSPECTOR;
  47882. private _onPropertyChangedObservable?;
  47883. /**
  47884. * Observable triggered when a property is changed through the inspector.
  47885. */
  47886. get onPropertyChangedObservable(): any;
  47887. /**
  47888. * Instantiates a new debug layer.
  47889. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47890. * what is happening in your scene
  47891. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47892. * @param scene Defines the scene to inspect
  47893. */
  47894. constructor(scene: Scene);
  47895. /** Creates the inspector window. */
  47896. private _createInspector;
  47897. /**
  47898. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47899. * @param entity defines the entity to select
  47900. * @param lineContainerTitle defines the specific block to highlight
  47901. */
  47902. select(entity: any, lineContainerTitle?: string): void;
  47903. /** Get the inspector from bundle or global */
  47904. private _getGlobalInspector;
  47905. /**
  47906. * Get if the inspector is visible or not.
  47907. * @returns true if visible otherwise, false
  47908. */
  47909. isVisible(): boolean;
  47910. /**
  47911. * Hide the inspector and close its window.
  47912. */
  47913. hide(): void;
  47914. /**
  47915. * Launch the debugLayer.
  47916. * @param config Define the configuration of the inspector
  47917. * @return a promise fulfilled when the debug layer is visible
  47918. */
  47919. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47920. }
  47921. }
  47922. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47923. import { Nullable } from "babylonjs/types";
  47924. import { Scene } from "babylonjs/scene";
  47925. import { Vector4 } from "babylonjs/Maths/math.vector";
  47926. import { Color4 } from "babylonjs/Maths/math.color";
  47927. import { Mesh } from "babylonjs/Meshes/mesh";
  47928. /**
  47929. * Class containing static functions to help procedurally build meshes
  47930. */
  47931. export class BoxBuilder {
  47932. /**
  47933. * Creates a box mesh
  47934. * * The parameter `size` sets the size (float) of each box side (default 1)
  47935. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47936. * * 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)
  47937. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47939. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47941. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47942. * @param name defines the name of the mesh
  47943. * @param options defines the options used to create the mesh
  47944. * @param scene defines the hosting scene
  47945. * @returns the box mesh
  47946. */
  47947. static CreateBox(name: string, options: {
  47948. size?: number;
  47949. width?: number;
  47950. height?: number;
  47951. depth?: number;
  47952. faceUV?: Vector4[];
  47953. faceColors?: Color4[];
  47954. sideOrientation?: number;
  47955. frontUVs?: Vector4;
  47956. backUVs?: Vector4;
  47957. wrap?: boolean;
  47958. topBaseAt?: number;
  47959. bottomBaseAt?: number;
  47960. updatable?: boolean;
  47961. }, scene?: Nullable<Scene>): Mesh;
  47962. }
  47963. }
  47964. declare module "babylonjs/Debug/physicsViewer" {
  47965. import { Nullable } from "babylonjs/types";
  47966. import { Scene } from "babylonjs/scene";
  47967. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47968. import { Mesh } from "babylonjs/Meshes/mesh";
  47969. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  47970. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  47971. /**
  47972. * Used to show the physics impostor around the specific mesh
  47973. */
  47974. export class PhysicsViewer {
  47975. /** @hidden */
  47976. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  47977. /** @hidden */
  47978. protected _meshes: Array<Nullable<AbstractMesh>>;
  47979. /** @hidden */
  47980. protected _scene: Nullable<Scene>;
  47981. /** @hidden */
  47982. protected _numMeshes: number;
  47983. /** @hidden */
  47984. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  47985. private _renderFunction;
  47986. private _utilityLayer;
  47987. private _debugBoxMesh;
  47988. private _debugSphereMesh;
  47989. private _debugCylinderMesh;
  47990. private _debugMaterial;
  47991. private _debugMeshMeshes;
  47992. /**
  47993. * Creates a new PhysicsViewer
  47994. * @param scene defines the hosting scene
  47995. */
  47996. constructor(scene: Scene);
  47997. /** @hidden */
  47998. protected _updateDebugMeshes(): void;
  47999. /**
  48000. * Renders a specified physic impostor
  48001. * @param impostor defines the impostor to render
  48002. * @param targetMesh defines the mesh represented by the impostor
  48003. * @returns the new debug mesh used to render the impostor
  48004. */
  48005. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48006. /**
  48007. * Hides a specified physic impostor
  48008. * @param impostor defines the impostor to hide
  48009. */
  48010. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48011. private _getDebugMaterial;
  48012. private _getDebugBoxMesh;
  48013. private _getDebugSphereMesh;
  48014. private _getDebugCylinderMesh;
  48015. private _getDebugMeshMesh;
  48016. private _getDebugMesh;
  48017. /** Releases all resources */
  48018. dispose(): void;
  48019. }
  48020. }
  48021. declare module "babylonjs/Debug/rayHelper" {
  48022. import { Nullable } from "babylonjs/types";
  48023. import { Ray } from "babylonjs/Culling/ray";
  48024. import { Vector3 } from "babylonjs/Maths/math.vector";
  48025. import { Color3 } from "babylonjs/Maths/math.color";
  48026. import { Scene } from "babylonjs/scene";
  48027. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48028. import "babylonjs/Meshes/Builders/linesBuilder";
  48029. /**
  48030. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48031. * in order to better appreciate the issue one might have.
  48032. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48033. */
  48034. export class RayHelper {
  48035. /**
  48036. * Defines the ray we are currently tryin to visualize.
  48037. */
  48038. ray: Nullable<Ray>;
  48039. private _renderPoints;
  48040. private _renderLine;
  48041. private _renderFunction;
  48042. private _scene;
  48043. private _updateToMeshFunction;
  48044. private _attachedToMesh;
  48045. private _meshSpaceDirection;
  48046. private _meshSpaceOrigin;
  48047. /**
  48048. * Helper function to create a colored helper in a scene in one line.
  48049. * @param ray Defines the ray we are currently tryin to visualize
  48050. * @param scene Defines the scene the ray is used in
  48051. * @param color Defines the color we want to see the ray in
  48052. * @returns The newly created ray helper.
  48053. */
  48054. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48055. /**
  48056. * Instantiate a new ray helper.
  48057. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48058. * in order to better appreciate the issue one might have.
  48059. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48060. * @param ray Defines the ray we are currently tryin to visualize
  48061. */
  48062. constructor(ray: Ray);
  48063. /**
  48064. * Shows the ray we are willing to debug.
  48065. * @param scene Defines the scene the ray needs to be rendered in
  48066. * @param color Defines the color the ray needs to be rendered in
  48067. */
  48068. show(scene: Scene, color?: Color3): void;
  48069. /**
  48070. * Hides the ray we are debugging.
  48071. */
  48072. hide(): void;
  48073. private _render;
  48074. /**
  48075. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48076. * @param mesh Defines the mesh we want the helper attached to
  48077. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48078. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48079. * @param length Defines the length of the ray
  48080. */
  48081. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48082. /**
  48083. * Detach the ray helper from the mesh it has previously been attached to.
  48084. */
  48085. detachFromMesh(): void;
  48086. private _updateToMesh;
  48087. /**
  48088. * Dispose the helper and release its associated resources.
  48089. */
  48090. dispose(): void;
  48091. }
  48092. }
  48093. declare module "babylonjs/Debug/skeletonViewer" {
  48094. import { Color3 } from "babylonjs/Maths/math.color";
  48095. import { Scene } from "babylonjs/scene";
  48096. import { Nullable } from "babylonjs/types";
  48097. import { Skeleton } from "babylonjs/Bones/skeleton";
  48098. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48099. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48100. /**
  48101. * Class used to render a debug view of a given skeleton
  48102. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48103. */
  48104. export class SkeletonViewer {
  48105. /** defines the skeleton to render */
  48106. skeleton: Skeleton;
  48107. /** defines the mesh attached to the skeleton */
  48108. mesh: AbstractMesh;
  48109. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48110. autoUpdateBonesMatrices: boolean;
  48111. /** defines the rendering group id to use with the viewer */
  48112. renderingGroupId: number;
  48113. /** Gets or sets the color used to render the skeleton */
  48114. color: Color3;
  48115. private _scene;
  48116. private _debugLines;
  48117. private _debugMesh;
  48118. private _isEnabled;
  48119. private _renderFunction;
  48120. private _utilityLayer;
  48121. /**
  48122. * Returns the mesh used to render the bones
  48123. */
  48124. get debugMesh(): Nullable<LinesMesh>;
  48125. /**
  48126. * Creates a new SkeletonViewer
  48127. * @param skeleton defines the skeleton to render
  48128. * @param mesh defines the mesh attached to the skeleton
  48129. * @param scene defines the hosting scene
  48130. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48131. * @param renderingGroupId defines the rendering group id to use with the viewer
  48132. */
  48133. constructor(
  48134. /** defines the skeleton to render */
  48135. skeleton: Skeleton,
  48136. /** defines the mesh attached to the skeleton */
  48137. mesh: AbstractMesh, scene: Scene,
  48138. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48139. autoUpdateBonesMatrices?: boolean,
  48140. /** defines the rendering group id to use with the viewer */
  48141. renderingGroupId?: number);
  48142. /** Gets or sets a boolean indicating if the viewer is enabled */
  48143. set isEnabled(value: boolean);
  48144. get isEnabled(): boolean;
  48145. private _getBonePosition;
  48146. private _getLinesForBonesWithLength;
  48147. private _getLinesForBonesNoLength;
  48148. /** Update the viewer to sync with current skeleton state */
  48149. update(): void;
  48150. /** Release associated resources */
  48151. dispose(): void;
  48152. }
  48153. }
  48154. declare module "babylonjs/Debug/index" {
  48155. export * from "babylonjs/Debug/axesViewer";
  48156. export * from "babylonjs/Debug/boneAxesViewer";
  48157. export * from "babylonjs/Debug/debugLayer";
  48158. export * from "babylonjs/Debug/physicsViewer";
  48159. export * from "babylonjs/Debug/rayHelper";
  48160. export * from "babylonjs/Debug/skeletonViewer";
  48161. }
  48162. declare module "babylonjs/Engines/nullEngine" {
  48163. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48164. import { Engine } from "babylonjs/Engines/engine";
  48165. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48166. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48167. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48168. import { Effect } from "babylonjs/Materials/effect";
  48169. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48170. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48171. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48172. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48173. /**
  48174. * Options to create the null engine
  48175. */
  48176. export class NullEngineOptions {
  48177. /**
  48178. * Render width (Default: 512)
  48179. */
  48180. renderWidth: number;
  48181. /**
  48182. * Render height (Default: 256)
  48183. */
  48184. renderHeight: number;
  48185. /**
  48186. * Texture size (Default: 512)
  48187. */
  48188. textureSize: number;
  48189. /**
  48190. * If delta time between frames should be constant
  48191. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48192. */
  48193. deterministicLockstep: boolean;
  48194. /**
  48195. * Maximum about of steps between frames (Default: 4)
  48196. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48197. */
  48198. lockstepMaxSteps: number;
  48199. }
  48200. /**
  48201. * The null engine class provides support for headless version of babylon.js.
  48202. * This can be used in server side scenario or for testing purposes
  48203. */
  48204. export class NullEngine extends Engine {
  48205. private _options;
  48206. /**
  48207. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48208. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48209. * @returns true if engine is in deterministic lock step mode
  48210. */
  48211. isDeterministicLockStep(): boolean;
  48212. /**
  48213. * Gets the max steps when engine is running in deterministic lock step
  48214. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48215. * @returns the max steps
  48216. */
  48217. getLockstepMaxSteps(): number;
  48218. /**
  48219. * Gets the current hardware scaling level.
  48220. * By default the hardware scaling level is computed from the window device ratio.
  48221. * 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.
  48222. * @returns a number indicating the current hardware scaling level
  48223. */
  48224. getHardwareScalingLevel(): number;
  48225. constructor(options?: NullEngineOptions);
  48226. /**
  48227. * Creates a vertex buffer
  48228. * @param vertices the data for the vertex buffer
  48229. * @returns the new WebGL static buffer
  48230. */
  48231. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48232. /**
  48233. * Creates a new index buffer
  48234. * @param indices defines the content of the index buffer
  48235. * @param updatable defines if the index buffer must be updatable
  48236. * @returns a new webGL buffer
  48237. */
  48238. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48239. /**
  48240. * Clear the current render buffer or the current render target (if any is set up)
  48241. * @param color defines the color to use
  48242. * @param backBuffer defines if the back buffer must be cleared
  48243. * @param depth defines if the depth buffer must be cleared
  48244. * @param stencil defines if the stencil buffer must be cleared
  48245. */
  48246. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48247. /**
  48248. * Gets the current render width
  48249. * @param useScreen defines if screen size must be used (or the current render target if any)
  48250. * @returns a number defining the current render width
  48251. */
  48252. getRenderWidth(useScreen?: boolean): number;
  48253. /**
  48254. * Gets the current render height
  48255. * @param useScreen defines if screen size must be used (or the current render target if any)
  48256. * @returns a number defining the current render height
  48257. */
  48258. getRenderHeight(useScreen?: boolean): number;
  48259. /**
  48260. * Set the WebGL's viewport
  48261. * @param viewport defines the viewport element to be used
  48262. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48263. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48264. */
  48265. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48266. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48267. /**
  48268. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48269. * @param pipelineContext defines the pipeline context to use
  48270. * @param uniformsNames defines the list of uniform names
  48271. * @returns an array of webGL uniform locations
  48272. */
  48273. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48274. /**
  48275. * Gets the lsit of active attributes for a given webGL program
  48276. * @param pipelineContext defines the pipeline context to use
  48277. * @param attributesNames defines the list of attribute names to get
  48278. * @returns an array of indices indicating the offset of each attribute
  48279. */
  48280. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48281. /**
  48282. * Binds an effect to the webGL context
  48283. * @param effect defines the effect to bind
  48284. */
  48285. bindSamplers(effect: Effect): void;
  48286. /**
  48287. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48288. * @param effect defines the effect to activate
  48289. */
  48290. enableEffect(effect: Effect): void;
  48291. /**
  48292. * Set various states to the webGL context
  48293. * @param culling defines backface culling state
  48294. * @param zOffset defines the value to apply to zOffset (0 by default)
  48295. * @param force defines if states must be applied even if cache is up to date
  48296. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48297. */
  48298. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48299. /**
  48300. * Set the value of an uniform to an array of int32
  48301. * @param uniform defines the webGL uniform location where to store the value
  48302. * @param array defines the array of int32 to store
  48303. */
  48304. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48305. /**
  48306. * Set the value of an uniform to an array of int32 (stored as vec2)
  48307. * @param uniform defines the webGL uniform location where to store the value
  48308. * @param array defines the array of int32 to store
  48309. */
  48310. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48311. /**
  48312. * Set the value of an uniform to an array of int32 (stored as vec3)
  48313. * @param uniform defines the webGL uniform location where to store the value
  48314. * @param array defines the array of int32 to store
  48315. */
  48316. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48317. /**
  48318. * Set the value of an uniform to an array of int32 (stored as vec4)
  48319. * @param uniform defines the webGL uniform location where to store the value
  48320. * @param array defines the array of int32 to store
  48321. */
  48322. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48323. /**
  48324. * Set the value of an uniform to an array of float32
  48325. * @param uniform defines the webGL uniform location where to store the value
  48326. * @param array defines the array of float32 to store
  48327. */
  48328. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48329. /**
  48330. * Set the value of an uniform to an array of float32 (stored as vec2)
  48331. * @param uniform defines the webGL uniform location where to store the value
  48332. * @param array defines the array of float32 to store
  48333. */
  48334. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48335. /**
  48336. * Set the value of an uniform to an array of float32 (stored as vec3)
  48337. * @param uniform defines the webGL uniform location where to store the value
  48338. * @param array defines the array of float32 to store
  48339. */
  48340. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48341. /**
  48342. * Set the value of an uniform to an array of float32 (stored as vec4)
  48343. * @param uniform defines the webGL uniform location where to store the value
  48344. * @param array defines the array of float32 to store
  48345. */
  48346. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48347. /**
  48348. * Set the value of an uniform to an array of number
  48349. * @param uniform defines the webGL uniform location where to store the value
  48350. * @param array defines the array of number to store
  48351. */
  48352. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48353. /**
  48354. * Set the value of an uniform to an array of number (stored as vec2)
  48355. * @param uniform defines the webGL uniform location where to store the value
  48356. * @param array defines the array of number to store
  48357. */
  48358. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48359. /**
  48360. * Set the value of an uniform to an array of number (stored as vec3)
  48361. * @param uniform defines the webGL uniform location where to store the value
  48362. * @param array defines the array of number to store
  48363. */
  48364. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48365. /**
  48366. * Set the value of an uniform to an array of number (stored as vec4)
  48367. * @param uniform defines the webGL uniform location where to store the value
  48368. * @param array defines the array of number to store
  48369. */
  48370. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48371. /**
  48372. * Set the value of an uniform to an array of float32 (stored as matrices)
  48373. * @param uniform defines the webGL uniform location where to store the value
  48374. * @param matrices defines the array of float32 to store
  48375. */
  48376. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48377. /**
  48378. * Set the value of an uniform to a matrix (3x3)
  48379. * @param uniform defines the webGL uniform location where to store the value
  48380. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48381. */
  48382. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48383. /**
  48384. * Set the value of an uniform to a matrix (2x2)
  48385. * @param uniform defines the webGL uniform location where to store the value
  48386. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48387. */
  48388. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48389. /**
  48390. * Set the value of an uniform to a number (float)
  48391. * @param uniform defines the webGL uniform location where to store the value
  48392. * @param value defines the float number to store
  48393. */
  48394. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48395. /**
  48396. * Set the value of an uniform to a vec2
  48397. * @param uniform defines the webGL uniform location where to store the value
  48398. * @param x defines the 1st component of the value
  48399. * @param y defines the 2nd component of the value
  48400. */
  48401. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48402. /**
  48403. * Set the value of an uniform to a vec3
  48404. * @param uniform defines the webGL uniform location where to store the value
  48405. * @param x defines the 1st component of the value
  48406. * @param y defines the 2nd component of the value
  48407. * @param z defines the 3rd component of the value
  48408. */
  48409. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48410. /**
  48411. * Set the value of an uniform to a boolean
  48412. * @param uniform defines the webGL uniform location where to store the value
  48413. * @param bool defines the boolean to store
  48414. */
  48415. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48416. /**
  48417. * Set the value of an uniform to a vec4
  48418. * @param uniform defines the webGL uniform location where to store the value
  48419. * @param x defines the 1st component of the value
  48420. * @param y defines the 2nd component of the value
  48421. * @param z defines the 3rd component of the value
  48422. * @param w defines the 4th component of the value
  48423. */
  48424. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48425. /**
  48426. * Sets the current alpha mode
  48427. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48428. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48429. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48430. */
  48431. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48432. /**
  48433. * Bind webGl buffers directly to the webGL context
  48434. * @param vertexBuffers defines the vertex buffer to bind
  48435. * @param indexBuffer defines the index buffer to bind
  48436. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48437. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48438. * @param effect defines the effect associated with the vertex buffer
  48439. */
  48440. bindBuffers(vertexBuffers: {
  48441. [key: string]: VertexBuffer;
  48442. }, indexBuffer: DataBuffer, effect: Effect): void;
  48443. /**
  48444. * Force the entire cache to be cleared
  48445. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48446. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48447. */
  48448. wipeCaches(bruteForce?: boolean): void;
  48449. /**
  48450. * Send a draw order
  48451. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48452. * @param indexStart defines the starting index
  48453. * @param indexCount defines the number of index to draw
  48454. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48455. */
  48456. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48457. /**
  48458. * Draw a list of indexed primitives
  48459. * @param fillMode defines the primitive to use
  48460. * @param indexStart defines the starting index
  48461. * @param indexCount defines the number of index to draw
  48462. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48463. */
  48464. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48465. /**
  48466. * Draw a list of unindexed primitives
  48467. * @param fillMode defines the primitive to use
  48468. * @param verticesStart defines the index of first vertex to draw
  48469. * @param verticesCount defines the count of vertices to draw
  48470. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48471. */
  48472. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48473. /** @hidden */
  48474. _createTexture(): WebGLTexture;
  48475. /** @hidden */
  48476. _releaseTexture(texture: InternalTexture): void;
  48477. /**
  48478. * Usually called from Texture.ts.
  48479. * Passed information to create a WebGLTexture
  48480. * @param urlArg defines a value which contains one of the following:
  48481. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48482. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48483. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48484. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48485. * @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)
  48486. * @param scene needed for loading to the correct scene
  48487. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48488. * @param onLoad optional callback to be called upon successful completion
  48489. * @param onError optional callback to be called upon failure
  48490. * @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
  48491. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48492. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48493. * @param forcedExtension defines the extension to use to pick the right loader
  48494. * @param mimeType defines an optional mime type
  48495. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48496. */
  48497. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  48498. /**
  48499. * Creates a new render target texture
  48500. * @param size defines the size of the texture
  48501. * @param options defines the options used to create the texture
  48502. * @returns a new render target texture stored in an InternalTexture
  48503. */
  48504. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48505. /**
  48506. * Update the sampling mode of a given texture
  48507. * @param samplingMode defines the required sampling mode
  48508. * @param texture defines the texture to update
  48509. */
  48510. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48511. /**
  48512. * Binds the frame buffer to the specified texture.
  48513. * @param texture The texture to render to or null for the default canvas
  48514. * @param faceIndex The face of the texture to render to in case of cube texture
  48515. * @param requiredWidth The width of the target to render to
  48516. * @param requiredHeight The height of the target to render to
  48517. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48518. * @param lodLevel defines le lod level to bind to the frame buffer
  48519. */
  48520. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48521. /**
  48522. * Unbind the current render target texture from the webGL context
  48523. * @param texture defines the render target texture to unbind
  48524. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48525. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48526. */
  48527. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48528. /**
  48529. * Creates a dynamic vertex buffer
  48530. * @param vertices the data for the dynamic vertex buffer
  48531. * @returns the new WebGL dynamic buffer
  48532. */
  48533. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48534. /**
  48535. * Update the content of a dynamic texture
  48536. * @param texture defines the texture to update
  48537. * @param canvas defines the canvas containing the source
  48538. * @param invertY defines if data must be stored with Y axis inverted
  48539. * @param premulAlpha defines if alpha is stored as premultiplied
  48540. * @param format defines the format of the data
  48541. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48542. */
  48543. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48544. /**
  48545. * Gets a boolean indicating if all created effects are ready
  48546. * @returns true if all effects are ready
  48547. */
  48548. areAllEffectsReady(): boolean;
  48549. /**
  48550. * @hidden
  48551. * Get the current error code of the webGL context
  48552. * @returns the error code
  48553. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48554. */
  48555. getError(): number;
  48556. /** @hidden */
  48557. _getUnpackAlignement(): number;
  48558. /** @hidden */
  48559. _unpackFlipY(value: boolean): void;
  48560. /**
  48561. * Update a dynamic index buffer
  48562. * @param indexBuffer defines the target index buffer
  48563. * @param indices defines the data to update
  48564. * @param offset defines the offset in the target index buffer where update should start
  48565. */
  48566. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48567. /**
  48568. * Updates a dynamic vertex buffer.
  48569. * @param vertexBuffer the vertex buffer to update
  48570. * @param vertices the data used to update the vertex buffer
  48571. * @param byteOffset the byte offset of the data (optional)
  48572. * @param byteLength the byte length of the data (optional)
  48573. */
  48574. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48575. /** @hidden */
  48576. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48577. /** @hidden */
  48578. _bindTexture(channel: number, texture: InternalTexture): void;
  48579. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48580. /**
  48581. * 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
  48582. */
  48583. releaseEffects(): void;
  48584. displayLoadingUI(): void;
  48585. hideLoadingUI(): void;
  48586. /** @hidden */
  48587. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48588. /** @hidden */
  48589. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48590. /** @hidden */
  48591. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48592. /** @hidden */
  48593. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48594. }
  48595. }
  48596. declare module "babylonjs/Instrumentation/timeToken" {
  48597. import { Nullable } from "babylonjs/types";
  48598. /**
  48599. * @hidden
  48600. **/
  48601. export class _TimeToken {
  48602. _startTimeQuery: Nullable<WebGLQuery>;
  48603. _endTimeQuery: Nullable<WebGLQuery>;
  48604. _timeElapsedQuery: Nullable<WebGLQuery>;
  48605. _timeElapsedQueryEnded: boolean;
  48606. }
  48607. }
  48608. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48609. import { Nullable, int } from "babylonjs/types";
  48610. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48611. /** @hidden */
  48612. export class _OcclusionDataStorage {
  48613. /** @hidden */
  48614. occlusionInternalRetryCounter: number;
  48615. /** @hidden */
  48616. isOcclusionQueryInProgress: boolean;
  48617. /** @hidden */
  48618. isOccluded: boolean;
  48619. /** @hidden */
  48620. occlusionRetryCount: number;
  48621. /** @hidden */
  48622. occlusionType: number;
  48623. /** @hidden */
  48624. occlusionQueryAlgorithmType: number;
  48625. }
  48626. module "babylonjs/Engines/engine" {
  48627. interface Engine {
  48628. /**
  48629. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48630. * @return the new query
  48631. */
  48632. createQuery(): WebGLQuery;
  48633. /**
  48634. * Delete and release a webGL query
  48635. * @param query defines the query to delete
  48636. * @return the current engine
  48637. */
  48638. deleteQuery(query: WebGLQuery): Engine;
  48639. /**
  48640. * Check if a given query has resolved and got its value
  48641. * @param query defines the query to check
  48642. * @returns true if the query got its value
  48643. */
  48644. isQueryResultAvailable(query: WebGLQuery): boolean;
  48645. /**
  48646. * Gets the value of a given query
  48647. * @param query defines the query to check
  48648. * @returns the value of the query
  48649. */
  48650. getQueryResult(query: WebGLQuery): number;
  48651. /**
  48652. * Initiates an occlusion query
  48653. * @param algorithmType defines the algorithm to use
  48654. * @param query defines the query to use
  48655. * @returns the current engine
  48656. * @see http://doc.babylonjs.com/features/occlusionquery
  48657. */
  48658. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48659. /**
  48660. * Ends an occlusion query
  48661. * @see http://doc.babylonjs.com/features/occlusionquery
  48662. * @param algorithmType defines the algorithm to use
  48663. * @returns the current engine
  48664. */
  48665. endOcclusionQuery(algorithmType: number): Engine;
  48666. /**
  48667. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48668. * Please note that only one query can be issued at a time
  48669. * @returns a time token used to track the time span
  48670. */
  48671. startTimeQuery(): Nullable<_TimeToken>;
  48672. /**
  48673. * Ends a time query
  48674. * @param token defines the token used to measure the time span
  48675. * @returns the time spent (in ns)
  48676. */
  48677. endTimeQuery(token: _TimeToken): int;
  48678. /** @hidden */
  48679. _currentNonTimestampToken: Nullable<_TimeToken>;
  48680. /** @hidden */
  48681. _createTimeQuery(): WebGLQuery;
  48682. /** @hidden */
  48683. _deleteTimeQuery(query: WebGLQuery): void;
  48684. /** @hidden */
  48685. _getGlAlgorithmType(algorithmType: number): number;
  48686. /** @hidden */
  48687. _getTimeQueryResult(query: WebGLQuery): any;
  48688. /** @hidden */
  48689. _getTimeQueryAvailability(query: WebGLQuery): any;
  48690. }
  48691. }
  48692. module "babylonjs/Meshes/abstractMesh" {
  48693. interface AbstractMesh {
  48694. /**
  48695. * Backing filed
  48696. * @hidden
  48697. */
  48698. __occlusionDataStorage: _OcclusionDataStorage;
  48699. /**
  48700. * Access property
  48701. * @hidden
  48702. */
  48703. _occlusionDataStorage: _OcclusionDataStorage;
  48704. /**
  48705. * 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.
  48706. * The default value is -1 which means don't break the query and wait till the result
  48707. * @see http://doc.babylonjs.com/features/occlusionquery
  48708. */
  48709. occlusionRetryCount: number;
  48710. /**
  48711. * 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:
  48712. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48713. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48714. * * 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.
  48715. * @see http://doc.babylonjs.com/features/occlusionquery
  48716. */
  48717. occlusionType: number;
  48718. /**
  48719. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48720. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48721. * * 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.
  48722. * @see http://doc.babylonjs.com/features/occlusionquery
  48723. */
  48724. occlusionQueryAlgorithmType: number;
  48725. /**
  48726. * 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
  48727. * @see http://doc.babylonjs.com/features/occlusionquery
  48728. */
  48729. isOccluded: boolean;
  48730. /**
  48731. * Flag to check the progress status of the query
  48732. * @see http://doc.babylonjs.com/features/occlusionquery
  48733. */
  48734. isOcclusionQueryInProgress: boolean;
  48735. }
  48736. }
  48737. }
  48738. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48739. import { Nullable } from "babylonjs/types";
  48740. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48741. /** @hidden */
  48742. export var _forceTransformFeedbackToBundle: boolean;
  48743. module "babylonjs/Engines/engine" {
  48744. interface Engine {
  48745. /**
  48746. * Creates a webGL transform feedback object
  48747. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48748. * @returns the webGL transform feedback object
  48749. */
  48750. createTransformFeedback(): WebGLTransformFeedback;
  48751. /**
  48752. * Delete a webGL transform feedback object
  48753. * @param value defines the webGL transform feedback object to delete
  48754. */
  48755. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48756. /**
  48757. * Bind a webGL transform feedback object to the webgl context
  48758. * @param value defines the webGL transform feedback object to bind
  48759. */
  48760. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48761. /**
  48762. * Begins a transform feedback operation
  48763. * @param usePoints defines if points or triangles must be used
  48764. */
  48765. beginTransformFeedback(usePoints: boolean): void;
  48766. /**
  48767. * Ends a transform feedback operation
  48768. */
  48769. endTransformFeedback(): void;
  48770. /**
  48771. * Specify the varyings to use with transform feedback
  48772. * @param program defines the associated webGL program
  48773. * @param value defines the list of strings representing the varying names
  48774. */
  48775. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48776. /**
  48777. * Bind a webGL buffer for a transform feedback operation
  48778. * @param value defines the webGL buffer to bind
  48779. */
  48780. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48781. }
  48782. }
  48783. }
  48784. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48785. import { Scene } from "babylonjs/scene";
  48786. import { Engine } from "babylonjs/Engines/engine";
  48787. import { Texture } from "babylonjs/Materials/Textures/texture";
  48788. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48789. import "babylonjs/Engines/Extensions/engine.multiRender";
  48790. /**
  48791. * Creation options of the multi render target texture.
  48792. */
  48793. export interface IMultiRenderTargetOptions {
  48794. /**
  48795. * Define if the texture needs to create mip maps after render.
  48796. */
  48797. generateMipMaps?: boolean;
  48798. /**
  48799. * Define the types of all the draw buffers we want to create
  48800. */
  48801. types?: number[];
  48802. /**
  48803. * Define the sampling modes of all the draw buffers we want to create
  48804. */
  48805. samplingModes?: number[];
  48806. /**
  48807. * Define if a depth buffer is required
  48808. */
  48809. generateDepthBuffer?: boolean;
  48810. /**
  48811. * Define if a stencil buffer is required
  48812. */
  48813. generateStencilBuffer?: boolean;
  48814. /**
  48815. * Define if a depth texture is required instead of a depth buffer
  48816. */
  48817. generateDepthTexture?: boolean;
  48818. /**
  48819. * Define the number of desired draw buffers
  48820. */
  48821. textureCount?: number;
  48822. /**
  48823. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48824. */
  48825. doNotChangeAspectRatio?: boolean;
  48826. /**
  48827. * Define the default type of the buffers we are creating
  48828. */
  48829. defaultType?: number;
  48830. }
  48831. /**
  48832. * A multi render target, like a render target provides the ability to render to a texture.
  48833. * Unlike the render target, it can render to several draw buffers in one draw.
  48834. * This is specially interesting in deferred rendering or for any effects requiring more than
  48835. * just one color from a single pass.
  48836. */
  48837. export class MultiRenderTarget extends RenderTargetTexture {
  48838. private _internalTextures;
  48839. private _textures;
  48840. private _multiRenderTargetOptions;
  48841. /**
  48842. * Get if draw buffers are currently supported by the used hardware and browser.
  48843. */
  48844. get isSupported(): boolean;
  48845. /**
  48846. * Get the list of textures generated by the multi render target.
  48847. */
  48848. get textures(): Texture[];
  48849. /**
  48850. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48851. */
  48852. get depthTexture(): Texture;
  48853. /**
  48854. * Set the wrapping mode on U of all the textures we are rendering to.
  48855. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48856. */
  48857. set wrapU(wrap: number);
  48858. /**
  48859. * Set the wrapping mode on V of all the textures we are rendering to.
  48860. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48861. */
  48862. set wrapV(wrap: number);
  48863. /**
  48864. * Instantiate a new multi render target texture.
  48865. * A multi render target, like a render target provides the ability to render to a texture.
  48866. * Unlike the render target, it can render to several draw buffers in one draw.
  48867. * This is specially interesting in deferred rendering or for any effects requiring more than
  48868. * just one color from a single pass.
  48869. * @param name Define the name of the texture
  48870. * @param size Define the size of the buffers to render to
  48871. * @param count Define the number of target we are rendering into
  48872. * @param scene Define the scene the texture belongs to
  48873. * @param options Define the options used to create the multi render target
  48874. */
  48875. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48876. /** @hidden */
  48877. _rebuild(): void;
  48878. private _createInternalTextures;
  48879. private _createTextures;
  48880. /**
  48881. * Define the number of samples used if MSAA is enabled.
  48882. */
  48883. get samples(): number;
  48884. set samples(value: number);
  48885. /**
  48886. * Resize all the textures in the multi render target.
  48887. * Be carrefull as it will recreate all the data in the new texture.
  48888. * @param size Define the new size
  48889. */
  48890. resize(size: any): void;
  48891. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48892. /**
  48893. * Dispose the render targets and their associated resources
  48894. */
  48895. dispose(): void;
  48896. /**
  48897. * Release all the underlying texture used as draw buffers.
  48898. */
  48899. releaseInternalTextures(): void;
  48900. }
  48901. }
  48902. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48903. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48904. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48905. import { Nullable } from "babylonjs/types";
  48906. module "babylonjs/Engines/thinEngine" {
  48907. interface ThinEngine {
  48908. /**
  48909. * Unbind a list of render target textures from the webGL context
  48910. * This is used only when drawBuffer extension or webGL2 are active
  48911. * @param textures defines the render target textures to unbind
  48912. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48913. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48914. */
  48915. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48916. /**
  48917. * Create a multi render target texture
  48918. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48919. * @param size defines the size of the texture
  48920. * @param options defines the creation options
  48921. * @returns the cube texture as an InternalTexture
  48922. */
  48923. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48924. /**
  48925. * Update the sample count for a given multiple render target texture
  48926. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48927. * @param textures defines the textures to update
  48928. * @param samples defines the sample count to set
  48929. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48930. */
  48931. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48932. }
  48933. }
  48934. }
  48935. declare module "babylonjs/Engines/Extensions/engine.views" {
  48936. import { Camera } from "babylonjs/Cameras/camera";
  48937. import { Nullable } from "babylonjs/types";
  48938. /**
  48939. * Class used to define an additional view for the engine
  48940. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48941. */
  48942. export class EngineView {
  48943. /** Defines the canvas where to render the view */
  48944. target: HTMLCanvasElement;
  48945. /** Defines an optional camera used to render the view (will use active camera else) */
  48946. camera?: Camera;
  48947. }
  48948. module "babylonjs/Engines/engine" {
  48949. interface Engine {
  48950. /**
  48951. * Gets or sets the HTML element to use for attaching events
  48952. */
  48953. inputElement: Nullable<HTMLElement>;
  48954. /**
  48955. * Gets the current engine view
  48956. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48957. */
  48958. activeView: Nullable<EngineView>;
  48959. /** Gets or sets the list of views */
  48960. views: EngineView[];
  48961. /**
  48962. * Register a new child canvas
  48963. * @param canvas defines the canvas to register
  48964. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  48965. * @returns the associated view
  48966. */
  48967. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  48968. /**
  48969. * Remove a registered child canvas
  48970. * @param canvas defines the canvas to remove
  48971. * @returns the current engine
  48972. */
  48973. unRegisterView(canvas: HTMLCanvasElement): Engine;
  48974. }
  48975. }
  48976. }
  48977. declare module "babylonjs/Engines/Extensions/index" {
  48978. export * from "babylonjs/Engines/Extensions/engine.alpha";
  48979. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  48980. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  48981. export * from "babylonjs/Engines/Extensions/engine.multiview";
  48982. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  48983. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48984. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  48985. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  48986. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  48987. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  48988. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  48989. export * from "babylonjs/Engines/Extensions/engine.webVR";
  48990. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  48991. export * from "babylonjs/Engines/Extensions/engine.views";
  48992. }
  48993. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  48994. import { Nullable } from "babylonjs/types";
  48995. /**
  48996. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  48997. */
  48998. export interface CubeMapInfo {
  48999. /**
  49000. * The pixel array for the front face.
  49001. * This is stored in format, left to right, up to down format.
  49002. */
  49003. front: Nullable<ArrayBufferView>;
  49004. /**
  49005. * The pixel array for the back face.
  49006. * This is stored in format, left to right, up to down format.
  49007. */
  49008. back: Nullable<ArrayBufferView>;
  49009. /**
  49010. * The pixel array for the left face.
  49011. * This is stored in format, left to right, up to down format.
  49012. */
  49013. left: Nullable<ArrayBufferView>;
  49014. /**
  49015. * The pixel array for the right face.
  49016. * This is stored in format, left to right, up to down format.
  49017. */
  49018. right: Nullable<ArrayBufferView>;
  49019. /**
  49020. * The pixel array for the up face.
  49021. * This is stored in format, left to right, up to down format.
  49022. */
  49023. up: Nullable<ArrayBufferView>;
  49024. /**
  49025. * The pixel array for the down face.
  49026. * This is stored in format, left to right, up to down format.
  49027. */
  49028. down: Nullable<ArrayBufferView>;
  49029. /**
  49030. * The size of the cubemap stored.
  49031. *
  49032. * Each faces will be size * size pixels.
  49033. */
  49034. size: number;
  49035. /**
  49036. * The format of the texture.
  49037. *
  49038. * RGBA, RGB.
  49039. */
  49040. format: number;
  49041. /**
  49042. * The type of the texture data.
  49043. *
  49044. * UNSIGNED_INT, FLOAT.
  49045. */
  49046. type: number;
  49047. /**
  49048. * Specifies whether the texture is in gamma space.
  49049. */
  49050. gammaSpace: boolean;
  49051. }
  49052. /**
  49053. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49054. */
  49055. export class PanoramaToCubeMapTools {
  49056. private static FACE_FRONT;
  49057. private static FACE_BACK;
  49058. private static FACE_RIGHT;
  49059. private static FACE_LEFT;
  49060. private static FACE_DOWN;
  49061. private static FACE_UP;
  49062. /**
  49063. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49064. *
  49065. * @param float32Array The source data.
  49066. * @param inputWidth The width of the input panorama.
  49067. * @param inputHeight The height of the input panorama.
  49068. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49069. * @return The cubemap data
  49070. */
  49071. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49072. private static CreateCubemapTexture;
  49073. private static CalcProjectionSpherical;
  49074. }
  49075. }
  49076. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49077. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49078. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49079. import { Nullable } from "babylonjs/types";
  49080. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49081. /**
  49082. * Helper class dealing with the extraction of spherical polynomial dataArray
  49083. * from a cube map.
  49084. */
  49085. export class CubeMapToSphericalPolynomialTools {
  49086. private static FileFaces;
  49087. /**
  49088. * Converts a texture to the according Spherical Polynomial data.
  49089. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49090. *
  49091. * @param texture The texture to extract the information from.
  49092. * @return The Spherical Polynomial data.
  49093. */
  49094. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49095. /**
  49096. * Converts a cubemap to the according Spherical Polynomial data.
  49097. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49098. *
  49099. * @param cubeInfo The Cube map to extract the information from.
  49100. * @return The Spherical Polynomial data.
  49101. */
  49102. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49103. }
  49104. }
  49105. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49106. import { Nullable } from "babylonjs/types";
  49107. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49108. module "babylonjs/Materials/Textures/baseTexture" {
  49109. interface BaseTexture {
  49110. /**
  49111. * Get the polynomial representation of the texture data.
  49112. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49113. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49114. */
  49115. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49116. }
  49117. }
  49118. }
  49119. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49120. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49121. /** @hidden */
  49122. export var rgbdEncodePixelShader: {
  49123. name: string;
  49124. shader: string;
  49125. };
  49126. }
  49127. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49128. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49129. /** @hidden */
  49130. export var rgbdDecodePixelShader: {
  49131. name: string;
  49132. shader: string;
  49133. };
  49134. }
  49135. declare module "babylonjs/Misc/environmentTextureTools" {
  49136. import { Nullable } from "babylonjs/types";
  49137. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49138. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49139. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49140. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49141. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49142. import "babylonjs/Shaders/rgbdEncode.fragment";
  49143. import "babylonjs/Shaders/rgbdDecode.fragment";
  49144. /**
  49145. * Raw texture data and descriptor sufficient for WebGL texture upload
  49146. */
  49147. export interface EnvironmentTextureInfo {
  49148. /**
  49149. * Version of the environment map
  49150. */
  49151. version: number;
  49152. /**
  49153. * Width of image
  49154. */
  49155. width: number;
  49156. /**
  49157. * Irradiance information stored in the file.
  49158. */
  49159. irradiance: any;
  49160. /**
  49161. * Specular information stored in the file.
  49162. */
  49163. specular: any;
  49164. }
  49165. /**
  49166. * Defines One Image in the file. It requires only the position in the file
  49167. * as well as the length.
  49168. */
  49169. interface BufferImageData {
  49170. /**
  49171. * Length of the image data.
  49172. */
  49173. length: number;
  49174. /**
  49175. * Position of the data from the null terminator delimiting the end of the JSON.
  49176. */
  49177. position: number;
  49178. }
  49179. /**
  49180. * Defines the specular data enclosed in the file.
  49181. * This corresponds to the version 1 of the data.
  49182. */
  49183. export interface EnvironmentTextureSpecularInfoV1 {
  49184. /**
  49185. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49186. */
  49187. specularDataPosition?: number;
  49188. /**
  49189. * This contains all the images data needed to reconstruct the cubemap.
  49190. */
  49191. mipmaps: Array<BufferImageData>;
  49192. /**
  49193. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49194. */
  49195. lodGenerationScale: number;
  49196. }
  49197. /**
  49198. * Sets of helpers addressing the serialization and deserialization of environment texture
  49199. * stored in a BabylonJS env file.
  49200. * Those files are usually stored as .env files.
  49201. */
  49202. export class EnvironmentTextureTools {
  49203. /**
  49204. * Magic number identifying the env file.
  49205. */
  49206. private static _MagicBytes;
  49207. /**
  49208. * Gets the environment info from an env file.
  49209. * @param data The array buffer containing the .env bytes.
  49210. * @returns the environment file info (the json header) if successfully parsed.
  49211. */
  49212. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49213. /**
  49214. * Creates an environment texture from a loaded cube texture.
  49215. * @param texture defines the cube texture to convert in env file
  49216. * @return a promise containing the environment data if succesfull.
  49217. */
  49218. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49219. /**
  49220. * Creates a JSON representation of the spherical data.
  49221. * @param texture defines the texture containing the polynomials
  49222. * @return the JSON representation of the spherical info
  49223. */
  49224. private static _CreateEnvTextureIrradiance;
  49225. /**
  49226. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49227. * @param data the image data
  49228. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49229. * @return the views described by info providing access to the underlying buffer
  49230. */
  49231. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49232. /**
  49233. * Uploads the texture info contained in the env file to the GPU.
  49234. * @param texture defines the internal texture to upload to
  49235. * @param data defines the data to load
  49236. * @param info defines the texture info retrieved through the GetEnvInfo method
  49237. * @returns a promise
  49238. */
  49239. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49240. private static _OnImageReadyAsync;
  49241. /**
  49242. * Uploads the levels of image data to the GPU.
  49243. * @param texture defines the internal texture to upload to
  49244. * @param imageData defines the array buffer views of image data [mipmap][face]
  49245. * @returns a promise
  49246. */
  49247. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49248. /**
  49249. * Uploads spherical polynomials information to the texture.
  49250. * @param texture defines the texture we are trying to upload the information to
  49251. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49252. */
  49253. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49254. /** @hidden */
  49255. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49256. }
  49257. }
  49258. declare module "babylonjs/Maths/math.vertexFormat" {
  49259. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49260. /**
  49261. * Contains position and normal vectors for a vertex
  49262. */
  49263. export class PositionNormalVertex {
  49264. /** the position of the vertex (defaut: 0,0,0) */
  49265. position: Vector3;
  49266. /** the normal of the vertex (defaut: 0,1,0) */
  49267. normal: Vector3;
  49268. /**
  49269. * Creates a PositionNormalVertex
  49270. * @param position the position of the vertex (defaut: 0,0,0)
  49271. * @param normal the normal of the vertex (defaut: 0,1,0)
  49272. */
  49273. constructor(
  49274. /** the position of the vertex (defaut: 0,0,0) */
  49275. position?: Vector3,
  49276. /** the normal of the vertex (defaut: 0,1,0) */
  49277. normal?: Vector3);
  49278. /**
  49279. * Clones the PositionNormalVertex
  49280. * @returns the cloned PositionNormalVertex
  49281. */
  49282. clone(): PositionNormalVertex;
  49283. }
  49284. /**
  49285. * Contains position, normal and uv vectors for a vertex
  49286. */
  49287. export class PositionNormalTextureVertex {
  49288. /** the position of the vertex (defaut: 0,0,0) */
  49289. position: Vector3;
  49290. /** the normal of the vertex (defaut: 0,1,0) */
  49291. normal: Vector3;
  49292. /** the uv of the vertex (default: 0,0) */
  49293. uv: Vector2;
  49294. /**
  49295. * Creates a PositionNormalTextureVertex
  49296. * @param position the position of the vertex (defaut: 0,0,0)
  49297. * @param normal the normal of the vertex (defaut: 0,1,0)
  49298. * @param uv the uv of the vertex (default: 0,0)
  49299. */
  49300. constructor(
  49301. /** the position of the vertex (defaut: 0,0,0) */
  49302. position?: Vector3,
  49303. /** the normal of the vertex (defaut: 0,1,0) */
  49304. normal?: Vector3,
  49305. /** the uv of the vertex (default: 0,0) */
  49306. uv?: Vector2);
  49307. /**
  49308. * Clones the PositionNormalTextureVertex
  49309. * @returns the cloned PositionNormalTextureVertex
  49310. */
  49311. clone(): PositionNormalTextureVertex;
  49312. }
  49313. }
  49314. declare module "babylonjs/Maths/math" {
  49315. export * from "babylonjs/Maths/math.axis";
  49316. export * from "babylonjs/Maths/math.color";
  49317. export * from "babylonjs/Maths/math.constants";
  49318. export * from "babylonjs/Maths/math.frustum";
  49319. export * from "babylonjs/Maths/math.path";
  49320. export * from "babylonjs/Maths/math.plane";
  49321. export * from "babylonjs/Maths/math.size";
  49322. export * from "babylonjs/Maths/math.vector";
  49323. export * from "babylonjs/Maths/math.vertexFormat";
  49324. export * from "babylonjs/Maths/math.viewport";
  49325. }
  49326. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49327. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49328. /** @hidden */
  49329. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49330. private _genericAttributeLocation;
  49331. private _varyingLocationCount;
  49332. private _varyingLocationMap;
  49333. private _replacements;
  49334. private _textureCount;
  49335. private _uniforms;
  49336. lineProcessor(line: string): string;
  49337. attributeProcessor(attribute: string): string;
  49338. varyingProcessor(varying: string, isFragment: boolean): string;
  49339. uniformProcessor(uniform: string): string;
  49340. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49341. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49342. }
  49343. }
  49344. declare module "babylonjs/Engines/nativeEngine" {
  49345. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49346. import { Engine } from "babylonjs/Engines/engine";
  49347. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49348. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49349. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49350. import { Effect } from "babylonjs/Materials/effect";
  49351. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49352. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49353. import { IColor4Like } from "babylonjs/Maths/math.like";
  49354. import { Scene } from "babylonjs/scene";
  49355. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49356. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49357. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  49358. /**
  49359. * Container for accessors for natively-stored mesh data buffers.
  49360. */
  49361. class NativeDataBuffer extends DataBuffer {
  49362. /**
  49363. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49364. */
  49365. nativeIndexBuffer?: any;
  49366. /**
  49367. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49368. */
  49369. nativeVertexBuffer?: any;
  49370. }
  49371. /** @hidden */
  49372. class NativeTexture extends InternalTexture {
  49373. getInternalTexture(): InternalTexture;
  49374. getViewCount(): number;
  49375. }
  49376. /** @hidden */
  49377. export class NativeEngine extends Engine {
  49378. private readonly _native;
  49379. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49380. private readonly INVALID_HANDLE;
  49381. getHardwareScalingLevel(): number;
  49382. constructor();
  49383. /**
  49384. * Can be used to override the current requestAnimationFrame requester.
  49385. * @hidden
  49386. */
  49387. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49388. /**
  49389. * Override default engine behavior.
  49390. * @param color
  49391. * @param backBuffer
  49392. * @param depth
  49393. * @param stencil
  49394. */
  49395. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49396. /**
  49397. * Gets host document
  49398. * @returns the host document object
  49399. */
  49400. getHostDocument(): Nullable<Document>;
  49401. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49402. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49403. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49404. recordVertexArrayObject(vertexBuffers: {
  49405. [key: string]: VertexBuffer;
  49406. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49407. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49408. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49409. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49410. /**
  49411. * Draw a list of indexed primitives
  49412. * @param fillMode defines the primitive to use
  49413. * @param indexStart defines the starting index
  49414. * @param indexCount defines the number of index to draw
  49415. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49416. */
  49417. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49418. /**
  49419. * Draw a list of unindexed primitives
  49420. * @param fillMode defines the primitive to use
  49421. * @param verticesStart defines the index of first vertex to draw
  49422. * @param verticesCount defines the count of vertices to draw
  49423. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49424. */
  49425. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49426. createPipelineContext(): IPipelineContext;
  49427. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49428. /** @hidden */
  49429. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49430. /** @hidden */
  49431. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49432. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49433. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49434. protected _setProgram(program: WebGLProgram): void;
  49435. _releaseEffect(effect: Effect): void;
  49436. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49437. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49438. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49439. bindSamplers(effect: Effect): void;
  49440. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49441. getRenderWidth(useScreen?: boolean): number;
  49442. getRenderHeight(useScreen?: boolean): number;
  49443. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49444. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49445. /**
  49446. * Set the z offset to apply to current rendering
  49447. * @param value defines the offset to apply
  49448. */
  49449. setZOffset(value: number): void;
  49450. /**
  49451. * Gets the current value of the zOffset
  49452. * @returns the current zOffset state
  49453. */
  49454. getZOffset(): number;
  49455. /**
  49456. * Enable or disable depth buffering
  49457. * @param enable defines the state to set
  49458. */
  49459. setDepthBuffer(enable: boolean): void;
  49460. /**
  49461. * Gets a boolean indicating if depth writing is enabled
  49462. * @returns the current depth writing state
  49463. */
  49464. getDepthWrite(): boolean;
  49465. /**
  49466. * Enable or disable depth writing
  49467. * @param enable defines the state to set
  49468. */
  49469. setDepthWrite(enable: boolean): void;
  49470. /**
  49471. * Enable or disable color writing
  49472. * @param enable defines the state to set
  49473. */
  49474. setColorWrite(enable: boolean): void;
  49475. /**
  49476. * Gets a boolean indicating if color writing is enabled
  49477. * @returns the current color writing state
  49478. */
  49479. getColorWrite(): boolean;
  49480. /**
  49481. * Sets alpha constants used by some alpha blending modes
  49482. * @param r defines the red component
  49483. * @param g defines the green component
  49484. * @param b defines the blue component
  49485. * @param a defines the alpha component
  49486. */
  49487. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49488. /**
  49489. * Sets the current alpha mode
  49490. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49491. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49492. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49493. */
  49494. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49495. /**
  49496. * Gets the current alpha mode
  49497. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49498. * @returns the current alpha mode
  49499. */
  49500. getAlphaMode(): number;
  49501. setInt(uniform: WebGLUniformLocation, int: number): void;
  49502. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49503. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49504. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49505. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49506. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49507. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49508. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49509. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49510. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49511. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49512. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49513. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49514. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49515. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49516. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49517. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49518. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49519. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49520. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49521. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49522. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49523. wipeCaches(bruteForce?: boolean): void;
  49524. _createTexture(): WebGLTexture;
  49525. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49526. /**
  49527. * Usually called from Texture.ts.
  49528. * Passed information to create a WebGLTexture
  49529. * @param urlArg defines a value which contains one of the following:
  49530. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49531. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49532. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49533. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49534. * @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)
  49535. * @param scene needed for loading to the correct scene
  49536. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  49537. * @param onLoad optional callback to be called upon successful completion
  49538. * @param onError optional callback to be called upon failure
  49539. * @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
  49540. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49541. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49542. * @param forcedExtension defines the extension to use to pick the right loader
  49543. * @param mimeType defines an optional mime type
  49544. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49545. */
  49546. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  49547. /**
  49548. * Creates a cube texture
  49549. * @param rootUrl defines the url where the files to load is located
  49550. * @param scene defines the current scene
  49551. * @param files defines the list of files to load (1 per face)
  49552. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49553. * @param onLoad defines an optional callback raised when the texture is loaded
  49554. * @param onError defines an optional callback raised if there is an issue to load the texture
  49555. * @param format defines the format of the data
  49556. * @param forcedExtension defines the extension to use to pick the right loader
  49557. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49558. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49559. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49560. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49561. * @returns the cube texture as an InternalTexture
  49562. */
  49563. 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;
  49564. private _getSamplingFilter;
  49565. private static _GetNativeTextureFormat;
  49566. createRenderTargetTexture(size: number | {
  49567. width: number;
  49568. height: number;
  49569. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49570. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49571. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49572. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49573. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49574. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49575. /**
  49576. * Updates a dynamic vertex buffer.
  49577. * @param vertexBuffer the vertex buffer to update
  49578. * @param data the data used to update the vertex buffer
  49579. * @param byteOffset the byte offset of the data (optional)
  49580. * @param byteLength the byte length of the data (optional)
  49581. */
  49582. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49583. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49584. private _updateAnisotropicLevel;
  49585. private _getAddressMode;
  49586. /** @hidden */
  49587. _bindTexture(channel: number, texture: InternalTexture): void;
  49588. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49589. releaseEffects(): void;
  49590. /** @hidden */
  49591. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49592. /** @hidden */
  49593. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49594. /** @hidden */
  49595. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49596. /** @hidden */
  49597. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49598. }
  49599. }
  49600. declare module "babylonjs/Engines/index" {
  49601. export * from "babylonjs/Engines/constants";
  49602. export * from "babylonjs/Engines/engineCapabilities";
  49603. export * from "babylonjs/Engines/instancingAttributeInfo";
  49604. export * from "babylonjs/Engines/thinEngine";
  49605. export * from "babylonjs/Engines/engine";
  49606. export * from "babylonjs/Engines/engineStore";
  49607. export * from "babylonjs/Engines/nullEngine";
  49608. export * from "babylonjs/Engines/Extensions/index";
  49609. export * from "babylonjs/Engines/IPipelineContext";
  49610. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49611. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49612. export * from "babylonjs/Engines/nativeEngine";
  49613. }
  49614. declare module "babylonjs/Events/clipboardEvents" {
  49615. /**
  49616. * Gather the list of clipboard event types as constants.
  49617. */
  49618. export class ClipboardEventTypes {
  49619. /**
  49620. * The clipboard event is fired when a copy command is active (pressed).
  49621. */
  49622. static readonly COPY: number;
  49623. /**
  49624. * The clipboard event is fired when a cut command is active (pressed).
  49625. */
  49626. static readonly CUT: number;
  49627. /**
  49628. * The clipboard event is fired when a paste command is active (pressed).
  49629. */
  49630. static readonly PASTE: number;
  49631. }
  49632. /**
  49633. * This class is used to store clipboard related info for the onClipboardObservable event.
  49634. */
  49635. export class ClipboardInfo {
  49636. /**
  49637. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49638. */
  49639. type: number;
  49640. /**
  49641. * Defines the related dom event
  49642. */
  49643. event: ClipboardEvent;
  49644. /**
  49645. *Creates an instance of ClipboardInfo.
  49646. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49647. * @param event Defines the related dom event
  49648. */
  49649. constructor(
  49650. /**
  49651. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49652. */
  49653. type: number,
  49654. /**
  49655. * Defines the related dom event
  49656. */
  49657. event: ClipboardEvent);
  49658. /**
  49659. * Get the clipboard event's type from the keycode.
  49660. * @param keyCode Defines the keyCode for the current keyboard event.
  49661. * @return {number}
  49662. */
  49663. static GetTypeFromCharacter(keyCode: number): number;
  49664. }
  49665. }
  49666. declare module "babylonjs/Events/index" {
  49667. export * from "babylonjs/Events/keyboardEvents";
  49668. export * from "babylonjs/Events/pointerEvents";
  49669. export * from "babylonjs/Events/clipboardEvents";
  49670. }
  49671. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49672. import { Scene } from "babylonjs/scene";
  49673. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49674. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49675. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49676. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49677. /**
  49678. * Google Daydream controller
  49679. */
  49680. export class DaydreamController extends WebVRController {
  49681. /**
  49682. * Base Url for the controller model.
  49683. */
  49684. static MODEL_BASE_URL: string;
  49685. /**
  49686. * File name for the controller model.
  49687. */
  49688. static MODEL_FILENAME: string;
  49689. /**
  49690. * Gamepad Id prefix used to identify Daydream Controller.
  49691. */
  49692. static readonly GAMEPAD_ID_PREFIX: string;
  49693. /**
  49694. * Creates a new DaydreamController from a gamepad
  49695. * @param vrGamepad the gamepad that the controller should be created from
  49696. */
  49697. constructor(vrGamepad: any);
  49698. /**
  49699. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49700. * @param scene scene in which to add meshes
  49701. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49702. */
  49703. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49704. /**
  49705. * Called once for each button that changed state since the last frame
  49706. * @param buttonIdx Which button index changed
  49707. * @param state New state of the button
  49708. * @param changes Which properties on the state changed since last frame
  49709. */
  49710. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49711. }
  49712. }
  49713. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49714. import { Scene } from "babylonjs/scene";
  49715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49716. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49717. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49718. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49719. /**
  49720. * Gear VR Controller
  49721. */
  49722. export class GearVRController extends WebVRController {
  49723. /**
  49724. * Base Url for the controller model.
  49725. */
  49726. static MODEL_BASE_URL: string;
  49727. /**
  49728. * File name for the controller model.
  49729. */
  49730. static MODEL_FILENAME: string;
  49731. /**
  49732. * Gamepad Id prefix used to identify this controller.
  49733. */
  49734. static readonly GAMEPAD_ID_PREFIX: string;
  49735. private readonly _buttonIndexToObservableNameMap;
  49736. /**
  49737. * Creates a new GearVRController from a gamepad
  49738. * @param vrGamepad the gamepad that the controller should be created from
  49739. */
  49740. constructor(vrGamepad: any);
  49741. /**
  49742. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49743. * @param scene scene in which to add meshes
  49744. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49745. */
  49746. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49747. /**
  49748. * Called once for each button that changed state since the last frame
  49749. * @param buttonIdx Which button index changed
  49750. * @param state New state of the button
  49751. * @param changes Which properties on the state changed since last frame
  49752. */
  49753. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49754. }
  49755. }
  49756. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49757. import { Scene } from "babylonjs/scene";
  49758. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49759. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49760. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49761. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49762. /**
  49763. * Generic Controller
  49764. */
  49765. export class GenericController extends WebVRController {
  49766. /**
  49767. * Base Url for the controller model.
  49768. */
  49769. static readonly MODEL_BASE_URL: string;
  49770. /**
  49771. * File name for the controller model.
  49772. */
  49773. static readonly MODEL_FILENAME: string;
  49774. /**
  49775. * Creates a new GenericController from a gamepad
  49776. * @param vrGamepad the gamepad that the controller should be created from
  49777. */
  49778. constructor(vrGamepad: any);
  49779. /**
  49780. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49781. * @param scene scene in which to add meshes
  49782. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49783. */
  49784. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49785. /**
  49786. * Called once for each button that changed state since the last frame
  49787. * @param buttonIdx Which button index changed
  49788. * @param state New state of the button
  49789. * @param changes Which properties on the state changed since last frame
  49790. */
  49791. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49792. }
  49793. }
  49794. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  49795. import { Observable } from "babylonjs/Misc/observable";
  49796. import { Scene } from "babylonjs/scene";
  49797. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49798. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49799. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49800. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49801. /**
  49802. * Oculus Touch Controller
  49803. */
  49804. export class OculusTouchController extends WebVRController {
  49805. /**
  49806. * Base Url for the controller model.
  49807. */
  49808. static MODEL_BASE_URL: string;
  49809. /**
  49810. * File name for the left controller model.
  49811. */
  49812. static MODEL_LEFT_FILENAME: string;
  49813. /**
  49814. * File name for the right controller model.
  49815. */
  49816. static MODEL_RIGHT_FILENAME: string;
  49817. /**
  49818. * Base Url for the Quest controller model.
  49819. */
  49820. static QUEST_MODEL_BASE_URL: string;
  49821. /**
  49822. * @hidden
  49823. * If the controllers are running on a device that needs the updated Quest controller models
  49824. */
  49825. static _IsQuest: boolean;
  49826. /**
  49827. * Fired when the secondary trigger on this controller is modified
  49828. */
  49829. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  49830. /**
  49831. * Fired when the thumb rest on this controller is modified
  49832. */
  49833. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  49834. /**
  49835. * Creates a new OculusTouchController from a gamepad
  49836. * @param vrGamepad the gamepad that the controller should be created from
  49837. */
  49838. constructor(vrGamepad: any);
  49839. /**
  49840. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49841. * @param scene scene in which to add meshes
  49842. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49843. */
  49844. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49845. /**
  49846. * Fired when the A button on this controller is modified
  49847. */
  49848. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49849. /**
  49850. * Fired when the B button on this controller is modified
  49851. */
  49852. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49853. /**
  49854. * Fired when the X button on this controller is modified
  49855. */
  49856. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49857. /**
  49858. * Fired when the Y button on this controller is modified
  49859. */
  49860. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49861. /**
  49862. * Called once for each button that changed state since the last frame
  49863. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  49864. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  49865. * 2) secondary trigger (same)
  49866. * 3) A (right) X (left), touch, pressed = value
  49867. * 4) B / Y
  49868. * 5) thumb rest
  49869. * @param buttonIdx Which button index changed
  49870. * @param state New state of the button
  49871. * @param changes Which properties on the state changed since last frame
  49872. */
  49873. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49874. }
  49875. }
  49876. declare module "babylonjs/Gamepads/Controllers/viveController" {
  49877. import { Scene } from "babylonjs/scene";
  49878. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49879. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49880. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49881. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49882. import { Observable } from "babylonjs/Misc/observable";
  49883. /**
  49884. * Vive Controller
  49885. */
  49886. export class ViveController extends WebVRController {
  49887. /**
  49888. * Base Url for the controller model.
  49889. */
  49890. static MODEL_BASE_URL: string;
  49891. /**
  49892. * File name for the controller model.
  49893. */
  49894. static MODEL_FILENAME: string;
  49895. /**
  49896. * Creates a new ViveController from a gamepad
  49897. * @param vrGamepad the gamepad that the controller should be created from
  49898. */
  49899. constructor(vrGamepad: any);
  49900. /**
  49901. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49902. * @param scene scene in which to add meshes
  49903. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49904. */
  49905. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49906. /**
  49907. * Fired when the left button on this controller is modified
  49908. */
  49909. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49910. /**
  49911. * Fired when the right button on this controller is modified
  49912. */
  49913. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49914. /**
  49915. * Fired when the menu button on this controller is modified
  49916. */
  49917. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49918. /**
  49919. * Called once for each button that changed state since the last frame
  49920. * Vive mapping:
  49921. * 0: touchpad
  49922. * 1: trigger
  49923. * 2: left AND right buttons
  49924. * 3: menu button
  49925. * @param buttonIdx Which button index changed
  49926. * @param state New state of the button
  49927. * @param changes Which properties on the state changed since last frame
  49928. */
  49929. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49930. }
  49931. }
  49932. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  49933. import { Observable } from "babylonjs/Misc/observable";
  49934. import { Scene } from "babylonjs/scene";
  49935. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49936. import { Ray } from "babylonjs/Culling/ray";
  49937. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49938. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49939. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49940. /**
  49941. * Defines the WindowsMotionController object that the state of the windows motion controller
  49942. */
  49943. export class WindowsMotionController extends WebVRController {
  49944. /**
  49945. * The base url used to load the left and right controller models
  49946. */
  49947. static MODEL_BASE_URL: string;
  49948. /**
  49949. * The name of the left controller model file
  49950. */
  49951. static MODEL_LEFT_FILENAME: string;
  49952. /**
  49953. * The name of the right controller model file
  49954. */
  49955. static MODEL_RIGHT_FILENAME: string;
  49956. /**
  49957. * The controller name prefix for this controller type
  49958. */
  49959. static readonly GAMEPAD_ID_PREFIX: string;
  49960. /**
  49961. * The controller id pattern for this controller type
  49962. */
  49963. private static readonly GAMEPAD_ID_PATTERN;
  49964. private _loadedMeshInfo;
  49965. protected readonly _mapping: {
  49966. buttons: string[];
  49967. buttonMeshNames: {
  49968. 'trigger': string;
  49969. 'menu': string;
  49970. 'grip': string;
  49971. 'thumbstick': string;
  49972. 'trackpad': string;
  49973. };
  49974. buttonObservableNames: {
  49975. 'trigger': string;
  49976. 'menu': string;
  49977. 'grip': string;
  49978. 'thumbstick': string;
  49979. 'trackpad': string;
  49980. };
  49981. axisMeshNames: string[];
  49982. pointingPoseMeshName: string;
  49983. };
  49984. /**
  49985. * Fired when the trackpad on this controller is clicked
  49986. */
  49987. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  49988. /**
  49989. * Fired when the trackpad on this controller is modified
  49990. */
  49991. onTrackpadValuesChangedObservable: Observable<StickValues>;
  49992. /**
  49993. * The current x and y values of this controller's trackpad
  49994. */
  49995. trackpad: StickValues;
  49996. /**
  49997. * Creates a new WindowsMotionController from a gamepad
  49998. * @param vrGamepad the gamepad that the controller should be created from
  49999. */
  50000. constructor(vrGamepad: any);
  50001. /**
  50002. * Fired when the trigger on this controller is modified
  50003. */
  50004. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50005. /**
  50006. * Fired when the menu button on this controller is modified
  50007. */
  50008. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50009. /**
  50010. * Fired when the grip button on this controller is modified
  50011. */
  50012. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50013. /**
  50014. * Fired when the thumbstick button on this controller is modified
  50015. */
  50016. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50017. /**
  50018. * Fired when the touchpad button on this controller is modified
  50019. */
  50020. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50021. /**
  50022. * Fired when the touchpad values on this controller are modified
  50023. */
  50024. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50025. protected _updateTrackpad(): void;
  50026. /**
  50027. * Called once per frame by the engine.
  50028. */
  50029. update(): void;
  50030. /**
  50031. * Called once for each button that changed state since the last frame
  50032. * @param buttonIdx Which button index changed
  50033. * @param state New state of the button
  50034. * @param changes Which properties on the state changed since last frame
  50035. */
  50036. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50037. /**
  50038. * Moves the buttons on the controller mesh based on their current state
  50039. * @param buttonName the name of the button to move
  50040. * @param buttonValue the value of the button which determines the buttons new position
  50041. */
  50042. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50043. /**
  50044. * Moves the axis on the controller mesh based on its current state
  50045. * @param axis the index of the axis
  50046. * @param axisValue the value of the axis which determines the meshes new position
  50047. * @hidden
  50048. */
  50049. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50050. /**
  50051. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50052. * @param scene scene in which to add meshes
  50053. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50054. */
  50055. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50056. /**
  50057. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50058. * can be transformed by button presses and axes values, based on this._mapping.
  50059. *
  50060. * @param scene scene in which the meshes exist
  50061. * @param meshes list of meshes that make up the controller model to process
  50062. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50063. */
  50064. private processModel;
  50065. private createMeshInfo;
  50066. /**
  50067. * Gets the ray of the controller in the direction the controller is pointing
  50068. * @param length the length the resulting ray should be
  50069. * @returns a ray in the direction the controller is pointing
  50070. */
  50071. getForwardRay(length?: number): Ray;
  50072. /**
  50073. * Disposes of the controller
  50074. */
  50075. dispose(): void;
  50076. }
  50077. /**
  50078. * This class represents a new windows motion controller in XR.
  50079. */
  50080. export class XRWindowsMotionController extends WindowsMotionController {
  50081. /**
  50082. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50083. */
  50084. protected readonly _mapping: {
  50085. buttons: string[];
  50086. buttonMeshNames: {
  50087. 'trigger': string;
  50088. 'menu': string;
  50089. 'grip': string;
  50090. 'thumbstick': string;
  50091. 'trackpad': string;
  50092. };
  50093. buttonObservableNames: {
  50094. 'trigger': string;
  50095. 'menu': string;
  50096. 'grip': string;
  50097. 'thumbstick': string;
  50098. 'trackpad': string;
  50099. };
  50100. axisMeshNames: string[];
  50101. pointingPoseMeshName: string;
  50102. };
  50103. /**
  50104. * Construct a new XR-Based windows motion controller
  50105. *
  50106. * @param gamepadInfo the gamepad object from the browser
  50107. */
  50108. constructor(gamepadInfo: any);
  50109. /**
  50110. * holds the thumbstick values (X,Y)
  50111. */
  50112. thumbstickValues: StickValues;
  50113. /**
  50114. * Fired when the thumbstick on this controller is clicked
  50115. */
  50116. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50117. /**
  50118. * Fired when the thumbstick on this controller is modified
  50119. */
  50120. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50121. /**
  50122. * Fired when the touchpad button on this controller is modified
  50123. */
  50124. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50125. /**
  50126. * Fired when the touchpad values on this controller are modified
  50127. */
  50128. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50129. /**
  50130. * Fired when the thumbstick button on this controller is modified
  50131. * here to prevent breaking changes
  50132. */
  50133. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50134. /**
  50135. * updating the thumbstick(!) and not the trackpad.
  50136. * This is named this way due to the difference between WebVR and XR and to avoid
  50137. * changing the parent class.
  50138. */
  50139. protected _updateTrackpad(): void;
  50140. /**
  50141. * Disposes the class with joy
  50142. */
  50143. dispose(): void;
  50144. }
  50145. }
  50146. declare module "babylonjs/Gamepads/Controllers/index" {
  50147. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50148. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50149. export * from "babylonjs/Gamepads/Controllers/genericController";
  50150. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50151. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50152. export * from "babylonjs/Gamepads/Controllers/viveController";
  50153. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50154. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50155. }
  50156. declare module "babylonjs/Gamepads/index" {
  50157. export * from "babylonjs/Gamepads/Controllers/index";
  50158. export * from "babylonjs/Gamepads/gamepad";
  50159. export * from "babylonjs/Gamepads/gamepadManager";
  50160. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50161. export * from "babylonjs/Gamepads/xboxGamepad";
  50162. export * from "babylonjs/Gamepads/dualShockGamepad";
  50163. }
  50164. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50165. import { Scene } from "babylonjs/scene";
  50166. import { Vector4 } from "babylonjs/Maths/math.vector";
  50167. import { Color4 } from "babylonjs/Maths/math.color";
  50168. import { Mesh } from "babylonjs/Meshes/mesh";
  50169. import { Nullable } from "babylonjs/types";
  50170. /**
  50171. * Class containing static functions to help procedurally build meshes
  50172. */
  50173. export class PolyhedronBuilder {
  50174. /**
  50175. * Creates a polyhedron mesh
  50176. * * 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
  50177. * * The parameter `size` (positive float, default 1) sets the polygon size
  50178. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50179. * * 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`
  50180. * * 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
  50181. * * 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)`)
  50182. * * 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
  50183. * * 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
  50184. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50185. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50186. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50187. * @param name defines the name of the mesh
  50188. * @param options defines the options used to create the mesh
  50189. * @param scene defines the hosting scene
  50190. * @returns the polyhedron mesh
  50191. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50192. */
  50193. static CreatePolyhedron(name: string, options: {
  50194. type?: number;
  50195. size?: number;
  50196. sizeX?: number;
  50197. sizeY?: number;
  50198. sizeZ?: number;
  50199. custom?: any;
  50200. faceUV?: Vector4[];
  50201. faceColors?: Color4[];
  50202. flat?: boolean;
  50203. updatable?: boolean;
  50204. sideOrientation?: number;
  50205. frontUVs?: Vector4;
  50206. backUVs?: Vector4;
  50207. }, scene?: Nullable<Scene>): Mesh;
  50208. }
  50209. }
  50210. declare module "babylonjs/Gizmos/scaleGizmo" {
  50211. import { Observable } from "babylonjs/Misc/observable";
  50212. import { Nullable } from "babylonjs/types";
  50213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50214. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50215. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50216. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50217. /**
  50218. * Gizmo that enables scaling a mesh along 3 axis
  50219. */
  50220. export class ScaleGizmo extends Gizmo {
  50221. /**
  50222. * Internal gizmo used for interactions on the x axis
  50223. */
  50224. xGizmo: AxisScaleGizmo;
  50225. /**
  50226. * Internal gizmo used for interactions on the y axis
  50227. */
  50228. yGizmo: AxisScaleGizmo;
  50229. /**
  50230. * Internal gizmo used for interactions on the z axis
  50231. */
  50232. zGizmo: AxisScaleGizmo;
  50233. /**
  50234. * Internal gizmo used to scale all axis equally
  50235. */
  50236. uniformScaleGizmo: AxisScaleGizmo;
  50237. private _meshAttached;
  50238. private _updateGizmoRotationToMatchAttachedMesh;
  50239. private _snapDistance;
  50240. private _scaleRatio;
  50241. private _uniformScalingMesh;
  50242. private _octahedron;
  50243. private _sensitivity;
  50244. /** Fires an event when any of it's sub gizmos are dragged */
  50245. onDragStartObservable: Observable<unknown>;
  50246. /** Fires an event when any of it's sub gizmos are released from dragging */
  50247. onDragEndObservable: Observable<unknown>;
  50248. get attachedMesh(): Nullable<AbstractMesh>;
  50249. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50250. /**
  50251. * Creates a ScaleGizmo
  50252. * @param gizmoLayer The utility layer the gizmo will be added to
  50253. */
  50254. constructor(gizmoLayer?: UtilityLayerRenderer);
  50255. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50256. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50257. /**
  50258. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50259. */
  50260. set snapDistance(value: number);
  50261. get snapDistance(): number;
  50262. /**
  50263. * Ratio for the scale of the gizmo (Default: 1)
  50264. */
  50265. set scaleRatio(value: number);
  50266. get scaleRatio(): number;
  50267. /**
  50268. * Sensitivity factor for dragging (Default: 1)
  50269. */
  50270. set sensitivity(value: number);
  50271. get sensitivity(): number;
  50272. /**
  50273. * Disposes of the gizmo
  50274. */
  50275. dispose(): void;
  50276. }
  50277. }
  50278. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50279. import { Observable } from "babylonjs/Misc/observable";
  50280. import { Nullable } from "babylonjs/types";
  50281. import { Vector3 } from "babylonjs/Maths/math.vector";
  50282. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50283. import { Mesh } from "babylonjs/Meshes/mesh";
  50284. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50285. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50286. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50287. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50288. import { Color3 } from "babylonjs/Maths/math.color";
  50289. /**
  50290. * Single axis scale gizmo
  50291. */
  50292. export class AxisScaleGizmo extends Gizmo {
  50293. /**
  50294. * Drag behavior responsible for the gizmos dragging interactions
  50295. */
  50296. dragBehavior: PointerDragBehavior;
  50297. private _pointerObserver;
  50298. /**
  50299. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50300. */
  50301. snapDistance: number;
  50302. /**
  50303. * Event that fires each time the gizmo snaps to a new location.
  50304. * * snapDistance is the the change in distance
  50305. */
  50306. onSnapObservable: Observable<{
  50307. snapDistance: number;
  50308. }>;
  50309. /**
  50310. * If the scaling operation should be done on all axis (default: false)
  50311. */
  50312. uniformScaling: boolean;
  50313. /**
  50314. * Custom sensitivity value for the drag strength
  50315. */
  50316. sensitivity: number;
  50317. private _isEnabled;
  50318. private _parent;
  50319. private _arrow;
  50320. private _coloredMaterial;
  50321. private _hoverMaterial;
  50322. /**
  50323. * Creates an AxisScaleGizmo
  50324. * @param gizmoLayer The utility layer the gizmo will be added to
  50325. * @param dragAxis The axis which the gizmo will be able to scale on
  50326. * @param color The color of the gizmo
  50327. */
  50328. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50329. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50330. /**
  50331. * If the gizmo is enabled
  50332. */
  50333. set isEnabled(value: boolean);
  50334. get isEnabled(): boolean;
  50335. /**
  50336. * Disposes of the gizmo
  50337. */
  50338. dispose(): void;
  50339. /**
  50340. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50341. * @param mesh The mesh to replace the default mesh of the gizmo
  50342. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50343. */
  50344. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50345. }
  50346. }
  50347. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50348. import { Observable } from "babylonjs/Misc/observable";
  50349. import { Nullable } from "babylonjs/types";
  50350. import { Vector3 } from "babylonjs/Maths/math.vector";
  50351. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50352. import { Mesh } from "babylonjs/Meshes/mesh";
  50353. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50354. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50355. import { Color3 } from "babylonjs/Maths/math.color";
  50356. import "babylonjs/Meshes/Builders/boxBuilder";
  50357. /**
  50358. * Bounding box gizmo
  50359. */
  50360. export class BoundingBoxGizmo extends Gizmo {
  50361. private _lineBoundingBox;
  50362. private _rotateSpheresParent;
  50363. private _scaleBoxesParent;
  50364. private _boundingDimensions;
  50365. private _renderObserver;
  50366. private _pointerObserver;
  50367. private _scaleDragSpeed;
  50368. private _tmpQuaternion;
  50369. private _tmpVector;
  50370. private _tmpRotationMatrix;
  50371. /**
  50372. * 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)
  50373. */
  50374. ignoreChildren: boolean;
  50375. /**
  50376. * 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)
  50377. */
  50378. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50379. /**
  50380. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50381. */
  50382. rotationSphereSize: number;
  50383. /**
  50384. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50385. */
  50386. scaleBoxSize: number;
  50387. /**
  50388. * 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)
  50389. */
  50390. fixedDragMeshScreenSize: boolean;
  50391. /**
  50392. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50393. */
  50394. fixedDragMeshScreenSizeDistanceFactor: number;
  50395. /**
  50396. * Fired when a rotation sphere or scale box is dragged
  50397. */
  50398. onDragStartObservable: Observable<{}>;
  50399. /**
  50400. * Fired when a scale box is dragged
  50401. */
  50402. onScaleBoxDragObservable: Observable<{}>;
  50403. /**
  50404. * Fired when a scale box drag is ended
  50405. */
  50406. onScaleBoxDragEndObservable: Observable<{}>;
  50407. /**
  50408. * Fired when a rotation sphere is dragged
  50409. */
  50410. onRotationSphereDragObservable: Observable<{}>;
  50411. /**
  50412. * Fired when a rotation sphere drag is ended
  50413. */
  50414. onRotationSphereDragEndObservable: Observable<{}>;
  50415. /**
  50416. * 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)
  50417. */
  50418. scalePivot: Nullable<Vector3>;
  50419. /**
  50420. * Mesh used as a pivot to rotate the attached mesh
  50421. */
  50422. private _anchorMesh;
  50423. private _existingMeshScale;
  50424. private _dragMesh;
  50425. private pointerDragBehavior;
  50426. private coloredMaterial;
  50427. private hoverColoredMaterial;
  50428. /**
  50429. * Sets the color of the bounding box gizmo
  50430. * @param color the color to set
  50431. */
  50432. setColor(color: Color3): void;
  50433. /**
  50434. * Creates an BoundingBoxGizmo
  50435. * @param gizmoLayer The utility layer the gizmo will be added to
  50436. * @param color The color of the gizmo
  50437. */
  50438. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50439. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50440. private _selectNode;
  50441. /**
  50442. * Updates the bounding box information for the Gizmo
  50443. */
  50444. updateBoundingBox(): void;
  50445. private _updateRotationSpheres;
  50446. private _updateScaleBoxes;
  50447. /**
  50448. * Enables rotation on the specified axis and disables rotation on the others
  50449. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50450. */
  50451. setEnabledRotationAxis(axis: string): void;
  50452. /**
  50453. * Enables/disables scaling
  50454. * @param enable if scaling should be enabled
  50455. */
  50456. setEnabledScaling(enable: boolean): void;
  50457. private _updateDummy;
  50458. /**
  50459. * Enables a pointer drag behavior on the bounding box of the gizmo
  50460. */
  50461. enableDragBehavior(): void;
  50462. /**
  50463. * Disposes of the gizmo
  50464. */
  50465. dispose(): void;
  50466. /**
  50467. * 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)
  50468. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50469. * @returns the bounding box mesh with the passed in mesh as a child
  50470. */
  50471. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50472. /**
  50473. * CustomMeshes are not supported by this gizmo
  50474. * @param mesh The mesh to replace the default mesh of the gizmo
  50475. */
  50476. setCustomMesh(mesh: Mesh): void;
  50477. }
  50478. }
  50479. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50480. import { Observable } from "babylonjs/Misc/observable";
  50481. import { Nullable } from "babylonjs/types";
  50482. import { Vector3 } from "babylonjs/Maths/math.vector";
  50483. import { Color3 } from "babylonjs/Maths/math.color";
  50484. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50485. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50486. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50487. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50488. import "babylonjs/Meshes/Builders/linesBuilder";
  50489. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50490. /**
  50491. * Single plane rotation gizmo
  50492. */
  50493. export class PlaneRotationGizmo extends Gizmo {
  50494. /**
  50495. * Drag behavior responsible for the gizmos dragging interactions
  50496. */
  50497. dragBehavior: PointerDragBehavior;
  50498. private _pointerObserver;
  50499. /**
  50500. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50501. */
  50502. snapDistance: number;
  50503. /**
  50504. * Event that fires each time the gizmo snaps to a new location.
  50505. * * snapDistance is the the change in distance
  50506. */
  50507. onSnapObservable: Observable<{
  50508. snapDistance: number;
  50509. }>;
  50510. private _isEnabled;
  50511. private _parent;
  50512. /**
  50513. * Creates a PlaneRotationGizmo
  50514. * @param gizmoLayer The utility layer the gizmo will be added to
  50515. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50516. * @param color The color of the gizmo
  50517. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50518. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50519. */
  50520. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50521. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50522. /**
  50523. * If the gizmo is enabled
  50524. */
  50525. set isEnabled(value: boolean);
  50526. get isEnabled(): boolean;
  50527. /**
  50528. * Disposes of the gizmo
  50529. */
  50530. dispose(): void;
  50531. }
  50532. }
  50533. declare module "babylonjs/Gizmos/rotationGizmo" {
  50534. import { Observable } from "babylonjs/Misc/observable";
  50535. import { Nullable } from "babylonjs/types";
  50536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50537. import { Mesh } from "babylonjs/Meshes/mesh";
  50538. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50539. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50540. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50541. /**
  50542. * Gizmo that enables rotating a mesh along 3 axis
  50543. */
  50544. export class RotationGizmo extends Gizmo {
  50545. /**
  50546. * Internal gizmo used for interactions on the x axis
  50547. */
  50548. xGizmo: PlaneRotationGizmo;
  50549. /**
  50550. * Internal gizmo used for interactions on the y axis
  50551. */
  50552. yGizmo: PlaneRotationGizmo;
  50553. /**
  50554. * Internal gizmo used for interactions on the z axis
  50555. */
  50556. zGizmo: PlaneRotationGizmo;
  50557. /** Fires an event when any of it's sub gizmos are dragged */
  50558. onDragStartObservable: Observable<unknown>;
  50559. /** Fires an event when any of it's sub gizmos are released from dragging */
  50560. onDragEndObservable: Observable<unknown>;
  50561. private _meshAttached;
  50562. get attachedMesh(): Nullable<AbstractMesh>;
  50563. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50564. /**
  50565. * Creates a RotationGizmo
  50566. * @param gizmoLayer The utility layer the gizmo will be added to
  50567. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50568. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50569. */
  50570. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50571. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50572. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50573. /**
  50574. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50575. */
  50576. set snapDistance(value: number);
  50577. get snapDistance(): number;
  50578. /**
  50579. * Ratio for the scale of the gizmo (Default: 1)
  50580. */
  50581. set scaleRatio(value: number);
  50582. get scaleRatio(): number;
  50583. /**
  50584. * Disposes of the gizmo
  50585. */
  50586. dispose(): void;
  50587. /**
  50588. * CustomMeshes are not supported by this gizmo
  50589. * @param mesh The mesh to replace the default mesh of the gizmo
  50590. */
  50591. setCustomMesh(mesh: Mesh): void;
  50592. }
  50593. }
  50594. declare module "babylonjs/Gizmos/gizmoManager" {
  50595. import { Observable } from "babylonjs/Misc/observable";
  50596. import { Nullable } from "babylonjs/types";
  50597. import { Scene, IDisposable } from "babylonjs/scene";
  50598. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50599. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50600. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50601. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50602. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50603. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50604. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50605. /**
  50606. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50607. */
  50608. export class GizmoManager implements IDisposable {
  50609. private scene;
  50610. /**
  50611. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50612. */
  50613. gizmos: {
  50614. positionGizmo: Nullable<PositionGizmo>;
  50615. rotationGizmo: Nullable<RotationGizmo>;
  50616. scaleGizmo: Nullable<ScaleGizmo>;
  50617. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50618. };
  50619. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50620. clearGizmoOnEmptyPointerEvent: boolean;
  50621. /** Fires an event when the manager is attached to a mesh */
  50622. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50623. private _gizmosEnabled;
  50624. private _pointerObserver;
  50625. private _attachedMesh;
  50626. private _boundingBoxColor;
  50627. private _defaultUtilityLayer;
  50628. private _defaultKeepDepthUtilityLayer;
  50629. /**
  50630. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50631. */
  50632. boundingBoxDragBehavior: SixDofDragBehavior;
  50633. /**
  50634. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50635. */
  50636. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50637. /**
  50638. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50639. */
  50640. usePointerToAttachGizmos: boolean;
  50641. /**
  50642. * Utility layer that the bounding box gizmo belongs to
  50643. */
  50644. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50645. /**
  50646. * Utility layer that all gizmos besides bounding box belong to
  50647. */
  50648. get utilityLayer(): UtilityLayerRenderer;
  50649. /**
  50650. * Instatiates a gizmo manager
  50651. * @param scene the scene to overlay the gizmos on top of
  50652. */
  50653. constructor(scene: Scene);
  50654. /**
  50655. * Attaches a set of gizmos to the specified mesh
  50656. * @param mesh The mesh the gizmo's should be attached to
  50657. */
  50658. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50659. /**
  50660. * If the position gizmo is enabled
  50661. */
  50662. set positionGizmoEnabled(value: boolean);
  50663. get positionGizmoEnabled(): boolean;
  50664. /**
  50665. * If the rotation gizmo is enabled
  50666. */
  50667. set rotationGizmoEnabled(value: boolean);
  50668. get rotationGizmoEnabled(): boolean;
  50669. /**
  50670. * If the scale gizmo is enabled
  50671. */
  50672. set scaleGizmoEnabled(value: boolean);
  50673. get scaleGizmoEnabled(): boolean;
  50674. /**
  50675. * If the boundingBox gizmo is enabled
  50676. */
  50677. set boundingBoxGizmoEnabled(value: boolean);
  50678. get boundingBoxGizmoEnabled(): boolean;
  50679. /**
  50680. * Disposes of the gizmo manager
  50681. */
  50682. dispose(): void;
  50683. }
  50684. }
  50685. declare module "babylonjs/Lights/directionalLight" {
  50686. import { Camera } from "babylonjs/Cameras/camera";
  50687. import { Scene } from "babylonjs/scene";
  50688. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50689. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50690. import { Light } from "babylonjs/Lights/light";
  50691. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50692. import { Effect } from "babylonjs/Materials/effect";
  50693. /**
  50694. * A directional light is defined by a direction (what a surprise!).
  50695. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50696. * 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.
  50697. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50698. */
  50699. export class DirectionalLight extends ShadowLight {
  50700. private _shadowFrustumSize;
  50701. /**
  50702. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50703. */
  50704. get shadowFrustumSize(): number;
  50705. /**
  50706. * Specifies a fix frustum size for the shadow generation.
  50707. */
  50708. set shadowFrustumSize(value: number);
  50709. private _shadowOrthoScale;
  50710. /**
  50711. * Gets the shadow projection scale against the optimal computed one.
  50712. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50713. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50714. */
  50715. get shadowOrthoScale(): number;
  50716. /**
  50717. * Sets the shadow projection scale against the optimal computed one.
  50718. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50719. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50720. */
  50721. set shadowOrthoScale(value: number);
  50722. /**
  50723. * Automatically compute the projection matrix to best fit (including all the casters)
  50724. * on each frame.
  50725. */
  50726. autoUpdateExtends: boolean;
  50727. /**
  50728. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50729. * on each frame. autoUpdateExtends must be set to true for this to work
  50730. */
  50731. autoCalcShadowZBounds: boolean;
  50732. private _orthoLeft;
  50733. private _orthoRight;
  50734. private _orthoTop;
  50735. private _orthoBottom;
  50736. /**
  50737. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50738. * The directional light is emitted from everywhere in the given direction.
  50739. * It can cast shadows.
  50740. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50741. * @param name The friendly name of the light
  50742. * @param direction The direction of the light
  50743. * @param scene The scene the light belongs to
  50744. */
  50745. constructor(name: string, direction: Vector3, scene: Scene);
  50746. /**
  50747. * Returns the string "DirectionalLight".
  50748. * @return The class name
  50749. */
  50750. getClassName(): string;
  50751. /**
  50752. * Returns the integer 1.
  50753. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50754. */
  50755. getTypeID(): number;
  50756. /**
  50757. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50758. * Returns the DirectionalLight Shadow projection matrix.
  50759. */
  50760. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50761. /**
  50762. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50763. * Returns the DirectionalLight Shadow projection matrix.
  50764. */
  50765. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50766. /**
  50767. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50768. * Returns the DirectionalLight Shadow projection matrix.
  50769. */
  50770. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50771. protected _buildUniformLayout(): void;
  50772. /**
  50773. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50774. * @param effect The effect to update
  50775. * @param lightIndex The index of the light in the effect to update
  50776. * @returns The directional light
  50777. */
  50778. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50779. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50780. /**
  50781. * Gets the minZ used for shadow according to both the scene and the light.
  50782. *
  50783. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50784. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50785. * @param activeCamera The camera we are returning the min for
  50786. * @returns the depth min z
  50787. */
  50788. getDepthMinZ(activeCamera: Camera): number;
  50789. /**
  50790. * Gets the maxZ used for shadow according to both the scene and the light.
  50791. *
  50792. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50793. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50794. * @param activeCamera The camera we are returning the max for
  50795. * @returns the depth max z
  50796. */
  50797. getDepthMaxZ(activeCamera: Camera): number;
  50798. /**
  50799. * Prepares the list of defines specific to the light type.
  50800. * @param defines the list of defines
  50801. * @param lightIndex defines the index of the light for the effect
  50802. */
  50803. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50804. }
  50805. }
  50806. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  50807. import { Mesh } from "babylonjs/Meshes/mesh";
  50808. /**
  50809. * Class containing static functions to help procedurally build meshes
  50810. */
  50811. export class HemisphereBuilder {
  50812. /**
  50813. * Creates a hemisphere mesh
  50814. * @param name defines the name of the mesh
  50815. * @param options defines the options used to create the mesh
  50816. * @param scene defines the hosting scene
  50817. * @returns the hemisphere mesh
  50818. */
  50819. static CreateHemisphere(name: string, options: {
  50820. segments?: number;
  50821. diameter?: number;
  50822. sideOrientation?: number;
  50823. }, scene: any): Mesh;
  50824. }
  50825. }
  50826. declare module "babylonjs/Lights/spotLight" {
  50827. import { Nullable } from "babylonjs/types";
  50828. import { Scene } from "babylonjs/scene";
  50829. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50830. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50831. import { Effect } from "babylonjs/Materials/effect";
  50832. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50833. import { Light } from "babylonjs/Lights/light";
  50834. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50835. /**
  50836. * A spot light is defined by a position, a direction, an angle, and an exponent.
  50837. * These values define a cone of light starting from the position, emitting toward the direction.
  50838. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  50839. * and the exponent defines the speed of the decay of the light with distance (reach).
  50840. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50841. */
  50842. export class SpotLight extends ShadowLight {
  50843. private _angle;
  50844. private _innerAngle;
  50845. private _cosHalfAngle;
  50846. private _lightAngleScale;
  50847. private _lightAngleOffset;
  50848. /**
  50849. * Gets the cone angle of the spot light in Radians.
  50850. */
  50851. get angle(): number;
  50852. /**
  50853. * Sets the cone angle of the spot light in Radians.
  50854. */
  50855. set angle(value: number);
  50856. /**
  50857. * Only used in gltf falloff mode, this defines the angle where
  50858. * the directional falloff will start before cutting at angle which could be seen
  50859. * as outer angle.
  50860. */
  50861. get innerAngle(): number;
  50862. /**
  50863. * Only used in gltf falloff mode, this defines the angle where
  50864. * the directional falloff will start before cutting at angle which could be seen
  50865. * as outer angle.
  50866. */
  50867. set innerAngle(value: number);
  50868. private _shadowAngleScale;
  50869. /**
  50870. * Allows scaling the angle of the light for shadow generation only.
  50871. */
  50872. get shadowAngleScale(): number;
  50873. /**
  50874. * Allows scaling the angle of the light for shadow generation only.
  50875. */
  50876. set shadowAngleScale(value: number);
  50877. /**
  50878. * The light decay speed with the distance from the emission spot.
  50879. */
  50880. exponent: number;
  50881. private _projectionTextureMatrix;
  50882. /**
  50883. * Allows reading the projecton texture
  50884. */
  50885. get projectionTextureMatrix(): Matrix;
  50886. protected _projectionTextureLightNear: number;
  50887. /**
  50888. * Gets the near clip of the Spotlight for texture projection.
  50889. */
  50890. get projectionTextureLightNear(): number;
  50891. /**
  50892. * Sets the near clip of the Spotlight for texture projection.
  50893. */
  50894. set projectionTextureLightNear(value: number);
  50895. protected _projectionTextureLightFar: number;
  50896. /**
  50897. * Gets the far clip of the Spotlight for texture projection.
  50898. */
  50899. get projectionTextureLightFar(): number;
  50900. /**
  50901. * Sets the far clip of the Spotlight for texture projection.
  50902. */
  50903. set projectionTextureLightFar(value: number);
  50904. protected _projectionTextureUpDirection: Vector3;
  50905. /**
  50906. * Gets the Up vector of the Spotlight for texture projection.
  50907. */
  50908. get projectionTextureUpDirection(): Vector3;
  50909. /**
  50910. * Sets the Up vector of the Spotlight for texture projection.
  50911. */
  50912. set projectionTextureUpDirection(value: Vector3);
  50913. private _projectionTexture;
  50914. /**
  50915. * Gets the projection texture of the light.
  50916. */
  50917. get projectionTexture(): Nullable<BaseTexture>;
  50918. /**
  50919. * Sets the projection texture of the light.
  50920. */
  50921. set projectionTexture(value: Nullable<BaseTexture>);
  50922. private _projectionTextureViewLightDirty;
  50923. private _projectionTextureProjectionLightDirty;
  50924. private _projectionTextureDirty;
  50925. private _projectionTextureViewTargetVector;
  50926. private _projectionTextureViewLightMatrix;
  50927. private _projectionTextureProjectionLightMatrix;
  50928. private _projectionTextureScalingMatrix;
  50929. /**
  50930. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  50931. * It can cast shadows.
  50932. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50933. * @param name The light friendly name
  50934. * @param position The position of the spot light in the scene
  50935. * @param direction The direction of the light in the scene
  50936. * @param angle The cone angle of the light in Radians
  50937. * @param exponent The light decay speed with the distance from the emission spot
  50938. * @param scene The scene the lights belongs to
  50939. */
  50940. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  50941. /**
  50942. * Returns the string "SpotLight".
  50943. * @returns the class name
  50944. */
  50945. getClassName(): string;
  50946. /**
  50947. * Returns the integer 2.
  50948. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50949. */
  50950. getTypeID(): number;
  50951. /**
  50952. * Overrides the direction setter to recompute the projection texture view light Matrix.
  50953. */
  50954. protected _setDirection(value: Vector3): void;
  50955. /**
  50956. * Overrides the position setter to recompute the projection texture view light Matrix.
  50957. */
  50958. protected _setPosition(value: Vector3): void;
  50959. /**
  50960. * 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.
  50961. * Returns the SpotLight.
  50962. */
  50963. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50964. protected _computeProjectionTextureViewLightMatrix(): void;
  50965. protected _computeProjectionTextureProjectionLightMatrix(): void;
  50966. /**
  50967. * Main function for light texture projection matrix computing.
  50968. */
  50969. protected _computeProjectionTextureMatrix(): void;
  50970. protected _buildUniformLayout(): void;
  50971. private _computeAngleValues;
  50972. /**
  50973. * Sets the passed Effect "effect" with the Light textures.
  50974. * @param effect The effect to update
  50975. * @param lightIndex The index of the light in the effect to update
  50976. * @returns The light
  50977. */
  50978. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  50979. /**
  50980. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  50981. * @param effect The effect to update
  50982. * @param lightIndex The index of the light in the effect to update
  50983. * @returns The spot light
  50984. */
  50985. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  50986. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  50987. /**
  50988. * Disposes the light and the associated resources.
  50989. */
  50990. dispose(): void;
  50991. /**
  50992. * Prepares the list of defines specific to the light type.
  50993. * @param defines the list of defines
  50994. * @param lightIndex defines the index of the light for the effect
  50995. */
  50996. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50997. }
  50998. }
  50999. declare module "babylonjs/Gizmos/lightGizmo" {
  51000. import { Nullable } from "babylonjs/types";
  51001. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51002. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51003. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51004. import { Light } from "babylonjs/Lights/light";
  51005. /**
  51006. * Gizmo that enables viewing a light
  51007. */
  51008. export class LightGizmo extends Gizmo {
  51009. private _lightMesh;
  51010. private _material;
  51011. private _cachedPosition;
  51012. private _cachedForward;
  51013. private _attachedMeshParent;
  51014. /**
  51015. * Creates a LightGizmo
  51016. * @param gizmoLayer The utility layer the gizmo will be added to
  51017. */
  51018. constructor(gizmoLayer?: UtilityLayerRenderer);
  51019. private _light;
  51020. /**
  51021. * The light that the gizmo is attached to
  51022. */
  51023. set light(light: Nullable<Light>);
  51024. get light(): Nullable<Light>;
  51025. /**
  51026. * Gets the material used to render the light gizmo
  51027. */
  51028. get material(): StandardMaterial;
  51029. /**
  51030. * @hidden
  51031. * Updates the gizmo to match the attached mesh's position/rotation
  51032. */
  51033. protected _update(): void;
  51034. private static _Scale;
  51035. /**
  51036. * Creates the lines for a light mesh
  51037. */
  51038. private static _CreateLightLines;
  51039. /**
  51040. * Disposes of the light gizmo
  51041. */
  51042. dispose(): void;
  51043. private static _CreateHemisphericLightMesh;
  51044. private static _CreatePointLightMesh;
  51045. private static _CreateSpotLightMesh;
  51046. private static _CreateDirectionalLightMesh;
  51047. }
  51048. }
  51049. declare module "babylonjs/Gizmos/index" {
  51050. export * from "babylonjs/Gizmos/axisDragGizmo";
  51051. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51052. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51053. export * from "babylonjs/Gizmos/gizmo";
  51054. export * from "babylonjs/Gizmos/gizmoManager";
  51055. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51056. export * from "babylonjs/Gizmos/positionGizmo";
  51057. export * from "babylonjs/Gizmos/rotationGizmo";
  51058. export * from "babylonjs/Gizmos/scaleGizmo";
  51059. export * from "babylonjs/Gizmos/lightGizmo";
  51060. export * from "babylonjs/Gizmos/planeDragGizmo";
  51061. }
  51062. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51063. /** @hidden */
  51064. export var backgroundFragmentDeclaration: {
  51065. name: string;
  51066. shader: string;
  51067. };
  51068. }
  51069. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51070. /** @hidden */
  51071. export var backgroundUboDeclaration: {
  51072. name: string;
  51073. shader: string;
  51074. };
  51075. }
  51076. declare module "babylonjs/Shaders/background.fragment" {
  51077. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51078. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51079. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51080. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51081. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51082. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51083. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51084. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51085. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51086. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51087. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51088. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51089. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51090. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51091. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51092. /** @hidden */
  51093. export var backgroundPixelShader: {
  51094. name: string;
  51095. shader: string;
  51096. };
  51097. }
  51098. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51099. /** @hidden */
  51100. export var backgroundVertexDeclaration: {
  51101. name: string;
  51102. shader: string;
  51103. };
  51104. }
  51105. declare module "babylonjs/Shaders/background.vertex" {
  51106. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51107. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51108. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51109. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51110. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51111. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51112. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51113. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51114. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51115. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51116. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51117. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51118. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51119. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51120. /** @hidden */
  51121. export var backgroundVertexShader: {
  51122. name: string;
  51123. shader: string;
  51124. };
  51125. }
  51126. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51127. import { Nullable, int, float } from "babylonjs/types";
  51128. import { Scene } from "babylonjs/scene";
  51129. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51130. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51131. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51132. import { Mesh } from "babylonjs/Meshes/mesh";
  51133. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51134. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51135. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51136. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51137. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51138. import { Color3 } from "babylonjs/Maths/math.color";
  51139. import "babylonjs/Shaders/background.fragment";
  51140. import "babylonjs/Shaders/background.vertex";
  51141. /**
  51142. * Background material used to create an efficient environement around your scene.
  51143. */
  51144. export class BackgroundMaterial extends PushMaterial {
  51145. /**
  51146. * Standard reflectance value at parallel view angle.
  51147. */
  51148. static StandardReflectance0: number;
  51149. /**
  51150. * Standard reflectance value at grazing angle.
  51151. */
  51152. static StandardReflectance90: number;
  51153. protected _primaryColor: Color3;
  51154. /**
  51155. * Key light Color (multiply against the environement texture)
  51156. */
  51157. primaryColor: Color3;
  51158. protected __perceptualColor: Nullable<Color3>;
  51159. /**
  51160. * Experimental Internal Use Only.
  51161. *
  51162. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51163. * This acts as a helper to set the primary color to a more "human friendly" value.
  51164. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51165. * output color as close as possible from the chosen value.
  51166. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51167. * part of lighting setup.)
  51168. */
  51169. get _perceptualColor(): Nullable<Color3>;
  51170. set _perceptualColor(value: Nullable<Color3>);
  51171. protected _primaryColorShadowLevel: float;
  51172. /**
  51173. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51174. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51175. */
  51176. get primaryColorShadowLevel(): float;
  51177. set primaryColorShadowLevel(value: float);
  51178. protected _primaryColorHighlightLevel: float;
  51179. /**
  51180. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51181. * The primary color is used at the level chosen to define what the white area would look.
  51182. */
  51183. get primaryColorHighlightLevel(): float;
  51184. set primaryColorHighlightLevel(value: float);
  51185. protected _reflectionTexture: Nullable<BaseTexture>;
  51186. /**
  51187. * Reflection Texture used in the material.
  51188. * Should be author in a specific way for the best result (refer to the documentation).
  51189. */
  51190. reflectionTexture: Nullable<BaseTexture>;
  51191. protected _reflectionBlur: float;
  51192. /**
  51193. * Reflection Texture level of blur.
  51194. *
  51195. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51196. * texture twice.
  51197. */
  51198. reflectionBlur: float;
  51199. protected _diffuseTexture: Nullable<BaseTexture>;
  51200. /**
  51201. * Diffuse Texture used in the material.
  51202. * Should be author in a specific way for the best result (refer to the documentation).
  51203. */
  51204. diffuseTexture: Nullable<BaseTexture>;
  51205. protected _shadowLights: Nullable<IShadowLight[]>;
  51206. /**
  51207. * Specify the list of lights casting shadow on the material.
  51208. * All scene shadow lights will be included if null.
  51209. */
  51210. shadowLights: Nullable<IShadowLight[]>;
  51211. protected _shadowLevel: float;
  51212. /**
  51213. * Helps adjusting the shadow to a softer level if required.
  51214. * 0 means black shadows and 1 means no shadows.
  51215. */
  51216. shadowLevel: float;
  51217. protected _sceneCenter: Vector3;
  51218. /**
  51219. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51220. * It is usually zero but might be interesting to modify according to your setup.
  51221. */
  51222. sceneCenter: Vector3;
  51223. protected _opacityFresnel: boolean;
  51224. /**
  51225. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51226. * This helps ensuring a nice transition when the camera goes under the ground.
  51227. */
  51228. opacityFresnel: boolean;
  51229. protected _reflectionFresnel: boolean;
  51230. /**
  51231. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51232. * This helps adding a mirror texture on the ground.
  51233. */
  51234. reflectionFresnel: boolean;
  51235. protected _reflectionFalloffDistance: number;
  51236. /**
  51237. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51238. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51239. */
  51240. reflectionFalloffDistance: number;
  51241. protected _reflectionAmount: number;
  51242. /**
  51243. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51244. */
  51245. reflectionAmount: number;
  51246. protected _reflectionReflectance0: number;
  51247. /**
  51248. * This specifies the weight of the reflection at grazing angle.
  51249. */
  51250. reflectionReflectance0: number;
  51251. protected _reflectionReflectance90: number;
  51252. /**
  51253. * This specifies the weight of the reflection at a perpendicular point of view.
  51254. */
  51255. reflectionReflectance90: number;
  51256. /**
  51257. * Sets the reflection reflectance fresnel values according to the default standard
  51258. * empirically know to work well :-)
  51259. */
  51260. set reflectionStandardFresnelWeight(value: number);
  51261. protected _useRGBColor: boolean;
  51262. /**
  51263. * Helps to directly use the maps channels instead of their level.
  51264. */
  51265. useRGBColor: boolean;
  51266. protected _enableNoise: boolean;
  51267. /**
  51268. * This helps reducing the banding effect that could occur on the background.
  51269. */
  51270. enableNoise: boolean;
  51271. /**
  51272. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51273. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51274. * Recommended to be keep at 1.0 except for special cases.
  51275. */
  51276. get fovMultiplier(): number;
  51277. set fovMultiplier(value: number);
  51278. private _fovMultiplier;
  51279. /**
  51280. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51281. */
  51282. useEquirectangularFOV: boolean;
  51283. private _maxSimultaneousLights;
  51284. /**
  51285. * Number of Simultaneous lights allowed on the material.
  51286. */
  51287. maxSimultaneousLights: int;
  51288. /**
  51289. * Default configuration related to image processing available in the Background Material.
  51290. */
  51291. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51292. /**
  51293. * Keep track of the image processing observer to allow dispose and replace.
  51294. */
  51295. private _imageProcessingObserver;
  51296. /**
  51297. * Attaches a new image processing configuration to the PBR Material.
  51298. * @param configuration (if null the scene configuration will be use)
  51299. */
  51300. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51301. /**
  51302. * Gets the image processing configuration used either in this material.
  51303. */
  51304. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51305. /**
  51306. * Sets the Default image processing configuration used either in the this material.
  51307. *
  51308. * If sets to null, the scene one is in use.
  51309. */
  51310. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51311. /**
  51312. * Gets wether the color curves effect is enabled.
  51313. */
  51314. get cameraColorCurvesEnabled(): boolean;
  51315. /**
  51316. * Sets wether the color curves effect is enabled.
  51317. */
  51318. set cameraColorCurvesEnabled(value: boolean);
  51319. /**
  51320. * Gets wether the color grading effect is enabled.
  51321. */
  51322. get cameraColorGradingEnabled(): boolean;
  51323. /**
  51324. * Gets wether the color grading effect is enabled.
  51325. */
  51326. set cameraColorGradingEnabled(value: boolean);
  51327. /**
  51328. * Gets wether tonemapping is enabled or not.
  51329. */
  51330. get cameraToneMappingEnabled(): boolean;
  51331. /**
  51332. * Sets wether tonemapping is enabled or not
  51333. */
  51334. set cameraToneMappingEnabled(value: boolean);
  51335. /**
  51336. * The camera exposure used on this material.
  51337. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51338. * This corresponds to a photographic exposure.
  51339. */
  51340. get cameraExposure(): float;
  51341. /**
  51342. * The camera exposure used on this material.
  51343. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51344. * This corresponds to a photographic exposure.
  51345. */
  51346. set cameraExposure(value: float);
  51347. /**
  51348. * Gets The camera contrast used on this material.
  51349. */
  51350. get cameraContrast(): float;
  51351. /**
  51352. * Sets The camera contrast used on this material.
  51353. */
  51354. set cameraContrast(value: float);
  51355. /**
  51356. * Gets the Color Grading 2D Lookup Texture.
  51357. */
  51358. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51359. /**
  51360. * Sets the Color Grading 2D Lookup Texture.
  51361. */
  51362. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51363. /**
  51364. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51365. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51366. * 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;
  51367. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51368. */
  51369. get cameraColorCurves(): Nullable<ColorCurves>;
  51370. /**
  51371. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51372. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51373. * 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;
  51374. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51375. */
  51376. set cameraColorCurves(value: Nullable<ColorCurves>);
  51377. /**
  51378. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51379. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51380. */
  51381. switchToBGR: boolean;
  51382. private _renderTargets;
  51383. private _reflectionControls;
  51384. private _white;
  51385. private _primaryShadowColor;
  51386. private _primaryHighlightColor;
  51387. /**
  51388. * Instantiates a Background Material in the given scene
  51389. * @param name The friendly name of the material
  51390. * @param scene The scene to add the material to
  51391. */
  51392. constructor(name: string, scene: Scene);
  51393. /**
  51394. * Gets a boolean indicating that current material needs to register RTT
  51395. */
  51396. get hasRenderTargetTextures(): boolean;
  51397. /**
  51398. * The entire material has been created in order to prevent overdraw.
  51399. * @returns false
  51400. */
  51401. needAlphaTesting(): boolean;
  51402. /**
  51403. * The entire material has been created in order to prevent overdraw.
  51404. * @returns true if blending is enable
  51405. */
  51406. needAlphaBlending(): boolean;
  51407. /**
  51408. * Checks wether the material is ready to be rendered for a given mesh.
  51409. * @param mesh The mesh to render
  51410. * @param subMesh The submesh to check against
  51411. * @param useInstances Specify wether or not the material is used with instances
  51412. * @returns true if all the dependencies are ready (Textures, Effects...)
  51413. */
  51414. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51415. /**
  51416. * Compute the primary color according to the chosen perceptual color.
  51417. */
  51418. private _computePrimaryColorFromPerceptualColor;
  51419. /**
  51420. * Compute the highlights and shadow colors according to their chosen levels.
  51421. */
  51422. private _computePrimaryColors;
  51423. /**
  51424. * Build the uniform buffer used in the material.
  51425. */
  51426. buildUniformLayout(): void;
  51427. /**
  51428. * Unbind the material.
  51429. */
  51430. unbind(): void;
  51431. /**
  51432. * Bind only the world matrix to the material.
  51433. * @param world The world matrix to bind.
  51434. */
  51435. bindOnlyWorldMatrix(world: Matrix): void;
  51436. /**
  51437. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51438. * @param world The world matrix to bind.
  51439. * @param subMesh The submesh to bind for.
  51440. */
  51441. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51442. /**
  51443. * Checks to see if a texture is used in the material.
  51444. * @param texture - Base texture to use.
  51445. * @returns - Boolean specifying if a texture is used in the material.
  51446. */
  51447. hasTexture(texture: BaseTexture): boolean;
  51448. /**
  51449. * Dispose the material.
  51450. * @param forceDisposeEffect Force disposal of the associated effect.
  51451. * @param forceDisposeTextures Force disposal of the associated textures.
  51452. */
  51453. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51454. /**
  51455. * Clones the material.
  51456. * @param name The cloned name.
  51457. * @returns The cloned material.
  51458. */
  51459. clone(name: string): BackgroundMaterial;
  51460. /**
  51461. * Serializes the current material to its JSON representation.
  51462. * @returns The JSON representation.
  51463. */
  51464. serialize(): any;
  51465. /**
  51466. * Gets the class name of the material
  51467. * @returns "BackgroundMaterial"
  51468. */
  51469. getClassName(): string;
  51470. /**
  51471. * Parse a JSON input to create back a background material.
  51472. * @param source The JSON data to parse
  51473. * @param scene The scene to create the parsed material in
  51474. * @param rootUrl The root url of the assets the material depends upon
  51475. * @returns the instantiated BackgroundMaterial.
  51476. */
  51477. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51478. }
  51479. }
  51480. declare module "babylonjs/Helpers/environmentHelper" {
  51481. import { Observable } from "babylonjs/Misc/observable";
  51482. import { Nullable } from "babylonjs/types";
  51483. import { Scene } from "babylonjs/scene";
  51484. import { Vector3 } from "babylonjs/Maths/math.vector";
  51485. import { Color3 } from "babylonjs/Maths/math.color";
  51486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51487. import { Mesh } from "babylonjs/Meshes/mesh";
  51488. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51489. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51490. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51491. import "babylonjs/Meshes/Builders/planeBuilder";
  51492. import "babylonjs/Meshes/Builders/boxBuilder";
  51493. /**
  51494. * Represents the different options available during the creation of
  51495. * a Environment helper.
  51496. *
  51497. * This can control the default ground, skybox and image processing setup of your scene.
  51498. */
  51499. export interface IEnvironmentHelperOptions {
  51500. /**
  51501. * Specifies whether or not to create a ground.
  51502. * True by default.
  51503. */
  51504. createGround: boolean;
  51505. /**
  51506. * Specifies the ground size.
  51507. * 15 by default.
  51508. */
  51509. groundSize: number;
  51510. /**
  51511. * The texture used on the ground for the main color.
  51512. * Comes from the BabylonJS CDN by default.
  51513. *
  51514. * Remarks: Can be either a texture or a url.
  51515. */
  51516. groundTexture: string | BaseTexture;
  51517. /**
  51518. * The color mixed in the ground texture by default.
  51519. * BabylonJS clearColor by default.
  51520. */
  51521. groundColor: Color3;
  51522. /**
  51523. * Specifies the ground opacity.
  51524. * 1 by default.
  51525. */
  51526. groundOpacity: number;
  51527. /**
  51528. * Enables the ground to receive shadows.
  51529. * True by default.
  51530. */
  51531. enableGroundShadow: boolean;
  51532. /**
  51533. * Helps preventing the shadow to be fully black on the ground.
  51534. * 0.5 by default.
  51535. */
  51536. groundShadowLevel: number;
  51537. /**
  51538. * Creates a mirror texture attach to the ground.
  51539. * false by default.
  51540. */
  51541. enableGroundMirror: boolean;
  51542. /**
  51543. * Specifies the ground mirror size ratio.
  51544. * 0.3 by default as the default kernel is 64.
  51545. */
  51546. groundMirrorSizeRatio: number;
  51547. /**
  51548. * Specifies the ground mirror blur kernel size.
  51549. * 64 by default.
  51550. */
  51551. groundMirrorBlurKernel: number;
  51552. /**
  51553. * Specifies the ground mirror visibility amount.
  51554. * 1 by default
  51555. */
  51556. groundMirrorAmount: number;
  51557. /**
  51558. * Specifies the ground mirror reflectance weight.
  51559. * This uses the standard weight of the background material to setup the fresnel effect
  51560. * of the mirror.
  51561. * 1 by default.
  51562. */
  51563. groundMirrorFresnelWeight: number;
  51564. /**
  51565. * Specifies the ground mirror Falloff distance.
  51566. * This can helps reducing the size of the reflection.
  51567. * 0 by Default.
  51568. */
  51569. groundMirrorFallOffDistance: number;
  51570. /**
  51571. * Specifies the ground mirror texture type.
  51572. * Unsigned Int by Default.
  51573. */
  51574. groundMirrorTextureType: number;
  51575. /**
  51576. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51577. * the shown objects.
  51578. */
  51579. groundYBias: number;
  51580. /**
  51581. * Specifies whether or not to create a skybox.
  51582. * True by default.
  51583. */
  51584. createSkybox: boolean;
  51585. /**
  51586. * Specifies the skybox size.
  51587. * 20 by default.
  51588. */
  51589. skyboxSize: number;
  51590. /**
  51591. * The texture used on the skybox for the main color.
  51592. * Comes from the BabylonJS CDN by default.
  51593. *
  51594. * Remarks: Can be either a texture or a url.
  51595. */
  51596. skyboxTexture: string | BaseTexture;
  51597. /**
  51598. * The color mixed in the skybox texture by default.
  51599. * BabylonJS clearColor by default.
  51600. */
  51601. skyboxColor: Color3;
  51602. /**
  51603. * The background rotation around the Y axis of the scene.
  51604. * This helps aligning the key lights of your scene with the background.
  51605. * 0 by default.
  51606. */
  51607. backgroundYRotation: number;
  51608. /**
  51609. * Compute automatically the size of the elements to best fit with the scene.
  51610. */
  51611. sizeAuto: boolean;
  51612. /**
  51613. * Default position of the rootMesh if autoSize is not true.
  51614. */
  51615. rootPosition: Vector3;
  51616. /**
  51617. * Sets up the image processing in the scene.
  51618. * true by default.
  51619. */
  51620. setupImageProcessing: boolean;
  51621. /**
  51622. * The texture used as your environment texture in the scene.
  51623. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51624. *
  51625. * Remarks: Can be either a texture or a url.
  51626. */
  51627. environmentTexture: string | BaseTexture;
  51628. /**
  51629. * The value of the exposure to apply to the scene.
  51630. * 0.6 by default if setupImageProcessing is true.
  51631. */
  51632. cameraExposure: number;
  51633. /**
  51634. * The value of the contrast to apply to the scene.
  51635. * 1.6 by default if setupImageProcessing is true.
  51636. */
  51637. cameraContrast: number;
  51638. /**
  51639. * Specifies whether or not tonemapping should be enabled in the scene.
  51640. * true by default if setupImageProcessing is true.
  51641. */
  51642. toneMappingEnabled: boolean;
  51643. }
  51644. /**
  51645. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51646. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51647. * It also helps with the default setup of your imageProcessing configuration.
  51648. */
  51649. export class EnvironmentHelper {
  51650. /**
  51651. * Default ground texture URL.
  51652. */
  51653. private static _groundTextureCDNUrl;
  51654. /**
  51655. * Default skybox texture URL.
  51656. */
  51657. private static _skyboxTextureCDNUrl;
  51658. /**
  51659. * Default environment texture URL.
  51660. */
  51661. private static _environmentTextureCDNUrl;
  51662. /**
  51663. * Creates the default options for the helper.
  51664. */
  51665. private static _getDefaultOptions;
  51666. private _rootMesh;
  51667. /**
  51668. * Gets the root mesh created by the helper.
  51669. */
  51670. get rootMesh(): Mesh;
  51671. private _skybox;
  51672. /**
  51673. * Gets the skybox created by the helper.
  51674. */
  51675. get skybox(): Nullable<Mesh>;
  51676. private _skyboxTexture;
  51677. /**
  51678. * Gets the skybox texture created by the helper.
  51679. */
  51680. get skyboxTexture(): Nullable<BaseTexture>;
  51681. private _skyboxMaterial;
  51682. /**
  51683. * Gets the skybox material created by the helper.
  51684. */
  51685. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51686. private _ground;
  51687. /**
  51688. * Gets the ground mesh created by the helper.
  51689. */
  51690. get ground(): Nullable<Mesh>;
  51691. private _groundTexture;
  51692. /**
  51693. * Gets the ground texture created by the helper.
  51694. */
  51695. get groundTexture(): Nullable<BaseTexture>;
  51696. private _groundMirror;
  51697. /**
  51698. * Gets the ground mirror created by the helper.
  51699. */
  51700. get groundMirror(): Nullable<MirrorTexture>;
  51701. /**
  51702. * Gets the ground mirror render list to helps pushing the meshes
  51703. * you wish in the ground reflection.
  51704. */
  51705. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51706. private _groundMaterial;
  51707. /**
  51708. * Gets the ground material created by the helper.
  51709. */
  51710. get groundMaterial(): Nullable<BackgroundMaterial>;
  51711. /**
  51712. * Stores the creation options.
  51713. */
  51714. private readonly _scene;
  51715. private _options;
  51716. /**
  51717. * This observable will be notified with any error during the creation of the environment,
  51718. * mainly texture creation errors.
  51719. */
  51720. onErrorObservable: Observable<{
  51721. message?: string;
  51722. exception?: any;
  51723. }>;
  51724. /**
  51725. * constructor
  51726. * @param options Defines the options we want to customize the helper
  51727. * @param scene The scene to add the material to
  51728. */
  51729. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51730. /**
  51731. * Updates the background according to the new options
  51732. * @param options
  51733. */
  51734. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51735. /**
  51736. * Sets the primary color of all the available elements.
  51737. * @param color the main color to affect to the ground and the background
  51738. */
  51739. setMainColor(color: Color3): void;
  51740. /**
  51741. * Setup the image processing according to the specified options.
  51742. */
  51743. private _setupImageProcessing;
  51744. /**
  51745. * Setup the environment texture according to the specified options.
  51746. */
  51747. private _setupEnvironmentTexture;
  51748. /**
  51749. * Setup the background according to the specified options.
  51750. */
  51751. private _setupBackground;
  51752. /**
  51753. * Get the scene sizes according to the setup.
  51754. */
  51755. private _getSceneSize;
  51756. /**
  51757. * Setup the ground according to the specified options.
  51758. */
  51759. private _setupGround;
  51760. /**
  51761. * Setup the ground material according to the specified options.
  51762. */
  51763. private _setupGroundMaterial;
  51764. /**
  51765. * Setup the ground diffuse texture according to the specified options.
  51766. */
  51767. private _setupGroundDiffuseTexture;
  51768. /**
  51769. * Setup the ground mirror texture according to the specified options.
  51770. */
  51771. private _setupGroundMirrorTexture;
  51772. /**
  51773. * Setup the ground to receive the mirror texture.
  51774. */
  51775. private _setupMirrorInGroundMaterial;
  51776. /**
  51777. * Setup the skybox according to the specified options.
  51778. */
  51779. private _setupSkybox;
  51780. /**
  51781. * Setup the skybox material according to the specified options.
  51782. */
  51783. private _setupSkyboxMaterial;
  51784. /**
  51785. * Setup the skybox reflection texture according to the specified options.
  51786. */
  51787. private _setupSkyboxReflectionTexture;
  51788. private _errorHandler;
  51789. /**
  51790. * Dispose all the elements created by the Helper.
  51791. */
  51792. dispose(): void;
  51793. }
  51794. }
  51795. declare module "babylonjs/Helpers/photoDome" {
  51796. import { Observable } from "babylonjs/Misc/observable";
  51797. import { Nullable } from "babylonjs/types";
  51798. import { Scene } from "babylonjs/scene";
  51799. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51800. import { Mesh } from "babylonjs/Meshes/mesh";
  51801. import { Texture } from "babylonjs/Materials/Textures/texture";
  51802. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51803. import "babylonjs/Meshes/Builders/sphereBuilder";
  51804. /**
  51805. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  51806. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  51807. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  51808. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51809. */
  51810. export class PhotoDome extends TransformNode {
  51811. /**
  51812. * Define the image as a Monoscopic panoramic 360 image.
  51813. */
  51814. static readonly MODE_MONOSCOPIC: number;
  51815. /**
  51816. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51817. */
  51818. static readonly MODE_TOPBOTTOM: number;
  51819. /**
  51820. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51821. */
  51822. static readonly MODE_SIDEBYSIDE: number;
  51823. private _useDirectMapping;
  51824. /**
  51825. * The texture being displayed on the sphere
  51826. */
  51827. protected _photoTexture: Texture;
  51828. /**
  51829. * Gets or sets the texture being displayed on the sphere
  51830. */
  51831. get photoTexture(): Texture;
  51832. set photoTexture(value: Texture);
  51833. /**
  51834. * Observable raised when an error occured while loading the 360 image
  51835. */
  51836. onLoadErrorObservable: Observable<string>;
  51837. /**
  51838. * The skybox material
  51839. */
  51840. protected _material: BackgroundMaterial;
  51841. /**
  51842. * The surface used for the skybox
  51843. */
  51844. protected _mesh: Mesh;
  51845. /**
  51846. * Gets the mesh used for the skybox.
  51847. */
  51848. get mesh(): Mesh;
  51849. /**
  51850. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51851. * Also see the options.resolution property.
  51852. */
  51853. get fovMultiplier(): number;
  51854. set fovMultiplier(value: number);
  51855. private _imageMode;
  51856. /**
  51857. * Gets or set the current video mode for the video. It can be:
  51858. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  51859. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51860. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51861. */
  51862. get imageMode(): number;
  51863. set imageMode(value: number);
  51864. /**
  51865. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  51866. * @param name Element's name, child elements will append suffixes for their own names.
  51867. * @param urlsOfPhoto defines the url of the photo to display
  51868. * @param options defines an object containing optional or exposed sub element properties
  51869. * @param onError defines a callback called when an error occured while loading the texture
  51870. */
  51871. constructor(name: string, urlOfPhoto: string, options: {
  51872. resolution?: number;
  51873. size?: number;
  51874. useDirectMapping?: boolean;
  51875. faceForward?: boolean;
  51876. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  51877. private _onBeforeCameraRenderObserver;
  51878. private _changeImageMode;
  51879. /**
  51880. * Releases resources associated with this node.
  51881. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51882. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51883. */
  51884. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51885. }
  51886. }
  51887. declare module "babylonjs/Misc/rgbdTextureTools" {
  51888. import "babylonjs/Shaders/rgbdDecode.fragment";
  51889. import "babylonjs/Engines/Extensions/engine.renderTarget";
  51890. import { Texture } from "babylonjs/Materials/Textures/texture";
  51891. /**
  51892. * Class used to host RGBD texture specific utilities
  51893. */
  51894. export class RGBDTextureTools {
  51895. /**
  51896. * Expand the RGBD Texture from RGBD to Half Float if possible.
  51897. * @param texture the texture to expand.
  51898. */
  51899. static ExpandRGBDTexture(texture: Texture): void;
  51900. }
  51901. }
  51902. declare module "babylonjs/Misc/brdfTextureTools" {
  51903. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51904. import { Scene } from "babylonjs/scene";
  51905. /**
  51906. * Class used to host texture specific utilities
  51907. */
  51908. export class BRDFTextureTools {
  51909. /**
  51910. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  51911. * @param scene defines the hosting scene
  51912. * @returns the environment BRDF texture
  51913. */
  51914. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  51915. private static _environmentBRDFBase64Texture;
  51916. }
  51917. }
  51918. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  51919. import { Nullable } from "babylonjs/types";
  51920. import { Color3 } from "babylonjs/Maths/math.color";
  51921. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51922. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51923. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51924. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51925. import { Engine } from "babylonjs/Engines/engine";
  51926. import { Scene } from "babylonjs/scene";
  51927. /**
  51928. * @hidden
  51929. */
  51930. export interface IMaterialClearCoatDefines {
  51931. CLEARCOAT: boolean;
  51932. CLEARCOAT_DEFAULTIOR: boolean;
  51933. CLEARCOAT_TEXTURE: boolean;
  51934. CLEARCOAT_TEXTUREDIRECTUV: number;
  51935. CLEARCOAT_BUMP: boolean;
  51936. CLEARCOAT_BUMPDIRECTUV: number;
  51937. CLEARCOAT_TINT: boolean;
  51938. CLEARCOAT_TINT_TEXTURE: boolean;
  51939. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51940. /** @hidden */
  51941. _areTexturesDirty: boolean;
  51942. }
  51943. /**
  51944. * Define the code related to the clear coat parameters of the pbr material.
  51945. */
  51946. export class PBRClearCoatConfiguration {
  51947. /**
  51948. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51949. * The default fits with a polyurethane material.
  51950. */
  51951. private static readonly _DefaultIndexOfRefraction;
  51952. private _isEnabled;
  51953. /**
  51954. * Defines if the clear coat is enabled in the material.
  51955. */
  51956. isEnabled: boolean;
  51957. /**
  51958. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  51959. */
  51960. intensity: number;
  51961. /**
  51962. * Defines the clear coat layer roughness.
  51963. */
  51964. roughness: number;
  51965. private _indexOfRefraction;
  51966. /**
  51967. * Defines the index of refraction of the clear coat.
  51968. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51969. * The default fits with a polyurethane material.
  51970. * Changing the default value is more performance intensive.
  51971. */
  51972. indexOfRefraction: number;
  51973. private _texture;
  51974. /**
  51975. * Stores the clear coat values in a texture.
  51976. */
  51977. texture: Nullable<BaseTexture>;
  51978. private _bumpTexture;
  51979. /**
  51980. * Define the clear coat specific bump texture.
  51981. */
  51982. bumpTexture: Nullable<BaseTexture>;
  51983. private _isTintEnabled;
  51984. /**
  51985. * Defines if the clear coat tint is enabled in the material.
  51986. */
  51987. isTintEnabled: boolean;
  51988. /**
  51989. * Defines the clear coat tint of the material.
  51990. * This is only use if tint is enabled
  51991. */
  51992. tintColor: Color3;
  51993. /**
  51994. * Defines the distance at which the tint color should be found in the
  51995. * clear coat media.
  51996. * This is only use if tint is enabled
  51997. */
  51998. tintColorAtDistance: number;
  51999. /**
  52000. * Defines the clear coat layer thickness.
  52001. * This is only use if tint is enabled
  52002. */
  52003. tintThickness: number;
  52004. private _tintTexture;
  52005. /**
  52006. * Stores the clear tint values in a texture.
  52007. * rgb is tint
  52008. * a is a thickness factor
  52009. */
  52010. tintTexture: Nullable<BaseTexture>;
  52011. /** @hidden */
  52012. private _internalMarkAllSubMeshesAsTexturesDirty;
  52013. /** @hidden */
  52014. _markAllSubMeshesAsTexturesDirty(): void;
  52015. /**
  52016. * Instantiate a new istance of clear coat configuration.
  52017. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52018. */
  52019. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52020. /**
  52021. * Gets wehter the submesh is ready to be used or not.
  52022. * @param defines the list of "defines" to update.
  52023. * @param scene defines the scene the material belongs to.
  52024. * @param engine defines the engine the material belongs to.
  52025. * @param disableBumpMap defines wether the material disables bump or not.
  52026. * @returns - boolean indicating that the submesh is ready or not.
  52027. */
  52028. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52029. /**
  52030. * Checks to see if a texture is used in the material.
  52031. * @param defines the list of "defines" to update.
  52032. * @param scene defines the scene to the material belongs to.
  52033. */
  52034. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52035. /**
  52036. * Binds the material data.
  52037. * @param uniformBuffer defines the Uniform buffer to fill in.
  52038. * @param scene defines the scene the material belongs to.
  52039. * @param engine defines the engine the material belongs to.
  52040. * @param disableBumpMap defines wether the material disables bump or not.
  52041. * @param isFrozen defines wether the material is frozen or not.
  52042. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52043. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52044. */
  52045. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52046. /**
  52047. * Checks to see if a texture is used in the material.
  52048. * @param texture - Base texture to use.
  52049. * @returns - Boolean specifying if a texture is used in the material.
  52050. */
  52051. hasTexture(texture: BaseTexture): boolean;
  52052. /**
  52053. * Returns an array of the actively used textures.
  52054. * @param activeTextures Array of BaseTextures
  52055. */
  52056. getActiveTextures(activeTextures: BaseTexture[]): void;
  52057. /**
  52058. * Returns the animatable textures.
  52059. * @param animatables Array of animatable textures.
  52060. */
  52061. getAnimatables(animatables: IAnimatable[]): void;
  52062. /**
  52063. * Disposes the resources of the material.
  52064. * @param forceDisposeTextures - Forces the disposal of all textures.
  52065. */
  52066. dispose(forceDisposeTextures?: boolean): void;
  52067. /**
  52068. * Get the current class name of the texture useful for serialization or dynamic coding.
  52069. * @returns "PBRClearCoatConfiguration"
  52070. */
  52071. getClassName(): string;
  52072. /**
  52073. * Add fallbacks to the effect fallbacks list.
  52074. * @param defines defines the Base texture to use.
  52075. * @param fallbacks defines the current fallback list.
  52076. * @param currentRank defines the current fallback rank.
  52077. * @returns the new fallback rank.
  52078. */
  52079. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52080. /**
  52081. * Add the required uniforms to the current list.
  52082. * @param uniforms defines the current uniform list.
  52083. */
  52084. static AddUniforms(uniforms: string[]): void;
  52085. /**
  52086. * Add the required samplers to the current list.
  52087. * @param samplers defines the current sampler list.
  52088. */
  52089. static AddSamplers(samplers: string[]): void;
  52090. /**
  52091. * Add the required uniforms to the current buffer.
  52092. * @param uniformBuffer defines the current uniform buffer.
  52093. */
  52094. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52095. /**
  52096. * Makes a duplicate of the current configuration into another one.
  52097. * @param clearCoatConfiguration define the config where to copy the info
  52098. */
  52099. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52100. /**
  52101. * Serializes this clear coat configuration.
  52102. * @returns - An object with the serialized config.
  52103. */
  52104. serialize(): any;
  52105. /**
  52106. * Parses a anisotropy Configuration from a serialized object.
  52107. * @param source - Serialized object.
  52108. * @param scene Defines the scene we are parsing for
  52109. * @param rootUrl Defines the rootUrl to load from
  52110. */
  52111. parse(source: any, scene: Scene, rootUrl: string): void;
  52112. }
  52113. }
  52114. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52115. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52116. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52117. import { Vector2 } from "babylonjs/Maths/math.vector";
  52118. import { Scene } from "babylonjs/scene";
  52119. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52120. import { Nullable } from "babylonjs/types";
  52121. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52122. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52123. /**
  52124. * @hidden
  52125. */
  52126. export interface IMaterialAnisotropicDefines {
  52127. ANISOTROPIC: boolean;
  52128. ANISOTROPIC_TEXTURE: boolean;
  52129. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52130. MAINUV1: boolean;
  52131. _areTexturesDirty: boolean;
  52132. _needUVs: boolean;
  52133. }
  52134. /**
  52135. * Define the code related to the anisotropic parameters of the pbr material.
  52136. */
  52137. export class PBRAnisotropicConfiguration {
  52138. private _isEnabled;
  52139. /**
  52140. * Defines if the anisotropy is enabled in the material.
  52141. */
  52142. isEnabled: boolean;
  52143. /**
  52144. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52145. */
  52146. intensity: number;
  52147. /**
  52148. * Defines if the effect is along the tangents, bitangents or in between.
  52149. * By default, the effect is "strectching" the highlights along the tangents.
  52150. */
  52151. direction: Vector2;
  52152. private _texture;
  52153. /**
  52154. * Stores the anisotropy values in a texture.
  52155. * rg is direction (like normal from -1 to 1)
  52156. * b is a intensity
  52157. */
  52158. texture: Nullable<BaseTexture>;
  52159. /** @hidden */
  52160. private _internalMarkAllSubMeshesAsTexturesDirty;
  52161. /** @hidden */
  52162. _markAllSubMeshesAsTexturesDirty(): void;
  52163. /**
  52164. * Instantiate a new istance of anisotropy configuration.
  52165. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52166. */
  52167. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52168. /**
  52169. * Specifies that the submesh is ready to be used.
  52170. * @param defines the list of "defines" to update.
  52171. * @param scene defines the scene the material belongs to.
  52172. * @returns - boolean indicating that the submesh is ready or not.
  52173. */
  52174. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52175. /**
  52176. * Checks to see if a texture is used in the material.
  52177. * @param defines the list of "defines" to update.
  52178. * @param mesh the mesh we are preparing the defines for.
  52179. * @param scene defines the scene the material belongs to.
  52180. */
  52181. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52182. /**
  52183. * Binds the material data.
  52184. * @param uniformBuffer defines the Uniform buffer to fill in.
  52185. * @param scene defines the scene the material belongs to.
  52186. * @param isFrozen defines wether the material is frozen or not.
  52187. */
  52188. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52189. /**
  52190. * Checks to see if a texture is used in the material.
  52191. * @param texture - Base texture to use.
  52192. * @returns - Boolean specifying if a texture is used in the material.
  52193. */
  52194. hasTexture(texture: BaseTexture): boolean;
  52195. /**
  52196. * Returns an array of the actively used textures.
  52197. * @param activeTextures Array of BaseTextures
  52198. */
  52199. getActiveTextures(activeTextures: BaseTexture[]): void;
  52200. /**
  52201. * Returns the animatable textures.
  52202. * @param animatables Array of animatable textures.
  52203. */
  52204. getAnimatables(animatables: IAnimatable[]): void;
  52205. /**
  52206. * Disposes the resources of the material.
  52207. * @param forceDisposeTextures - Forces the disposal of all textures.
  52208. */
  52209. dispose(forceDisposeTextures?: boolean): void;
  52210. /**
  52211. * Get the current class name of the texture useful for serialization or dynamic coding.
  52212. * @returns "PBRAnisotropicConfiguration"
  52213. */
  52214. getClassName(): string;
  52215. /**
  52216. * Add fallbacks to the effect fallbacks list.
  52217. * @param defines defines the Base texture to use.
  52218. * @param fallbacks defines the current fallback list.
  52219. * @param currentRank defines the current fallback rank.
  52220. * @returns the new fallback rank.
  52221. */
  52222. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52223. /**
  52224. * Add the required uniforms to the current list.
  52225. * @param uniforms defines the current uniform list.
  52226. */
  52227. static AddUniforms(uniforms: string[]): void;
  52228. /**
  52229. * Add the required uniforms to the current buffer.
  52230. * @param uniformBuffer defines the current uniform buffer.
  52231. */
  52232. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52233. /**
  52234. * Add the required samplers to the current list.
  52235. * @param samplers defines the current sampler list.
  52236. */
  52237. static AddSamplers(samplers: string[]): void;
  52238. /**
  52239. * Makes a duplicate of the current configuration into another one.
  52240. * @param anisotropicConfiguration define the config where to copy the info
  52241. */
  52242. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52243. /**
  52244. * Serializes this anisotropy configuration.
  52245. * @returns - An object with the serialized config.
  52246. */
  52247. serialize(): any;
  52248. /**
  52249. * Parses a anisotropy Configuration from a serialized object.
  52250. * @param source - Serialized object.
  52251. * @param scene Defines the scene we are parsing for
  52252. * @param rootUrl Defines the rootUrl to load from
  52253. */
  52254. parse(source: any, scene: Scene, rootUrl: string): void;
  52255. }
  52256. }
  52257. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52258. import { Scene } from "babylonjs/scene";
  52259. /**
  52260. * @hidden
  52261. */
  52262. export interface IMaterialBRDFDefines {
  52263. BRDF_V_HEIGHT_CORRELATED: boolean;
  52264. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52265. SPHERICAL_HARMONICS: boolean;
  52266. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52267. /** @hidden */
  52268. _areMiscDirty: boolean;
  52269. }
  52270. /**
  52271. * Define the code related to the BRDF parameters of the pbr material.
  52272. */
  52273. export class PBRBRDFConfiguration {
  52274. /**
  52275. * Default value used for the energy conservation.
  52276. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52277. */
  52278. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52279. /**
  52280. * Default value used for the Smith Visibility Height Correlated mode.
  52281. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52282. */
  52283. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52284. /**
  52285. * Default value used for the IBL diffuse part.
  52286. * This can help switching back to the polynomials mode globally which is a tiny bit
  52287. * less GPU intensive at the drawback of a lower quality.
  52288. */
  52289. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52290. /**
  52291. * Default value used for activating energy conservation for the specular workflow.
  52292. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52293. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52294. */
  52295. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52296. private _useEnergyConservation;
  52297. /**
  52298. * Defines if the material uses energy conservation.
  52299. */
  52300. useEnergyConservation: boolean;
  52301. private _useSmithVisibilityHeightCorrelated;
  52302. /**
  52303. * LEGACY Mode set to false
  52304. * Defines if the material uses height smith correlated visibility term.
  52305. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52306. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52307. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52308. * Not relying on height correlated will also disable energy conservation.
  52309. */
  52310. useSmithVisibilityHeightCorrelated: boolean;
  52311. private _useSphericalHarmonics;
  52312. /**
  52313. * LEGACY Mode set to false
  52314. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52315. * diffuse part of the IBL.
  52316. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52317. * to the ground truth.
  52318. */
  52319. useSphericalHarmonics: boolean;
  52320. private _useSpecularGlossinessInputEnergyConservation;
  52321. /**
  52322. * Defines if the material uses energy conservation, when the specular workflow is active.
  52323. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52324. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52325. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52326. */
  52327. useSpecularGlossinessInputEnergyConservation: boolean;
  52328. /** @hidden */
  52329. private _internalMarkAllSubMeshesAsMiscDirty;
  52330. /** @hidden */
  52331. _markAllSubMeshesAsMiscDirty(): void;
  52332. /**
  52333. * Instantiate a new istance of clear coat configuration.
  52334. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52335. */
  52336. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52337. /**
  52338. * Checks to see if a texture is used in the material.
  52339. * @param defines the list of "defines" to update.
  52340. */
  52341. prepareDefines(defines: IMaterialBRDFDefines): void;
  52342. /**
  52343. * Get the current class name of the texture useful for serialization or dynamic coding.
  52344. * @returns "PBRClearCoatConfiguration"
  52345. */
  52346. getClassName(): string;
  52347. /**
  52348. * Makes a duplicate of the current configuration into another one.
  52349. * @param brdfConfiguration define the config where to copy the info
  52350. */
  52351. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52352. /**
  52353. * Serializes this BRDF configuration.
  52354. * @returns - An object with the serialized config.
  52355. */
  52356. serialize(): any;
  52357. /**
  52358. * Parses a anisotropy Configuration from a serialized object.
  52359. * @param source - Serialized object.
  52360. * @param scene Defines the scene we are parsing for
  52361. * @param rootUrl Defines the rootUrl to load from
  52362. */
  52363. parse(source: any, scene: Scene, rootUrl: string): void;
  52364. }
  52365. }
  52366. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52367. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52368. import { Color3 } from "babylonjs/Maths/math.color";
  52369. import { Scene } from "babylonjs/scene";
  52370. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52371. import { Nullable } from "babylonjs/types";
  52372. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52373. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52374. /**
  52375. * @hidden
  52376. */
  52377. export interface IMaterialSheenDefines {
  52378. SHEEN: boolean;
  52379. SHEEN_TEXTURE: boolean;
  52380. SHEEN_TEXTUREDIRECTUV: number;
  52381. SHEEN_LINKWITHALBEDO: boolean;
  52382. /** @hidden */
  52383. _areTexturesDirty: boolean;
  52384. }
  52385. /**
  52386. * Define the code related to the Sheen parameters of the pbr material.
  52387. */
  52388. export class PBRSheenConfiguration {
  52389. private _isEnabled;
  52390. /**
  52391. * Defines if the material uses sheen.
  52392. */
  52393. isEnabled: boolean;
  52394. private _linkSheenWithAlbedo;
  52395. /**
  52396. * Defines if the sheen is linked to the sheen color.
  52397. */
  52398. linkSheenWithAlbedo: boolean;
  52399. /**
  52400. * Defines the sheen intensity.
  52401. */
  52402. intensity: number;
  52403. /**
  52404. * Defines the sheen color.
  52405. */
  52406. color: Color3;
  52407. private _texture;
  52408. /**
  52409. * Stores the sheen tint values in a texture.
  52410. * rgb is tint
  52411. * a is a intensity
  52412. */
  52413. texture: Nullable<BaseTexture>;
  52414. /** @hidden */
  52415. private _internalMarkAllSubMeshesAsTexturesDirty;
  52416. /** @hidden */
  52417. _markAllSubMeshesAsTexturesDirty(): void;
  52418. /**
  52419. * Instantiate a new istance of clear coat configuration.
  52420. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52421. */
  52422. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52423. /**
  52424. * Specifies that the submesh is ready to be used.
  52425. * @param defines the list of "defines" to update.
  52426. * @param scene defines the scene the material belongs to.
  52427. * @returns - boolean indicating that the submesh is ready or not.
  52428. */
  52429. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52430. /**
  52431. * Checks to see if a texture is used in the material.
  52432. * @param defines the list of "defines" to update.
  52433. * @param scene defines the scene the material belongs to.
  52434. */
  52435. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52436. /**
  52437. * Binds the material data.
  52438. * @param uniformBuffer defines the Uniform buffer to fill in.
  52439. * @param scene defines the scene the material belongs to.
  52440. * @param isFrozen defines wether the material is frozen or not.
  52441. */
  52442. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52443. /**
  52444. * Checks to see if a texture is used in the material.
  52445. * @param texture - Base texture to use.
  52446. * @returns - Boolean specifying if a texture is used in the material.
  52447. */
  52448. hasTexture(texture: BaseTexture): boolean;
  52449. /**
  52450. * Returns an array of the actively used textures.
  52451. * @param activeTextures Array of BaseTextures
  52452. */
  52453. getActiveTextures(activeTextures: BaseTexture[]): void;
  52454. /**
  52455. * Returns the animatable textures.
  52456. * @param animatables Array of animatable textures.
  52457. */
  52458. getAnimatables(animatables: IAnimatable[]): void;
  52459. /**
  52460. * Disposes the resources of the material.
  52461. * @param forceDisposeTextures - Forces the disposal of all textures.
  52462. */
  52463. dispose(forceDisposeTextures?: boolean): void;
  52464. /**
  52465. * Get the current class name of the texture useful for serialization or dynamic coding.
  52466. * @returns "PBRSheenConfiguration"
  52467. */
  52468. getClassName(): string;
  52469. /**
  52470. * Add fallbacks to the effect fallbacks list.
  52471. * @param defines defines the Base texture to use.
  52472. * @param fallbacks defines the current fallback list.
  52473. * @param currentRank defines the current fallback rank.
  52474. * @returns the new fallback rank.
  52475. */
  52476. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52477. /**
  52478. * Add the required uniforms to the current list.
  52479. * @param uniforms defines the current uniform list.
  52480. */
  52481. static AddUniforms(uniforms: string[]): void;
  52482. /**
  52483. * Add the required uniforms to the current buffer.
  52484. * @param uniformBuffer defines the current uniform buffer.
  52485. */
  52486. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52487. /**
  52488. * Add the required samplers to the current list.
  52489. * @param samplers defines the current sampler list.
  52490. */
  52491. static AddSamplers(samplers: string[]): void;
  52492. /**
  52493. * Makes a duplicate of the current configuration into another one.
  52494. * @param sheenConfiguration define the config where to copy the info
  52495. */
  52496. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52497. /**
  52498. * Serializes this BRDF configuration.
  52499. * @returns - An object with the serialized config.
  52500. */
  52501. serialize(): any;
  52502. /**
  52503. * Parses a anisotropy Configuration from a serialized object.
  52504. * @param source - Serialized object.
  52505. * @param scene Defines the scene we are parsing for
  52506. * @param rootUrl Defines the rootUrl to load from
  52507. */
  52508. parse(source: any, scene: Scene, rootUrl: string): void;
  52509. }
  52510. }
  52511. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52512. import { Nullable } from "babylonjs/types";
  52513. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52514. import { Color3 } from "babylonjs/Maths/math.color";
  52515. import { SmartArray } from "babylonjs/Misc/smartArray";
  52516. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52517. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52518. import { Effect } from "babylonjs/Materials/effect";
  52519. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52520. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52521. import { Engine } from "babylonjs/Engines/engine";
  52522. import { Scene } from "babylonjs/scene";
  52523. /**
  52524. * @hidden
  52525. */
  52526. export interface IMaterialSubSurfaceDefines {
  52527. SUBSURFACE: boolean;
  52528. SS_REFRACTION: boolean;
  52529. SS_TRANSLUCENCY: boolean;
  52530. SS_SCATERRING: boolean;
  52531. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52532. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52533. SS_REFRACTIONMAP_3D: boolean;
  52534. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52535. SS_LODINREFRACTIONALPHA: boolean;
  52536. SS_GAMMAREFRACTION: boolean;
  52537. SS_RGBDREFRACTION: boolean;
  52538. SS_LINEARSPECULARREFRACTION: boolean;
  52539. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52540. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52541. /** @hidden */
  52542. _areTexturesDirty: boolean;
  52543. }
  52544. /**
  52545. * Define the code related to the sub surface parameters of the pbr material.
  52546. */
  52547. export class PBRSubSurfaceConfiguration {
  52548. private _isRefractionEnabled;
  52549. /**
  52550. * Defines if the refraction is enabled in the material.
  52551. */
  52552. isRefractionEnabled: boolean;
  52553. private _isTranslucencyEnabled;
  52554. /**
  52555. * Defines if the translucency is enabled in the material.
  52556. */
  52557. isTranslucencyEnabled: boolean;
  52558. private _isScatteringEnabled;
  52559. /**
  52560. * Defines the refraction intensity of the material.
  52561. * The refraction when enabled replaces the Diffuse part of the material.
  52562. * The intensity helps transitionning between diffuse and refraction.
  52563. */
  52564. refractionIntensity: number;
  52565. /**
  52566. * Defines the translucency intensity of the material.
  52567. * When translucency has been enabled, this defines how much of the "translucency"
  52568. * is addded to the diffuse part of the material.
  52569. */
  52570. translucencyIntensity: number;
  52571. /**
  52572. * Defines the scattering intensity of the material.
  52573. * When scattering has been enabled, this defines how much of the "scattered light"
  52574. * is addded to the diffuse part of the material.
  52575. */
  52576. scatteringIntensity: number;
  52577. private _thicknessTexture;
  52578. /**
  52579. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52580. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52581. * 0 would mean minimumThickness
  52582. * 1 would mean maximumThickness
  52583. * The other channels might be use as a mask to vary the different effects intensity.
  52584. */
  52585. thicknessTexture: Nullable<BaseTexture>;
  52586. private _refractionTexture;
  52587. /**
  52588. * Defines the texture to use for refraction.
  52589. */
  52590. refractionTexture: Nullable<BaseTexture>;
  52591. private _indexOfRefraction;
  52592. /**
  52593. * Defines the index of refraction used in the material.
  52594. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52595. */
  52596. indexOfRefraction: number;
  52597. private _invertRefractionY;
  52598. /**
  52599. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52600. */
  52601. invertRefractionY: boolean;
  52602. private _linkRefractionWithTransparency;
  52603. /**
  52604. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52605. * Materials half opaque for instance using refraction could benefit from this control.
  52606. */
  52607. linkRefractionWithTransparency: boolean;
  52608. /**
  52609. * Defines the minimum thickness stored in the thickness map.
  52610. * If no thickness map is defined, this value will be used to simulate thickness.
  52611. */
  52612. minimumThickness: number;
  52613. /**
  52614. * Defines the maximum thickness stored in the thickness map.
  52615. */
  52616. maximumThickness: number;
  52617. /**
  52618. * Defines the volume tint of the material.
  52619. * This is used for both translucency and scattering.
  52620. */
  52621. tintColor: Color3;
  52622. /**
  52623. * Defines the distance at which the tint color should be found in the media.
  52624. * This is used for refraction only.
  52625. */
  52626. tintColorAtDistance: number;
  52627. /**
  52628. * Defines how far each channel transmit through the media.
  52629. * It is defined as a color to simplify it selection.
  52630. */
  52631. diffusionDistance: Color3;
  52632. private _useMaskFromThicknessTexture;
  52633. /**
  52634. * Stores the intensity of the different subsurface effects in the thickness texture.
  52635. * * the green channel is the translucency intensity.
  52636. * * the blue channel is the scattering intensity.
  52637. * * the alpha channel is the refraction intensity.
  52638. */
  52639. useMaskFromThicknessTexture: boolean;
  52640. /** @hidden */
  52641. private _internalMarkAllSubMeshesAsTexturesDirty;
  52642. /** @hidden */
  52643. _markAllSubMeshesAsTexturesDirty(): void;
  52644. /**
  52645. * Instantiate a new istance of sub surface configuration.
  52646. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52647. */
  52648. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52649. /**
  52650. * Gets wehter the submesh is ready to be used or not.
  52651. * @param defines the list of "defines" to update.
  52652. * @param scene defines the scene the material belongs to.
  52653. * @returns - boolean indicating that the submesh is ready or not.
  52654. */
  52655. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52656. /**
  52657. * Checks to see if a texture is used in the material.
  52658. * @param defines the list of "defines" to update.
  52659. * @param scene defines the scene to the material belongs to.
  52660. */
  52661. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52662. /**
  52663. * Binds the material data.
  52664. * @param uniformBuffer defines the Uniform buffer to fill in.
  52665. * @param scene defines the scene the material belongs to.
  52666. * @param engine defines the engine the material belongs to.
  52667. * @param isFrozen defines wether the material is frozen or not.
  52668. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52669. */
  52670. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52671. /**
  52672. * Unbinds the material from the mesh.
  52673. * @param activeEffect defines the effect that should be unbound from.
  52674. * @returns true if unbound, otherwise false
  52675. */
  52676. unbind(activeEffect: Effect): boolean;
  52677. /**
  52678. * Returns the texture used for refraction or null if none is used.
  52679. * @param scene defines the scene the material belongs to.
  52680. * @returns - Refraction texture if present. If no refraction texture and refraction
  52681. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52682. */
  52683. private _getRefractionTexture;
  52684. /**
  52685. * Returns true if alpha blending should be disabled.
  52686. */
  52687. get disableAlphaBlending(): boolean;
  52688. /**
  52689. * Fills the list of render target textures.
  52690. * @param renderTargets the list of render targets to update
  52691. */
  52692. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52693. /**
  52694. * Checks to see if a texture is used in the material.
  52695. * @param texture - Base texture to use.
  52696. * @returns - Boolean specifying if a texture is used in the material.
  52697. */
  52698. hasTexture(texture: BaseTexture): boolean;
  52699. /**
  52700. * Gets a boolean indicating that current material needs to register RTT
  52701. * @returns true if this uses a render target otherwise false.
  52702. */
  52703. hasRenderTargetTextures(): boolean;
  52704. /**
  52705. * Returns an array of the actively used textures.
  52706. * @param activeTextures Array of BaseTextures
  52707. */
  52708. getActiveTextures(activeTextures: BaseTexture[]): void;
  52709. /**
  52710. * Returns the animatable textures.
  52711. * @param animatables Array of animatable textures.
  52712. */
  52713. getAnimatables(animatables: IAnimatable[]): void;
  52714. /**
  52715. * Disposes the resources of the material.
  52716. * @param forceDisposeTextures - Forces the disposal of all textures.
  52717. */
  52718. dispose(forceDisposeTextures?: boolean): void;
  52719. /**
  52720. * Get the current class name of the texture useful for serialization or dynamic coding.
  52721. * @returns "PBRSubSurfaceConfiguration"
  52722. */
  52723. getClassName(): string;
  52724. /**
  52725. * Add fallbacks to the effect fallbacks list.
  52726. * @param defines defines the Base texture to use.
  52727. * @param fallbacks defines the current fallback list.
  52728. * @param currentRank defines the current fallback rank.
  52729. * @returns the new fallback rank.
  52730. */
  52731. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52732. /**
  52733. * Add the required uniforms to the current list.
  52734. * @param uniforms defines the current uniform list.
  52735. */
  52736. static AddUniforms(uniforms: string[]): void;
  52737. /**
  52738. * Add the required samplers to the current list.
  52739. * @param samplers defines the current sampler list.
  52740. */
  52741. static AddSamplers(samplers: string[]): void;
  52742. /**
  52743. * Add the required uniforms to the current buffer.
  52744. * @param uniformBuffer defines the current uniform buffer.
  52745. */
  52746. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52747. /**
  52748. * Makes a duplicate of the current configuration into another one.
  52749. * @param configuration define the config where to copy the info
  52750. */
  52751. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52752. /**
  52753. * Serializes this Sub Surface configuration.
  52754. * @returns - An object with the serialized config.
  52755. */
  52756. serialize(): any;
  52757. /**
  52758. * Parses a anisotropy Configuration from a serialized object.
  52759. * @param source - Serialized object.
  52760. * @param scene Defines the scene we are parsing for
  52761. * @param rootUrl Defines the rootUrl to load from
  52762. */
  52763. parse(source: any, scene: Scene, rootUrl: string): void;
  52764. }
  52765. }
  52766. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52767. /** @hidden */
  52768. export var pbrFragmentDeclaration: {
  52769. name: string;
  52770. shader: string;
  52771. };
  52772. }
  52773. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  52774. /** @hidden */
  52775. export var pbrUboDeclaration: {
  52776. name: string;
  52777. shader: string;
  52778. };
  52779. }
  52780. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  52781. /** @hidden */
  52782. export var pbrFragmentExtraDeclaration: {
  52783. name: string;
  52784. shader: string;
  52785. };
  52786. }
  52787. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  52788. /** @hidden */
  52789. export var pbrFragmentSamplersDeclaration: {
  52790. name: string;
  52791. shader: string;
  52792. };
  52793. }
  52794. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  52795. /** @hidden */
  52796. export var pbrHelperFunctions: {
  52797. name: string;
  52798. shader: string;
  52799. };
  52800. }
  52801. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  52802. /** @hidden */
  52803. export var harmonicsFunctions: {
  52804. name: string;
  52805. shader: string;
  52806. };
  52807. }
  52808. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  52809. /** @hidden */
  52810. export var pbrDirectLightingSetupFunctions: {
  52811. name: string;
  52812. shader: string;
  52813. };
  52814. }
  52815. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  52816. /** @hidden */
  52817. export var pbrDirectLightingFalloffFunctions: {
  52818. name: string;
  52819. shader: string;
  52820. };
  52821. }
  52822. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  52823. /** @hidden */
  52824. export var pbrBRDFFunctions: {
  52825. name: string;
  52826. shader: string;
  52827. };
  52828. }
  52829. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  52830. /** @hidden */
  52831. export var pbrDirectLightingFunctions: {
  52832. name: string;
  52833. shader: string;
  52834. };
  52835. }
  52836. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  52837. /** @hidden */
  52838. export var pbrIBLFunctions: {
  52839. name: string;
  52840. shader: string;
  52841. };
  52842. }
  52843. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  52844. /** @hidden */
  52845. export var pbrDebug: {
  52846. name: string;
  52847. shader: string;
  52848. };
  52849. }
  52850. declare module "babylonjs/Shaders/pbr.fragment" {
  52851. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  52852. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52853. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  52854. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52855. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52856. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  52857. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52858. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  52859. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52860. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  52861. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52862. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  52863. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52864. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  52865. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52866. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  52867. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  52868. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  52869. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  52870. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  52871. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  52872. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  52873. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52874. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  52875. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  52876. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  52877. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  52878. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  52879. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  52880. /** @hidden */
  52881. export var pbrPixelShader: {
  52882. name: string;
  52883. shader: string;
  52884. };
  52885. }
  52886. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  52887. /** @hidden */
  52888. export var pbrVertexDeclaration: {
  52889. name: string;
  52890. shader: string;
  52891. };
  52892. }
  52893. declare module "babylonjs/Shaders/pbr.vertex" {
  52894. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  52895. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52896. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52897. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52898. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52899. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52900. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  52901. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  52902. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  52903. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52904. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52905. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52906. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52907. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52908. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52909. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52910. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52911. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  52912. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52913. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  52914. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  52915. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  52916. /** @hidden */
  52917. export var pbrVertexShader: {
  52918. name: string;
  52919. shader: string;
  52920. };
  52921. }
  52922. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  52923. import { Nullable } from "babylonjs/types";
  52924. import { Scene } from "babylonjs/scene";
  52925. import { Matrix } from "babylonjs/Maths/math.vector";
  52926. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52928. import { Mesh } from "babylonjs/Meshes/mesh";
  52929. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  52930. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  52931. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  52932. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  52933. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  52934. import { Color3 } from "babylonjs/Maths/math.color";
  52935. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  52936. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  52937. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  52938. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52939. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52940. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52941. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  52942. import "babylonjs/Shaders/pbr.fragment";
  52943. import "babylonjs/Shaders/pbr.vertex";
  52944. /**
  52945. * Manages the defines for the PBR Material.
  52946. * @hidden
  52947. */
  52948. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  52949. PBR: boolean;
  52950. MAINUV1: boolean;
  52951. MAINUV2: boolean;
  52952. UV1: boolean;
  52953. UV2: boolean;
  52954. ALBEDO: boolean;
  52955. GAMMAALBEDO: boolean;
  52956. ALBEDODIRECTUV: number;
  52957. VERTEXCOLOR: boolean;
  52958. AMBIENT: boolean;
  52959. AMBIENTDIRECTUV: number;
  52960. AMBIENTINGRAYSCALE: boolean;
  52961. OPACITY: boolean;
  52962. VERTEXALPHA: boolean;
  52963. OPACITYDIRECTUV: number;
  52964. OPACITYRGB: boolean;
  52965. ALPHATEST: boolean;
  52966. DEPTHPREPASS: boolean;
  52967. ALPHABLEND: boolean;
  52968. ALPHAFROMALBEDO: boolean;
  52969. ALPHATESTVALUE: string;
  52970. SPECULAROVERALPHA: boolean;
  52971. RADIANCEOVERALPHA: boolean;
  52972. ALPHAFRESNEL: boolean;
  52973. LINEARALPHAFRESNEL: boolean;
  52974. PREMULTIPLYALPHA: boolean;
  52975. EMISSIVE: boolean;
  52976. EMISSIVEDIRECTUV: number;
  52977. REFLECTIVITY: boolean;
  52978. REFLECTIVITYDIRECTUV: number;
  52979. SPECULARTERM: boolean;
  52980. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  52981. MICROSURFACEAUTOMATIC: boolean;
  52982. LODBASEDMICROSFURACE: boolean;
  52983. MICROSURFACEMAP: boolean;
  52984. MICROSURFACEMAPDIRECTUV: number;
  52985. METALLICWORKFLOW: boolean;
  52986. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  52987. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  52988. METALLNESSSTOREINMETALMAPBLUE: boolean;
  52989. AOSTOREINMETALMAPRED: boolean;
  52990. METALLICF0FACTORFROMMETALLICMAP: boolean;
  52991. ENVIRONMENTBRDF: boolean;
  52992. ENVIRONMENTBRDF_RGBD: boolean;
  52993. NORMAL: boolean;
  52994. TANGENT: boolean;
  52995. BUMP: boolean;
  52996. BUMPDIRECTUV: number;
  52997. OBJECTSPACE_NORMALMAP: boolean;
  52998. PARALLAX: boolean;
  52999. PARALLAXOCCLUSION: boolean;
  53000. NORMALXYSCALE: boolean;
  53001. LIGHTMAP: boolean;
  53002. LIGHTMAPDIRECTUV: number;
  53003. USELIGHTMAPASSHADOWMAP: boolean;
  53004. GAMMALIGHTMAP: boolean;
  53005. RGBDLIGHTMAP: boolean;
  53006. REFLECTION: boolean;
  53007. REFLECTIONMAP_3D: boolean;
  53008. REFLECTIONMAP_SPHERICAL: boolean;
  53009. REFLECTIONMAP_PLANAR: boolean;
  53010. REFLECTIONMAP_CUBIC: boolean;
  53011. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53012. REFLECTIONMAP_PROJECTION: boolean;
  53013. REFLECTIONMAP_SKYBOX: boolean;
  53014. REFLECTIONMAP_EXPLICIT: boolean;
  53015. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53016. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53017. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53018. INVERTCUBICMAP: boolean;
  53019. USESPHERICALFROMREFLECTIONMAP: boolean;
  53020. USEIRRADIANCEMAP: boolean;
  53021. SPHERICAL_HARMONICS: boolean;
  53022. USESPHERICALINVERTEX: boolean;
  53023. REFLECTIONMAP_OPPOSITEZ: boolean;
  53024. LODINREFLECTIONALPHA: boolean;
  53025. GAMMAREFLECTION: boolean;
  53026. RGBDREFLECTION: boolean;
  53027. LINEARSPECULARREFLECTION: boolean;
  53028. RADIANCEOCCLUSION: boolean;
  53029. HORIZONOCCLUSION: boolean;
  53030. INSTANCES: boolean;
  53031. NUM_BONE_INFLUENCERS: number;
  53032. BonesPerMesh: number;
  53033. BONETEXTURE: boolean;
  53034. NONUNIFORMSCALING: boolean;
  53035. MORPHTARGETS: boolean;
  53036. MORPHTARGETS_NORMAL: boolean;
  53037. MORPHTARGETS_TANGENT: boolean;
  53038. MORPHTARGETS_UV: boolean;
  53039. NUM_MORPH_INFLUENCERS: number;
  53040. IMAGEPROCESSING: boolean;
  53041. VIGNETTE: boolean;
  53042. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53043. VIGNETTEBLENDMODEOPAQUE: boolean;
  53044. TONEMAPPING: boolean;
  53045. TONEMAPPING_ACES: boolean;
  53046. CONTRAST: boolean;
  53047. COLORCURVES: boolean;
  53048. COLORGRADING: boolean;
  53049. COLORGRADING3D: boolean;
  53050. SAMPLER3DGREENDEPTH: boolean;
  53051. SAMPLER3DBGRMAP: boolean;
  53052. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53053. EXPOSURE: boolean;
  53054. MULTIVIEW: boolean;
  53055. USEPHYSICALLIGHTFALLOFF: boolean;
  53056. USEGLTFLIGHTFALLOFF: boolean;
  53057. TWOSIDEDLIGHTING: boolean;
  53058. SHADOWFLOAT: boolean;
  53059. CLIPPLANE: boolean;
  53060. CLIPPLANE2: boolean;
  53061. CLIPPLANE3: boolean;
  53062. CLIPPLANE4: boolean;
  53063. CLIPPLANE5: boolean;
  53064. CLIPPLANE6: boolean;
  53065. POINTSIZE: boolean;
  53066. FOG: boolean;
  53067. LOGARITHMICDEPTH: boolean;
  53068. FORCENORMALFORWARD: boolean;
  53069. SPECULARAA: boolean;
  53070. CLEARCOAT: boolean;
  53071. CLEARCOAT_DEFAULTIOR: boolean;
  53072. CLEARCOAT_TEXTURE: boolean;
  53073. CLEARCOAT_TEXTUREDIRECTUV: number;
  53074. CLEARCOAT_BUMP: boolean;
  53075. CLEARCOAT_BUMPDIRECTUV: number;
  53076. CLEARCOAT_TINT: boolean;
  53077. CLEARCOAT_TINT_TEXTURE: boolean;
  53078. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53079. ANISOTROPIC: boolean;
  53080. ANISOTROPIC_TEXTURE: boolean;
  53081. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53082. BRDF_V_HEIGHT_CORRELATED: boolean;
  53083. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53084. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53085. SHEEN: boolean;
  53086. SHEEN_TEXTURE: boolean;
  53087. SHEEN_TEXTUREDIRECTUV: number;
  53088. SHEEN_LINKWITHALBEDO: boolean;
  53089. SUBSURFACE: boolean;
  53090. SS_REFRACTION: boolean;
  53091. SS_TRANSLUCENCY: boolean;
  53092. SS_SCATERRING: boolean;
  53093. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53094. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53095. SS_REFRACTIONMAP_3D: boolean;
  53096. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53097. SS_LODINREFRACTIONALPHA: boolean;
  53098. SS_GAMMAREFRACTION: boolean;
  53099. SS_RGBDREFRACTION: boolean;
  53100. SS_LINEARSPECULARREFRACTION: boolean;
  53101. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53102. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53103. UNLIT: boolean;
  53104. DEBUGMODE: number;
  53105. /**
  53106. * Initializes the PBR Material defines.
  53107. */
  53108. constructor();
  53109. /**
  53110. * Resets the PBR Material defines.
  53111. */
  53112. reset(): void;
  53113. }
  53114. /**
  53115. * The Physically based material base class of BJS.
  53116. *
  53117. * This offers the main features of a standard PBR material.
  53118. * For more information, please refer to the documentation :
  53119. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53120. */
  53121. export abstract class PBRBaseMaterial extends PushMaterial {
  53122. /**
  53123. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53124. */
  53125. static readonly PBRMATERIAL_OPAQUE: number;
  53126. /**
  53127. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53128. */
  53129. static readonly PBRMATERIAL_ALPHATEST: number;
  53130. /**
  53131. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53132. */
  53133. static readonly PBRMATERIAL_ALPHABLEND: number;
  53134. /**
  53135. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53136. * They are also discarded below the alpha cutoff threshold to improve performances.
  53137. */
  53138. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53139. /**
  53140. * Defines the default value of how much AO map is occluding the analytical lights
  53141. * (point spot...).
  53142. */
  53143. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53144. /**
  53145. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53146. */
  53147. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53148. /**
  53149. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53150. * to enhance interoperability with other engines.
  53151. */
  53152. static readonly LIGHTFALLOFF_GLTF: number;
  53153. /**
  53154. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53155. * to enhance interoperability with other materials.
  53156. */
  53157. static readonly LIGHTFALLOFF_STANDARD: number;
  53158. /**
  53159. * Intensity of the direct lights e.g. the four lights available in your scene.
  53160. * This impacts both the direct diffuse and specular highlights.
  53161. */
  53162. protected _directIntensity: number;
  53163. /**
  53164. * Intensity of the emissive part of the material.
  53165. * This helps controlling the emissive effect without modifying the emissive color.
  53166. */
  53167. protected _emissiveIntensity: number;
  53168. /**
  53169. * Intensity of the environment e.g. how much the environment will light the object
  53170. * either through harmonics for rough material or through the refelction for shiny ones.
  53171. */
  53172. protected _environmentIntensity: number;
  53173. /**
  53174. * This is a special control allowing the reduction of the specular highlights coming from the
  53175. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53176. */
  53177. protected _specularIntensity: number;
  53178. /**
  53179. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53180. */
  53181. private _lightingInfos;
  53182. /**
  53183. * Debug Control allowing disabling the bump map on this material.
  53184. */
  53185. protected _disableBumpMap: boolean;
  53186. /**
  53187. * AKA Diffuse Texture in standard nomenclature.
  53188. */
  53189. protected _albedoTexture: Nullable<BaseTexture>;
  53190. /**
  53191. * AKA Occlusion Texture in other nomenclature.
  53192. */
  53193. protected _ambientTexture: Nullable<BaseTexture>;
  53194. /**
  53195. * AKA Occlusion Texture Intensity in other nomenclature.
  53196. */
  53197. protected _ambientTextureStrength: number;
  53198. /**
  53199. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53200. * 1 means it completely occludes it
  53201. * 0 mean it has no impact
  53202. */
  53203. protected _ambientTextureImpactOnAnalyticalLights: number;
  53204. /**
  53205. * Stores the alpha values in a texture.
  53206. */
  53207. protected _opacityTexture: Nullable<BaseTexture>;
  53208. /**
  53209. * Stores the reflection values in a texture.
  53210. */
  53211. protected _reflectionTexture: Nullable<BaseTexture>;
  53212. /**
  53213. * Stores the emissive values in a texture.
  53214. */
  53215. protected _emissiveTexture: Nullable<BaseTexture>;
  53216. /**
  53217. * AKA Specular texture in other nomenclature.
  53218. */
  53219. protected _reflectivityTexture: Nullable<BaseTexture>;
  53220. /**
  53221. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53222. */
  53223. protected _metallicTexture: Nullable<BaseTexture>;
  53224. /**
  53225. * Specifies the metallic scalar of the metallic/roughness workflow.
  53226. * Can also be used to scale the metalness values of the metallic texture.
  53227. */
  53228. protected _metallic: Nullable<number>;
  53229. /**
  53230. * Specifies the roughness scalar of the metallic/roughness workflow.
  53231. * Can also be used to scale the roughness values of the metallic texture.
  53232. */
  53233. protected _roughness: Nullable<number>;
  53234. /**
  53235. * Specifies the an F0 factor to help configuring the material F0.
  53236. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53237. * to 0.5 the previously hard coded value stays the same.
  53238. * Can also be used to scale the F0 values of the metallic texture.
  53239. */
  53240. protected _metallicF0Factor: number;
  53241. /**
  53242. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53243. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53244. * your expectation as it multiplies with the texture data.
  53245. */
  53246. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53247. /**
  53248. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53249. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53250. */
  53251. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53252. /**
  53253. * Stores surface normal data used to displace a mesh in a texture.
  53254. */
  53255. protected _bumpTexture: Nullable<BaseTexture>;
  53256. /**
  53257. * Stores the pre-calculated light information of a mesh in a texture.
  53258. */
  53259. protected _lightmapTexture: Nullable<BaseTexture>;
  53260. /**
  53261. * The color of a material in ambient lighting.
  53262. */
  53263. protected _ambientColor: Color3;
  53264. /**
  53265. * AKA Diffuse Color in other nomenclature.
  53266. */
  53267. protected _albedoColor: Color3;
  53268. /**
  53269. * AKA Specular Color in other nomenclature.
  53270. */
  53271. protected _reflectivityColor: Color3;
  53272. /**
  53273. * The color applied when light is reflected from a material.
  53274. */
  53275. protected _reflectionColor: Color3;
  53276. /**
  53277. * The color applied when light is emitted from a material.
  53278. */
  53279. protected _emissiveColor: Color3;
  53280. /**
  53281. * AKA Glossiness in other nomenclature.
  53282. */
  53283. protected _microSurface: number;
  53284. /**
  53285. * Specifies that the material will use the light map as a show map.
  53286. */
  53287. protected _useLightmapAsShadowmap: boolean;
  53288. /**
  53289. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53290. * makes the reflect vector face the model (under horizon).
  53291. */
  53292. protected _useHorizonOcclusion: boolean;
  53293. /**
  53294. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53295. * too much the area relying on ambient texture to define their ambient occlusion.
  53296. */
  53297. protected _useRadianceOcclusion: boolean;
  53298. /**
  53299. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53300. */
  53301. protected _useAlphaFromAlbedoTexture: boolean;
  53302. /**
  53303. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53304. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53305. */
  53306. protected _useSpecularOverAlpha: boolean;
  53307. /**
  53308. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53309. */
  53310. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53311. /**
  53312. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53313. */
  53314. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53315. /**
  53316. * Specifies if the metallic texture contains the roughness information in its green channel.
  53317. */
  53318. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53319. /**
  53320. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53321. */
  53322. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53323. /**
  53324. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53325. */
  53326. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53327. /**
  53328. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53329. */
  53330. protected _useAmbientInGrayScale: boolean;
  53331. /**
  53332. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53333. * The material will try to infer what glossiness each pixel should be.
  53334. */
  53335. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53336. /**
  53337. * Defines the falloff type used in this material.
  53338. * It by default is Physical.
  53339. */
  53340. protected _lightFalloff: number;
  53341. /**
  53342. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53343. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53344. */
  53345. protected _useRadianceOverAlpha: boolean;
  53346. /**
  53347. * Allows using an object space normal map (instead of tangent space).
  53348. */
  53349. protected _useObjectSpaceNormalMap: boolean;
  53350. /**
  53351. * Allows using the bump map in parallax mode.
  53352. */
  53353. protected _useParallax: boolean;
  53354. /**
  53355. * Allows using the bump map in parallax occlusion mode.
  53356. */
  53357. protected _useParallaxOcclusion: boolean;
  53358. /**
  53359. * Controls the scale bias of the parallax mode.
  53360. */
  53361. protected _parallaxScaleBias: number;
  53362. /**
  53363. * If sets to true, disables all the lights affecting the material.
  53364. */
  53365. protected _disableLighting: boolean;
  53366. /**
  53367. * Number of Simultaneous lights allowed on the material.
  53368. */
  53369. protected _maxSimultaneousLights: number;
  53370. /**
  53371. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53372. */
  53373. protected _invertNormalMapX: boolean;
  53374. /**
  53375. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53376. */
  53377. protected _invertNormalMapY: boolean;
  53378. /**
  53379. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53380. */
  53381. protected _twoSidedLighting: boolean;
  53382. /**
  53383. * Defines the alpha limits in alpha test mode.
  53384. */
  53385. protected _alphaCutOff: number;
  53386. /**
  53387. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53388. */
  53389. protected _forceAlphaTest: boolean;
  53390. /**
  53391. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53392. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53393. */
  53394. protected _useAlphaFresnel: boolean;
  53395. /**
  53396. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53397. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53398. */
  53399. protected _useLinearAlphaFresnel: boolean;
  53400. /**
  53401. * The transparency mode of the material.
  53402. */
  53403. protected _transparencyMode: Nullable<number>;
  53404. /**
  53405. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53406. * from cos thetav and roughness:
  53407. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53408. */
  53409. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53410. /**
  53411. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53412. */
  53413. protected _forceIrradianceInFragment: boolean;
  53414. /**
  53415. * Force normal to face away from face.
  53416. */
  53417. protected _forceNormalForward: boolean;
  53418. /**
  53419. * Enables specular anti aliasing in the PBR shader.
  53420. * It will both interacts on the Geometry for analytical and IBL lighting.
  53421. * It also prefilter the roughness map based on the bump values.
  53422. */
  53423. protected _enableSpecularAntiAliasing: boolean;
  53424. /**
  53425. * Default configuration related to image processing available in the PBR Material.
  53426. */
  53427. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53428. /**
  53429. * Keep track of the image processing observer to allow dispose and replace.
  53430. */
  53431. private _imageProcessingObserver;
  53432. /**
  53433. * Attaches a new image processing configuration to the PBR Material.
  53434. * @param configuration
  53435. */
  53436. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53437. /**
  53438. * Stores the available render targets.
  53439. */
  53440. private _renderTargets;
  53441. /**
  53442. * Sets the global ambient color for the material used in lighting calculations.
  53443. */
  53444. private _globalAmbientColor;
  53445. /**
  53446. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53447. */
  53448. private _useLogarithmicDepth;
  53449. /**
  53450. * If set to true, no lighting calculations will be applied.
  53451. */
  53452. private _unlit;
  53453. private _debugMode;
  53454. /**
  53455. * @hidden
  53456. * This is reserved for the inspector.
  53457. * Defines the material debug mode.
  53458. * It helps seeing only some components of the material while troubleshooting.
  53459. */
  53460. debugMode: number;
  53461. /**
  53462. * @hidden
  53463. * This is reserved for the inspector.
  53464. * Specify from where on screen the debug mode should start.
  53465. * The value goes from -1 (full screen) to 1 (not visible)
  53466. * It helps with side by side comparison against the final render
  53467. * This defaults to -1
  53468. */
  53469. private debugLimit;
  53470. /**
  53471. * @hidden
  53472. * This is reserved for the inspector.
  53473. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53474. * You can use the factor to better multiply the final value.
  53475. */
  53476. private debugFactor;
  53477. /**
  53478. * Defines the clear coat layer parameters for the material.
  53479. */
  53480. readonly clearCoat: PBRClearCoatConfiguration;
  53481. /**
  53482. * Defines the anisotropic parameters for the material.
  53483. */
  53484. readonly anisotropy: PBRAnisotropicConfiguration;
  53485. /**
  53486. * Defines the BRDF parameters for the material.
  53487. */
  53488. readonly brdf: PBRBRDFConfiguration;
  53489. /**
  53490. * Defines the Sheen parameters for the material.
  53491. */
  53492. readonly sheen: PBRSheenConfiguration;
  53493. /**
  53494. * Defines the SubSurface parameters for the material.
  53495. */
  53496. readonly subSurface: PBRSubSurfaceConfiguration;
  53497. /**
  53498. * Custom callback helping to override the default shader used in the material.
  53499. */
  53500. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53501. protected _rebuildInParallel: boolean;
  53502. /**
  53503. * Instantiates a new PBRMaterial instance.
  53504. *
  53505. * @param name The material name
  53506. * @param scene The scene the material will be use in.
  53507. */
  53508. constructor(name: string, scene: Scene);
  53509. /**
  53510. * Gets a boolean indicating that current material needs to register RTT
  53511. */
  53512. get hasRenderTargetTextures(): boolean;
  53513. /**
  53514. * Gets the name of the material class.
  53515. */
  53516. getClassName(): string;
  53517. /**
  53518. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53519. */
  53520. get useLogarithmicDepth(): boolean;
  53521. /**
  53522. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53523. */
  53524. set useLogarithmicDepth(value: boolean);
  53525. /**
  53526. * Gets the current transparency mode.
  53527. */
  53528. get transparencyMode(): Nullable<number>;
  53529. /**
  53530. * Sets the transparency mode of the material.
  53531. *
  53532. * | Value | Type | Description |
  53533. * | ----- | ----------------------------------- | ----------- |
  53534. * | 0 | OPAQUE | |
  53535. * | 1 | ALPHATEST | |
  53536. * | 2 | ALPHABLEND | |
  53537. * | 3 | ALPHATESTANDBLEND | |
  53538. *
  53539. */
  53540. set transparencyMode(value: Nullable<number>);
  53541. /**
  53542. * Returns true if alpha blending should be disabled.
  53543. */
  53544. private get _disableAlphaBlending();
  53545. /**
  53546. * Specifies whether or not this material should be rendered in alpha blend mode.
  53547. */
  53548. needAlphaBlending(): boolean;
  53549. /**
  53550. * Specifies if the mesh will require alpha blending.
  53551. * @param mesh - BJS mesh.
  53552. */
  53553. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53554. /**
  53555. * Specifies whether or not this material should be rendered in alpha test mode.
  53556. */
  53557. needAlphaTesting(): boolean;
  53558. /**
  53559. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53560. */
  53561. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53562. /**
  53563. * Gets the texture used for the alpha test.
  53564. */
  53565. getAlphaTestTexture(): Nullable<BaseTexture>;
  53566. /**
  53567. * Specifies that the submesh is ready to be used.
  53568. * @param mesh - BJS mesh.
  53569. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53570. * @param useInstances - Specifies that instances should be used.
  53571. * @returns - boolean indicating that the submesh is ready or not.
  53572. */
  53573. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53574. /**
  53575. * Specifies if the material uses metallic roughness workflow.
  53576. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53577. */
  53578. isMetallicWorkflow(): boolean;
  53579. private _prepareEffect;
  53580. private _prepareDefines;
  53581. /**
  53582. * Force shader compilation
  53583. */
  53584. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53585. /**
  53586. * Initializes the uniform buffer layout for the shader.
  53587. */
  53588. buildUniformLayout(): void;
  53589. /**
  53590. * Unbinds the material from the mesh
  53591. */
  53592. unbind(): void;
  53593. /**
  53594. * Binds the submesh data.
  53595. * @param world - The world matrix.
  53596. * @param mesh - The BJS mesh.
  53597. * @param subMesh - A submesh of the BJS mesh.
  53598. */
  53599. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53600. /**
  53601. * Returns the animatable textures.
  53602. * @returns - Array of animatable textures.
  53603. */
  53604. getAnimatables(): IAnimatable[];
  53605. /**
  53606. * Returns the texture used for reflections.
  53607. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53608. */
  53609. private _getReflectionTexture;
  53610. /**
  53611. * Returns an array of the actively used textures.
  53612. * @returns - Array of BaseTextures
  53613. */
  53614. getActiveTextures(): BaseTexture[];
  53615. /**
  53616. * Checks to see if a texture is used in the material.
  53617. * @param texture - Base texture to use.
  53618. * @returns - Boolean specifying if a texture is used in the material.
  53619. */
  53620. hasTexture(texture: BaseTexture): boolean;
  53621. /**
  53622. * Disposes the resources of the material.
  53623. * @param forceDisposeEffect - Forces the disposal of effects.
  53624. * @param forceDisposeTextures - Forces the disposal of all textures.
  53625. */
  53626. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53627. }
  53628. }
  53629. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53630. import { Nullable } from "babylonjs/types";
  53631. import { Scene } from "babylonjs/scene";
  53632. import { Color3 } from "babylonjs/Maths/math.color";
  53633. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53634. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53635. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53636. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53637. /**
  53638. * The Physically based material of BJS.
  53639. *
  53640. * This offers the main features of a standard PBR material.
  53641. * For more information, please refer to the documentation :
  53642. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53643. */
  53644. export class PBRMaterial extends PBRBaseMaterial {
  53645. /**
  53646. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53647. */
  53648. static readonly PBRMATERIAL_OPAQUE: number;
  53649. /**
  53650. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53651. */
  53652. static readonly PBRMATERIAL_ALPHATEST: number;
  53653. /**
  53654. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53655. */
  53656. static readonly PBRMATERIAL_ALPHABLEND: number;
  53657. /**
  53658. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53659. * They are also discarded below the alpha cutoff threshold to improve performances.
  53660. */
  53661. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53662. /**
  53663. * Defines the default value of how much AO map is occluding the analytical lights
  53664. * (point spot...).
  53665. */
  53666. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53667. /**
  53668. * Intensity of the direct lights e.g. the four lights available in your scene.
  53669. * This impacts both the direct diffuse and specular highlights.
  53670. */
  53671. directIntensity: number;
  53672. /**
  53673. * Intensity of the emissive part of the material.
  53674. * This helps controlling the emissive effect without modifying the emissive color.
  53675. */
  53676. emissiveIntensity: number;
  53677. /**
  53678. * Intensity of the environment e.g. how much the environment will light the object
  53679. * either through harmonics for rough material or through the refelction for shiny ones.
  53680. */
  53681. environmentIntensity: number;
  53682. /**
  53683. * This is a special control allowing the reduction of the specular highlights coming from the
  53684. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53685. */
  53686. specularIntensity: number;
  53687. /**
  53688. * Debug Control allowing disabling the bump map on this material.
  53689. */
  53690. disableBumpMap: boolean;
  53691. /**
  53692. * AKA Diffuse Texture in standard nomenclature.
  53693. */
  53694. albedoTexture: BaseTexture;
  53695. /**
  53696. * AKA Occlusion Texture in other nomenclature.
  53697. */
  53698. ambientTexture: BaseTexture;
  53699. /**
  53700. * AKA Occlusion Texture Intensity in other nomenclature.
  53701. */
  53702. ambientTextureStrength: number;
  53703. /**
  53704. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53705. * 1 means it completely occludes it
  53706. * 0 mean it has no impact
  53707. */
  53708. ambientTextureImpactOnAnalyticalLights: number;
  53709. /**
  53710. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53711. */
  53712. opacityTexture: BaseTexture;
  53713. /**
  53714. * Stores the reflection values in a texture.
  53715. */
  53716. reflectionTexture: Nullable<BaseTexture>;
  53717. /**
  53718. * Stores the emissive values in a texture.
  53719. */
  53720. emissiveTexture: BaseTexture;
  53721. /**
  53722. * AKA Specular texture in other nomenclature.
  53723. */
  53724. reflectivityTexture: BaseTexture;
  53725. /**
  53726. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53727. */
  53728. metallicTexture: BaseTexture;
  53729. /**
  53730. * Specifies the metallic scalar of the metallic/roughness workflow.
  53731. * Can also be used to scale the metalness values of the metallic texture.
  53732. */
  53733. metallic: Nullable<number>;
  53734. /**
  53735. * Specifies the roughness scalar of the metallic/roughness workflow.
  53736. * Can also be used to scale the roughness values of the metallic texture.
  53737. */
  53738. roughness: Nullable<number>;
  53739. /**
  53740. * Specifies the an F0 factor to help configuring the material F0.
  53741. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53742. * to 0.5 the previously hard coded value stays the same.
  53743. * Can also be used to scale the F0 values of the metallic texture.
  53744. */
  53745. metallicF0Factor: number;
  53746. /**
  53747. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53748. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53749. * your expectation as it multiplies with the texture data.
  53750. */
  53751. useMetallicF0FactorFromMetallicTexture: boolean;
  53752. /**
  53753. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53754. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53755. */
  53756. microSurfaceTexture: BaseTexture;
  53757. /**
  53758. * Stores surface normal data used to displace a mesh in a texture.
  53759. */
  53760. bumpTexture: BaseTexture;
  53761. /**
  53762. * Stores the pre-calculated light information of a mesh in a texture.
  53763. */
  53764. lightmapTexture: BaseTexture;
  53765. /**
  53766. * Stores the refracted light information in a texture.
  53767. */
  53768. get refractionTexture(): Nullable<BaseTexture>;
  53769. set refractionTexture(value: Nullable<BaseTexture>);
  53770. /**
  53771. * The color of a material in ambient lighting.
  53772. */
  53773. ambientColor: Color3;
  53774. /**
  53775. * AKA Diffuse Color in other nomenclature.
  53776. */
  53777. albedoColor: Color3;
  53778. /**
  53779. * AKA Specular Color in other nomenclature.
  53780. */
  53781. reflectivityColor: Color3;
  53782. /**
  53783. * The color reflected from the material.
  53784. */
  53785. reflectionColor: Color3;
  53786. /**
  53787. * The color emitted from the material.
  53788. */
  53789. emissiveColor: Color3;
  53790. /**
  53791. * AKA Glossiness in other nomenclature.
  53792. */
  53793. microSurface: number;
  53794. /**
  53795. * source material index of refraction (IOR)' / 'destination material IOR.
  53796. */
  53797. get indexOfRefraction(): number;
  53798. set indexOfRefraction(value: number);
  53799. /**
  53800. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53801. */
  53802. get invertRefractionY(): boolean;
  53803. set invertRefractionY(value: boolean);
  53804. /**
  53805. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53806. * Materials half opaque for instance using refraction could benefit from this control.
  53807. */
  53808. get linkRefractionWithTransparency(): boolean;
  53809. set linkRefractionWithTransparency(value: boolean);
  53810. /**
  53811. * If true, the light map contains occlusion information instead of lighting info.
  53812. */
  53813. useLightmapAsShadowmap: boolean;
  53814. /**
  53815. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53816. */
  53817. useAlphaFromAlbedoTexture: boolean;
  53818. /**
  53819. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53820. */
  53821. forceAlphaTest: boolean;
  53822. /**
  53823. * Defines the alpha limits in alpha test mode.
  53824. */
  53825. alphaCutOff: number;
  53826. /**
  53827. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53828. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53829. */
  53830. useSpecularOverAlpha: boolean;
  53831. /**
  53832. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53833. */
  53834. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53835. /**
  53836. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53837. */
  53838. useRoughnessFromMetallicTextureAlpha: boolean;
  53839. /**
  53840. * Specifies if the metallic texture contains the roughness information in its green channel.
  53841. */
  53842. useRoughnessFromMetallicTextureGreen: boolean;
  53843. /**
  53844. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53845. */
  53846. useMetallnessFromMetallicTextureBlue: boolean;
  53847. /**
  53848. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53849. */
  53850. useAmbientOcclusionFromMetallicTextureRed: boolean;
  53851. /**
  53852. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53853. */
  53854. useAmbientInGrayScale: boolean;
  53855. /**
  53856. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53857. * The material will try to infer what glossiness each pixel should be.
  53858. */
  53859. useAutoMicroSurfaceFromReflectivityMap: boolean;
  53860. /**
  53861. * BJS is using an harcoded light falloff based on a manually sets up range.
  53862. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53863. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53864. */
  53865. get usePhysicalLightFalloff(): boolean;
  53866. /**
  53867. * BJS is using an harcoded light falloff based on a manually sets up range.
  53868. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53869. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53870. */
  53871. set usePhysicalLightFalloff(value: boolean);
  53872. /**
  53873. * In order to support the falloff compatibility with gltf, a special mode has been added
  53874. * to reproduce the gltf light falloff.
  53875. */
  53876. get useGLTFLightFalloff(): boolean;
  53877. /**
  53878. * In order to support the falloff compatibility with gltf, a special mode has been added
  53879. * to reproduce the gltf light falloff.
  53880. */
  53881. set useGLTFLightFalloff(value: boolean);
  53882. /**
  53883. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53884. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53885. */
  53886. useRadianceOverAlpha: boolean;
  53887. /**
  53888. * Allows using an object space normal map (instead of tangent space).
  53889. */
  53890. useObjectSpaceNormalMap: boolean;
  53891. /**
  53892. * Allows using the bump map in parallax mode.
  53893. */
  53894. useParallax: boolean;
  53895. /**
  53896. * Allows using the bump map in parallax occlusion mode.
  53897. */
  53898. useParallaxOcclusion: boolean;
  53899. /**
  53900. * Controls the scale bias of the parallax mode.
  53901. */
  53902. parallaxScaleBias: number;
  53903. /**
  53904. * If sets to true, disables all the lights affecting the material.
  53905. */
  53906. disableLighting: boolean;
  53907. /**
  53908. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53909. */
  53910. forceIrradianceInFragment: boolean;
  53911. /**
  53912. * Number of Simultaneous lights allowed on the material.
  53913. */
  53914. maxSimultaneousLights: number;
  53915. /**
  53916. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53917. */
  53918. invertNormalMapX: boolean;
  53919. /**
  53920. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53921. */
  53922. invertNormalMapY: boolean;
  53923. /**
  53924. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53925. */
  53926. twoSidedLighting: boolean;
  53927. /**
  53928. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53929. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53930. */
  53931. useAlphaFresnel: boolean;
  53932. /**
  53933. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53934. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53935. */
  53936. useLinearAlphaFresnel: boolean;
  53937. /**
  53938. * Let user defines the brdf lookup texture used for IBL.
  53939. * A default 8bit version is embedded but you could point at :
  53940. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  53941. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  53942. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  53943. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  53944. */
  53945. environmentBRDFTexture: Nullable<BaseTexture>;
  53946. /**
  53947. * Force normal to face away from face.
  53948. */
  53949. forceNormalForward: boolean;
  53950. /**
  53951. * Enables specular anti aliasing in the PBR shader.
  53952. * It will both interacts on the Geometry for analytical and IBL lighting.
  53953. * It also prefilter the roughness map based on the bump values.
  53954. */
  53955. enableSpecularAntiAliasing: boolean;
  53956. /**
  53957. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53958. * makes the reflect vector face the model (under horizon).
  53959. */
  53960. useHorizonOcclusion: boolean;
  53961. /**
  53962. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53963. * too much the area relying on ambient texture to define their ambient occlusion.
  53964. */
  53965. useRadianceOcclusion: boolean;
  53966. /**
  53967. * If set to true, no lighting calculations will be applied.
  53968. */
  53969. unlit: boolean;
  53970. /**
  53971. * Gets the image processing configuration used either in this material.
  53972. */
  53973. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  53974. /**
  53975. * Sets the Default image processing configuration used either in the this material.
  53976. *
  53977. * If sets to null, the scene one is in use.
  53978. */
  53979. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  53980. /**
  53981. * Gets wether the color curves effect is enabled.
  53982. */
  53983. get cameraColorCurvesEnabled(): boolean;
  53984. /**
  53985. * Sets wether the color curves effect is enabled.
  53986. */
  53987. set cameraColorCurvesEnabled(value: boolean);
  53988. /**
  53989. * Gets wether the color grading effect is enabled.
  53990. */
  53991. get cameraColorGradingEnabled(): boolean;
  53992. /**
  53993. * Gets wether the color grading effect is enabled.
  53994. */
  53995. set cameraColorGradingEnabled(value: boolean);
  53996. /**
  53997. * Gets wether tonemapping is enabled or not.
  53998. */
  53999. get cameraToneMappingEnabled(): boolean;
  54000. /**
  54001. * Sets wether tonemapping is enabled or not
  54002. */
  54003. set cameraToneMappingEnabled(value: boolean);
  54004. /**
  54005. * The camera exposure used on this material.
  54006. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54007. * This corresponds to a photographic exposure.
  54008. */
  54009. get cameraExposure(): number;
  54010. /**
  54011. * The camera exposure used on this material.
  54012. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54013. * This corresponds to a photographic exposure.
  54014. */
  54015. set cameraExposure(value: number);
  54016. /**
  54017. * Gets The camera contrast used on this material.
  54018. */
  54019. get cameraContrast(): number;
  54020. /**
  54021. * Sets The camera contrast used on this material.
  54022. */
  54023. set cameraContrast(value: number);
  54024. /**
  54025. * Gets the Color Grading 2D Lookup Texture.
  54026. */
  54027. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54028. /**
  54029. * Sets the Color Grading 2D Lookup Texture.
  54030. */
  54031. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54032. /**
  54033. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54034. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54035. * 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;
  54036. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54037. */
  54038. get cameraColorCurves(): Nullable<ColorCurves>;
  54039. /**
  54040. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54041. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54042. * 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;
  54043. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54044. */
  54045. set cameraColorCurves(value: Nullable<ColorCurves>);
  54046. /**
  54047. * Instantiates a new PBRMaterial instance.
  54048. *
  54049. * @param name The material name
  54050. * @param scene The scene the material will be use in.
  54051. */
  54052. constructor(name: string, scene: Scene);
  54053. /**
  54054. * Returns the name of this material class.
  54055. */
  54056. getClassName(): string;
  54057. /**
  54058. * Makes a duplicate of the current material.
  54059. * @param name - name to use for the new material.
  54060. */
  54061. clone(name: string): PBRMaterial;
  54062. /**
  54063. * Serializes this PBR Material.
  54064. * @returns - An object with the serialized material.
  54065. */
  54066. serialize(): any;
  54067. /**
  54068. * Parses a PBR Material from a serialized object.
  54069. * @param source - Serialized object.
  54070. * @param scene - BJS scene instance.
  54071. * @param rootUrl - url for the scene object
  54072. * @returns - PBRMaterial
  54073. */
  54074. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54075. }
  54076. }
  54077. declare module "babylonjs/Misc/dds" {
  54078. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54079. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54080. import { Nullable } from "babylonjs/types";
  54081. import { Scene } from "babylonjs/scene";
  54082. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54083. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54084. /**
  54085. * Direct draw surface info
  54086. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54087. */
  54088. export interface DDSInfo {
  54089. /**
  54090. * Width of the texture
  54091. */
  54092. width: number;
  54093. /**
  54094. * Width of the texture
  54095. */
  54096. height: number;
  54097. /**
  54098. * Number of Mipmaps for the texture
  54099. * @see https://en.wikipedia.org/wiki/Mipmap
  54100. */
  54101. mipmapCount: number;
  54102. /**
  54103. * If the textures format is a known fourCC format
  54104. * @see https://www.fourcc.org/
  54105. */
  54106. isFourCC: boolean;
  54107. /**
  54108. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54109. */
  54110. isRGB: boolean;
  54111. /**
  54112. * If the texture is a lumincance format
  54113. */
  54114. isLuminance: boolean;
  54115. /**
  54116. * If this is a cube texture
  54117. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54118. */
  54119. isCube: boolean;
  54120. /**
  54121. * If the texture is a compressed format eg. FOURCC_DXT1
  54122. */
  54123. isCompressed: boolean;
  54124. /**
  54125. * The dxgiFormat of the texture
  54126. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54127. */
  54128. dxgiFormat: number;
  54129. /**
  54130. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54131. */
  54132. textureType: number;
  54133. /**
  54134. * Sphericle polynomial created for the dds texture
  54135. */
  54136. sphericalPolynomial?: SphericalPolynomial;
  54137. }
  54138. /**
  54139. * Class used to provide DDS decompression tools
  54140. */
  54141. export class DDSTools {
  54142. /**
  54143. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54144. */
  54145. static StoreLODInAlphaChannel: boolean;
  54146. /**
  54147. * Gets DDS information from an array buffer
  54148. * @param data defines the array buffer view to read data from
  54149. * @returns the DDS information
  54150. */
  54151. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54152. private static _FloatView;
  54153. private static _Int32View;
  54154. private static _ToHalfFloat;
  54155. private static _FromHalfFloat;
  54156. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54157. private static _GetHalfFloatRGBAArrayBuffer;
  54158. private static _GetFloatRGBAArrayBuffer;
  54159. private static _GetFloatAsUIntRGBAArrayBuffer;
  54160. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54161. private static _GetRGBAArrayBuffer;
  54162. private static _ExtractLongWordOrder;
  54163. private static _GetRGBArrayBuffer;
  54164. private static _GetLuminanceArrayBuffer;
  54165. /**
  54166. * Uploads DDS Levels to a Babylon Texture
  54167. * @hidden
  54168. */
  54169. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54170. }
  54171. module "babylonjs/Engines/thinEngine" {
  54172. interface ThinEngine {
  54173. /**
  54174. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54175. * @param rootUrl defines the url where the file to load is located
  54176. * @param scene defines the current scene
  54177. * @param lodScale defines scale to apply to the mip map selection
  54178. * @param lodOffset defines offset to apply to the mip map selection
  54179. * @param onLoad defines an optional callback raised when the texture is loaded
  54180. * @param onError defines an optional callback raised if there is an issue to load the texture
  54181. * @param format defines the format of the data
  54182. * @param forcedExtension defines the extension to use to pick the right loader
  54183. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54184. * @returns the cube texture as an InternalTexture
  54185. */
  54186. 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;
  54187. }
  54188. }
  54189. }
  54190. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54191. import { Nullable } from "babylonjs/types";
  54192. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54193. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54194. /**
  54195. * Implementation of the DDS Texture Loader.
  54196. * @hidden
  54197. */
  54198. export class _DDSTextureLoader implements IInternalTextureLoader {
  54199. /**
  54200. * Defines wether the loader supports cascade loading the different faces.
  54201. */
  54202. readonly supportCascades: boolean;
  54203. /**
  54204. * This returns if the loader support the current file information.
  54205. * @param extension defines the file extension of the file being loaded
  54206. * @returns true if the loader can load the specified file
  54207. */
  54208. canLoad(extension: string): boolean;
  54209. /**
  54210. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54211. * @param data contains the texture data
  54212. * @param texture defines the BabylonJS internal texture
  54213. * @param createPolynomials will be true if polynomials have been requested
  54214. * @param onLoad defines the callback to trigger once the texture is ready
  54215. * @param onError defines the callback to trigger in case of error
  54216. */
  54217. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54218. /**
  54219. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54220. * @param data contains the texture data
  54221. * @param texture defines the BabylonJS internal texture
  54222. * @param callback defines the method to call once ready to upload
  54223. */
  54224. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54225. }
  54226. }
  54227. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54228. import { Nullable } from "babylonjs/types";
  54229. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54230. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54231. /**
  54232. * Implementation of the ENV Texture Loader.
  54233. * @hidden
  54234. */
  54235. export class _ENVTextureLoader implements IInternalTextureLoader {
  54236. /**
  54237. * Defines wether the loader supports cascade loading the different faces.
  54238. */
  54239. readonly supportCascades: boolean;
  54240. /**
  54241. * This returns if the loader support the current file information.
  54242. * @param extension defines the file extension of the file being loaded
  54243. * @returns true if the loader can load the specified file
  54244. */
  54245. canLoad(extension: string): boolean;
  54246. /**
  54247. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54248. * @param data contains the texture data
  54249. * @param texture defines the BabylonJS internal texture
  54250. * @param createPolynomials will be true if polynomials have been requested
  54251. * @param onLoad defines the callback to trigger once the texture is ready
  54252. * @param onError defines the callback to trigger in case of error
  54253. */
  54254. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54255. /**
  54256. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54257. * @param data contains the texture data
  54258. * @param texture defines the BabylonJS internal texture
  54259. * @param callback defines the method to call once ready to upload
  54260. */
  54261. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54262. }
  54263. }
  54264. declare module "babylonjs/Misc/khronosTextureContainer" {
  54265. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54266. /**
  54267. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54268. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54269. */
  54270. export class KhronosTextureContainer {
  54271. /** contents of the KTX container file */
  54272. data: ArrayBufferView;
  54273. private static HEADER_LEN;
  54274. private static COMPRESSED_2D;
  54275. private static COMPRESSED_3D;
  54276. private static TEX_2D;
  54277. private static TEX_3D;
  54278. /**
  54279. * Gets the openGL type
  54280. */
  54281. glType: number;
  54282. /**
  54283. * Gets the openGL type size
  54284. */
  54285. glTypeSize: number;
  54286. /**
  54287. * Gets the openGL format
  54288. */
  54289. glFormat: number;
  54290. /**
  54291. * Gets the openGL internal format
  54292. */
  54293. glInternalFormat: number;
  54294. /**
  54295. * Gets the base internal format
  54296. */
  54297. glBaseInternalFormat: number;
  54298. /**
  54299. * Gets image width in pixel
  54300. */
  54301. pixelWidth: number;
  54302. /**
  54303. * Gets image height in pixel
  54304. */
  54305. pixelHeight: number;
  54306. /**
  54307. * Gets image depth in pixels
  54308. */
  54309. pixelDepth: number;
  54310. /**
  54311. * Gets the number of array elements
  54312. */
  54313. numberOfArrayElements: number;
  54314. /**
  54315. * Gets the number of faces
  54316. */
  54317. numberOfFaces: number;
  54318. /**
  54319. * Gets the number of mipmap levels
  54320. */
  54321. numberOfMipmapLevels: number;
  54322. /**
  54323. * Gets the bytes of key value data
  54324. */
  54325. bytesOfKeyValueData: number;
  54326. /**
  54327. * Gets the load type
  54328. */
  54329. loadType: number;
  54330. /**
  54331. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54332. */
  54333. isInvalid: boolean;
  54334. /**
  54335. * Creates a new KhronosTextureContainer
  54336. * @param data contents of the KTX container file
  54337. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54338. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54339. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54340. */
  54341. constructor(
  54342. /** contents of the KTX container file */
  54343. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54344. /**
  54345. * Uploads KTX content to a Babylon Texture.
  54346. * It is assumed that the texture has already been created & is currently bound
  54347. * @hidden
  54348. */
  54349. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54350. private _upload2DCompressedLevels;
  54351. /**
  54352. * Checks if the given data starts with a KTX file identifier.
  54353. * @param data the data to check
  54354. * @returns true if the data is a KTX file or false otherwise
  54355. */
  54356. static IsValid(data: ArrayBufferView): boolean;
  54357. }
  54358. }
  54359. declare module "babylonjs/Misc/khronosTextureContainer2" {
  54360. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54361. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54362. /**
  54363. * Class for loading KTX2 files
  54364. * !!! Experimental Extension Subject to Changes !!!
  54365. * @hidden
  54366. */
  54367. export class KhronosTextureContainer2 {
  54368. private static _ModulePromise;
  54369. private static _TranscodeFormat;
  54370. constructor(engine: ThinEngine);
  54371. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  54372. private _determineTranscodeFormat;
  54373. /**
  54374. * Checks if the given data starts with a KTX2 file identifier.
  54375. * @param data the data to check
  54376. * @returns true if the data is a KTX2 file or false otherwise
  54377. */
  54378. static IsValid(data: ArrayBufferView): boolean;
  54379. }
  54380. }
  54381. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54382. import { Nullable } from "babylonjs/types";
  54383. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54384. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54385. /**
  54386. * Implementation of the KTX Texture Loader.
  54387. * @hidden
  54388. */
  54389. export class _KTXTextureLoader implements IInternalTextureLoader {
  54390. /**
  54391. * Defines wether the loader supports cascade loading the different faces.
  54392. */
  54393. readonly supportCascades: boolean;
  54394. /**
  54395. * This returns if the loader support the current file information.
  54396. * @param extension defines the file extension of the file being loaded
  54397. * @returns true if the loader can load the specified file
  54398. */
  54399. canLoad(extension: string): boolean;
  54400. /**
  54401. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54402. * @param data contains the texture data
  54403. * @param texture defines the BabylonJS internal texture
  54404. * @param createPolynomials will be true if polynomials have been requested
  54405. * @param onLoad defines the callback to trigger once the texture is ready
  54406. * @param onError defines the callback to trigger in case of error
  54407. */
  54408. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54409. /**
  54410. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54411. * @param data contains the texture data
  54412. * @param texture defines the BabylonJS internal texture
  54413. * @param callback defines the method to call once ready to upload
  54414. */
  54415. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54416. }
  54417. }
  54418. declare module "babylonjs/Helpers/sceneHelpers" {
  54419. import { Nullable } from "babylonjs/types";
  54420. import { Mesh } from "babylonjs/Meshes/mesh";
  54421. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54422. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54423. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54424. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54425. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54426. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54427. import "babylonjs/Meshes/Builders/boxBuilder";
  54428. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  54429. /** @hidden */
  54430. export var _forceSceneHelpersToBundle: boolean;
  54431. module "babylonjs/scene" {
  54432. interface Scene {
  54433. /**
  54434. * Creates a default light for the scene.
  54435. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54436. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54437. */
  54438. createDefaultLight(replace?: boolean): void;
  54439. /**
  54440. * Creates a default camera for the scene.
  54441. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54442. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54443. * @param replace has default false, when true replaces the active camera in the scene
  54444. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54445. */
  54446. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54447. /**
  54448. * Creates a default camera and a default light.
  54449. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54450. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54451. * @param replace has the default false, when true replaces the active camera/light in the scene
  54452. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54453. */
  54454. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54455. /**
  54456. * Creates a new sky box
  54457. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54458. * @param environmentTexture defines the texture to use as environment texture
  54459. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54460. * @param scale defines the overall scale of the skybox
  54461. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54462. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54463. * @returns a new mesh holding the sky box
  54464. */
  54465. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54466. /**
  54467. * Creates a new environment
  54468. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54469. * @param options defines the options you can use to configure the environment
  54470. * @returns the new EnvironmentHelper
  54471. */
  54472. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54473. /**
  54474. * Creates a new VREXperienceHelper
  54475. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54476. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54477. * @returns a new VREXperienceHelper
  54478. */
  54479. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54480. /**
  54481. * Creates a new WebXRDefaultExperience
  54482. * @see http://doc.babylonjs.com/how_to/webxr
  54483. * @param options experience options
  54484. * @returns a promise for a new WebXRDefaultExperience
  54485. */
  54486. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54487. }
  54488. }
  54489. }
  54490. declare module "babylonjs/Helpers/videoDome" {
  54491. import { Scene } from "babylonjs/scene";
  54492. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54493. import { Mesh } from "babylonjs/Meshes/mesh";
  54494. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54495. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54496. import "babylonjs/Meshes/Builders/sphereBuilder";
  54497. /**
  54498. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54499. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54500. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54501. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54502. */
  54503. export class VideoDome extends TransformNode {
  54504. /**
  54505. * Define the video source as a Monoscopic panoramic 360 video.
  54506. */
  54507. static readonly MODE_MONOSCOPIC: number;
  54508. /**
  54509. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54510. */
  54511. static readonly MODE_TOPBOTTOM: number;
  54512. /**
  54513. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54514. */
  54515. static readonly MODE_SIDEBYSIDE: number;
  54516. private _halfDome;
  54517. private _useDirectMapping;
  54518. /**
  54519. * The video texture being displayed on the sphere
  54520. */
  54521. protected _videoTexture: VideoTexture;
  54522. /**
  54523. * Gets the video texture being displayed on the sphere
  54524. */
  54525. get videoTexture(): VideoTexture;
  54526. /**
  54527. * The skybox material
  54528. */
  54529. protected _material: BackgroundMaterial;
  54530. /**
  54531. * The surface used for the skybox
  54532. */
  54533. protected _mesh: Mesh;
  54534. /**
  54535. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54536. */
  54537. private _halfDomeMask;
  54538. /**
  54539. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54540. * Also see the options.resolution property.
  54541. */
  54542. get fovMultiplier(): number;
  54543. set fovMultiplier(value: number);
  54544. private _videoMode;
  54545. /**
  54546. * Gets or set the current video mode for the video. It can be:
  54547. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54548. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54549. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54550. */
  54551. get videoMode(): number;
  54552. set videoMode(value: number);
  54553. /**
  54554. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54555. *
  54556. */
  54557. get halfDome(): boolean;
  54558. /**
  54559. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54560. */
  54561. set halfDome(enabled: boolean);
  54562. /**
  54563. * Oberserver used in Stereoscopic VR Mode.
  54564. */
  54565. private _onBeforeCameraRenderObserver;
  54566. /**
  54567. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54568. * @param name Element's name, child elements will append suffixes for their own names.
  54569. * @param urlsOrVideo defines the url(s) or the video element to use
  54570. * @param options An object containing optional or exposed sub element properties
  54571. */
  54572. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54573. resolution?: number;
  54574. clickToPlay?: boolean;
  54575. autoPlay?: boolean;
  54576. loop?: boolean;
  54577. size?: number;
  54578. poster?: string;
  54579. faceForward?: boolean;
  54580. useDirectMapping?: boolean;
  54581. halfDomeMode?: boolean;
  54582. }, scene: Scene);
  54583. private _changeVideoMode;
  54584. /**
  54585. * Releases resources associated with this node.
  54586. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54587. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54588. */
  54589. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54590. }
  54591. }
  54592. declare module "babylonjs/Helpers/index" {
  54593. export * from "babylonjs/Helpers/environmentHelper";
  54594. export * from "babylonjs/Helpers/photoDome";
  54595. export * from "babylonjs/Helpers/sceneHelpers";
  54596. export * from "babylonjs/Helpers/videoDome";
  54597. }
  54598. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54599. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54600. import { IDisposable } from "babylonjs/scene";
  54601. import { Engine } from "babylonjs/Engines/engine";
  54602. /**
  54603. * This class can be used to get instrumentation data from a Babylon engine
  54604. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54605. */
  54606. export class EngineInstrumentation implements IDisposable {
  54607. /**
  54608. * Define the instrumented engine.
  54609. */
  54610. engine: Engine;
  54611. private _captureGPUFrameTime;
  54612. private _gpuFrameTimeToken;
  54613. private _gpuFrameTime;
  54614. private _captureShaderCompilationTime;
  54615. private _shaderCompilationTime;
  54616. private _onBeginFrameObserver;
  54617. private _onEndFrameObserver;
  54618. private _onBeforeShaderCompilationObserver;
  54619. private _onAfterShaderCompilationObserver;
  54620. /**
  54621. * Gets the perf counter used for GPU frame time
  54622. */
  54623. get gpuFrameTimeCounter(): PerfCounter;
  54624. /**
  54625. * Gets the GPU frame time capture status
  54626. */
  54627. get captureGPUFrameTime(): boolean;
  54628. /**
  54629. * Enable or disable the GPU frame time capture
  54630. */
  54631. set captureGPUFrameTime(value: boolean);
  54632. /**
  54633. * Gets the perf counter used for shader compilation time
  54634. */
  54635. get shaderCompilationTimeCounter(): PerfCounter;
  54636. /**
  54637. * Gets the shader compilation time capture status
  54638. */
  54639. get captureShaderCompilationTime(): boolean;
  54640. /**
  54641. * Enable or disable the shader compilation time capture
  54642. */
  54643. set captureShaderCompilationTime(value: boolean);
  54644. /**
  54645. * Instantiates a new engine instrumentation.
  54646. * This class can be used to get instrumentation data from a Babylon engine
  54647. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54648. * @param engine Defines the engine to instrument
  54649. */
  54650. constructor(
  54651. /**
  54652. * Define the instrumented engine.
  54653. */
  54654. engine: Engine);
  54655. /**
  54656. * Dispose and release associated resources.
  54657. */
  54658. dispose(): void;
  54659. }
  54660. }
  54661. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54662. import { Scene, IDisposable } from "babylonjs/scene";
  54663. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54664. /**
  54665. * This class can be used to get instrumentation data from a Babylon engine
  54666. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54667. */
  54668. export class SceneInstrumentation implements IDisposable {
  54669. /**
  54670. * Defines the scene to instrument
  54671. */
  54672. scene: Scene;
  54673. private _captureActiveMeshesEvaluationTime;
  54674. private _activeMeshesEvaluationTime;
  54675. private _captureRenderTargetsRenderTime;
  54676. private _renderTargetsRenderTime;
  54677. private _captureFrameTime;
  54678. private _frameTime;
  54679. private _captureRenderTime;
  54680. private _renderTime;
  54681. private _captureInterFrameTime;
  54682. private _interFrameTime;
  54683. private _captureParticlesRenderTime;
  54684. private _particlesRenderTime;
  54685. private _captureSpritesRenderTime;
  54686. private _spritesRenderTime;
  54687. private _capturePhysicsTime;
  54688. private _physicsTime;
  54689. private _captureAnimationsTime;
  54690. private _animationsTime;
  54691. private _captureCameraRenderTime;
  54692. private _cameraRenderTime;
  54693. private _onBeforeActiveMeshesEvaluationObserver;
  54694. private _onAfterActiveMeshesEvaluationObserver;
  54695. private _onBeforeRenderTargetsRenderObserver;
  54696. private _onAfterRenderTargetsRenderObserver;
  54697. private _onAfterRenderObserver;
  54698. private _onBeforeDrawPhaseObserver;
  54699. private _onAfterDrawPhaseObserver;
  54700. private _onBeforeAnimationsObserver;
  54701. private _onBeforeParticlesRenderingObserver;
  54702. private _onAfterParticlesRenderingObserver;
  54703. private _onBeforeSpritesRenderingObserver;
  54704. private _onAfterSpritesRenderingObserver;
  54705. private _onBeforePhysicsObserver;
  54706. private _onAfterPhysicsObserver;
  54707. private _onAfterAnimationsObserver;
  54708. private _onBeforeCameraRenderObserver;
  54709. private _onAfterCameraRenderObserver;
  54710. /**
  54711. * Gets the perf counter used for active meshes evaluation time
  54712. */
  54713. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54714. /**
  54715. * Gets the active meshes evaluation time capture status
  54716. */
  54717. get captureActiveMeshesEvaluationTime(): boolean;
  54718. /**
  54719. * Enable or disable the active meshes evaluation time capture
  54720. */
  54721. set captureActiveMeshesEvaluationTime(value: boolean);
  54722. /**
  54723. * Gets the perf counter used for render targets render time
  54724. */
  54725. get renderTargetsRenderTimeCounter(): PerfCounter;
  54726. /**
  54727. * Gets the render targets render time capture status
  54728. */
  54729. get captureRenderTargetsRenderTime(): boolean;
  54730. /**
  54731. * Enable or disable the render targets render time capture
  54732. */
  54733. set captureRenderTargetsRenderTime(value: boolean);
  54734. /**
  54735. * Gets the perf counter used for particles render time
  54736. */
  54737. get particlesRenderTimeCounter(): PerfCounter;
  54738. /**
  54739. * Gets the particles render time capture status
  54740. */
  54741. get captureParticlesRenderTime(): boolean;
  54742. /**
  54743. * Enable or disable the particles render time capture
  54744. */
  54745. set captureParticlesRenderTime(value: boolean);
  54746. /**
  54747. * Gets the perf counter used for sprites render time
  54748. */
  54749. get spritesRenderTimeCounter(): PerfCounter;
  54750. /**
  54751. * Gets the sprites render time capture status
  54752. */
  54753. get captureSpritesRenderTime(): boolean;
  54754. /**
  54755. * Enable or disable the sprites render time capture
  54756. */
  54757. set captureSpritesRenderTime(value: boolean);
  54758. /**
  54759. * Gets the perf counter used for physics time
  54760. */
  54761. get physicsTimeCounter(): PerfCounter;
  54762. /**
  54763. * Gets the physics time capture status
  54764. */
  54765. get capturePhysicsTime(): boolean;
  54766. /**
  54767. * Enable or disable the physics time capture
  54768. */
  54769. set capturePhysicsTime(value: boolean);
  54770. /**
  54771. * Gets the perf counter used for animations time
  54772. */
  54773. get animationsTimeCounter(): PerfCounter;
  54774. /**
  54775. * Gets the animations time capture status
  54776. */
  54777. get captureAnimationsTime(): boolean;
  54778. /**
  54779. * Enable or disable the animations time capture
  54780. */
  54781. set captureAnimationsTime(value: boolean);
  54782. /**
  54783. * Gets the perf counter used for frame time capture
  54784. */
  54785. get frameTimeCounter(): PerfCounter;
  54786. /**
  54787. * Gets the frame time capture status
  54788. */
  54789. get captureFrameTime(): boolean;
  54790. /**
  54791. * Enable or disable the frame time capture
  54792. */
  54793. set captureFrameTime(value: boolean);
  54794. /**
  54795. * Gets the perf counter used for inter-frames time capture
  54796. */
  54797. get interFrameTimeCounter(): PerfCounter;
  54798. /**
  54799. * Gets the inter-frames time capture status
  54800. */
  54801. get captureInterFrameTime(): boolean;
  54802. /**
  54803. * Enable or disable the inter-frames time capture
  54804. */
  54805. set captureInterFrameTime(value: boolean);
  54806. /**
  54807. * Gets the perf counter used for render time capture
  54808. */
  54809. get renderTimeCounter(): PerfCounter;
  54810. /**
  54811. * Gets the render time capture status
  54812. */
  54813. get captureRenderTime(): boolean;
  54814. /**
  54815. * Enable or disable the render time capture
  54816. */
  54817. set captureRenderTime(value: boolean);
  54818. /**
  54819. * Gets the perf counter used for camera render time capture
  54820. */
  54821. get cameraRenderTimeCounter(): PerfCounter;
  54822. /**
  54823. * Gets the camera render time capture status
  54824. */
  54825. get captureCameraRenderTime(): boolean;
  54826. /**
  54827. * Enable or disable the camera render time capture
  54828. */
  54829. set captureCameraRenderTime(value: boolean);
  54830. /**
  54831. * Gets the perf counter used for draw calls
  54832. */
  54833. get drawCallsCounter(): PerfCounter;
  54834. /**
  54835. * Instantiates a new scene instrumentation.
  54836. * This class can be used to get instrumentation data from a Babylon engine
  54837. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54838. * @param scene Defines the scene to instrument
  54839. */
  54840. constructor(
  54841. /**
  54842. * Defines the scene to instrument
  54843. */
  54844. scene: Scene);
  54845. /**
  54846. * Dispose and release associated resources.
  54847. */
  54848. dispose(): void;
  54849. }
  54850. }
  54851. declare module "babylonjs/Instrumentation/index" {
  54852. export * from "babylonjs/Instrumentation/engineInstrumentation";
  54853. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  54854. export * from "babylonjs/Instrumentation/timeToken";
  54855. }
  54856. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  54857. /** @hidden */
  54858. export var glowMapGenerationPixelShader: {
  54859. name: string;
  54860. shader: string;
  54861. };
  54862. }
  54863. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  54864. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54865. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  54866. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  54867. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54868. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  54869. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54870. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54871. /** @hidden */
  54872. export var glowMapGenerationVertexShader: {
  54873. name: string;
  54874. shader: string;
  54875. };
  54876. }
  54877. declare module "babylonjs/Layers/effectLayer" {
  54878. import { Observable } from "babylonjs/Misc/observable";
  54879. import { Nullable } from "babylonjs/types";
  54880. import { Camera } from "babylonjs/Cameras/camera";
  54881. import { Scene } from "babylonjs/scene";
  54882. import { ISize } from "babylonjs/Maths/math.size";
  54883. import { Color4 } from "babylonjs/Maths/math.color";
  54884. import { Engine } from "babylonjs/Engines/engine";
  54885. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54887. import { Mesh } from "babylonjs/Meshes/mesh";
  54888. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54889. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54890. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54891. import { Effect } from "babylonjs/Materials/effect";
  54892. import { Material } from "babylonjs/Materials/material";
  54893. import "babylonjs/Shaders/glowMapGeneration.fragment";
  54894. import "babylonjs/Shaders/glowMapGeneration.vertex";
  54895. /**
  54896. * Effect layer options. This helps customizing the behaviour
  54897. * of the effect layer.
  54898. */
  54899. export interface IEffectLayerOptions {
  54900. /**
  54901. * Multiplication factor apply to the canvas size to compute the render target size
  54902. * used to generated the objects (the smaller the faster).
  54903. */
  54904. mainTextureRatio: number;
  54905. /**
  54906. * Enforces a fixed size texture to ensure effect stability across devices.
  54907. */
  54908. mainTextureFixedSize?: number;
  54909. /**
  54910. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  54911. */
  54912. alphaBlendingMode: number;
  54913. /**
  54914. * The camera attached to the layer.
  54915. */
  54916. camera: Nullable<Camera>;
  54917. /**
  54918. * The rendering group to draw the layer in.
  54919. */
  54920. renderingGroupId: number;
  54921. }
  54922. /**
  54923. * The effect layer Helps adding post process effect blended with the main pass.
  54924. *
  54925. * This can be for instance use to generate glow or higlight effects on the scene.
  54926. *
  54927. * The effect layer class can not be used directly and is intented to inherited from to be
  54928. * customized per effects.
  54929. */
  54930. export abstract class EffectLayer {
  54931. private _vertexBuffers;
  54932. private _indexBuffer;
  54933. private _cachedDefines;
  54934. private _effectLayerMapGenerationEffect;
  54935. private _effectLayerOptions;
  54936. private _mergeEffect;
  54937. protected _scene: Scene;
  54938. protected _engine: Engine;
  54939. protected _maxSize: number;
  54940. protected _mainTextureDesiredSize: ISize;
  54941. protected _mainTexture: RenderTargetTexture;
  54942. protected _shouldRender: boolean;
  54943. protected _postProcesses: PostProcess[];
  54944. protected _textures: BaseTexture[];
  54945. protected _emissiveTextureAndColor: {
  54946. texture: Nullable<BaseTexture>;
  54947. color: Color4;
  54948. };
  54949. /**
  54950. * The name of the layer
  54951. */
  54952. name: string;
  54953. /**
  54954. * The clear color of the texture used to generate the glow map.
  54955. */
  54956. neutralColor: Color4;
  54957. /**
  54958. * Specifies whether the highlight layer is enabled or not.
  54959. */
  54960. isEnabled: boolean;
  54961. /**
  54962. * Gets the camera attached to the layer.
  54963. */
  54964. get camera(): Nullable<Camera>;
  54965. /**
  54966. * Gets the rendering group id the layer should render in.
  54967. */
  54968. get renderingGroupId(): number;
  54969. set renderingGroupId(renderingGroupId: number);
  54970. /**
  54971. * An event triggered when the effect layer has been disposed.
  54972. */
  54973. onDisposeObservable: Observable<EffectLayer>;
  54974. /**
  54975. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  54976. */
  54977. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  54978. /**
  54979. * An event triggered when the generated texture is being merged in the scene.
  54980. */
  54981. onBeforeComposeObservable: Observable<EffectLayer>;
  54982. /**
  54983. * An event triggered when the mesh is rendered into the effect render target.
  54984. */
  54985. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  54986. /**
  54987. * An event triggered after the mesh has been rendered into the effect render target.
  54988. */
  54989. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  54990. /**
  54991. * An event triggered when the generated texture has been merged in the scene.
  54992. */
  54993. onAfterComposeObservable: Observable<EffectLayer>;
  54994. /**
  54995. * An event triggered when the efffect layer changes its size.
  54996. */
  54997. onSizeChangedObservable: Observable<EffectLayer>;
  54998. /** @hidden */
  54999. static _SceneComponentInitialization: (scene: Scene) => void;
  55000. /**
  55001. * Instantiates a new effect Layer and references it in the scene.
  55002. * @param name The name of the layer
  55003. * @param scene The scene to use the layer in
  55004. */
  55005. constructor(
  55006. /** The Friendly of the effect in the scene */
  55007. name: string, scene: Scene);
  55008. /**
  55009. * Get the effect name of the layer.
  55010. * @return The effect name
  55011. */
  55012. abstract getEffectName(): string;
  55013. /**
  55014. * Checks for the readiness of the element composing the layer.
  55015. * @param subMesh the mesh to check for
  55016. * @param useInstances specify whether or not to use instances to render the mesh
  55017. * @return true if ready otherwise, false
  55018. */
  55019. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55020. /**
  55021. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55022. * @returns true if the effect requires stencil during the main canvas render pass.
  55023. */
  55024. abstract needStencil(): boolean;
  55025. /**
  55026. * Create the merge effect. This is the shader use to blit the information back
  55027. * to the main canvas at the end of the scene rendering.
  55028. * @returns The effect containing the shader used to merge the effect on the main canvas
  55029. */
  55030. protected abstract _createMergeEffect(): Effect;
  55031. /**
  55032. * Creates the render target textures and post processes used in the effect layer.
  55033. */
  55034. protected abstract _createTextureAndPostProcesses(): void;
  55035. /**
  55036. * Implementation specific of rendering the generating effect on the main canvas.
  55037. * @param effect The effect used to render through
  55038. */
  55039. protected abstract _internalRender(effect: Effect): void;
  55040. /**
  55041. * Sets the required values for both the emissive texture and and the main color.
  55042. */
  55043. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55044. /**
  55045. * Free any resources and references associated to a mesh.
  55046. * Internal use
  55047. * @param mesh The mesh to free.
  55048. */
  55049. abstract _disposeMesh(mesh: Mesh): void;
  55050. /**
  55051. * Serializes this layer (Glow or Highlight for example)
  55052. * @returns a serialized layer object
  55053. */
  55054. abstract serialize?(): any;
  55055. /**
  55056. * Initializes the effect layer with the required options.
  55057. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55058. */
  55059. protected _init(options: Partial<IEffectLayerOptions>): void;
  55060. /**
  55061. * Generates the index buffer of the full screen quad blending to the main canvas.
  55062. */
  55063. private _generateIndexBuffer;
  55064. /**
  55065. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55066. */
  55067. private _generateVertexBuffer;
  55068. /**
  55069. * Sets the main texture desired size which is the closest power of two
  55070. * of the engine canvas size.
  55071. */
  55072. private _setMainTextureSize;
  55073. /**
  55074. * Creates the main texture for the effect layer.
  55075. */
  55076. protected _createMainTexture(): void;
  55077. /**
  55078. * Adds specific effects defines.
  55079. * @param defines The defines to add specifics to.
  55080. */
  55081. protected _addCustomEffectDefines(defines: string[]): void;
  55082. /**
  55083. * Checks for the readiness of the element composing the layer.
  55084. * @param subMesh the mesh to check for
  55085. * @param useInstances specify whether or not to use instances to render the mesh
  55086. * @param emissiveTexture the associated emissive texture used to generate the glow
  55087. * @return true if ready otherwise, false
  55088. */
  55089. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55090. /**
  55091. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55092. */
  55093. render(): void;
  55094. /**
  55095. * Determine if a given mesh will be used in the current effect.
  55096. * @param mesh mesh to test
  55097. * @returns true if the mesh will be used
  55098. */
  55099. hasMesh(mesh: AbstractMesh): boolean;
  55100. /**
  55101. * Returns true if the layer contains information to display, otherwise false.
  55102. * @returns true if the glow layer should be rendered
  55103. */
  55104. shouldRender(): boolean;
  55105. /**
  55106. * Returns true if the mesh should render, otherwise false.
  55107. * @param mesh The mesh to render
  55108. * @returns true if it should render otherwise false
  55109. */
  55110. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55111. /**
  55112. * Returns true if the mesh can be rendered, otherwise false.
  55113. * @param mesh The mesh to render
  55114. * @param material The material used on the mesh
  55115. * @returns true if it can be rendered otherwise false
  55116. */
  55117. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55118. /**
  55119. * Returns true if the mesh should render, otherwise false.
  55120. * @param mesh The mesh to render
  55121. * @returns true if it should render otherwise false
  55122. */
  55123. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55124. /**
  55125. * Renders the submesh passed in parameter to the generation map.
  55126. */
  55127. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55128. /**
  55129. * Defines whether the current material of the mesh should be use to render the effect.
  55130. * @param mesh defines the current mesh to render
  55131. */
  55132. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55133. /**
  55134. * Rebuild the required buffers.
  55135. * @hidden Internal use only.
  55136. */
  55137. _rebuild(): void;
  55138. /**
  55139. * Dispose only the render target textures and post process.
  55140. */
  55141. private _disposeTextureAndPostProcesses;
  55142. /**
  55143. * Dispose the highlight layer and free resources.
  55144. */
  55145. dispose(): void;
  55146. /**
  55147. * Gets the class name of the effect layer
  55148. * @returns the string with the class name of the effect layer
  55149. */
  55150. getClassName(): string;
  55151. /**
  55152. * Creates an effect layer from parsed effect layer data
  55153. * @param parsedEffectLayer defines effect layer data
  55154. * @param scene defines the current scene
  55155. * @param rootUrl defines the root URL containing the effect layer information
  55156. * @returns a parsed effect Layer
  55157. */
  55158. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55159. }
  55160. }
  55161. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55162. import { Scene } from "babylonjs/scene";
  55163. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55164. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55165. import { AbstractScene } from "babylonjs/abstractScene";
  55166. module "babylonjs/abstractScene" {
  55167. interface AbstractScene {
  55168. /**
  55169. * The list of effect layers (highlights/glow) added to the scene
  55170. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55171. * @see http://doc.babylonjs.com/how_to/glow_layer
  55172. */
  55173. effectLayers: Array<EffectLayer>;
  55174. /**
  55175. * Removes the given effect layer from this scene.
  55176. * @param toRemove defines the effect layer to remove
  55177. * @returns the index of the removed effect layer
  55178. */
  55179. removeEffectLayer(toRemove: EffectLayer): number;
  55180. /**
  55181. * Adds the given effect layer to this scene
  55182. * @param newEffectLayer defines the effect layer to add
  55183. */
  55184. addEffectLayer(newEffectLayer: EffectLayer): void;
  55185. }
  55186. }
  55187. /**
  55188. * Defines the layer scene component responsible to manage any effect layers
  55189. * in a given scene.
  55190. */
  55191. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55192. /**
  55193. * The component name helpfull to identify the component in the list of scene components.
  55194. */
  55195. readonly name: string;
  55196. /**
  55197. * The scene the component belongs to.
  55198. */
  55199. scene: Scene;
  55200. private _engine;
  55201. private _renderEffects;
  55202. private _needStencil;
  55203. private _previousStencilState;
  55204. /**
  55205. * Creates a new instance of the component for the given scene
  55206. * @param scene Defines the scene to register the component in
  55207. */
  55208. constructor(scene: Scene);
  55209. /**
  55210. * Registers the component in a given scene
  55211. */
  55212. register(): void;
  55213. /**
  55214. * Rebuilds the elements related to this component in case of
  55215. * context lost for instance.
  55216. */
  55217. rebuild(): void;
  55218. /**
  55219. * Serializes the component data to the specified json object
  55220. * @param serializationObject The object to serialize to
  55221. */
  55222. serialize(serializationObject: any): void;
  55223. /**
  55224. * Adds all the elements from the container to the scene
  55225. * @param container the container holding the elements
  55226. */
  55227. addFromContainer(container: AbstractScene): void;
  55228. /**
  55229. * Removes all the elements in the container from the scene
  55230. * @param container contains the elements to remove
  55231. * @param dispose if the removed element should be disposed (default: false)
  55232. */
  55233. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55234. /**
  55235. * Disposes the component and the associated ressources.
  55236. */
  55237. dispose(): void;
  55238. private _isReadyForMesh;
  55239. private _renderMainTexture;
  55240. private _setStencil;
  55241. private _setStencilBack;
  55242. private _draw;
  55243. private _drawCamera;
  55244. private _drawRenderingGroup;
  55245. }
  55246. }
  55247. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55248. /** @hidden */
  55249. export var glowMapMergePixelShader: {
  55250. name: string;
  55251. shader: string;
  55252. };
  55253. }
  55254. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55255. /** @hidden */
  55256. export var glowMapMergeVertexShader: {
  55257. name: string;
  55258. shader: string;
  55259. };
  55260. }
  55261. declare module "babylonjs/Layers/glowLayer" {
  55262. import { Nullable } from "babylonjs/types";
  55263. import { Camera } from "babylonjs/Cameras/camera";
  55264. import { Scene } from "babylonjs/scene";
  55265. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55266. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55267. import { Mesh } from "babylonjs/Meshes/mesh";
  55268. import { Texture } from "babylonjs/Materials/Textures/texture";
  55269. import { Effect } from "babylonjs/Materials/effect";
  55270. import { Material } from "babylonjs/Materials/material";
  55271. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55272. import { Color4 } from "babylonjs/Maths/math.color";
  55273. import "babylonjs/Shaders/glowMapMerge.fragment";
  55274. import "babylonjs/Shaders/glowMapMerge.vertex";
  55275. import "babylonjs/Layers/effectLayerSceneComponent";
  55276. module "babylonjs/abstractScene" {
  55277. interface AbstractScene {
  55278. /**
  55279. * Return a the first highlight layer of the scene with a given name.
  55280. * @param name The name of the highlight layer to look for.
  55281. * @return The highlight layer if found otherwise null.
  55282. */
  55283. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55284. }
  55285. }
  55286. /**
  55287. * Glow layer options. This helps customizing the behaviour
  55288. * of the glow layer.
  55289. */
  55290. export interface IGlowLayerOptions {
  55291. /**
  55292. * Multiplication factor apply to the canvas size to compute the render target size
  55293. * used to generated the glowing objects (the smaller the faster).
  55294. */
  55295. mainTextureRatio: number;
  55296. /**
  55297. * Enforces a fixed size texture to ensure resize independant blur.
  55298. */
  55299. mainTextureFixedSize?: number;
  55300. /**
  55301. * How big is the kernel of the blur texture.
  55302. */
  55303. blurKernelSize: number;
  55304. /**
  55305. * The camera attached to the layer.
  55306. */
  55307. camera: Nullable<Camera>;
  55308. /**
  55309. * Enable MSAA by chosing the number of samples.
  55310. */
  55311. mainTextureSamples?: number;
  55312. /**
  55313. * The rendering group to draw the layer in.
  55314. */
  55315. renderingGroupId: number;
  55316. }
  55317. /**
  55318. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55319. *
  55320. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55321. *
  55322. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55323. */
  55324. export class GlowLayer extends EffectLayer {
  55325. /**
  55326. * Effect Name of the layer.
  55327. */
  55328. static readonly EffectName: string;
  55329. /**
  55330. * The default blur kernel size used for the glow.
  55331. */
  55332. static DefaultBlurKernelSize: number;
  55333. /**
  55334. * The default texture size ratio used for the glow.
  55335. */
  55336. static DefaultTextureRatio: number;
  55337. /**
  55338. * Sets the kernel size of the blur.
  55339. */
  55340. set blurKernelSize(value: number);
  55341. /**
  55342. * Gets the kernel size of the blur.
  55343. */
  55344. get blurKernelSize(): number;
  55345. /**
  55346. * Sets the glow intensity.
  55347. */
  55348. set intensity(value: number);
  55349. /**
  55350. * Gets the glow intensity.
  55351. */
  55352. get intensity(): number;
  55353. private _options;
  55354. private _intensity;
  55355. private _horizontalBlurPostprocess1;
  55356. private _verticalBlurPostprocess1;
  55357. private _horizontalBlurPostprocess2;
  55358. private _verticalBlurPostprocess2;
  55359. private _blurTexture1;
  55360. private _blurTexture2;
  55361. private _postProcesses1;
  55362. private _postProcesses2;
  55363. private _includedOnlyMeshes;
  55364. private _excludedMeshes;
  55365. private _meshesUsingTheirOwnMaterials;
  55366. /**
  55367. * Callback used to let the user override the color selection on a per mesh basis
  55368. */
  55369. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55370. /**
  55371. * Callback used to let the user override the texture selection on a per mesh basis
  55372. */
  55373. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55374. /**
  55375. * Instantiates a new glow Layer and references it to the scene.
  55376. * @param name The name of the layer
  55377. * @param scene The scene to use the layer in
  55378. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55379. */
  55380. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55381. /**
  55382. * Get the effect name of the layer.
  55383. * @return The effect name
  55384. */
  55385. getEffectName(): string;
  55386. /**
  55387. * Create the merge effect. This is the shader use to blit the information back
  55388. * to the main canvas at the end of the scene rendering.
  55389. */
  55390. protected _createMergeEffect(): Effect;
  55391. /**
  55392. * Creates the render target textures and post processes used in the glow layer.
  55393. */
  55394. protected _createTextureAndPostProcesses(): void;
  55395. /**
  55396. * Checks for the readiness of the element composing the layer.
  55397. * @param subMesh the mesh to check for
  55398. * @param useInstances specify wether or not to use instances to render the mesh
  55399. * @param emissiveTexture the associated emissive texture used to generate the glow
  55400. * @return true if ready otherwise, false
  55401. */
  55402. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55403. /**
  55404. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55405. */
  55406. needStencil(): boolean;
  55407. /**
  55408. * Returns true if the mesh can be rendered, otherwise false.
  55409. * @param mesh The mesh to render
  55410. * @param material The material used on the mesh
  55411. * @returns true if it can be rendered otherwise false
  55412. */
  55413. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55414. /**
  55415. * Implementation specific of rendering the generating effect on the main canvas.
  55416. * @param effect The effect used to render through
  55417. */
  55418. protected _internalRender(effect: Effect): void;
  55419. /**
  55420. * Sets the required values for both the emissive texture and and the main color.
  55421. */
  55422. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55423. /**
  55424. * Returns true if the mesh should render, otherwise false.
  55425. * @param mesh The mesh to render
  55426. * @returns true if it should render otherwise false
  55427. */
  55428. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55429. /**
  55430. * Adds specific effects defines.
  55431. * @param defines The defines to add specifics to.
  55432. */
  55433. protected _addCustomEffectDefines(defines: string[]): void;
  55434. /**
  55435. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55436. * @param mesh The mesh to exclude from the glow layer
  55437. */
  55438. addExcludedMesh(mesh: Mesh): void;
  55439. /**
  55440. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55441. * @param mesh The mesh to remove
  55442. */
  55443. removeExcludedMesh(mesh: Mesh): void;
  55444. /**
  55445. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55446. * @param mesh The mesh to include in the glow layer
  55447. */
  55448. addIncludedOnlyMesh(mesh: Mesh): void;
  55449. /**
  55450. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55451. * @param mesh The mesh to remove
  55452. */
  55453. removeIncludedOnlyMesh(mesh: Mesh): void;
  55454. /**
  55455. * Determine if a given mesh will be used in the glow layer
  55456. * @param mesh The mesh to test
  55457. * @returns true if the mesh will be highlighted by the current glow layer
  55458. */
  55459. hasMesh(mesh: AbstractMesh): boolean;
  55460. /**
  55461. * Defines whether the current material of the mesh should be use to render the effect.
  55462. * @param mesh defines the current mesh to render
  55463. */
  55464. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55465. /**
  55466. * Add a mesh to be rendered through its own material and not with emissive only.
  55467. * @param mesh The mesh for which we need to use its material
  55468. */
  55469. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55470. /**
  55471. * Remove a mesh from being rendered through its own material and not with emissive only.
  55472. * @param mesh The mesh for which we need to not use its material
  55473. */
  55474. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55475. /**
  55476. * Free any resources and references associated to a mesh.
  55477. * Internal use
  55478. * @param mesh The mesh to free.
  55479. * @hidden
  55480. */
  55481. _disposeMesh(mesh: Mesh): void;
  55482. /**
  55483. * Gets the class name of the effect layer
  55484. * @returns the string with the class name of the effect layer
  55485. */
  55486. getClassName(): string;
  55487. /**
  55488. * Serializes this glow layer
  55489. * @returns a serialized glow layer object
  55490. */
  55491. serialize(): any;
  55492. /**
  55493. * Creates a Glow Layer from parsed glow layer data
  55494. * @param parsedGlowLayer defines glow layer data
  55495. * @param scene defines the current scene
  55496. * @param rootUrl defines the root URL containing the glow layer information
  55497. * @returns a parsed Glow Layer
  55498. */
  55499. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55500. }
  55501. }
  55502. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55503. /** @hidden */
  55504. export var glowBlurPostProcessPixelShader: {
  55505. name: string;
  55506. shader: string;
  55507. };
  55508. }
  55509. declare module "babylonjs/Layers/highlightLayer" {
  55510. import { Observable } from "babylonjs/Misc/observable";
  55511. import { Nullable } from "babylonjs/types";
  55512. import { Camera } from "babylonjs/Cameras/camera";
  55513. import { Scene } from "babylonjs/scene";
  55514. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55516. import { Mesh } from "babylonjs/Meshes/mesh";
  55517. import { Effect } from "babylonjs/Materials/effect";
  55518. import { Material } from "babylonjs/Materials/material";
  55519. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55520. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55521. import "babylonjs/Shaders/glowMapMerge.fragment";
  55522. import "babylonjs/Shaders/glowMapMerge.vertex";
  55523. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55524. module "babylonjs/abstractScene" {
  55525. interface AbstractScene {
  55526. /**
  55527. * Return a the first highlight layer of the scene with a given name.
  55528. * @param name The name of the highlight layer to look for.
  55529. * @return The highlight layer if found otherwise null.
  55530. */
  55531. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55532. }
  55533. }
  55534. /**
  55535. * Highlight layer options. This helps customizing the behaviour
  55536. * of the highlight layer.
  55537. */
  55538. export interface IHighlightLayerOptions {
  55539. /**
  55540. * Multiplication factor apply to the canvas size to compute the render target size
  55541. * used to generated the glowing objects (the smaller the faster).
  55542. */
  55543. mainTextureRatio: number;
  55544. /**
  55545. * Enforces a fixed size texture to ensure resize independant blur.
  55546. */
  55547. mainTextureFixedSize?: number;
  55548. /**
  55549. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55550. * of the picture to blur (the smaller the faster).
  55551. */
  55552. blurTextureSizeRatio: number;
  55553. /**
  55554. * How big in texel of the blur texture is the vertical blur.
  55555. */
  55556. blurVerticalSize: number;
  55557. /**
  55558. * How big in texel of the blur texture is the horizontal blur.
  55559. */
  55560. blurHorizontalSize: number;
  55561. /**
  55562. * Alpha blending mode used to apply the blur. Default is combine.
  55563. */
  55564. alphaBlendingMode: number;
  55565. /**
  55566. * The camera attached to the layer.
  55567. */
  55568. camera: Nullable<Camera>;
  55569. /**
  55570. * Should we display highlight as a solid stroke?
  55571. */
  55572. isStroke?: boolean;
  55573. /**
  55574. * The rendering group to draw the layer in.
  55575. */
  55576. renderingGroupId: number;
  55577. }
  55578. /**
  55579. * The highlight layer Helps adding a glow effect around a mesh.
  55580. *
  55581. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55582. * glowy meshes to your scene.
  55583. *
  55584. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55585. */
  55586. export class HighlightLayer extends EffectLayer {
  55587. name: string;
  55588. /**
  55589. * Effect Name of the highlight layer.
  55590. */
  55591. static readonly EffectName: string;
  55592. /**
  55593. * The neutral color used during the preparation of the glow effect.
  55594. * This is black by default as the blend operation is a blend operation.
  55595. */
  55596. static NeutralColor: Color4;
  55597. /**
  55598. * Stencil value used for glowing meshes.
  55599. */
  55600. static GlowingMeshStencilReference: number;
  55601. /**
  55602. * Stencil value used for the other meshes in the scene.
  55603. */
  55604. static NormalMeshStencilReference: number;
  55605. /**
  55606. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55607. */
  55608. innerGlow: boolean;
  55609. /**
  55610. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55611. */
  55612. outerGlow: boolean;
  55613. /**
  55614. * Specifies the horizontal size of the blur.
  55615. */
  55616. set blurHorizontalSize(value: number);
  55617. /**
  55618. * Specifies the vertical size of the blur.
  55619. */
  55620. set blurVerticalSize(value: number);
  55621. /**
  55622. * Gets the horizontal size of the blur.
  55623. */
  55624. get blurHorizontalSize(): number;
  55625. /**
  55626. * Gets the vertical size of the blur.
  55627. */
  55628. get blurVerticalSize(): number;
  55629. /**
  55630. * An event triggered when the highlight layer is being blurred.
  55631. */
  55632. onBeforeBlurObservable: Observable<HighlightLayer>;
  55633. /**
  55634. * An event triggered when the highlight layer has been blurred.
  55635. */
  55636. onAfterBlurObservable: Observable<HighlightLayer>;
  55637. private _instanceGlowingMeshStencilReference;
  55638. private _options;
  55639. private _downSamplePostprocess;
  55640. private _horizontalBlurPostprocess;
  55641. private _verticalBlurPostprocess;
  55642. private _blurTexture;
  55643. private _meshes;
  55644. private _excludedMeshes;
  55645. /**
  55646. * Instantiates a new highlight Layer and references it to the scene..
  55647. * @param name The name of the layer
  55648. * @param scene The scene to use the layer in
  55649. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55650. */
  55651. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55652. /**
  55653. * Get the effect name of the layer.
  55654. * @return The effect name
  55655. */
  55656. getEffectName(): string;
  55657. /**
  55658. * Create the merge effect. This is the shader use to blit the information back
  55659. * to the main canvas at the end of the scene rendering.
  55660. */
  55661. protected _createMergeEffect(): Effect;
  55662. /**
  55663. * Creates the render target textures and post processes used in the highlight layer.
  55664. */
  55665. protected _createTextureAndPostProcesses(): void;
  55666. /**
  55667. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55668. */
  55669. needStencil(): boolean;
  55670. /**
  55671. * Checks for the readiness of the element composing the layer.
  55672. * @param subMesh the mesh to check for
  55673. * @param useInstances specify wether or not to use instances to render the mesh
  55674. * @param emissiveTexture the associated emissive texture used to generate the glow
  55675. * @return true if ready otherwise, false
  55676. */
  55677. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55678. /**
  55679. * Implementation specific of rendering the generating effect on the main canvas.
  55680. * @param effect The effect used to render through
  55681. */
  55682. protected _internalRender(effect: Effect): void;
  55683. /**
  55684. * Returns true if the layer contains information to display, otherwise false.
  55685. */
  55686. shouldRender(): boolean;
  55687. /**
  55688. * Returns true if the mesh should render, otherwise false.
  55689. * @param mesh The mesh to render
  55690. * @returns true if it should render otherwise false
  55691. */
  55692. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55693. /**
  55694. * Sets the required values for both the emissive texture and and the main color.
  55695. */
  55696. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55697. /**
  55698. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55699. * @param mesh The mesh to exclude from the highlight layer
  55700. */
  55701. addExcludedMesh(mesh: Mesh): void;
  55702. /**
  55703. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55704. * @param mesh The mesh to highlight
  55705. */
  55706. removeExcludedMesh(mesh: Mesh): void;
  55707. /**
  55708. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55709. * @param mesh mesh to test
  55710. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55711. */
  55712. hasMesh(mesh: AbstractMesh): boolean;
  55713. /**
  55714. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55715. * @param mesh The mesh to highlight
  55716. * @param color The color of the highlight
  55717. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55718. */
  55719. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55720. /**
  55721. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55722. * @param mesh The mesh to highlight
  55723. */
  55724. removeMesh(mesh: Mesh): void;
  55725. /**
  55726. * Remove all the meshes currently referenced in the highlight layer
  55727. */
  55728. removeAllMeshes(): void;
  55729. /**
  55730. * Force the stencil to the normal expected value for none glowing parts
  55731. */
  55732. private _defaultStencilReference;
  55733. /**
  55734. * Free any resources and references associated to a mesh.
  55735. * Internal use
  55736. * @param mesh The mesh to free.
  55737. * @hidden
  55738. */
  55739. _disposeMesh(mesh: Mesh): void;
  55740. /**
  55741. * Dispose the highlight layer and free resources.
  55742. */
  55743. dispose(): void;
  55744. /**
  55745. * Gets the class name of the effect layer
  55746. * @returns the string with the class name of the effect layer
  55747. */
  55748. getClassName(): string;
  55749. /**
  55750. * Serializes this Highlight layer
  55751. * @returns a serialized Highlight layer object
  55752. */
  55753. serialize(): any;
  55754. /**
  55755. * Creates a Highlight layer from parsed Highlight layer data
  55756. * @param parsedHightlightLayer defines the Highlight layer data
  55757. * @param scene defines the current scene
  55758. * @param rootUrl defines the root URL containing the Highlight layer information
  55759. * @returns a parsed Highlight layer
  55760. */
  55761. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55762. }
  55763. }
  55764. declare module "babylonjs/Layers/layerSceneComponent" {
  55765. import { Scene } from "babylonjs/scene";
  55766. import { ISceneComponent } from "babylonjs/sceneComponent";
  55767. import { Layer } from "babylonjs/Layers/layer";
  55768. import { AbstractScene } from "babylonjs/abstractScene";
  55769. module "babylonjs/abstractScene" {
  55770. interface AbstractScene {
  55771. /**
  55772. * The list of layers (background and foreground) of the scene
  55773. */
  55774. layers: Array<Layer>;
  55775. }
  55776. }
  55777. /**
  55778. * Defines the layer scene component responsible to manage any layers
  55779. * in a given scene.
  55780. */
  55781. export class LayerSceneComponent implements ISceneComponent {
  55782. /**
  55783. * The component name helpfull to identify the component in the list of scene components.
  55784. */
  55785. readonly name: string;
  55786. /**
  55787. * The scene the component belongs to.
  55788. */
  55789. scene: Scene;
  55790. private _engine;
  55791. /**
  55792. * Creates a new instance of the component for the given scene
  55793. * @param scene Defines the scene to register the component in
  55794. */
  55795. constructor(scene: Scene);
  55796. /**
  55797. * Registers the component in a given scene
  55798. */
  55799. register(): void;
  55800. /**
  55801. * Rebuilds the elements related to this component in case of
  55802. * context lost for instance.
  55803. */
  55804. rebuild(): void;
  55805. /**
  55806. * Disposes the component and the associated ressources.
  55807. */
  55808. dispose(): void;
  55809. private _draw;
  55810. private _drawCameraPredicate;
  55811. private _drawCameraBackground;
  55812. private _drawCameraForeground;
  55813. private _drawRenderTargetPredicate;
  55814. private _drawRenderTargetBackground;
  55815. private _drawRenderTargetForeground;
  55816. /**
  55817. * Adds all the elements from the container to the scene
  55818. * @param container the container holding the elements
  55819. */
  55820. addFromContainer(container: AbstractScene): void;
  55821. /**
  55822. * Removes all the elements in the container from the scene
  55823. * @param container contains the elements to remove
  55824. * @param dispose if the removed element should be disposed (default: false)
  55825. */
  55826. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55827. }
  55828. }
  55829. declare module "babylonjs/Shaders/layer.fragment" {
  55830. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55831. /** @hidden */
  55832. export var layerPixelShader: {
  55833. name: string;
  55834. shader: string;
  55835. };
  55836. }
  55837. declare module "babylonjs/Shaders/layer.vertex" {
  55838. /** @hidden */
  55839. export var layerVertexShader: {
  55840. name: string;
  55841. shader: string;
  55842. };
  55843. }
  55844. declare module "babylonjs/Layers/layer" {
  55845. import { Observable } from "babylonjs/Misc/observable";
  55846. import { Nullable } from "babylonjs/types";
  55847. import { Scene } from "babylonjs/scene";
  55848. import { Vector2 } from "babylonjs/Maths/math.vector";
  55849. import { Color4 } from "babylonjs/Maths/math.color";
  55850. import { Texture } from "babylonjs/Materials/Textures/texture";
  55851. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55852. import "babylonjs/Shaders/layer.fragment";
  55853. import "babylonjs/Shaders/layer.vertex";
  55854. /**
  55855. * This represents a full screen 2d layer.
  55856. * This can be useful to display a picture in the background of your scene for instance.
  55857. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55858. */
  55859. export class Layer {
  55860. /**
  55861. * Define the name of the layer.
  55862. */
  55863. name: string;
  55864. /**
  55865. * Define the texture the layer should display.
  55866. */
  55867. texture: Nullable<Texture>;
  55868. /**
  55869. * Is the layer in background or foreground.
  55870. */
  55871. isBackground: boolean;
  55872. /**
  55873. * Define the color of the layer (instead of texture).
  55874. */
  55875. color: Color4;
  55876. /**
  55877. * Define the scale of the layer in order to zoom in out of the texture.
  55878. */
  55879. scale: Vector2;
  55880. /**
  55881. * Define an offset for the layer in order to shift the texture.
  55882. */
  55883. offset: Vector2;
  55884. /**
  55885. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  55886. */
  55887. alphaBlendingMode: number;
  55888. /**
  55889. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  55890. * Alpha test will not mix with the background color in case of transparency.
  55891. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  55892. */
  55893. alphaTest: boolean;
  55894. /**
  55895. * Define a mask to restrict the layer to only some of the scene cameras.
  55896. */
  55897. layerMask: number;
  55898. /**
  55899. * Define the list of render target the layer is visible into.
  55900. */
  55901. renderTargetTextures: RenderTargetTexture[];
  55902. /**
  55903. * Define if the layer is only used in renderTarget or if it also
  55904. * renders in the main frame buffer of the canvas.
  55905. */
  55906. renderOnlyInRenderTargetTextures: boolean;
  55907. private _scene;
  55908. private _vertexBuffers;
  55909. private _indexBuffer;
  55910. private _effect;
  55911. private _previousDefines;
  55912. /**
  55913. * An event triggered when the layer is disposed.
  55914. */
  55915. onDisposeObservable: Observable<Layer>;
  55916. private _onDisposeObserver;
  55917. /**
  55918. * Back compatibility with callback before the onDisposeObservable existed.
  55919. * The set callback will be triggered when the layer has been disposed.
  55920. */
  55921. set onDispose(callback: () => void);
  55922. /**
  55923. * An event triggered before rendering the scene
  55924. */
  55925. onBeforeRenderObservable: Observable<Layer>;
  55926. private _onBeforeRenderObserver;
  55927. /**
  55928. * Back compatibility with callback before the onBeforeRenderObservable existed.
  55929. * The set callback will be triggered just before rendering the layer.
  55930. */
  55931. set onBeforeRender(callback: () => void);
  55932. /**
  55933. * An event triggered after rendering the scene
  55934. */
  55935. onAfterRenderObservable: Observable<Layer>;
  55936. private _onAfterRenderObserver;
  55937. /**
  55938. * Back compatibility with callback before the onAfterRenderObservable existed.
  55939. * The set callback will be triggered just after rendering the layer.
  55940. */
  55941. set onAfterRender(callback: () => void);
  55942. /**
  55943. * Instantiates a new layer.
  55944. * This represents a full screen 2d layer.
  55945. * This can be useful to display a picture in the background of your scene for instance.
  55946. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55947. * @param name Define the name of the layer in the scene
  55948. * @param imgUrl Define the url of the texture to display in the layer
  55949. * @param scene Define the scene the layer belongs to
  55950. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  55951. * @param color Defines a color for the layer
  55952. */
  55953. constructor(
  55954. /**
  55955. * Define the name of the layer.
  55956. */
  55957. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  55958. private _createIndexBuffer;
  55959. /** @hidden */
  55960. _rebuild(): void;
  55961. /**
  55962. * Renders the layer in the scene.
  55963. */
  55964. render(): void;
  55965. /**
  55966. * Disposes and releases the associated ressources.
  55967. */
  55968. dispose(): void;
  55969. }
  55970. }
  55971. declare module "babylonjs/Layers/index" {
  55972. export * from "babylonjs/Layers/effectLayer";
  55973. export * from "babylonjs/Layers/effectLayerSceneComponent";
  55974. export * from "babylonjs/Layers/glowLayer";
  55975. export * from "babylonjs/Layers/highlightLayer";
  55976. export * from "babylonjs/Layers/layer";
  55977. export * from "babylonjs/Layers/layerSceneComponent";
  55978. }
  55979. declare module "babylonjs/Shaders/lensFlare.fragment" {
  55980. /** @hidden */
  55981. export var lensFlarePixelShader: {
  55982. name: string;
  55983. shader: string;
  55984. };
  55985. }
  55986. declare module "babylonjs/Shaders/lensFlare.vertex" {
  55987. /** @hidden */
  55988. export var lensFlareVertexShader: {
  55989. name: string;
  55990. shader: string;
  55991. };
  55992. }
  55993. declare module "babylonjs/LensFlares/lensFlareSystem" {
  55994. import { Scene } from "babylonjs/scene";
  55995. import { Vector3 } from "babylonjs/Maths/math.vector";
  55996. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55997. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  55998. import "babylonjs/Shaders/lensFlare.fragment";
  55999. import "babylonjs/Shaders/lensFlare.vertex";
  56000. import { Viewport } from "babylonjs/Maths/math.viewport";
  56001. /**
  56002. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56003. * It is usually composed of several `lensFlare`.
  56004. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56005. */
  56006. export class LensFlareSystem {
  56007. /**
  56008. * Define the name of the lens flare system
  56009. */
  56010. name: string;
  56011. /**
  56012. * List of lens flares used in this system.
  56013. */
  56014. lensFlares: LensFlare[];
  56015. /**
  56016. * Define a limit from the border the lens flare can be visible.
  56017. */
  56018. borderLimit: number;
  56019. /**
  56020. * Define a viewport border we do not want to see the lens flare in.
  56021. */
  56022. viewportBorder: number;
  56023. /**
  56024. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56025. */
  56026. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56027. /**
  56028. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56029. */
  56030. layerMask: number;
  56031. /**
  56032. * Define the id of the lens flare system in the scene.
  56033. * (equal to name by default)
  56034. */
  56035. id: string;
  56036. private _scene;
  56037. private _emitter;
  56038. private _vertexBuffers;
  56039. private _indexBuffer;
  56040. private _effect;
  56041. private _positionX;
  56042. private _positionY;
  56043. private _isEnabled;
  56044. /** @hidden */
  56045. static _SceneComponentInitialization: (scene: Scene) => void;
  56046. /**
  56047. * Instantiates a lens flare system.
  56048. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56049. * It is usually composed of several `lensFlare`.
  56050. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56051. * @param name Define the name of the lens flare system in the scene
  56052. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56053. * @param scene Define the scene the lens flare system belongs to
  56054. */
  56055. constructor(
  56056. /**
  56057. * Define the name of the lens flare system
  56058. */
  56059. name: string, emitter: any, scene: Scene);
  56060. /**
  56061. * Define if the lens flare system is enabled.
  56062. */
  56063. get isEnabled(): boolean;
  56064. set isEnabled(value: boolean);
  56065. /**
  56066. * Get the scene the effects belongs to.
  56067. * @returns the scene holding the lens flare system
  56068. */
  56069. getScene(): Scene;
  56070. /**
  56071. * Get the emitter of the lens flare system.
  56072. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56073. * @returns the emitter of the lens flare system
  56074. */
  56075. getEmitter(): any;
  56076. /**
  56077. * Set the emitter of the lens flare system.
  56078. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56079. * @param newEmitter Define the new emitter of the system
  56080. */
  56081. setEmitter(newEmitter: any): void;
  56082. /**
  56083. * Get the lens flare system emitter position.
  56084. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56085. * @returns the position
  56086. */
  56087. getEmitterPosition(): Vector3;
  56088. /**
  56089. * @hidden
  56090. */
  56091. computeEffectivePosition(globalViewport: Viewport): boolean;
  56092. /** @hidden */
  56093. _isVisible(): boolean;
  56094. /**
  56095. * @hidden
  56096. */
  56097. render(): boolean;
  56098. /**
  56099. * Dispose and release the lens flare with its associated resources.
  56100. */
  56101. dispose(): void;
  56102. /**
  56103. * Parse a lens flare system from a JSON repressentation
  56104. * @param parsedLensFlareSystem Define the JSON to parse
  56105. * @param scene Define the scene the parsed system should be instantiated in
  56106. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56107. * @returns the parsed system
  56108. */
  56109. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56110. /**
  56111. * Serialize the current Lens Flare System into a JSON representation.
  56112. * @returns the serialized JSON
  56113. */
  56114. serialize(): any;
  56115. }
  56116. }
  56117. declare module "babylonjs/LensFlares/lensFlare" {
  56118. import { Nullable } from "babylonjs/types";
  56119. import { Color3 } from "babylonjs/Maths/math.color";
  56120. import { Texture } from "babylonjs/Materials/Textures/texture";
  56121. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56122. /**
  56123. * This represents one of the lens effect in a `lensFlareSystem`.
  56124. * It controls one of the indiviual texture used in the effect.
  56125. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56126. */
  56127. export class LensFlare {
  56128. /**
  56129. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56130. */
  56131. size: number;
  56132. /**
  56133. * 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.
  56134. */
  56135. position: number;
  56136. /**
  56137. * Define the lens color.
  56138. */
  56139. color: Color3;
  56140. /**
  56141. * Define the lens texture.
  56142. */
  56143. texture: Nullable<Texture>;
  56144. /**
  56145. * Define the alpha mode to render this particular lens.
  56146. */
  56147. alphaMode: number;
  56148. private _system;
  56149. /**
  56150. * Creates a new Lens Flare.
  56151. * This represents one of the lens effect in a `lensFlareSystem`.
  56152. * It controls one of the indiviual texture used in the effect.
  56153. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56154. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56155. * @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.
  56156. * @param color Define the lens color
  56157. * @param imgUrl Define the lens texture url
  56158. * @param system Define the `lensFlareSystem` this flare is part of
  56159. * @returns The newly created Lens Flare
  56160. */
  56161. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56162. /**
  56163. * Instantiates a new Lens Flare.
  56164. * This represents one of the lens effect in a `lensFlareSystem`.
  56165. * It controls one of the indiviual texture used in the effect.
  56166. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56167. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56168. * @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.
  56169. * @param color Define the lens color
  56170. * @param imgUrl Define the lens texture url
  56171. * @param system Define the `lensFlareSystem` this flare is part of
  56172. */
  56173. constructor(
  56174. /**
  56175. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56176. */
  56177. size: number,
  56178. /**
  56179. * 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.
  56180. */
  56181. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56182. /**
  56183. * Dispose and release the lens flare with its associated resources.
  56184. */
  56185. dispose(): void;
  56186. }
  56187. }
  56188. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56189. import { Nullable } from "babylonjs/types";
  56190. import { Scene } from "babylonjs/scene";
  56191. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56192. import { AbstractScene } from "babylonjs/abstractScene";
  56193. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56194. module "babylonjs/abstractScene" {
  56195. interface AbstractScene {
  56196. /**
  56197. * The list of lens flare system added to the scene
  56198. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56199. */
  56200. lensFlareSystems: Array<LensFlareSystem>;
  56201. /**
  56202. * Removes the given lens flare system from this scene.
  56203. * @param toRemove The lens flare system to remove
  56204. * @returns The index of the removed lens flare system
  56205. */
  56206. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56207. /**
  56208. * Adds the given lens flare system to this scene
  56209. * @param newLensFlareSystem The lens flare system to add
  56210. */
  56211. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56212. /**
  56213. * Gets a lens flare system using its name
  56214. * @param name defines the name to look for
  56215. * @returns the lens flare system or null if not found
  56216. */
  56217. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56218. /**
  56219. * Gets a lens flare system using its id
  56220. * @param id defines the id to look for
  56221. * @returns the lens flare system or null if not found
  56222. */
  56223. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56224. }
  56225. }
  56226. /**
  56227. * Defines the lens flare scene component responsible to manage any lens flares
  56228. * in a given scene.
  56229. */
  56230. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56231. /**
  56232. * The component name helpfull to identify the component in the list of scene components.
  56233. */
  56234. readonly name: string;
  56235. /**
  56236. * The scene the component belongs to.
  56237. */
  56238. scene: Scene;
  56239. /**
  56240. * Creates a new instance of the component for the given scene
  56241. * @param scene Defines the scene to register the component in
  56242. */
  56243. constructor(scene: Scene);
  56244. /**
  56245. * Registers the component in a given scene
  56246. */
  56247. register(): void;
  56248. /**
  56249. * Rebuilds the elements related to this component in case of
  56250. * context lost for instance.
  56251. */
  56252. rebuild(): void;
  56253. /**
  56254. * Adds all the elements from the container to the scene
  56255. * @param container the container holding the elements
  56256. */
  56257. addFromContainer(container: AbstractScene): void;
  56258. /**
  56259. * Removes all the elements in the container from the scene
  56260. * @param container contains the elements to remove
  56261. * @param dispose if the removed element should be disposed (default: false)
  56262. */
  56263. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56264. /**
  56265. * Serializes the component data to the specified json object
  56266. * @param serializationObject The object to serialize to
  56267. */
  56268. serialize(serializationObject: any): void;
  56269. /**
  56270. * Disposes the component and the associated ressources.
  56271. */
  56272. dispose(): void;
  56273. private _draw;
  56274. }
  56275. }
  56276. declare module "babylonjs/LensFlares/index" {
  56277. export * from "babylonjs/LensFlares/lensFlare";
  56278. export * from "babylonjs/LensFlares/lensFlareSystem";
  56279. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56280. }
  56281. declare module "babylonjs/Shaders/depth.fragment" {
  56282. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56283. /** @hidden */
  56284. export var depthPixelShader: {
  56285. name: string;
  56286. shader: string;
  56287. };
  56288. }
  56289. declare module "babylonjs/Shaders/depth.vertex" {
  56290. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56291. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56292. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56293. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56294. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56295. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56296. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56297. /** @hidden */
  56298. export var depthVertexShader: {
  56299. name: string;
  56300. shader: string;
  56301. };
  56302. }
  56303. declare module "babylonjs/Rendering/depthRenderer" {
  56304. import { Nullable } from "babylonjs/types";
  56305. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56306. import { Scene } from "babylonjs/scene";
  56307. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56308. import { Camera } from "babylonjs/Cameras/camera";
  56309. import "babylonjs/Shaders/depth.fragment";
  56310. import "babylonjs/Shaders/depth.vertex";
  56311. /**
  56312. * This represents a depth renderer in Babylon.
  56313. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56314. */
  56315. export class DepthRenderer {
  56316. private _scene;
  56317. private _depthMap;
  56318. private _effect;
  56319. private readonly _storeNonLinearDepth;
  56320. private readonly _clearColor;
  56321. /** Get if the depth renderer is using packed depth or not */
  56322. readonly isPacked: boolean;
  56323. private _cachedDefines;
  56324. private _camera;
  56325. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56326. enabled: boolean;
  56327. /**
  56328. * Specifiess that the depth renderer will only be used within
  56329. * the camera it is created for.
  56330. * This can help forcing its rendering during the camera processing.
  56331. */
  56332. useOnlyInActiveCamera: boolean;
  56333. /** @hidden */
  56334. static _SceneComponentInitialization: (scene: Scene) => void;
  56335. /**
  56336. * Instantiates a depth renderer
  56337. * @param scene The scene the renderer belongs to
  56338. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56339. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56340. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56341. */
  56342. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56343. /**
  56344. * Creates the depth rendering effect and checks if the effect is ready.
  56345. * @param subMesh The submesh to be used to render the depth map of
  56346. * @param useInstances If multiple world instances should be used
  56347. * @returns if the depth renderer is ready to render the depth map
  56348. */
  56349. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56350. /**
  56351. * Gets the texture which the depth map will be written to.
  56352. * @returns The depth map texture
  56353. */
  56354. getDepthMap(): RenderTargetTexture;
  56355. /**
  56356. * Disposes of the depth renderer.
  56357. */
  56358. dispose(): void;
  56359. }
  56360. }
  56361. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56362. /** @hidden */
  56363. export var minmaxReduxPixelShader: {
  56364. name: string;
  56365. shader: string;
  56366. };
  56367. }
  56368. declare module "babylonjs/Misc/minMaxReducer" {
  56369. import { Nullable } from "babylonjs/types";
  56370. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56371. import { Camera } from "babylonjs/Cameras/camera";
  56372. import { Observer } from "babylonjs/Misc/observable";
  56373. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56374. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56375. import { Observable } from "babylonjs/Misc/observable";
  56376. import "babylonjs/Shaders/minmaxRedux.fragment";
  56377. /**
  56378. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56379. * and maximum values from all values of the texture.
  56380. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56381. * The source values are read from the red channel of the texture.
  56382. */
  56383. export class MinMaxReducer {
  56384. /**
  56385. * Observable triggered when the computation has been performed
  56386. */
  56387. onAfterReductionPerformed: Observable<{
  56388. min: number;
  56389. max: number;
  56390. }>;
  56391. protected _camera: Camera;
  56392. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56393. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56394. protected _postProcessManager: PostProcessManager;
  56395. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56396. protected _forceFullscreenViewport: boolean;
  56397. /**
  56398. * Creates a min/max reducer
  56399. * @param camera The camera to use for the post processes
  56400. */
  56401. constructor(camera: Camera);
  56402. /**
  56403. * Gets the texture used to read the values from.
  56404. */
  56405. get sourceTexture(): Nullable<RenderTargetTexture>;
  56406. /**
  56407. * Sets the source texture to read the values from.
  56408. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56409. * because in such textures '1' value must not be taken into account to compute the maximum
  56410. * as this value is used to clear the texture.
  56411. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56412. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56413. * @param depthRedux Indicates if the texture is a depth texture or not
  56414. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56415. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56416. */
  56417. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56418. /**
  56419. * Defines the refresh rate of the computation.
  56420. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56421. */
  56422. get refreshRate(): number;
  56423. set refreshRate(value: number);
  56424. protected _activated: boolean;
  56425. /**
  56426. * Gets the activation status of the reducer
  56427. */
  56428. get activated(): boolean;
  56429. /**
  56430. * Activates the reduction computation.
  56431. * When activated, the observers registered in onAfterReductionPerformed are
  56432. * called after the compuation is performed
  56433. */
  56434. activate(): void;
  56435. /**
  56436. * Deactivates the reduction computation.
  56437. */
  56438. deactivate(): void;
  56439. /**
  56440. * Disposes the min/max reducer
  56441. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  56442. */
  56443. dispose(disposeAll?: boolean): void;
  56444. }
  56445. }
  56446. declare module "babylonjs/Misc/depthReducer" {
  56447. import { Nullable } from "babylonjs/types";
  56448. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56449. import { Camera } from "babylonjs/Cameras/camera";
  56450. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56451. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56452. /**
  56453. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56454. */
  56455. export class DepthReducer extends MinMaxReducer {
  56456. private _depthRenderer;
  56457. private _depthRendererId;
  56458. /**
  56459. * Gets the depth renderer used for the computation.
  56460. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56461. */
  56462. get depthRenderer(): Nullable<DepthRenderer>;
  56463. /**
  56464. * Creates a depth reducer
  56465. * @param camera The camera used to render the depth texture
  56466. */
  56467. constructor(camera: Camera);
  56468. /**
  56469. * Sets the depth renderer to use to generate the depth map
  56470. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56471. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56472. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56473. */
  56474. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56475. /** @hidden */
  56476. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56477. /**
  56478. * Activates the reduction computation.
  56479. * When activated, the observers registered in onAfterReductionPerformed are
  56480. * called after the compuation is performed
  56481. */
  56482. activate(): void;
  56483. /**
  56484. * Deactivates the reduction computation.
  56485. */
  56486. deactivate(): void;
  56487. /**
  56488. * Disposes the depth reducer
  56489. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  56490. */
  56491. dispose(disposeAll?: boolean): void;
  56492. }
  56493. }
  56494. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56495. import { Nullable } from "babylonjs/types";
  56496. import { Scene } from "babylonjs/scene";
  56497. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56498. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56499. import { Effect } from "babylonjs/Materials/effect";
  56500. import "babylonjs/Shaders/shadowMap.fragment";
  56501. import "babylonjs/Shaders/shadowMap.vertex";
  56502. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56503. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56504. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56505. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56506. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56507. /**
  56508. * A CSM implementation allowing casting shadows on large scenes.
  56509. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56510. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56511. */
  56512. export class CascadedShadowGenerator extends ShadowGenerator {
  56513. private static readonly frustumCornersNDCSpace;
  56514. /**
  56515. * Name of the CSM class
  56516. */
  56517. static CLASSNAME: string;
  56518. /**
  56519. * Defines the default number of cascades used by the CSM.
  56520. */
  56521. static readonly DEFAULT_CASCADES_COUNT: number;
  56522. /**
  56523. * Defines the minimum number of cascades used by the CSM.
  56524. */
  56525. static readonly MIN_CASCADES_COUNT: number;
  56526. /**
  56527. * Defines the maximum number of cascades used by the CSM.
  56528. */
  56529. static readonly MAX_CASCADES_COUNT: number;
  56530. protected _validateFilter(filter: number): number;
  56531. /**
  56532. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56533. */
  56534. penumbraDarkness: number;
  56535. private _numCascades;
  56536. /**
  56537. * Gets or set the number of cascades used by the CSM.
  56538. */
  56539. get numCascades(): number;
  56540. set numCascades(value: number);
  56541. /**
  56542. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56543. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56544. */
  56545. stabilizeCascades: boolean;
  56546. private _freezeShadowCastersBoundingInfo;
  56547. private _freezeShadowCastersBoundingInfoObservable;
  56548. /**
  56549. * Enables or disables the shadow casters bounding info computation.
  56550. * If your shadow casters don't move, you can disable this feature.
  56551. * If it is enabled, the bounding box computation is done every frame.
  56552. */
  56553. get freezeShadowCastersBoundingInfo(): boolean;
  56554. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56555. private _scbiMin;
  56556. private _scbiMax;
  56557. protected _computeShadowCastersBoundingInfo(): void;
  56558. protected _shadowCastersBoundingInfo: BoundingInfo;
  56559. /**
  56560. * Gets or sets the shadow casters bounding info.
  56561. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56562. * so that the system won't overwrite the bounds you provide
  56563. */
  56564. get shadowCastersBoundingInfo(): BoundingInfo;
  56565. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56566. protected _breaksAreDirty: boolean;
  56567. protected _minDistance: number;
  56568. protected _maxDistance: number;
  56569. /**
  56570. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56571. *
  56572. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56573. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56574. * @param min minimal distance for the breaks (default to 0.)
  56575. * @param max maximal distance for the breaks (default to 1.)
  56576. */
  56577. setMinMaxDistance(min: number, max: number): void;
  56578. /** Gets the minimal distance used in the cascade break computation */
  56579. get minDistance(): number;
  56580. /** Gets the maximal distance used in the cascade break computation */
  56581. get maxDistance(): number;
  56582. /**
  56583. * Gets the class name of that object
  56584. * @returns "CascadedShadowGenerator"
  56585. */
  56586. getClassName(): string;
  56587. private _cascadeMinExtents;
  56588. private _cascadeMaxExtents;
  56589. /**
  56590. * Gets a cascade minimum extents
  56591. * @param cascadeIndex index of the cascade
  56592. * @returns the minimum cascade extents
  56593. */
  56594. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56595. /**
  56596. * Gets a cascade maximum extents
  56597. * @param cascadeIndex index of the cascade
  56598. * @returns the maximum cascade extents
  56599. */
  56600. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56601. private _cascades;
  56602. private _currentLayer;
  56603. private _viewSpaceFrustumsZ;
  56604. private _viewMatrices;
  56605. private _projectionMatrices;
  56606. private _transformMatrices;
  56607. private _transformMatricesAsArray;
  56608. private _frustumLengths;
  56609. private _lightSizeUVCorrection;
  56610. private _depthCorrection;
  56611. private _frustumCornersWorldSpace;
  56612. private _frustumCenter;
  56613. private _shadowCameraPos;
  56614. private _shadowMaxZ;
  56615. /**
  56616. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56617. * It defaults to camera.maxZ
  56618. */
  56619. get shadowMaxZ(): number;
  56620. /**
  56621. * Sets the shadow max z distance.
  56622. */
  56623. set shadowMaxZ(value: number);
  56624. protected _debug: boolean;
  56625. /**
  56626. * Gets or sets the debug flag.
  56627. * When enabled, the cascades are materialized by different colors on the screen.
  56628. */
  56629. get debug(): boolean;
  56630. set debug(dbg: boolean);
  56631. private _depthClamp;
  56632. /**
  56633. * Gets or sets the depth clamping value.
  56634. *
  56635. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  56636. * to account for the shadow casters far away.
  56637. *
  56638. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  56639. */
  56640. get depthClamp(): boolean;
  56641. set depthClamp(value: boolean);
  56642. private _cascadeBlendPercentage;
  56643. /**
  56644. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  56645. * It defaults to 0.1 (10% blending).
  56646. */
  56647. get cascadeBlendPercentage(): number;
  56648. set cascadeBlendPercentage(value: number);
  56649. private _lambda;
  56650. /**
  56651. * Gets or set the lambda parameter.
  56652. * This parameter is used to split the camera frustum and create the cascades.
  56653. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  56654. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  56655. */
  56656. get lambda(): number;
  56657. set lambda(value: number);
  56658. /**
  56659. * Gets the view matrix corresponding to a given cascade
  56660. * @param cascadeNum cascade to retrieve the view matrix from
  56661. * @returns the cascade view matrix
  56662. */
  56663. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  56664. /**
  56665. * Gets the projection matrix corresponding to a given cascade
  56666. * @param cascadeNum cascade to retrieve the projection matrix from
  56667. * @returns the cascade projection matrix
  56668. */
  56669. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  56670. /**
  56671. * Gets the transformation matrix corresponding to a given cascade
  56672. * @param cascadeNum cascade to retrieve the transformation matrix from
  56673. * @returns the cascade transformation matrix
  56674. */
  56675. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  56676. private _depthRenderer;
  56677. /**
  56678. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  56679. *
  56680. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  56681. *
  56682. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  56683. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  56684. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  56685. */
  56686. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  56687. private _depthReducer;
  56688. private _autoCalcDepthBounds;
  56689. /**
  56690. * Gets or sets the autoCalcDepthBounds property.
  56691. *
  56692. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  56693. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  56694. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  56695. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  56696. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  56697. */
  56698. get autoCalcDepthBounds(): boolean;
  56699. set autoCalcDepthBounds(value: boolean);
  56700. /**
  56701. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  56702. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56703. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  56704. * for setting the refresh rate on the renderer yourself!
  56705. */
  56706. get autoCalcDepthBoundsRefreshRate(): number;
  56707. set autoCalcDepthBoundsRefreshRate(value: number);
  56708. /**
  56709. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  56710. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  56711. * you change the camera near/far planes!
  56712. */
  56713. splitFrustum(): void;
  56714. private _splitFrustum;
  56715. private _computeMatrices;
  56716. private _computeFrustumInWorldSpace;
  56717. private _computeCascadeFrustum;
  56718. /** @hidden */
  56719. static _SceneComponentInitialization: (scene: Scene) => void;
  56720. /**
  56721. * Creates a Cascaded Shadow Generator object.
  56722. * A ShadowGenerator is the required tool to use the shadows.
  56723. * Each directional light casting shadows needs to use its own ShadowGenerator.
  56724. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56725. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  56726. * @param light The directional light object generating the shadows.
  56727. * @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.
  56728. */
  56729. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  56730. protected _initializeGenerator(): void;
  56731. protected _createTargetRenderTexture(): void;
  56732. protected _initializeShadowMap(): void;
  56733. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  56734. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  56735. /**
  56736. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  56737. * @param defines Defines of the material we want to update
  56738. * @param lightIndex Index of the light in the enabled light list of the material
  56739. */
  56740. prepareDefines(defines: any, lightIndex: number): void;
  56741. /**
  56742. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  56743. * defined in the generator but impacting the effect).
  56744. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  56745. * @param effect The effect we are binfing the information for
  56746. */
  56747. bindShadowLight(lightIndex: string, effect: Effect): void;
  56748. /**
  56749. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  56750. * (eq to view projection * shadow projection matrices)
  56751. * @returns The transform matrix used to create the shadow map
  56752. */
  56753. getTransformMatrix(): Matrix;
  56754. /**
  56755. * Disposes the ShadowGenerator.
  56756. * Returns nothing.
  56757. */
  56758. dispose(): void;
  56759. /**
  56760. * Serializes the shadow generator setup to a json object.
  56761. * @returns The serialized JSON object
  56762. */
  56763. serialize(): any;
  56764. /**
  56765. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  56766. * @param parsedShadowGenerator The JSON object to parse
  56767. * @param scene The scene to create the shadow map for
  56768. * @returns The parsed shadow generator
  56769. */
  56770. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  56771. }
  56772. }
  56773. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  56774. import { Scene } from "babylonjs/scene";
  56775. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56776. import { AbstractScene } from "babylonjs/abstractScene";
  56777. /**
  56778. * Defines the shadow generator component responsible to manage any shadow generators
  56779. * in a given scene.
  56780. */
  56781. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  56782. /**
  56783. * The component name helpfull to identify the component in the list of scene components.
  56784. */
  56785. readonly name: string;
  56786. /**
  56787. * The scene the component belongs to.
  56788. */
  56789. scene: Scene;
  56790. /**
  56791. * Creates a new instance of the component for the given scene
  56792. * @param scene Defines the scene to register the component in
  56793. */
  56794. constructor(scene: Scene);
  56795. /**
  56796. * Registers the component in a given scene
  56797. */
  56798. register(): void;
  56799. /**
  56800. * Rebuilds the elements related to this component in case of
  56801. * context lost for instance.
  56802. */
  56803. rebuild(): void;
  56804. /**
  56805. * Serializes the component data to the specified json object
  56806. * @param serializationObject The object to serialize to
  56807. */
  56808. serialize(serializationObject: any): void;
  56809. /**
  56810. * Adds all the elements from the container to the scene
  56811. * @param container the container holding the elements
  56812. */
  56813. addFromContainer(container: AbstractScene): void;
  56814. /**
  56815. * Removes all the elements in the container from the scene
  56816. * @param container contains the elements to remove
  56817. * @param dispose if the removed element should be disposed (default: false)
  56818. */
  56819. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56820. /**
  56821. * Rebuilds the elements related to this component in case of
  56822. * context lost for instance.
  56823. */
  56824. dispose(): void;
  56825. private _gatherRenderTargets;
  56826. }
  56827. }
  56828. declare module "babylonjs/Lights/Shadows/index" {
  56829. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  56830. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  56831. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  56832. }
  56833. declare module "babylonjs/Lights/pointLight" {
  56834. import { Scene } from "babylonjs/scene";
  56835. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56836. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56837. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56838. import { Effect } from "babylonjs/Materials/effect";
  56839. /**
  56840. * A point light is a light defined by an unique point in world space.
  56841. * The light is emitted in every direction from this point.
  56842. * A good example of a point light is a standard light bulb.
  56843. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56844. */
  56845. export class PointLight extends ShadowLight {
  56846. private _shadowAngle;
  56847. /**
  56848. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56849. * This specifies what angle the shadow will use to be created.
  56850. *
  56851. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56852. */
  56853. get shadowAngle(): number;
  56854. /**
  56855. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56856. * This specifies what angle the shadow will use to be created.
  56857. *
  56858. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56859. */
  56860. set shadowAngle(value: number);
  56861. /**
  56862. * Gets the direction if it has been set.
  56863. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56864. */
  56865. get direction(): Vector3;
  56866. /**
  56867. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56868. */
  56869. set direction(value: Vector3);
  56870. /**
  56871. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  56872. * A PointLight emits the light in every direction.
  56873. * It can cast shadows.
  56874. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  56875. * ```javascript
  56876. * var pointLight = new PointLight("pl", camera.position, scene);
  56877. * ```
  56878. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56879. * @param name The light friendly name
  56880. * @param position The position of the point light in the scene
  56881. * @param scene The scene the lights belongs to
  56882. */
  56883. constructor(name: string, position: Vector3, scene: Scene);
  56884. /**
  56885. * Returns the string "PointLight"
  56886. * @returns the class name
  56887. */
  56888. getClassName(): string;
  56889. /**
  56890. * Returns the integer 0.
  56891. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56892. */
  56893. getTypeID(): number;
  56894. /**
  56895. * Specifies wether or not the shadowmap should be a cube texture.
  56896. * @returns true if the shadowmap needs to be a cube texture.
  56897. */
  56898. needCube(): boolean;
  56899. /**
  56900. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  56901. * @param faceIndex The index of the face we are computed the direction to generate shadow
  56902. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  56903. */
  56904. getShadowDirection(faceIndex?: number): Vector3;
  56905. /**
  56906. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  56907. * - fov = PI / 2
  56908. * - aspect ratio : 1.0
  56909. * - z-near and far equal to the active camera minZ and maxZ.
  56910. * Returns the PointLight.
  56911. */
  56912. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56913. protected _buildUniformLayout(): void;
  56914. /**
  56915. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  56916. * @param effect The effect to update
  56917. * @param lightIndex The index of the light in the effect to update
  56918. * @returns The point light
  56919. */
  56920. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  56921. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56922. /**
  56923. * Prepares the list of defines specific to the light type.
  56924. * @param defines the list of defines
  56925. * @param lightIndex defines the index of the light for the effect
  56926. */
  56927. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56928. }
  56929. }
  56930. declare module "babylonjs/Lights/index" {
  56931. export * from "babylonjs/Lights/light";
  56932. export * from "babylonjs/Lights/shadowLight";
  56933. export * from "babylonjs/Lights/Shadows/index";
  56934. export * from "babylonjs/Lights/directionalLight";
  56935. export * from "babylonjs/Lights/hemisphericLight";
  56936. export * from "babylonjs/Lights/pointLight";
  56937. export * from "babylonjs/Lights/spotLight";
  56938. }
  56939. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  56940. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  56941. /**
  56942. * Header information of HDR texture files.
  56943. */
  56944. export interface HDRInfo {
  56945. /**
  56946. * The height of the texture in pixels.
  56947. */
  56948. height: number;
  56949. /**
  56950. * The width of the texture in pixels.
  56951. */
  56952. width: number;
  56953. /**
  56954. * The index of the beginning of the data in the binary file.
  56955. */
  56956. dataPosition: number;
  56957. }
  56958. /**
  56959. * This groups tools to convert HDR texture to native colors array.
  56960. */
  56961. export class HDRTools {
  56962. private static Ldexp;
  56963. private static Rgbe2float;
  56964. private static readStringLine;
  56965. /**
  56966. * Reads header information from an RGBE texture stored in a native array.
  56967. * More information on this format are available here:
  56968. * https://en.wikipedia.org/wiki/RGBE_image_format
  56969. *
  56970. * @param uint8array The binary file stored in native array.
  56971. * @return The header information.
  56972. */
  56973. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  56974. /**
  56975. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  56976. * This RGBE texture needs to store the information as a panorama.
  56977. *
  56978. * More information on this format are available here:
  56979. * https://en.wikipedia.org/wiki/RGBE_image_format
  56980. *
  56981. * @param buffer The binary file stored in an array buffer.
  56982. * @param size The expected size of the extracted cubemap.
  56983. * @return The Cube Map information.
  56984. */
  56985. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  56986. /**
  56987. * Returns the pixels data extracted from an RGBE texture.
  56988. * This pixels will be stored left to right up to down in the R G B order in one array.
  56989. *
  56990. * More information on this format are available here:
  56991. * https://en.wikipedia.org/wiki/RGBE_image_format
  56992. *
  56993. * @param uint8array The binary file stored in an array buffer.
  56994. * @param hdrInfo The header information of the file.
  56995. * @return The pixels data in RGB right to left up to down order.
  56996. */
  56997. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  56998. private static RGBE_ReadPixels_RLE;
  56999. }
  57000. }
  57001. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57002. import { Nullable } from "babylonjs/types";
  57003. import { Scene } from "babylonjs/scene";
  57004. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57005. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57006. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57007. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57008. /**
  57009. * This represents a texture coming from an HDR input.
  57010. *
  57011. * The only supported format is currently panorama picture stored in RGBE format.
  57012. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57013. */
  57014. export class HDRCubeTexture extends BaseTexture {
  57015. private static _facesMapping;
  57016. private _generateHarmonics;
  57017. private _noMipmap;
  57018. private _textureMatrix;
  57019. private _size;
  57020. private _onLoad;
  57021. private _onError;
  57022. /**
  57023. * The texture URL.
  57024. */
  57025. url: string;
  57026. /**
  57027. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57028. */
  57029. coordinatesMode: number;
  57030. protected _isBlocking: boolean;
  57031. /**
  57032. * Sets wether or not the texture is blocking during loading.
  57033. */
  57034. set isBlocking(value: boolean);
  57035. /**
  57036. * Gets wether or not the texture is blocking during loading.
  57037. */
  57038. get isBlocking(): boolean;
  57039. protected _rotationY: number;
  57040. /**
  57041. * Sets texture matrix rotation angle around Y axis in radians.
  57042. */
  57043. set rotationY(value: number);
  57044. /**
  57045. * Gets texture matrix rotation angle around Y axis radians.
  57046. */
  57047. get rotationY(): number;
  57048. /**
  57049. * Gets or sets the center of the bounding box associated with the cube texture
  57050. * It must define where the camera used to render the texture was set
  57051. */
  57052. boundingBoxPosition: Vector3;
  57053. private _boundingBoxSize;
  57054. /**
  57055. * Gets or sets the size of the bounding box associated with the cube texture
  57056. * When defined, the cubemap will switch to local mode
  57057. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57058. * @example https://www.babylonjs-playground.com/#RNASML
  57059. */
  57060. set boundingBoxSize(value: Vector3);
  57061. get boundingBoxSize(): Vector3;
  57062. /**
  57063. * Instantiates an HDRTexture from the following parameters.
  57064. *
  57065. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57066. * @param scene The scene the texture will be used in
  57067. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57068. * @param noMipmap Forces to not generate the mipmap if true
  57069. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57070. * @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)
  57071. * @param reserved Reserved flag for internal use.
  57072. */
  57073. 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>);
  57074. /**
  57075. * Get the current class name of the texture useful for serialization or dynamic coding.
  57076. * @returns "HDRCubeTexture"
  57077. */
  57078. getClassName(): string;
  57079. /**
  57080. * Occurs when the file is raw .hdr file.
  57081. */
  57082. private loadTexture;
  57083. clone(): HDRCubeTexture;
  57084. delayLoad(): void;
  57085. /**
  57086. * Get the texture reflection matrix used to rotate/transform the reflection.
  57087. * @returns the reflection matrix
  57088. */
  57089. getReflectionTextureMatrix(): Matrix;
  57090. /**
  57091. * Set the texture reflection matrix used to rotate/transform the reflection.
  57092. * @param value Define the reflection matrix to set
  57093. */
  57094. setReflectionTextureMatrix(value: Matrix): void;
  57095. /**
  57096. * Parses a JSON representation of an HDR Texture in order to create the texture
  57097. * @param parsedTexture Define the JSON representation
  57098. * @param scene Define the scene the texture should be created in
  57099. * @param rootUrl Define the root url in case we need to load relative dependencies
  57100. * @returns the newly created texture after parsing
  57101. */
  57102. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57103. serialize(): any;
  57104. }
  57105. }
  57106. declare module "babylonjs/Physics/physicsEngine" {
  57107. import { Nullable } from "babylonjs/types";
  57108. import { Vector3 } from "babylonjs/Maths/math.vector";
  57109. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57110. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57111. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57112. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57113. /**
  57114. * Class used to control physics engine
  57115. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57116. */
  57117. export class PhysicsEngine implements IPhysicsEngine {
  57118. private _physicsPlugin;
  57119. /**
  57120. * Global value used to control the smallest number supported by the simulation
  57121. */
  57122. static Epsilon: number;
  57123. private _impostors;
  57124. private _joints;
  57125. private _subTimeStep;
  57126. /**
  57127. * Gets the gravity vector used by the simulation
  57128. */
  57129. gravity: Vector3;
  57130. /**
  57131. * Factory used to create the default physics plugin.
  57132. * @returns The default physics plugin
  57133. */
  57134. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57135. /**
  57136. * Creates a new Physics Engine
  57137. * @param gravity defines the gravity vector used by the simulation
  57138. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57139. */
  57140. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57141. /**
  57142. * Sets the gravity vector used by the simulation
  57143. * @param gravity defines the gravity vector to use
  57144. */
  57145. setGravity(gravity: Vector3): void;
  57146. /**
  57147. * Set the time step of the physics engine.
  57148. * Default is 1/60.
  57149. * To slow it down, enter 1/600 for example.
  57150. * To speed it up, 1/30
  57151. * @param newTimeStep defines the new timestep to apply to this world.
  57152. */
  57153. setTimeStep(newTimeStep?: number): void;
  57154. /**
  57155. * Get the time step of the physics engine.
  57156. * @returns the current time step
  57157. */
  57158. getTimeStep(): number;
  57159. /**
  57160. * Set the sub time step of the physics engine.
  57161. * Default is 0 meaning there is no sub steps
  57162. * To increase physics resolution precision, set a small value (like 1 ms)
  57163. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57164. */
  57165. setSubTimeStep(subTimeStep?: number): void;
  57166. /**
  57167. * Get the sub time step of the physics engine.
  57168. * @returns the current sub time step
  57169. */
  57170. getSubTimeStep(): number;
  57171. /**
  57172. * Release all resources
  57173. */
  57174. dispose(): void;
  57175. /**
  57176. * Gets the name of the current physics plugin
  57177. * @returns the name of the plugin
  57178. */
  57179. getPhysicsPluginName(): string;
  57180. /**
  57181. * Adding a new impostor for the impostor tracking.
  57182. * This will be done by the impostor itself.
  57183. * @param impostor the impostor to add
  57184. */
  57185. addImpostor(impostor: PhysicsImpostor): void;
  57186. /**
  57187. * Remove an impostor from the engine.
  57188. * This impostor and its mesh will not longer be updated by the physics engine.
  57189. * @param impostor the impostor to remove
  57190. */
  57191. removeImpostor(impostor: PhysicsImpostor): void;
  57192. /**
  57193. * Add a joint to the physics engine
  57194. * @param mainImpostor defines the main impostor to which the joint is added.
  57195. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57196. * @param joint defines the joint that will connect both impostors.
  57197. */
  57198. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57199. /**
  57200. * Removes a joint from the simulation
  57201. * @param mainImpostor defines the impostor used with the joint
  57202. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57203. * @param joint defines the joint to remove
  57204. */
  57205. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57206. /**
  57207. * Called by the scene. No need to call it.
  57208. * @param delta defines the timespam between frames
  57209. */
  57210. _step(delta: number): void;
  57211. /**
  57212. * Gets the current plugin used to run the simulation
  57213. * @returns current plugin
  57214. */
  57215. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57216. /**
  57217. * Gets the list of physic impostors
  57218. * @returns an array of PhysicsImpostor
  57219. */
  57220. getImpostors(): Array<PhysicsImpostor>;
  57221. /**
  57222. * Gets the impostor for a physics enabled object
  57223. * @param object defines the object impersonated by the impostor
  57224. * @returns the PhysicsImpostor or null if not found
  57225. */
  57226. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57227. /**
  57228. * Gets the impostor for a physics body object
  57229. * @param body defines physics body used by the impostor
  57230. * @returns the PhysicsImpostor or null if not found
  57231. */
  57232. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57233. /**
  57234. * Does a raycast in the physics world
  57235. * @param from when should the ray start?
  57236. * @param to when should the ray end?
  57237. * @returns PhysicsRaycastResult
  57238. */
  57239. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57240. }
  57241. }
  57242. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57243. import { Nullable } from "babylonjs/types";
  57244. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57246. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57247. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57248. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57249. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57250. /** @hidden */
  57251. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57252. private _useDeltaForWorldStep;
  57253. world: any;
  57254. name: string;
  57255. private _physicsMaterials;
  57256. private _fixedTimeStep;
  57257. private _cannonRaycastResult;
  57258. private _raycastResult;
  57259. private _physicsBodysToRemoveAfterStep;
  57260. BJSCANNON: any;
  57261. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57262. setGravity(gravity: Vector3): void;
  57263. setTimeStep(timeStep: number): void;
  57264. getTimeStep(): number;
  57265. executeStep(delta: number): void;
  57266. private _removeMarkedPhysicsBodiesFromWorld;
  57267. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57268. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57269. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57270. private _processChildMeshes;
  57271. removePhysicsBody(impostor: PhysicsImpostor): void;
  57272. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57273. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57274. private _addMaterial;
  57275. private _checkWithEpsilon;
  57276. private _createShape;
  57277. private _createHeightmap;
  57278. private _minus90X;
  57279. private _plus90X;
  57280. private _tmpPosition;
  57281. private _tmpDeltaPosition;
  57282. private _tmpUnityRotation;
  57283. private _updatePhysicsBodyTransformation;
  57284. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57285. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57286. isSupported(): boolean;
  57287. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57288. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57289. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57290. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57291. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57292. getBodyMass(impostor: PhysicsImpostor): number;
  57293. getBodyFriction(impostor: PhysicsImpostor): number;
  57294. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57295. getBodyRestitution(impostor: PhysicsImpostor): number;
  57296. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57297. sleepBody(impostor: PhysicsImpostor): void;
  57298. wakeUpBody(impostor: PhysicsImpostor): void;
  57299. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57300. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57301. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57302. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57303. getRadius(impostor: PhysicsImpostor): number;
  57304. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57305. dispose(): void;
  57306. private _extendNamespace;
  57307. /**
  57308. * Does a raycast in the physics world
  57309. * @param from when should the ray start?
  57310. * @param to when should the ray end?
  57311. * @returns PhysicsRaycastResult
  57312. */
  57313. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57314. }
  57315. }
  57316. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57317. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57318. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57319. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57320. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57321. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57322. import { Nullable } from "babylonjs/types";
  57323. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57324. /** @hidden */
  57325. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57326. world: any;
  57327. name: string;
  57328. BJSOIMO: any;
  57329. private _raycastResult;
  57330. constructor(iterations?: number, oimoInjection?: any);
  57331. setGravity(gravity: Vector3): void;
  57332. setTimeStep(timeStep: number): void;
  57333. getTimeStep(): number;
  57334. private _tmpImpostorsArray;
  57335. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57336. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57337. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57338. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57339. private _tmpPositionVector;
  57340. removePhysicsBody(impostor: PhysicsImpostor): void;
  57341. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57342. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57343. isSupported(): boolean;
  57344. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57345. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57346. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57347. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57348. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57349. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57350. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57351. getBodyMass(impostor: PhysicsImpostor): number;
  57352. getBodyFriction(impostor: PhysicsImpostor): number;
  57353. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57354. getBodyRestitution(impostor: PhysicsImpostor): number;
  57355. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57356. sleepBody(impostor: PhysicsImpostor): void;
  57357. wakeUpBody(impostor: PhysicsImpostor): void;
  57358. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57359. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57360. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57361. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57362. getRadius(impostor: PhysicsImpostor): number;
  57363. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57364. dispose(): void;
  57365. /**
  57366. * Does a raycast in the physics world
  57367. * @param from when should the ray start?
  57368. * @param to when should the ray end?
  57369. * @returns PhysicsRaycastResult
  57370. */
  57371. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57372. }
  57373. }
  57374. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57375. import { Nullable } from "babylonjs/types";
  57376. import { Scene } from "babylonjs/scene";
  57377. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57378. import { Color4 } from "babylonjs/Maths/math.color";
  57379. import { Mesh } from "babylonjs/Meshes/mesh";
  57380. /**
  57381. * Class containing static functions to help procedurally build meshes
  57382. */
  57383. export class RibbonBuilder {
  57384. /**
  57385. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57386. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57387. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57388. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57389. * * 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
  57390. * * 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
  57391. * * 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
  57392. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57393. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57394. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57395. * * 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
  57396. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57397. * * 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
  57398. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57399. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57400. * @param name defines the name of the mesh
  57401. * @param options defines the options used to create the mesh
  57402. * @param scene defines the hosting scene
  57403. * @returns the ribbon mesh
  57404. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57405. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57406. */
  57407. static CreateRibbon(name: string, options: {
  57408. pathArray: Vector3[][];
  57409. closeArray?: boolean;
  57410. closePath?: boolean;
  57411. offset?: number;
  57412. updatable?: boolean;
  57413. sideOrientation?: number;
  57414. frontUVs?: Vector4;
  57415. backUVs?: Vector4;
  57416. instance?: Mesh;
  57417. invertUV?: boolean;
  57418. uvs?: Vector2[];
  57419. colors?: Color4[];
  57420. }, scene?: Nullable<Scene>): Mesh;
  57421. }
  57422. }
  57423. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57424. import { Nullable } from "babylonjs/types";
  57425. import { Scene } from "babylonjs/scene";
  57426. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57427. import { Mesh } from "babylonjs/Meshes/mesh";
  57428. /**
  57429. * Class containing static functions to help procedurally build meshes
  57430. */
  57431. export class ShapeBuilder {
  57432. /**
  57433. * 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.
  57434. * * 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.
  57435. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57436. * * 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.
  57437. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57438. * * 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
  57439. * * 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
  57440. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57442. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57443. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57445. * @param name defines the name of the mesh
  57446. * @param options defines the options used to create the mesh
  57447. * @param scene defines the hosting scene
  57448. * @returns the extruded shape mesh
  57449. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57450. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57451. */
  57452. static ExtrudeShape(name: string, options: {
  57453. shape: Vector3[];
  57454. path: Vector3[];
  57455. scale?: number;
  57456. rotation?: number;
  57457. cap?: number;
  57458. updatable?: boolean;
  57459. sideOrientation?: number;
  57460. frontUVs?: Vector4;
  57461. backUVs?: Vector4;
  57462. instance?: Mesh;
  57463. invertUV?: boolean;
  57464. }, scene?: Nullable<Scene>): Mesh;
  57465. /**
  57466. * Creates an custom extruded shape mesh.
  57467. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57468. * * The parameter `shape` is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis.
  57469. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57470. * * The parameter `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
  57471. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57472. * * 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
  57473. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57474. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57475. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57476. * * 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
  57477. * * 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
  57478. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57479. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57480. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57481. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57482. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57483. * @param name defines the name of the mesh
  57484. * @param options defines the options used to create the mesh
  57485. * @param scene defines the hosting scene
  57486. * @returns the custom extruded shape mesh
  57487. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57488. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57489. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57490. */
  57491. static ExtrudeShapeCustom(name: string, options: {
  57492. shape: Vector3[];
  57493. path: Vector3[];
  57494. scaleFunction?: any;
  57495. rotationFunction?: any;
  57496. ribbonCloseArray?: boolean;
  57497. ribbonClosePath?: boolean;
  57498. cap?: number;
  57499. updatable?: boolean;
  57500. sideOrientation?: number;
  57501. frontUVs?: Vector4;
  57502. backUVs?: Vector4;
  57503. instance?: Mesh;
  57504. invertUV?: boolean;
  57505. }, scene?: Nullable<Scene>): Mesh;
  57506. private static _ExtrudeShapeGeneric;
  57507. }
  57508. }
  57509. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57510. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57511. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57512. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57513. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57514. import { Nullable } from "babylonjs/types";
  57515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57516. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57517. /**
  57518. * AmmoJS Physics plugin
  57519. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57520. * @see https://github.com/kripken/ammo.js/
  57521. */
  57522. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57523. private _useDeltaForWorldStep;
  57524. /**
  57525. * Reference to the Ammo library
  57526. */
  57527. bjsAMMO: any;
  57528. /**
  57529. * Created ammoJS world which physics bodies are added to
  57530. */
  57531. world: any;
  57532. /**
  57533. * Name of the plugin
  57534. */
  57535. name: string;
  57536. private _timeStep;
  57537. private _fixedTimeStep;
  57538. private _maxSteps;
  57539. private _tmpQuaternion;
  57540. private _tmpAmmoTransform;
  57541. private _tmpAmmoQuaternion;
  57542. private _tmpAmmoConcreteContactResultCallback;
  57543. private _collisionConfiguration;
  57544. private _dispatcher;
  57545. private _overlappingPairCache;
  57546. private _solver;
  57547. private _softBodySolver;
  57548. private _tmpAmmoVectorA;
  57549. private _tmpAmmoVectorB;
  57550. private _tmpAmmoVectorC;
  57551. private _tmpAmmoVectorD;
  57552. private _tmpContactCallbackResult;
  57553. private _tmpAmmoVectorRCA;
  57554. private _tmpAmmoVectorRCB;
  57555. private _raycastResult;
  57556. private static readonly DISABLE_COLLISION_FLAG;
  57557. private static readonly KINEMATIC_FLAG;
  57558. private static readonly DISABLE_DEACTIVATION_FLAG;
  57559. /**
  57560. * Initializes the ammoJS plugin
  57561. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57562. * @param ammoInjection can be used to inject your own ammo reference
  57563. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57564. */
  57565. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57566. /**
  57567. * Sets the gravity of the physics world (m/(s^2))
  57568. * @param gravity Gravity to set
  57569. */
  57570. setGravity(gravity: Vector3): void;
  57571. /**
  57572. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57573. * @param timeStep timestep to use in seconds
  57574. */
  57575. setTimeStep(timeStep: number): void;
  57576. /**
  57577. * 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)
  57578. * @param fixedTimeStep fixedTimeStep to use in seconds
  57579. */
  57580. setFixedTimeStep(fixedTimeStep: number): void;
  57581. /**
  57582. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57583. * @param maxSteps the maximum number of steps by the physics engine per frame
  57584. */
  57585. setMaxSteps(maxSteps: number): void;
  57586. /**
  57587. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57588. * @returns the current timestep in seconds
  57589. */
  57590. getTimeStep(): number;
  57591. /**
  57592. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57593. */
  57594. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57595. private _isImpostorInContact;
  57596. private _isImpostorPairInContact;
  57597. private _stepSimulation;
  57598. /**
  57599. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57600. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57601. * After the step the babylon meshes are set to the position of the physics imposters
  57602. * @param delta amount of time to step forward
  57603. * @param impostors array of imposters to update before/after the step
  57604. */
  57605. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57606. /**
  57607. * Update babylon mesh to match physics world object
  57608. * @param impostor imposter to match
  57609. */
  57610. private _afterSoftStep;
  57611. /**
  57612. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57613. * @param impostor imposter to match
  57614. */
  57615. private _ropeStep;
  57616. /**
  57617. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57618. * @param impostor imposter to match
  57619. */
  57620. private _softbodyOrClothStep;
  57621. private _tmpVector;
  57622. private _tmpMatrix;
  57623. /**
  57624. * Applies an impulse on the imposter
  57625. * @param impostor imposter to apply impulse to
  57626. * @param force amount of force to be applied to the imposter
  57627. * @param contactPoint the location to apply the impulse on the imposter
  57628. */
  57629. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57630. /**
  57631. * Applies a force on the imposter
  57632. * @param impostor imposter to apply force
  57633. * @param force amount of force to be applied to the imposter
  57634. * @param contactPoint the location to apply the force on the imposter
  57635. */
  57636. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57637. /**
  57638. * Creates a physics body using the plugin
  57639. * @param impostor the imposter to create the physics body on
  57640. */
  57641. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57642. /**
  57643. * Removes the physics body from the imposter and disposes of the body's memory
  57644. * @param impostor imposter to remove the physics body from
  57645. */
  57646. removePhysicsBody(impostor: PhysicsImpostor): void;
  57647. /**
  57648. * Generates a joint
  57649. * @param impostorJoint the imposter joint to create the joint with
  57650. */
  57651. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57652. /**
  57653. * Removes a joint
  57654. * @param impostorJoint the imposter joint to remove the joint from
  57655. */
  57656. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57657. private _addMeshVerts;
  57658. /**
  57659. * Initialise the soft body vertices to match its object's (mesh) vertices
  57660. * Softbody vertices (nodes) are in world space and to match this
  57661. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  57662. * @param impostor to create the softbody for
  57663. */
  57664. private _softVertexData;
  57665. /**
  57666. * Create an impostor's soft body
  57667. * @param impostor to create the softbody for
  57668. */
  57669. private _createSoftbody;
  57670. /**
  57671. * Create cloth for an impostor
  57672. * @param impostor to create the softbody for
  57673. */
  57674. private _createCloth;
  57675. /**
  57676. * Create rope for an impostor
  57677. * @param impostor to create the softbody for
  57678. */
  57679. private _createRope;
  57680. /**
  57681. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  57682. * @param impostor to create the custom physics shape for
  57683. */
  57684. private _createCustom;
  57685. private _addHullVerts;
  57686. private _createShape;
  57687. /**
  57688. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  57689. * @param impostor imposter containing the physics body and babylon object
  57690. */
  57691. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57692. /**
  57693. * Sets the babylon object's position/rotation from the physics body's position/rotation
  57694. * @param impostor imposter containing the physics body and babylon object
  57695. * @param newPosition new position
  57696. * @param newRotation new rotation
  57697. */
  57698. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57699. /**
  57700. * If this plugin is supported
  57701. * @returns true if its supported
  57702. */
  57703. isSupported(): boolean;
  57704. /**
  57705. * Sets the linear velocity of the physics body
  57706. * @param impostor imposter to set the velocity on
  57707. * @param velocity velocity to set
  57708. */
  57709. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57710. /**
  57711. * Sets the angular velocity of the physics body
  57712. * @param impostor imposter to set the velocity on
  57713. * @param velocity velocity to set
  57714. */
  57715. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57716. /**
  57717. * gets the linear velocity
  57718. * @param impostor imposter to get linear velocity from
  57719. * @returns linear velocity
  57720. */
  57721. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57722. /**
  57723. * gets the angular velocity
  57724. * @param impostor imposter to get angular velocity from
  57725. * @returns angular velocity
  57726. */
  57727. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57728. /**
  57729. * Sets the mass of physics body
  57730. * @param impostor imposter to set the mass on
  57731. * @param mass mass to set
  57732. */
  57733. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57734. /**
  57735. * Gets the mass of the physics body
  57736. * @param impostor imposter to get the mass from
  57737. * @returns mass
  57738. */
  57739. getBodyMass(impostor: PhysicsImpostor): number;
  57740. /**
  57741. * Gets friction of the impostor
  57742. * @param impostor impostor to get friction from
  57743. * @returns friction value
  57744. */
  57745. getBodyFriction(impostor: PhysicsImpostor): number;
  57746. /**
  57747. * Sets friction of the impostor
  57748. * @param impostor impostor to set friction on
  57749. * @param friction friction value
  57750. */
  57751. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57752. /**
  57753. * Gets restitution of the impostor
  57754. * @param impostor impostor to get restitution from
  57755. * @returns restitution value
  57756. */
  57757. getBodyRestitution(impostor: PhysicsImpostor): number;
  57758. /**
  57759. * Sets resitution of the impostor
  57760. * @param impostor impostor to set resitution on
  57761. * @param restitution resitution value
  57762. */
  57763. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57764. /**
  57765. * Gets pressure inside the impostor
  57766. * @param impostor impostor to get pressure from
  57767. * @returns pressure value
  57768. */
  57769. getBodyPressure(impostor: PhysicsImpostor): number;
  57770. /**
  57771. * Sets pressure inside a soft body impostor
  57772. * Cloth and rope must remain 0 pressure
  57773. * @param impostor impostor to set pressure on
  57774. * @param pressure pressure value
  57775. */
  57776. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  57777. /**
  57778. * Gets stiffness of the impostor
  57779. * @param impostor impostor to get stiffness from
  57780. * @returns pressure value
  57781. */
  57782. getBodyStiffness(impostor: PhysicsImpostor): number;
  57783. /**
  57784. * Sets stiffness of the impostor
  57785. * @param impostor impostor to set stiffness on
  57786. * @param stiffness stiffness value from 0 to 1
  57787. */
  57788. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  57789. /**
  57790. * Gets velocityIterations of the impostor
  57791. * @param impostor impostor to get velocity iterations from
  57792. * @returns velocityIterations value
  57793. */
  57794. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  57795. /**
  57796. * Sets velocityIterations of the impostor
  57797. * @param impostor impostor to set velocity iterations on
  57798. * @param velocityIterations velocityIterations value
  57799. */
  57800. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  57801. /**
  57802. * Gets positionIterations of the impostor
  57803. * @param impostor impostor to get position iterations from
  57804. * @returns positionIterations value
  57805. */
  57806. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  57807. /**
  57808. * Sets positionIterations of the impostor
  57809. * @param impostor impostor to set position on
  57810. * @param positionIterations positionIterations value
  57811. */
  57812. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  57813. /**
  57814. * Append an anchor to a cloth object
  57815. * @param impostor is the cloth impostor to add anchor to
  57816. * @param otherImpostor is the rigid impostor to anchor to
  57817. * @param width ratio across width from 0 to 1
  57818. * @param height ratio up height from 0 to 1
  57819. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  57820. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57821. */
  57822. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57823. /**
  57824. * Append an hook to a rope object
  57825. * @param impostor is the rope impostor to add hook to
  57826. * @param otherImpostor is the rigid impostor to hook to
  57827. * @param length ratio along the rope from 0 to 1
  57828. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  57829. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57830. */
  57831. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57832. /**
  57833. * Sleeps the physics body and stops it from being active
  57834. * @param impostor impostor to sleep
  57835. */
  57836. sleepBody(impostor: PhysicsImpostor): void;
  57837. /**
  57838. * Activates the physics body
  57839. * @param impostor impostor to activate
  57840. */
  57841. wakeUpBody(impostor: PhysicsImpostor): void;
  57842. /**
  57843. * Updates the distance parameters of the joint
  57844. * @param joint joint to update
  57845. * @param maxDistance maximum distance of the joint
  57846. * @param minDistance minimum distance of the joint
  57847. */
  57848. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57849. /**
  57850. * Sets a motor on the joint
  57851. * @param joint joint to set motor on
  57852. * @param speed speed of the motor
  57853. * @param maxForce maximum force of the motor
  57854. * @param motorIndex index of the motor
  57855. */
  57856. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57857. /**
  57858. * Sets the motors limit
  57859. * @param joint joint to set limit on
  57860. * @param upperLimit upper limit
  57861. * @param lowerLimit lower limit
  57862. */
  57863. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57864. /**
  57865. * Syncs the position and rotation of a mesh with the impostor
  57866. * @param mesh mesh to sync
  57867. * @param impostor impostor to update the mesh with
  57868. */
  57869. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57870. /**
  57871. * Gets the radius of the impostor
  57872. * @param impostor impostor to get radius from
  57873. * @returns the radius
  57874. */
  57875. getRadius(impostor: PhysicsImpostor): number;
  57876. /**
  57877. * Gets the box size of the impostor
  57878. * @param impostor impostor to get box size from
  57879. * @param result the resulting box size
  57880. */
  57881. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57882. /**
  57883. * Disposes of the impostor
  57884. */
  57885. dispose(): void;
  57886. /**
  57887. * Does a raycast in the physics world
  57888. * @param from when should the ray start?
  57889. * @param to when should the ray end?
  57890. * @returns PhysicsRaycastResult
  57891. */
  57892. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57893. }
  57894. }
  57895. declare module "babylonjs/Probes/reflectionProbe" {
  57896. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57897. import { Vector3 } from "babylonjs/Maths/math.vector";
  57898. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57899. import { Nullable } from "babylonjs/types";
  57900. import { Scene } from "babylonjs/scene";
  57901. module "babylonjs/abstractScene" {
  57902. interface AbstractScene {
  57903. /**
  57904. * The list of reflection probes added to the scene
  57905. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57906. */
  57907. reflectionProbes: Array<ReflectionProbe>;
  57908. /**
  57909. * Removes the given reflection probe from this scene.
  57910. * @param toRemove The reflection probe to remove
  57911. * @returns The index of the removed reflection probe
  57912. */
  57913. removeReflectionProbe(toRemove: ReflectionProbe): number;
  57914. /**
  57915. * Adds the given reflection probe to this scene.
  57916. * @param newReflectionProbe The reflection probe to add
  57917. */
  57918. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  57919. }
  57920. }
  57921. /**
  57922. * Class used to generate realtime reflection / refraction cube textures
  57923. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57924. */
  57925. export class ReflectionProbe {
  57926. /** defines the name of the probe */
  57927. name: string;
  57928. private _scene;
  57929. private _renderTargetTexture;
  57930. private _projectionMatrix;
  57931. private _viewMatrix;
  57932. private _target;
  57933. private _add;
  57934. private _attachedMesh;
  57935. private _invertYAxis;
  57936. /** Gets or sets probe position (center of the cube map) */
  57937. position: Vector3;
  57938. /**
  57939. * Creates a new reflection probe
  57940. * @param name defines the name of the probe
  57941. * @param size defines the texture resolution (for each face)
  57942. * @param scene defines the hosting scene
  57943. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  57944. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  57945. */
  57946. constructor(
  57947. /** defines the name of the probe */
  57948. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  57949. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  57950. get samples(): number;
  57951. set samples(value: number);
  57952. /** Gets or sets the refresh rate to use (on every frame by default) */
  57953. get refreshRate(): number;
  57954. set refreshRate(value: number);
  57955. /**
  57956. * Gets the hosting scene
  57957. * @returns a Scene
  57958. */
  57959. getScene(): Scene;
  57960. /** Gets the internal CubeTexture used to render to */
  57961. get cubeTexture(): RenderTargetTexture;
  57962. /** Gets the list of meshes to render */
  57963. get renderList(): Nullable<AbstractMesh[]>;
  57964. /**
  57965. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  57966. * @param mesh defines the mesh to attach to
  57967. */
  57968. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  57969. /**
  57970. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  57971. * @param renderingGroupId The rendering group id corresponding to its index
  57972. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  57973. */
  57974. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  57975. /**
  57976. * Clean all associated resources
  57977. */
  57978. dispose(): void;
  57979. /**
  57980. * Converts the reflection probe information to a readable string for debug purpose.
  57981. * @param fullDetails Supports for multiple levels of logging within scene loading
  57982. * @returns the human readable reflection probe info
  57983. */
  57984. toString(fullDetails?: boolean): string;
  57985. /**
  57986. * Get the class name of the relfection probe.
  57987. * @returns "ReflectionProbe"
  57988. */
  57989. getClassName(): string;
  57990. /**
  57991. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  57992. * @returns The JSON representation of the texture
  57993. */
  57994. serialize(): any;
  57995. /**
  57996. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  57997. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  57998. * @param scene Define the scene the parsed reflection probe should be instantiated in
  57999. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58000. * @returns The parsed reflection probe if successful
  58001. */
  58002. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58003. }
  58004. }
  58005. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58006. /** @hidden */
  58007. export var _BabylonLoaderRegistered: boolean;
  58008. /**
  58009. * Helps setting up some configuration for the babylon file loader.
  58010. */
  58011. export class BabylonFileLoaderConfiguration {
  58012. /**
  58013. * The loader does not allow injecting custom physix engine into the plugins.
  58014. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58015. * So you could set this variable to your engine import to make it work.
  58016. */
  58017. static LoaderInjectedPhysicsEngine: any;
  58018. }
  58019. }
  58020. declare module "babylonjs/Loading/Plugins/index" {
  58021. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58022. }
  58023. declare module "babylonjs/Loading/index" {
  58024. export * from "babylonjs/Loading/loadingScreen";
  58025. export * from "babylonjs/Loading/Plugins/index";
  58026. export * from "babylonjs/Loading/sceneLoader";
  58027. export * from "babylonjs/Loading/sceneLoaderFlags";
  58028. }
  58029. declare module "babylonjs/Materials/Background/index" {
  58030. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58031. }
  58032. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58033. import { Scene } from "babylonjs/scene";
  58034. import { Color3 } from "babylonjs/Maths/math.color";
  58035. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58036. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58037. /**
  58038. * The Physically based simple base material of BJS.
  58039. *
  58040. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58041. * It is used as the base class for both the specGloss and metalRough conventions.
  58042. */
  58043. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58044. /**
  58045. * Number of Simultaneous lights allowed on the material.
  58046. */
  58047. maxSimultaneousLights: number;
  58048. /**
  58049. * If sets to true, disables all the lights affecting the material.
  58050. */
  58051. disableLighting: boolean;
  58052. /**
  58053. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58054. */
  58055. environmentTexture: BaseTexture;
  58056. /**
  58057. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58058. */
  58059. invertNormalMapX: boolean;
  58060. /**
  58061. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58062. */
  58063. invertNormalMapY: boolean;
  58064. /**
  58065. * Normal map used in the model.
  58066. */
  58067. normalTexture: BaseTexture;
  58068. /**
  58069. * Emissivie color used to self-illuminate the model.
  58070. */
  58071. emissiveColor: Color3;
  58072. /**
  58073. * Emissivie texture used to self-illuminate the model.
  58074. */
  58075. emissiveTexture: BaseTexture;
  58076. /**
  58077. * Occlusion Channel Strenght.
  58078. */
  58079. occlusionStrength: number;
  58080. /**
  58081. * Occlusion Texture of the material (adding extra occlusion effects).
  58082. */
  58083. occlusionTexture: BaseTexture;
  58084. /**
  58085. * Defines the alpha limits in alpha test mode.
  58086. */
  58087. alphaCutOff: number;
  58088. /**
  58089. * Gets the current double sided mode.
  58090. */
  58091. get doubleSided(): boolean;
  58092. /**
  58093. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58094. */
  58095. set doubleSided(value: boolean);
  58096. /**
  58097. * Stores the pre-calculated light information of a mesh in a texture.
  58098. */
  58099. lightmapTexture: BaseTexture;
  58100. /**
  58101. * If true, the light map contains occlusion information instead of lighting info.
  58102. */
  58103. useLightmapAsShadowmap: boolean;
  58104. /**
  58105. * Instantiates a new PBRMaterial instance.
  58106. *
  58107. * @param name The material name
  58108. * @param scene The scene the material will be use in.
  58109. */
  58110. constructor(name: string, scene: Scene);
  58111. getClassName(): string;
  58112. }
  58113. }
  58114. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58115. import { Scene } from "babylonjs/scene";
  58116. import { Color3 } from "babylonjs/Maths/math.color";
  58117. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58118. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58119. /**
  58120. * The PBR material of BJS following the metal roughness convention.
  58121. *
  58122. * This fits to the PBR convention in the GLTF definition:
  58123. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58124. */
  58125. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58126. /**
  58127. * The base color has two different interpretations depending on the value of metalness.
  58128. * When the material is a metal, the base color is the specific measured reflectance value
  58129. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58130. * of the material.
  58131. */
  58132. baseColor: Color3;
  58133. /**
  58134. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58135. * well as opacity information in the alpha channel.
  58136. */
  58137. baseTexture: BaseTexture;
  58138. /**
  58139. * Specifies the metallic scalar value of the material.
  58140. * Can also be used to scale the metalness values of the metallic texture.
  58141. */
  58142. metallic: number;
  58143. /**
  58144. * Specifies the roughness scalar value of the material.
  58145. * Can also be used to scale the roughness values of the metallic texture.
  58146. */
  58147. roughness: number;
  58148. /**
  58149. * Texture containing both the metallic value in the B channel and the
  58150. * roughness value in the G channel to keep better precision.
  58151. */
  58152. metallicRoughnessTexture: BaseTexture;
  58153. /**
  58154. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58155. *
  58156. * @param name The material name
  58157. * @param scene The scene the material will be use in.
  58158. */
  58159. constructor(name: string, scene: Scene);
  58160. /**
  58161. * Return the currrent class name of the material.
  58162. */
  58163. getClassName(): string;
  58164. /**
  58165. * Makes a duplicate of the current material.
  58166. * @param name - name to use for the new material.
  58167. */
  58168. clone(name: string): PBRMetallicRoughnessMaterial;
  58169. /**
  58170. * Serialize the material to a parsable JSON object.
  58171. */
  58172. serialize(): any;
  58173. /**
  58174. * Parses a JSON object correponding to the serialize function.
  58175. */
  58176. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58177. }
  58178. }
  58179. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58180. import { Scene } from "babylonjs/scene";
  58181. import { Color3 } from "babylonjs/Maths/math.color";
  58182. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58183. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58184. /**
  58185. * The PBR material of BJS following the specular glossiness convention.
  58186. *
  58187. * This fits to the PBR convention in the GLTF definition:
  58188. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58189. */
  58190. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58191. /**
  58192. * Specifies the diffuse color of the material.
  58193. */
  58194. diffuseColor: Color3;
  58195. /**
  58196. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58197. * channel.
  58198. */
  58199. diffuseTexture: BaseTexture;
  58200. /**
  58201. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58202. */
  58203. specularColor: Color3;
  58204. /**
  58205. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58206. */
  58207. glossiness: number;
  58208. /**
  58209. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58210. */
  58211. specularGlossinessTexture: BaseTexture;
  58212. /**
  58213. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58214. *
  58215. * @param name The material name
  58216. * @param scene The scene the material will be use in.
  58217. */
  58218. constructor(name: string, scene: Scene);
  58219. /**
  58220. * Return the currrent class name of the material.
  58221. */
  58222. getClassName(): string;
  58223. /**
  58224. * Makes a duplicate of the current material.
  58225. * @param name - name to use for the new material.
  58226. */
  58227. clone(name: string): PBRSpecularGlossinessMaterial;
  58228. /**
  58229. * Serialize the material to a parsable JSON object.
  58230. */
  58231. serialize(): any;
  58232. /**
  58233. * Parses a JSON object correponding to the serialize function.
  58234. */
  58235. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58236. }
  58237. }
  58238. declare module "babylonjs/Materials/PBR/index" {
  58239. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58240. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58241. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58242. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58243. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58244. }
  58245. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58246. import { Nullable } from "babylonjs/types";
  58247. import { Scene } from "babylonjs/scene";
  58248. import { Matrix } from "babylonjs/Maths/math.vector";
  58249. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58250. /**
  58251. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58252. * It can help converting any input color in a desired output one. This can then be used to create effects
  58253. * from sepia, black and white to sixties or futuristic rendering...
  58254. *
  58255. * The only supported format is currently 3dl.
  58256. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58257. */
  58258. export class ColorGradingTexture extends BaseTexture {
  58259. /**
  58260. * The current texture matrix. (will always be identity in color grading texture)
  58261. */
  58262. private _textureMatrix;
  58263. /**
  58264. * The texture URL.
  58265. */
  58266. url: string;
  58267. /**
  58268. * Empty line regex stored for GC.
  58269. */
  58270. private static _noneEmptyLineRegex;
  58271. private _engine;
  58272. /**
  58273. * Instantiates a ColorGradingTexture from the following parameters.
  58274. *
  58275. * @param url The location of the color gradind data (currently only supporting 3dl)
  58276. * @param scene The scene the texture will be used in
  58277. */
  58278. constructor(url: string, scene: Scene);
  58279. /**
  58280. * Returns the texture matrix used in most of the material.
  58281. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58282. */
  58283. getTextureMatrix(): Matrix;
  58284. /**
  58285. * Occurs when the file being loaded is a .3dl LUT file.
  58286. */
  58287. private load3dlTexture;
  58288. /**
  58289. * Starts the loading process of the texture.
  58290. */
  58291. private loadTexture;
  58292. /**
  58293. * Clones the color gradind texture.
  58294. */
  58295. clone(): ColorGradingTexture;
  58296. /**
  58297. * Called during delayed load for textures.
  58298. */
  58299. delayLoad(): void;
  58300. /**
  58301. * Parses a color grading texture serialized by Babylon.
  58302. * @param parsedTexture The texture information being parsedTexture
  58303. * @param scene The scene to load the texture in
  58304. * @param rootUrl The root url of the data assets to load
  58305. * @return A color gradind texture
  58306. */
  58307. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58308. /**
  58309. * Serializes the LUT texture to json format.
  58310. */
  58311. serialize(): any;
  58312. }
  58313. }
  58314. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58315. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58316. import { Scene } from "babylonjs/scene";
  58317. import { Nullable } from "babylonjs/types";
  58318. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58319. /**
  58320. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58321. */
  58322. export class EquiRectangularCubeTexture extends BaseTexture {
  58323. /** The six faces of the cube. */
  58324. private static _FacesMapping;
  58325. private _noMipmap;
  58326. private _onLoad;
  58327. private _onError;
  58328. /** The size of the cubemap. */
  58329. private _size;
  58330. /** The buffer of the image. */
  58331. private _buffer;
  58332. /** The width of the input image. */
  58333. private _width;
  58334. /** The height of the input image. */
  58335. private _height;
  58336. /** The URL to the image. */
  58337. url: string;
  58338. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58339. coordinatesMode: number;
  58340. /**
  58341. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58342. * @param url The location of the image
  58343. * @param scene The scene the texture will be used in
  58344. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58345. * @param noMipmap Forces to not generate the mipmap if true
  58346. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58347. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58348. * @param onLoad — defines a callback called when texture is loaded
  58349. * @param onError — defines a callback called if there is an error
  58350. */
  58351. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58352. /**
  58353. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58354. */
  58355. private loadImage;
  58356. /**
  58357. * Convert the image buffer into a cubemap and create a CubeTexture.
  58358. */
  58359. private loadTexture;
  58360. /**
  58361. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58362. * @param buffer The ArrayBuffer that should be converted.
  58363. * @returns The buffer as Float32Array.
  58364. */
  58365. private getFloat32ArrayFromArrayBuffer;
  58366. /**
  58367. * Get the current class name of the texture useful for serialization or dynamic coding.
  58368. * @returns "EquiRectangularCubeTexture"
  58369. */
  58370. getClassName(): string;
  58371. /**
  58372. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58373. * @returns A clone of the current EquiRectangularCubeTexture.
  58374. */
  58375. clone(): EquiRectangularCubeTexture;
  58376. }
  58377. }
  58378. declare module "babylonjs/Misc/tga" {
  58379. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58380. /**
  58381. * Based on jsTGALoader - Javascript loader for TGA file
  58382. * By Vincent Thibault
  58383. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58384. */
  58385. export class TGATools {
  58386. private static _TYPE_INDEXED;
  58387. private static _TYPE_RGB;
  58388. private static _TYPE_GREY;
  58389. private static _TYPE_RLE_INDEXED;
  58390. private static _TYPE_RLE_RGB;
  58391. private static _TYPE_RLE_GREY;
  58392. private static _ORIGIN_MASK;
  58393. private static _ORIGIN_SHIFT;
  58394. private static _ORIGIN_BL;
  58395. private static _ORIGIN_BR;
  58396. private static _ORIGIN_UL;
  58397. private static _ORIGIN_UR;
  58398. /**
  58399. * Gets the header of a TGA file
  58400. * @param data defines the TGA data
  58401. * @returns the header
  58402. */
  58403. static GetTGAHeader(data: Uint8Array): any;
  58404. /**
  58405. * Uploads TGA content to a Babylon Texture
  58406. * @hidden
  58407. */
  58408. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58409. /** @hidden */
  58410. 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;
  58411. /** @hidden */
  58412. 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;
  58413. /** @hidden */
  58414. 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;
  58415. /** @hidden */
  58416. 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;
  58417. /** @hidden */
  58418. 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;
  58419. /** @hidden */
  58420. 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;
  58421. }
  58422. }
  58423. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58424. import { Nullable } from "babylonjs/types";
  58425. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58426. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58427. /**
  58428. * Implementation of the TGA Texture Loader.
  58429. * @hidden
  58430. */
  58431. export class _TGATextureLoader implements IInternalTextureLoader {
  58432. /**
  58433. * Defines wether the loader supports cascade loading the different faces.
  58434. */
  58435. readonly supportCascades: boolean;
  58436. /**
  58437. * This returns if the loader support the current file information.
  58438. * @param extension defines the file extension of the file being loaded
  58439. * @returns true if the loader can load the specified file
  58440. */
  58441. canLoad(extension: string): boolean;
  58442. /**
  58443. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58444. * @param data contains the texture data
  58445. * @param texture defines the BabylonJS internal texture
  58446. * @param createPolynomials will be true if polynomials have been requested
  58447. * @param onLoad defines the callback to trigger once the texture is ready
  58448. * @param onError defines the callback to trigger in case of error
  58449. */
  58450. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58451. /**
  58452. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58453. * @param data contains the texture data
  58454. * @param texture defines the BabylonJS internal texture
  58455. * @param callback defines the method to call once ready to upload
  58456. */
  58457. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58458. }
  58459. }
  58460. declare module "babylonjs/Misc/basis" {
  58461. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58462. /**
  58463. * Info about the .basis files
  58464. */
  58465. class BasisFileInfo {
  58466. /**
  58467. * If the file has alpha
  58468. */
  58469. hasAlpha: boolean;
  58470. /**
  58471. * Info about each image of the basis file
  58472. */
  58473. images: Array<{
  58474. levels: Array<{
  58475. width: number;
  58476. height: number;
  58477. transcodedPixels: ArrayBufferView;
  58478. }>;
  58479. }>;
  58480. }
  58481. /**
  58482. * Result of transcoding a basis file
  58483. */
  58484. class TranscodeResult {
  58485. /**
  58486. * Info about the .basis file
  58487. */
  58488. fileInfo: BasisFileInfo;
  58489. /**
  58490. * Format to use when loading the file
  58491. */
  58492. format: number;
  58493. }
  58494. /**
  58495. * Configuration options for the Basis transcoder
  58496. */
  58497. export class BasisTranscodeConfiguration {
  58498. /**
  58499. * Supported compression formats used to determine the supported output format of the transcoder
  58500. */
  58501. supportedCompressionFormats?: {
  58502. /**
  58503. * etc1 compression format
  58504. */
  58505. etc1?: boolean;
  58506. /**
  58507. * s3tc compression format
  58508. */
  58509. s3tc?: boolean;
  58510. /**
  58511. * pvrtc compression format
  58512. */
  58513. pvrtc?: boolean;
  58514. /**
  58515. * etc2 compression format
  58516. */
  58517. etc2?: boolean;
  58518. };
  58519. /**
  58520. * If mipmap levels should be loaded for transcoded images (Default: true)
  58521. */
  58522. loadMipmapLevels?: boolean;
  58523. /**
  58524. * Index of a single image to load (Default: all images)
  58525. */
  58526. loadSingleImage?: number;
  58527. }
  58528. /**
  58529. * Used to load .Basis files
  58530. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58531. */
  58532. export class BasisTools {
  58533. private static _IgnoreSupportedFormats;
  58534. /**
  58535. * URL to use when loading the basis transcoder
  58536. */
  58537. static JSModuleURL: string;
  58538. /**
  58539. * URL to use when loading the wasm module for the transcoder
  58540. */
  58541. static WasmModuleURL: string;
  58542. /**
  58543. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58544. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58545. * @returns internal format corresponding to the Basis format
  58546. */
  58547. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58548. private static _WorkerPromise;
  58549. private static _Worker;
  58550. private static _actionId;
  58551. private static _CreateWorkerAsync;
  58552. /**
  58553. * Transcodes a loaded image file to compressed pixel data
  58554. * @param data image data to transcode
  58555. * @param config configuration options for the transcoding
  58556. * @returns a promise resulting in the transcoded image
  58557. */
  58558. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58559. /**
  58560. * Loads a texture from the transcode result
  58561. * @param texture texture load to
  58562. * @param transcodeResult the result of transcoding the basis file to load from
  58563. */
  58564. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58565. }
  58566. }
  58567. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58568. import { Nullable } from "babylonjs/types";
  58569. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58570. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58571. /**
  58572. * Loader for .basis file format
  58573. */
  58574. export class _BasisTextureLoader implements IInternalTextureLoader {
  58575. /**
  58576. * Defines whether the loader supports cascade loading the different faces.
  58577. */
  58578. readonly supportCascades: boolean;
  58579. /**
  58580. * This returns if the loader support the current file information.
  58581. * @param extension defines the file extension of the file being loaded
  58582. * @returns true if the loader can load the specified file
  58583. */
  58584. canLoad(extension: string): boolean;
  58585. /**
  58586. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58587. * @param data contains the texture data
  58588. * @param texture defines the BabylonJS internal texture
  58589. * @param createPolynomials will be true if polynomials have been requested
  58590. * @param onLoad defines the callback to trigger once the texture is ready
  58591. * @param onError defines the callback to trigger in case of error
  58592. */
  58593. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58594. /**
  58595. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58596. * @param data contains the texture data
  58597. * @param texture defines the BabylonJS internal texture
  58598. * @param callback defines the method to call once ready to upload
  58599. */
  58600. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58601. }
  58602. }
  58603. declare module "babylonjs/Materials/Textures/Loaders/index" {
  58604. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58605. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58606. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58607. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  58608. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  58609. }
  58610. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  58611. import { Scene } from "babylonjs/scene";
  58612. import { Texture } from "babylonjs/Materials/Textures/texture";
  58613. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58614. /**
  58615. * 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.
  58616. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58617. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58618. */
  58619. export class CustomProceduralTexture extends ProceduralTexture {
  58620. private _animate;
  58621. private _time;
  58622. private _config;
  58623. private _texturePath;
  58624. /**
  58625. * Instantiates a new Custom Procedural Texture.
  58626. * 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.
  58627. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58628. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58629. * @param name Define the name of the texture
  58630. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  58631. * @param size Define the size of the texture to create
  58632. * @param scene Define the scene the texture belongs to
  58633. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58634. * @param generateMipMaps Define if the texture should creates mip maps or not
  58635. */
  58636. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58637. private _loadJson;
  58638. /**
  58639. * Is the texture ready to be used ? (rendered at least once)
  58640. * @returns true if ready, otherwise, false.
  58641. */
  58642. isReady(): boolean;
  58643. /**
  58644. * Render the texture to its associated render target.
  58645. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58646. */
  58647. render(useCameraPostProcess?: boolean): void;
  58648. /**
  58649. * Update the list of dependant textures samplers in the shader.
  58650. */
  58651. updateTextures(): void;
  58652. /**
  58653. * Update the uniform values of the procedural texture in the shader.
  58654. */
  58655. updateShaderUniforms(): void;
  58656. /**
  58657. * Define if the texture animates or not.
  58658. */
  58659. get animate(): boolean;
  58660. set animate(value: boolean);
  58661. }
  58662. }
  58663. declare module "babylonjs/Shaders/noise.fragment" {
  58664. /** @hidden */
  58665. export var noisePixelShader: {
  58666. name: string;
  58667. shader: string;
  58668. };
  58669. }
  58670. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58671. import { Nullable } from "babylonjs/types";
  58672. import { Scene } from "babylonjs/scene";
  58673. import { Texture } from "babylonjs/Materials/Textures/texture";
  58674. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58675. import "babylonjs/Shaders/noise.fragment";
  58676. /**
  58677. * Class used to generate noise procedural textures
  58678. */
  58679. export class NoiseProceduralTexture extends ProceduralTexture {
  58680. private _time;
  58681. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58682. brightness: number;
  58683. /** Defines the number of octaves to process */
  58684. octaves: number;
  58685. /** Defines the level of persistence (0.8 by default) */
  58686. persistence: number;
  58687. /** Gets or sets animation speed factor (default is 1) */
  58688. animationSpeedFactor: number;
  58689. /**
  58690. * Creates a new NoiseProceduralTexture
  58691. * @param name defines the name fo the texture
  58692. * @param size defines the size of the texture (default is 256)
  58693. * @param scene defines the hosting scene
  58694. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58695. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58696. */
  58697. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58698. private _updateShaderUniforms;
  58699. protected _getDefines(): string;
  58700. /** Generate the current state of the procedural texture */
  58701. render(useCameraPostProcess?: boolean): void;
  58702. /**
  58703. * Serializes this noise procedural texture
  58704. * @returns a serialized noise procedural texture object
  58705. */
  58706. serialize(): any;
  58707. /**
  58708. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58709. * @param parsedTexture defines parsed texture data
  58710. * @param scene defines the current scene
  58711. * @param rootUrl defines the root URL containing noise procedural texture information
  58712. * @returns a parsed NoiseProceduralTexture
  58713. */
  58714. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58715. }
  58716. }
  58717. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58718. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58719. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58720. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58721. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58722. }
  58723. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58724. import { Nullable } from "babylonjs/types";
  58725. import { Scene } from "babylonjs/scene";
  58726. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58727. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58728. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58729. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58730. /**
  58731. * Raw cube texture where the raw buffers are passed in
  58732. */
  58733. export class RawCubeTexture extends CubeTexture {
  58734. /**
  58735. * Creates a cube texture where the raw buffers are passed in.
  58736. * @param scene defines the scene the texture is attached to
  58737. * @param data defines the array of data to use to create each face
  58738. * @param size defines the size of the textures
  58739. * @param format defines the format of the data
  58740. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58741. * @param generateMipMaps defines if the engine should generate the mip levels
  58742. * @param invertY defines if data must be stored with Y axis inverted
  58743. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58744. * @param compression defines the compression used (null by default)
  58745. */
  58746. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  58747. /**
  58748. * Updates the raw cube texture.
  58749. * @param data defines the data to store
  58750. * @param format defines the data format
  58751. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58752. * @param invertY defines if data must be stored with Y axis inverted
  58753. * @param compression defines the compression used (null by default)
  58754. * @param level defines which level of the texture to update
  58755. */
  58756. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  58757. /**
  58758. * Updates a raw cube texture with RGBD encoded data.
  58759. * @param data defines the array of data [mipmap][face] to use to create each face
  58760. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58761. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58762. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58763. * @returns a promsie that resolves when the operation is complete
  58764. */
  58765. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  58766. /**
  58767. * Clones the raw cube texture.
  58768. * @return a new cube texture
  58769. */
  58770. clone(): CubeTexture;
  58771. /** @hidden */
  58772. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58773. }
  58774. }
  58775. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  58776. import { Scene } from "babylonjs/scene";
  58777. import { Texture } from "babylonjs/Materials/Textures/texture";
  58778. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58779. /**
  58780. * Class used to store 3D textures containing user data
  58781. */
  58782. export class RawTexture3D extends Texture {
  58783. /** Gets or sets the texture format to use */
  58784. format: number;
  58785. private _engine;
  58786. /**
  58787. * Create a new RawTexture3D
  58788. * @param data defines the data of the texture
  58789. * @param width defines the width of the texture
  58790. * @param height defines the height of the texture
  58791. * @param depth defines the depth of the texture
  58792. * @param format defines the texture format to use
  58793. * @param scene defines the hosting scene
  58794. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58795. * @param invertY defines if texture must be stored with Y axis inverted
  58796. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58797. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58798. */
  58799. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58800. /** Gets or sets the texture format to use */
  58801. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58802. /**
  58803. * Update the texture with new data
  58804. * @param data defines the data to store in the texture
  58805. */
  58806. update(data: ArrayBufferView): void;
  58807. }
  58808. }
  58809. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  58810. import { Scene } from "babylonjs/scene";
  58811. import { Texture } from "babylonjs/Materials/Textures/texture";
  58812. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58813. /**
  58814. * Class used to store 2D array textures containing user data
  58815. */
  58816. export class RawTexture2DArray extends Texture {
  58817. /** Gets or sets the texture format to use */
  58818. format: number;
  58819. private _engine;
  58820. /**
  58821. * Create a new RawTexture2DArray
  58822. * @param data defines the data of the texture
  58823. * @param width defines the width of the texture
  58824. * @param height defines the height of the texture
  58825. * @param depth defines the number of layers of the texture
  58826. * @param format defines the texture format to use
  58827. * @param scene defines the hosting scene
  58828. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58829. * @param invertY defines if texture must be stored with Y axis inverted
  58830. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58831. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58832. */
  58833. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58834. /** Gets or sets the texture format to use */
  58835. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58836. /**
  58837. * Update the texture with new data
  58838. * @param data defines the data to store in the texture
  58839. */
  58840. update(data: ArrayBufferView): void;
  58841. }
  58842. }
  58843. declare module "babylonjs/Materials/Textures/refractionTexture" {
  58844. import { Scene } from "babylonjs/scene";
  58845. import { Plane } from "babylonjs/Maths/math.plane";
  58846. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58847. /**
  58848. * Creates a refraction texture used by refraction channel of the standard material.
  58849. * It is like a mirror but to see through a material.
  58850. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58851. */
  58852. export class RefractionTexture extends RenderTargetTexture {
  58853. /**
  58854. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  58855. * 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.
  58856. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58857. */
  58858. refractionPlane: Plane;
  58859. /**
  58860. * Define how deep under the surface we should see.
  58861. */
  58862. depth: number;
  58863. /**
  58864. * Creates a refraction texture used by refraction channel of the standard material.
  58865. * It is like a mirror but to see through a material.
  58866. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58867. * @param name Define the texture name
  58868. * @param size Define the size of the underlying texture
  58869. * @param scene Define the scene the refraction belongs to
  58870. * @param generateMipMaps Define if we need to generate mips level for the refraction
  58871. */
  58872. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  58873. /**
  58874. * Clone the refraction texture.
  58875. * @returns the cloned texture
  58876. */
  58877. clone(): RefractionTexture;
  58878. /**
  58879. * Serialize the texture to a JSON representation you could use in Parse later on
  58880. * @returns the serialized JSON representation
  58881. */
  58882. serialize(): any;
  58883. }
  58884. }
  58885. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  58886. import { Nullable } from "babylonjs/types";
  58887. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58888. import { Matrix } from "babylonjs/Maths/math.vector";
  58889. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  58890. import "babylonjs/Engines/Extensions/engine.videoTexture";
  58891. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58892. import { Scene } from "babylonjs/scene";
  58893. /**
  58894. * Defines the options related to the creation of an HtmlElementTexture
  58895. */
  58896. export interface IHtmlElementTextureOptions {
  58897. /**
  58898. * Defines wether mip maps should be created or not.
  58899. */
  58900. generateMipMaps?: boolean;
  58901. /**
  58902. * Defines the sampling mode of the texture.
  58903. */
  58904. samplingMode?: number;
  58905. /**
  58906. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  58907. */
  58908. engine: Nullable<ThinEngine>;
  58909. /**
  58910. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  58911. */
  58912. scene: Nullable<Scene>;
  58913. }
  58914. /**
  58915. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  58916. * To be as efficient as possible depending on your constraints nothing aside the first upload
  58917. * is automatically managed.
  58918. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  58919. * in your application.
  58920. *
  58921. * As the update is not automatic, you need to call them manually.
  58922. */
  58923. export class HtmlElementTexture extends BaseTexture {
  58924. /**
  58925. * The texture URL.
  58926. */
  58927. element: HTMLVideoElement | HTMLCanvasElement;
  58928. private static readonly DefaultOptions;
  58929. private _textureMatrix;
  58930. private _engine;
  58931. private _isVideo;
  58932. private _generateMipMaps;
  58933. private _samplingMode;
  58934. /**
  58935. * Instantiates a HtmlElementTexture from the following parameters.
  58936. *
  58937. * @param name Defines the name of the texture
  58938. * @param element Defines the video or canvas the texture is filled with
  58939. * @param options Defines the other none mandatory texture creation options
  58940. */
  58941. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  58942. private _createInternalTexture;
  58943. /**
  58944. * Returns the texture matrix used in most of the material.
  58945. */
  58946. getTextureMatrix(): Matrix;
  58947. /**
  58948. * Updates the content of the texture.
  58949. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  58950. */
  58951. update(invertY?: Nullable<boolean>): void;
  58952. }
  58953. }
  58954. declare module "babylonjs/Materials/Textures/Packer/frame" {
  58955. import { Vector2 } from "babylonjs/Maths/math.vector";
  58956. /**
  58957. * Defines the basic options interface of a TexturePacker Frame
  58958. */
  58959. export interface ITexturePackerFrame {
  58960. /**
  58961. * The frame ID
  58962. */
  58963. id: number;
  58964. /**
  58965. * The frames Scale
  58966. */
  58967. scale: Vector2;
  58968. /**
  58969. * The Frames offset
  58970. */
  58971. offset: Vector2;
  58972. }
  58973. /**
  58974. * This is a support class for frame Data on texture packer sets.
  58975. */
  58976. export class TexturePackerFrame implements ITexturePackerFrame {
  58977. /**
  58978. * The frame ID
  58979. */
  58980. id: number;
  58981. /**
  58982. * The frames Scale
  58983. */
  58984. scale: Vector2;
  58985. /**
  58986. * The Frames offset
  58987. */
  58988. offset: Vector2;
  58989. /**
  58990. * Initializes a texture package frame.
  58991. * @param id The numerical frame identifier
  58992. * @param scale Scalar Vector2 for UV frame
  58993. * @param offset Vector2 for the frame position in UV units.
  58994. * @returns TexturePackerFrame
  58995. */
  58996. constructor(id: number, scale: Vector2, offset: Vector2);
  58997. }
  58998. }
  58999. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59001. import { Scene } from "babylonjs/scene";
  59002. import { Nullable } from "babylonjs/types";
  59003. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59004. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59005. /**
  59006. * Defines the basic options interface of a TexturePacker
  59007. */
  59008. export interface ITexturePackerOptions {
  59009. /**
  59010. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59011. */
  59012. map?: string[];
  59013. /**
  59014. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59015. */
  59016. uvsIn?: string;
  59017. /**
  59018. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59019. */
  59020. uvsOut?: string;
  59021. /**
  59022. * number representing the layout style. Defaults to LAYOUT_STRIP
  59023. */
  59024. layout?: number;
  59025. /**
  59026. * number of columns if using custom column count layout(2). This defaults to 4.
  59027. */
  59028. colnum?: number;
  59029. /**
  59030. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59031. */
  59032. updateInputMeshes?: boolean;
  59033. /**
  59034. * boolean flag to dispose all the source textures. Defaults to true.
  59035. */
  59036. disposeSources?: boolean;
  59037. /**
  59038. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59039. */
  59040. fillBlanks?: boolean;
  59041. /**
  59042. * string value representing the context fill style color. Defaults to 'black'.
  59043. */
  59044. customFillColor?: string;
  59045. /**
  59046. * Width and Height Value of each Frame in the TexturePacker Sets
  59047. */
  59048. frameSize?: number;
  59049. /**
  59050. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59051. */
  59052. paddingRatio?: number;
  59053. /**
  59054. * Number that declares the fill method for the padding gutter.
  59055. */
  59056. paddingMode?: number;
  59057. /**
  59058. * If in SUBUV_COLOR padding mode what color to use.
  59059. */
  59060. paddingColor?: Color3 | Color4;
  59061. }
  59062. /**
  59063. * Defines the basic interface of a TexturePacker JSON File
  59064. */
  59065. export interface ITexturePackerJSON {
  59066. /**
  59067. * The frame ID
  59068. */
  59069. name: string;
  59070. /**
  59071. * The base64 channel data
  59072. */
  59073. sets: any;
  59074. /**
  59075. * The options of the Packer
  59076. */
  59077. options: ITexturePackerOptions;
  59078. /**
  59079. * The frame data of the Packer
  59080. */
  59081. frames: Array<number>;
  59082. }
  59083. /**
  59084. * This is a support class that generates a series of packed texture sets.
  59085. * @see https://doc.babylonjs.com/babylon101/materials
  59086. */
  59087. export class TexturePacker {
  59088. /** Packer Layout Constant 0 */
  59089. static readonly LAYOUT_STRIP: number;
  59090. /** Packer Layout Constant 1 */
  59091. static readonly LAYOUT_POWER2: number;
  59092. /** Packer Layout Constant 2 */
  59093. static readonly LAYOUT_COLNUM: number;
  59094. /** Packer Layout Constant 0 */
  59095. static readonly SUBUV_WRAP: number;
  59096. /** Packer Layout Constant 1 */
  59097. static readonly SUBUV_EXTEND: number;
  59098. /** Packer Layout Constant 2 */
  59099. static readonly SUBUV_COLOR: number;
  59100. /** The Name of the Texture Package */
  59101. name: string;
  59102. /** The scene scope of the TexturePacker */
  59103. scene: Scene;
  59104. /** The Meshes to target */
  59105. meshes: AbstractMesh[];
  59106. /** Arguments passed with the Constructor */
  59107. options: ITexturePackerOptions;
  59108. /** The promise that is started upon initialization */
  59109. promise: Nullable<Promise<TexturePacker | string>>;
  59110. /** The Container object for the channel sets that are generated */
  59111. sets: object;
  59112. /** The Container array for the frames that are generated */
  59113. frames: TexturePackerFrame[];
  59114. /** The expected number of textures the system is parsing. */
  59115. private _expecting;
  59116. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59117. private _paddingValue;
  59118. /**
  59119. * Initializes a texture package series from an array of meshes or a single mesh.
  59120. * @param name The name of the package
  59121. * @param meshes The target meshes to compose the package from
  59122. * @param options The arguments that texture packer should follow while building.
  59123. * @param scene The scene which the textures are scoped to.
  59124. * @returns TexturePacker
  59125. */
  59126. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59127. /**
  59128. * Starts the package process
  59129. * @param resolve The promises resolution function
  59130. * @returns TexturePacker
  59131. */
  59132. private _createFrames;
  59133. /**
  59134. * Calculates the Size of the Channel Sets
  59135. * @returns Vector2
  59136. */
  59137. private _calculateSize;
  59138. /**
  59139. * Calculates the UV data for the frames.
  59140. * @param baseSize the base frameSize
  59141. * @param padding the base frame padding
  59142. * @param dtSize size of the Dynamic Texture for that channel
  59143. * @param dtUnits is 1/dtSize
  59144. * @param update flag to update the input meshes
  59145. */
  59146. private _calculateMeshUVFrames;
  59147. /**
  59148. * Calculates the frames Offset.
  59149. * @param index of the frame
  59150. * @returns Vector2
  59151. */
  59152. private _getFrameOffset;
  59153. /**
  59154. * Updates a Mesh to the frame data
  59155. * @param mesh that is the target
  59156. * @param frameID or the frame index
  59157. */
  59158. private _updateMeshUV;
  59159. /**
  59160. * Updates a Meshes materials to use the texture packer channels
  59161. * @param m is the mesh to target
  59162. * @param force all channels on the packer to be set.
  59163. */
  59164. private _updateTextureReferences;
  59165. /**
  59166. * Public method to set a Mesh to a frame
  59167. * @param m that is the target
  59168. * @param frameID or the frame index
  59169. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59170. */
  59171. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59172. /**
  59173. * Starts the async promise to compile the texture packer.
  59174. * @returns Promise<void>
  59175. */
  59176. processAsync(): Promise<void>;
  59177. /**
  59178. * Disposes all textures associated with this packer
  59179. */
  59180. dispose(): void;
  59181. /**
  59182. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59183. * @param imageType is the image type to use.
  59184. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59185. */
  59186. download(imageType?: string, quality?: number): void;
  59187. /**
  59188. * Public method to load a texturePacker JSON file.
  59189. * @param data of the JSON file in string format.
  59190. */
  59191. updateFromJSON(data: string): void;
  59192. }
  59193. }
  59194. declare module "babylonjs/Materials/Textures/Packer/index" {
  59195. export * from "babylonjs/Materials/Textures/Packer/packer";
  59196. export * from "babylonjs/Materials/Textures/Packer/frame";
  59197. }
  59198. declare module "babylonjs/Materials/Textures/index" {
  59199. export * from "babylonjs/Materials/Textures/baseTexture";
  59200. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59201. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59202. export * from "babylonjs/Materials/Textures/cubeTexture";
  59203. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59204. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59205. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59206. export * from "babylonjs/Materials/Textures/internalTexture";
  59207. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59208. export * from "babylonjs/Materials/Textures/Loaders/index";
  59209. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59210. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59211. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59212. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59213. export * from "babylonjs/Materials/Textures/rawTexture";
  59214. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59215. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59216. export * from "babylonjs/Materials/Textures/refractionTexture";
  59217. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59218. export * from "babylonjs/Materials/Textures/texture";
  59219. export * from "babylonjs/Materials/Textures/videoTexture";
  59220. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59221. export * from "babylonjs/Materials/Textures/Packer/index";
  59222. }
  59223. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59224. /**
  59225. * Enum used to define the target of a block
  59226. */
  59227. export enum NodeMaterialBlockTargets {
  59228. /** Vertex shader */
  59229. Vertex = 1,
  59230. /** Fragment shader */
  59231. Fragment = 2,
  59232. /** Neutral */
  59233. Neutral = 4,
  59234. /** Vertex and Fragment */
  59235. VertexAndFragment = 3
  59236. }
  59237. }
  59238. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59239. /**
  59240. * Defines the kind of connection point for node based material
  59241. */
  59242. export enum NodeMaterialBlockConnectionPointTypes {
  59243. /** Float */
  59244. Float = 1,
  59245. /** Int */
  59246. Int = 2,
  59247. /** Vector2 */
  59248. Vector2 = 4,
  59249. /** Vector3 */
  59250. Vector3 = 8,
  59251. /** Vector4 */
  59252. Vector4 = 16,
  59253. /** Color3 */
  59254. Color3 = 32,
  59255. /** Color4 */
  59256. Color4 = 64,
  59257. /** Matrix */
  59258. Matrix = 128,
  59259. /** Detect type based on connection */
  59260. AutoDetect = 1024,
  59261. /** Output type that will be defined by input type */
  59262. BasedOnInput = 2048
  59263. }
  59264. }
  59265. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59266. /**
  59267. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59268. */
  59269. export enum NodeMaterialBlockConnectionPointMode {
  59270. /** Value is an uniform */
  59271. Uniform = 0,
  59272. /** Value is a mesh attribute */
  59273. Attribute = 1,
  59274. /** Value is a varying between vertex and fragment shaders */
  59275. Varying = 2,
  59276. /** Mode is undefined */
  59277. Undefined = 3
  59278. }
  59279. }
  59280. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59281. /**
  59282. * Enum used to define system values e.g. values automatically provided by the system
  59283. */
  59284. export enum NodeMaterialSystemValues {
  59285. /** World */
  59286. World = 1,
  59287. /** View */
  59288. View = 2,
  59289. /** Projection */
  59290. Projection = 3,
  59291. /** ViewProjection */
  59292. ViewProjection = 4,
  59293. /** WorldView */
  59294. WorldView = 5,
  59295. /** WorldViewProjection */
  59296. WorldViewProjection = 6,
  59297. /** CameraPosition */
  59298. CameraPosition = 7,
  59299. /** Fog Color */
  59300. FogColor = 8,
  59301. /** Delta time */
  59302. DeltaTime = 9
  59303. }
  59304. }
  59305. declare module "babylonjs/Materials/Node/Enums/index" {
  59306. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59307. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59308. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59309. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59310. }
  59311. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59312. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59313. /**
  59314. * Root class for all node material optimizers
  59315. */
  59316. export class NodeMaterialOptimizer {
  59317. /**
  59318. * Function used to optimize a NodeMaterial graph
  59319. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59320. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59321. */
  59322. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59323. }
  59324. }
  59325. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59326. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59327. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59328. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59329. import { Scene } from "babylonjs/scene";
  59330. /**
  59331. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59332. */
  59333. export class TransformBlock extends NodeMaterialBlock {
  59334. /**
  59335. * Defines the value to use to complement W value to transform it to a Vector4
  59336. */
  59337. complementW: number;
  59338. /**
  59339. * Defines the value to use to complement z value to transform it to a Vector4
  59340. */
  59341. complementZ: number;
  59342. /**
  59343. * Creates a new TransformBlock
  59344. * @param name defines the block name
  59345. */
  59346. constructor(name: string);
  59347. /**
  59348. * Gets the current class name
  59349. * @returns the class name
  59350. */
  59351. getClassName(): string;
  59352. /**
  59353. * Gets the vector input
  59354. */
  59355. get vector(): NodeMaterialConnectionPoint;
  59356. /**
  59357. * Gets the output component
  59358. */
  59359. get output(): NodeMaterialConnectionPoint;
  59360. /**
  59361. * Gets the matrix transform input
  59362. */
  59363. get transform(): NodeMaterialConnectionPoint;
  59364. protected _buildBlock(state: NodeMaterialBuildState): this;
  59365. serialize(): any;
  59366. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59367. protected _dumpPropertiesCode(): string;
  59368. }
  59369. }
  59370. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59371. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59372. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59373. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59374. /**
  59375. * Block used to output the vertex position
  59376. */
  59377. export class VertexOutputBlock extends NodeMaterialBlock {
  59378. /**
  59379. * Creates a new VertexOutputBlock
  59380. * @param name defines the block name
  59381. */
  59382. constructor(name: string);
  59383. /**
  59384. * Gets the current class name
  59385. * @returns the class name
  59386. */
  59387. getClassName(): string;
  59388. /**
  59389. * Gets the vector input component
  59390. */
  59391. get vector(): NodeMaterialConnectionPoint;
  59392. protected _buildBlock(state: NodeMaterialBuildState): this;
  59393. }
  59394. }
  59395. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59396. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59397. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59398. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59399. /**
  59400. * Block used to output the final color
  59401. */
  59402. export class FragmentOutputBlock extends NodeMaterialBlock {
  59403. /**
  59404. * Create a new FragmentOutputBlock
  59405. * @param name defines the block name
  59406. */
  59407. constructor(name: string);
  59408. /**
  59409. * Gets the current class name
  59410. * @returns the class name
  59411. */
  59412. getClassName(): string;
  59413. /**
  59414. * Gets the rgba input component
  59415. */
  59416. get rgba(): NodeMaterialConnectionPoint;
  59417. /**
  59418. * Gets the rgb input component
  59419. */
  59420. get rgb(): NodeMaterialConnectionPoint;
  59421. /**
  59422. * Gets the a input component
  59423. */
  59424. get a(): NodeMaterialConnectionPoint;
  59425. protected _buildBlock(state: NodeMaterialBuildState): this;
  59426. }
  59427. }
  59428. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59429. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59430. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59431. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59432. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59434. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59435. import { Effect } from "babylonjs/Materials/effect";
  59436. import { Mesh } from "babylonjs/Meshes/mesh";
  59437. import { Nullable } from "babylonjs/types";
  59438. import { Scene } from "babylonjs/scene";
  59439. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59440. /**
  59441. * Block used to read a reflection texture from a sampler
  59442. */
  59443. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59444. private _define3DName;
  59445. private _defineCubicName;
  59446. private _defineExplicitName;
  59447. private _defineProjectionName;
  59448. private _defineLocalCubicName;
  59449. private _defineSphericalName;
  59450. private _definePlanarName;
  59451. private _defineEquirectangularName;
  59452. private _defineMirroredEquirectangularFixedName;
  59453. private _defineEquirectangularFixedName;
  59454. private _defineSkyboxName;
  59455. private _cubeSamplerName;
  59456. private _2DSamplerName;
  59457. private _positionUVWName;
  59458. private _directionWName;
  59459. private _reflectionCoordsName;
  59460. private _reflection2DCoordsName;
  59461. private _reflectionColorName;
  59462. private _reflectionMatrixName;
  59463. /**
  59464. * Gets or sets the texture associated with the node
  59465. */
  59466. texture: Nullable<BaseTexture>;
  59467. /**
  59468. * Create a new TextureBlock
  59469. * @param name defines the block name
  59470. */
  59471. constructor(name: string);
  59472. /**
  59473. * Gets the current class name
  59474. * @returns the class name
  59475. */
  59476. getClassName(): string;
  59477. /**
  59478. * Gets the world position input component
  59479. */
  59480. get position(): NodeMaterialConnectionPoint;
  59481. /**
  59482. * Gets the world position input component
  59483. */
  59484. get worldPosition(): NodeMaterialConnectionPoint;
  59485. /**
  59486. * Gets the world normal input component
  59487. */
  59488. get worldNormal(): NodeMaterialConnectionPoint;
  59489. /**
  59490. * Gets the world input component
  59491. */
  59492. get world(): NodeMaterialConnectionPoint;
  59493. /**
  59494. * Gets the camera (or eye) position component
  59495. */
  59496. get cameraPosition(): NodeMaterialConnectionPoint;
  59497. /**
  59498. * Gets the view input component
  59499. */
  59500. get view(): NodeMaterialConnectionPoint;
  59501. /**
  59502. * Gets the rgb output component
  59503. */
  59504. get rgb(): NodeMaterialConnectionPoint;
  59505. /**
  59506. * Gets the r output component
  59507. */
  59508. get r(): NodeMaterialConnectionPoint;
  59509. /**
  59510. * Gets the g output component
  59511. */
  59512. get g(): NodeMaterialConnectionPoint;
  59513. /**
  59514. * Gets the b output component
  59515. */
  59516. get b(): NodeMaterialConnectionPoint;
  59517. autoConfigure(material: NodeMaterial): void;
  59518. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59519. isReady(): boolean;
  59520. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59521. private _injectVertexCode;
  59522. private _writeOutput;
  59523. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59524. protected _dumpPropertiesCode(): string;
  59525. serialize(): any;
  59526. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59527. }
  59528. }
  59529. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59530. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59531. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59532. import { Scene } from "babylonjs/scene";
  59533. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59534. import { Matrix } from "babylonjs/Maths/math.vector";
  59535. import { Mesh } from "babylonjs/Meshes/mesh";
  59536. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59537. import { Observable } from "babylonjs/Misc/observable";
  59538. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59539. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59540. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59541. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59542. import { Nullable } from "babylonjs/types";
  59543. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59544. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59545. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59546. /**
  59547. * Interface used to configure the node material editor
  59548. */
  59549. export interface INodeMaterialEditorOptions {
  59550. /** Define the URl to load node editor script */
  59551. editorURL?: string;
  59552. }
  59553. /** @hidden */
  59554. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59555. NORMAL: boolean;
  59556. TANGENT: boolean;
  59557. UV1: boolean;
  59558. /** BONES */
  59559. NUM_BONE_INFLUENCERS: number;
  59560. BonesPerMesh: number;
  59561. BONETEXTURE: boolean;
  59562. /** MORPH TARGETS */
  59563. MORPHTARGETS: boolean;
  59564. MORPHTARGETS_NORMAL: boolean;
  59565. MORPHTARGETS_TANGENT: boolean;
  59566. MORPHTARGETS_UV: boolean;
  59567. NUM_MORPH_INFLUENCERS: number;
  59568. /** IMAGE PROCESSING */
  59569. IMAGEPROCESSING: boolean;
  59570. VIGNETTE: boolean;
  59571. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59572. VIGNETTEBLENDMODEOPAQUE: boolean;
  59573. TONEMAPPING: boolean;
  59574. TONEMAPPING_ACES: boolean;
  59575. CONTRAST: boolean;
  59576. EXPOSURE: boolean;
  59577. COLORCURVES: boolean;
  59578. COLORGRADING: boolean;
  59579. COLORGRADING3D: boolean;
  59580. SAMPLER3DGREENDEPTH: boolean;
  59581. SAMPLER3DBGRMAP: boolean;
  59582. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59583. /** MISC. */
  59584. BUMPDIRECTUV: number;
  59585. constructor();
  59586. setValue(name: string, value: boolean): void;
  59587. }
  59588. /**
  59589. * Class used to configure NodeMaterial
  59590. */
  59591. export interface INodeMaterialOptions {
  59592. /**
  59593. * Defines if blocks should emit comments
  59594. */
  59595. emitComments: boolean;
  59596. }
  59597. /**
  59598. * Class used to create a node based material built by assembling shader blocks
  59599. */
  59600. export class NodeMaterial extends PushMaterial {
  59601. private static _BuildIdGenerator;
  59602. private _options;
  59603. private _vertexCompilationState;
  59604. private _fragmentCompilationState;
  59605. private _sharedData;
  59606. private _buildId;
  59607. private _buildWasSuccessful;
  59608. private _cachedWorldViewMatrix;
  59609. private _cachedWorldViewProjectionMatrix;
  59610. private _optimizers;
  59611. private _animationFrame;
  59612. /** Define the Url to load node editor script */
  59613. static EditorURL: string;
  59614. /** Define the Url to load snippets */
  59615. static SnippetUrl: string;
  59616. private BJSNODEMATERIALEDITOR;
  59617. /** Get the inspector from bundle or global */
  59618. private _getGlobalNodeMaterialEditor;
  59619. /**
  59620. * Gets or sets data used by visual editor
  59621. * @see https://nme.babylonjs.com
  59622. */
  59623. editorData: any;
  59624. /**
  59625. * 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)
  59626. */
  59627. ignoreAlpha: boolean;
  59628. /**
  59629. * Defines the maximum number of lights that can be used in the material
  59630. */
  59631. maxSimultaneousLights: number;
  59632. /**
  59633. * Observable raised when the material is built
  59634. */
  59635. onBuildObservable: Observable<NodeMaterial>;
  59636. /**
  59637. * Gets or sets the root nodes of the material vertex shader
  59638. */
  59639. _vertexOutputNodes: NodeMaterialBlock[];
  59640. /**
  59641. * Gets or sets the root nodes of the material fragment (pixel) shader
  59642. */
  59643. _fragmentOutputNodes: NodeMaterialBlock[];
  59644. /** Gets or sets options to control the node material overall behavior */
  59645. get options(): INodeMaterialOptions;
  59646. set options(options: INodeMaterialOptions);
  59647. /**
  59648. * Default configuration related to image processing available in the standard Material.
  59649. */
  59650. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59651. /**
  59652. * Gets the image processing configuration used either in this material.
  59653. */
  59654. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59655. /**
  59656. * Sets the Default image processing configuration used either in the this material.
  59657. *
  59658. * If sets to null, the scene one is in use.
  59659. */
  59660. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59661. /**
  59662. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59663. */
  59664. attachedBlocks: NodeMaterialBlock[];
  59665. /**
  59666. * Create a new node based material
  59667. * @param name defines the material name
  59668. * @param scene defines the hosting scene
  59669. * @param options defines creation option
  59670. */
  59671. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59672. /**
  59673. * Gets the current class name of the material e.g. "NodeMaterial"
  59674. * @returns the class name
  59675. */
  59676. getClassName(): string;
  59677. /**
  59678. * Keep track of the image processing observer to allow dispose and replace.
  59679. */
  59680. private _imageProcessingObserver;
  59681. /**
  59682. * Attaches a new image processing configuration to the Standard Material.
  59683. * @param configuration
  59684. */
  59685. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59686. /**
  59687. * Get a block by its name
  59688. * @param name defines the name of the block to retrieve
  59689. * @returns the required block or null if not found
  59690. */
  59691. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59692. /**
  59693. * Get a block by its name
  59694. * @param predicate defines the predicate used to find the good candidate
  59695. * @returns the required block or null if not found
  59696. */
  59697. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59698. /**
  59699. * Get an input block by its name
  59700. * @param predicate defines the predicate used to find the good candidate
  59701. * @returns the required input block or null if not found
  59702. */
  59703. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59704. /**
  59705. * Gets the list of input blocks attached to this material
  59706. * @returns an array of InputBlocks
  59707. */
  59708. getInputBlocks(): InputBlock[];
  59709. /**
  59710. * Adds a new optimizer to the list of optimizers
  59711. * @param optimizer defines the optimizers to add
  59712. * @returns the current material
  59713. */
  59714. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59715. /**
  59716. * Remove an optimizer from the list of optimizers
  59717. * @param optimizer defines the optimizers to remove
  59718. * @returns the current material
  59719. */
  59720. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59721. /**
  59722. * Add a new block to the list of output nodes
  59723. * @param node defines the node to add
  59724. * @returns the current material
  59725. */
  59726. addOutputNode(node: NodeMaterialBlock): this;
  59727. /**
  59728. * Remove a block from the list of root nodes
  59729. * @param node defines the node to remove
  59730. * @returns the current material
  59731. */
  59732. removeOutputNode(node: NodeMaterialBlock): this;
  59733. private _addVertexOutputNode;
  59734. private _removeVertexOutputNode;
  59735. private _addFragmentOutputNode;
  59736. private _removeFragmentOutputNode;
  59737. /**
  59738. * Specifies if the material will require alpha blending
  59739. * @returns a boolean specifying if alpha blending is needed
  59740. */
  59741. needAlphaBlending(): boolean;
  59742. /**
  59743. * Specifies if this material should be rendered in alpha test mode
  59744. * @returns a boolean specifying if an alpha test is needed.
  59745. */
  59746. needAlphaTesting(): boolean;
  59747. private _initializeBlock;
  59748. private _resetDualBlocks;
  59749. /**
  59750. * Remove a block from the current node material
  59751. * @param block defines the block to remove
  59752. */
  59753. removeBlock(block: NodeMaterialBlock): void;
  59754. /**
  59755. * Build the material and generates the inner effect
  59756. * @param verbose defines if the build should log activity
  59757. */
  59758. build(verbose?: boolean): void;
  59759. /**
  59760. * Runs an otpimization phase to try to improve the shader code
  59761. */
  59762. optimize(): void;
  59763. private _prepareDefinesForAttributes;
  59764. /**
  59765. * Get if the submesh is ready to be used and all its information available.
  59766. * Child classes can use it to update shaders
  59767. * @param mesh defines the mesh to check
  59768. * @param subMesh defines which submesh to check
  59769. * @param useInstances specifies that instances should be used
  59770. * @returns a boolean indicating that the submesh is ready or not
  59771. */
  59772. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59773. /**
  59774. * Get a string representing the shaders built by the current node graph
  59775. */
  59776. get compiledShaders(): string;
  59777. /**
  59778. * Binds the world matrix to the material
  59779. * @param world defines the world transformation matrix
  59780. */
  59781. bindOnlyWorldMatrix(world: Matrix): void;
  59782. /**
  59783. * Binds the submesh to this material by preparing the effect and shader to draw
  59784. * @param world defines the world transformation matrix
  59785. * @param mesh defines the mesh containing the submesh
  59786. * @param subMesh defines the submesh to bind the material to
  59787. */
  59788. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59789. /**
  59790. * Gets the active textures from the material
  59791. * @returns an array of textures
  59792. */
  59793. getActiveTextures(): BaseTexture[];
  59794. /**
  59795. * Gets the list of texture blocks
  59796. * @returns an array of texture blocks
  59797. */
  59798. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  59799. /**
  59800. * Specifies if the material uses a texture
  59801. * @param texture defines the texture to check against the material
  59802. * @returns a boolean specifying if the material uses the texture
  59803. */
  59804. hasTexture(texture: BaseTexture): boolean;
  59805. /**
  59806. * Disposes the material
  59807. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  59808. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  59809. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  59810. */
  59811. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  59812. /** Creates the node editor window. */
  59813. private _createNodeEditor;
  59814. /**
  59815. * Launch the node material editor
  59816. * @param config Define the configuration of the editor
  59817. * @return a promise fulfilled when the node editor is visible
  59818. */
  59819. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  59820. /**
  59821. * Clear the current material
  59822. */
  59823. clear(): void;
  59824. /**
  59825. * Clear the current material and set it to a default state
  59826. */
  59827. setToDefault(): void;
  59828. /**
  59829. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  59830. * @param url defines the url to load from
  59831. * @returns a promise that will fullfil when the material is fully loaded
  59832. */
  59833. loadAsync(url: string): Promise<void>;
  59834. private _gatherBlocks;
  59835. /**
  59836. * Generate a string containing the code declaration required to create an equivalent of this material
  59837. * @returns a string
  59838. */
  59839. generateCode(): string;
  59840. /**
  59841. * Serializes this material in a JSON representation
  59842. * @returns the serialized material object
  59843. */
  59844. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  59845. private _restoreConnections;
  59846. /**
  59847. * Clear the current graph and load a new one from a serialization object
  59848. * @param source defines the JSON representation of the material
  59849. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59850. */
  59851. loadFromSerialization(source: any, rootUrl?: string): void;
  59852. /**
  59853. * Creates a node material from parsed material data
  59854. * @param source defines the JSON representation of the material
  59855. * @param scene defines the hosting scene
  59856. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59857. * @returns a new node material
  59858. */
  59859. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  59860. /**
  59861. * Creates a node material from a snippet saved in a remote file
  59862. * @param name defines the name of the material to create
  59863. * @param url defines the url to load from
  59864. * @param scene defines the hosting scene
  59865. * @returns a promise that will resolve to the new node material
  59866. */
  59867. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  59868. /**
  59869. * Creates a node material from a snippet saved by the node material editor
  59870. * @param snippetId defines the snippet to load
  59871. * @param scene defines the hosting scene
  59872. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59873. * @returns a promise that will resolve to the new node material
  59874. */
  59875. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  59876. /**
  59877. * Creates a new node material set to default basic configuration
  59878. * @param name defines the name of the material
  59879. * @param scene defines the hosting scene
  59880. * @returns a new NodeMaterial
  59881. */
  59882. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  59883. }
  59884. }
  59885. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  59886. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59887. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59888. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59889. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59890. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59891. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59892. import { Effect } from "babylonjs/Materials/effect";
  59893. import { Mesh } from "babylonjs/Meshes/mesh";
  59894. import { Nullable } from "babylonjs/types";
  59895. import { Texture } from "babylonjs/Materials/Textures/texture";
  59896. import { Scene } from "babylonjs/scene";
  59897. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59898. /**
  59899. * Block used to read a texture from a sampler
  59900. */
  59901. export class TextureBlock extends NodeMaterialBlock {
  59902. private _defineName;
  59903. private _linearDefineName;
  59904. private _tempTextureRead;
  59905. private _samplerName;
  59906. private _transformedUVName;
  59907. private _textureTransformName;
  59908. private _textureInfoName;
  59909. private _mainUVName;
  59910. private _mainUVDefineName;
  59911. /**
  59912. * Gets or sets the texture associated with the node
  59913. */
  59914. texture: Nullable<Texture>;
  59915. /**
  59916. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  59917. */
  59918. convertToGammaSpace: boolean;
  59919. /**
  59920. * Create a new TextureBlock
  59921. * @param name defines the block name
  59922. */
  59923. constructor(name: string);
  59924. /**
  59925. * Gets the current class name
  59926. * @returns the class name
  59927. */
  59928. getClassName(): string;
  59929. /**
  59930. * Gets the uv input component
  59931. */
  59932. get uv(): NodeMaterialConnectionPoint;
  59933. /**
  59934. * Gets the rgba output component
  59935. */
  59936. get rgba(): NodeMaterialConnectionPoint;
  59937. /**
  59938. * Gets the rgb output component
  59939. */
  59940. get rgb(): NodeMaterialConnectionPoint;
  59941. /**
  59942. * Gets the r output component
  59943. */
  59944. get r(): NodeMaterialConnectionPoint;
  59945. /**
  59946. * Gets the g output component
  59947. */
  59948. get g(): NodeMaterialConnectionPoint;
  59949. /**
  59950. * Gets the b output component
  59951. */
  59952. get b(): NodeMaterialConnectionPoint;
  59953. /**
  59954. * Gets the a output component
  59955. */
  59956. get a(): NodeMaterialConnectionPoint;
  59957. get target(): NodeMaterialBlockTargets;
  59958. autoConfigure(material: NodeMaterial): void;
  59959. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  59960. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59961. isReady(): boolean;
  59962. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59963. private get _isMixed();
  59964. private _injectVertexCode;
  59965. private _writeTextureRead;
  59966. private _writeOutput;
  59967. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59968. protected _dumpPropertiesCode(): string;
  59969. serialize(): any;
  59970. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59971. }
  59972. }
  59973. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  59974. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59975. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59976. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59977. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59978. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59979. import { Scene } from "babylonjs/scene";
  59980. /**
  59981. * Class used to store shared data between 2 NodeMaterialBuildState
  59982. */
  59983. export class NodeMaterialBuildStateSharedData {
  59984. /**
  59985. * Gets the list of emitted varyings
  59986. */
  59987. temps: string[];
  59988. /**
  59989. * Gets the list of emitted varyings
  59990. */
  59991. varyings: string[];
  59992. /**
  59993. * Gets the varying declaration string
  59994. */
  59995. varyingDeclaration: string;
  59996. /**
  59997. * Input blocks
  59998. */
  59999. inputBlocks: InputBlock[];
  60000. /**
  60001. * Input blocks
  60002. */
  60003. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60004. /**
  60005. * Bindable blocks (Blocks that need to set data to the effect)
  60006. */
  60007. bindableBlocks: NodeMaterialBlock[];
  60008. /**
  60009. * List of blocks that can provide a compilation fallback
  60010. */
  60011. blocksWithFallbacks: NodeMaterialBlock[];
  60012. /**
  60013. * List of blocks that can provide a define update
  60014. */
  60015. blocksWithDefines: NodeMaterialBlock[];
  60016. /**
  60017. * List of blocks that can provide a repeatable content
  60018. */
  60019. repeatableContentBlocks: NodeMaterialBlock[];
  60020. /**
  60021. * List of blocks that can provide a dynamic list of uniforms
  60022. */
  60023. dynamicUniformBlocks: NodeMaterialBlock[];
  60024. /**
  60025. * List of blocks that can block the isReady function for the material
  60026. */
  60027. blockingBlocks: NodeMaterialBlock[];
  60028. /**
  60029. * Gets the list of animated inputs
  60030. */
  60031. animatedInputs: InputBlock[];
  60032. /**
  60033. * Build Id used to avoid multiple recompilations
  60034. */
  60035. buildId: number;
  60036. /** List of emitted variables */
  60037. variableNames: {
  60038. [key: string]: number;
  60039. };
  60040. /** List of emitted defines */
  60041. defineNames: {
  60042. [key: string]: number;
  60043. };
  60044. /** Should emit comments? */
  60045. emitComments: boolean;
  60046. /** Emit build activity */
  60047. verbose: boolean;
  60048. /** Gets or sets the hosting scene */
  60049. scene: Scene;
  60050. /**
  60051. * Gets the compilation hints emitted at compilation time
  60052. */
  60053. hints: {
  60054. needWorldViewMatrix: boolean;
  60055. needWorldViewProjectionMatrix: boolean;
  60056. needAlphaBlending: boolean;
  60057. needAlphaTesting: boolean;
  60058. };
  60059. /**
  60060. * List of compilation checks
  60061. */
  60062. checks: {
  60063. emitVertex: boolean;
  60064. emitFragment: boolean;
  60065. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60066. };
  60067. /** Creates a new shared data */
  60068. constructor();
  60069. /**
  60070. * Emits console errors and exceptions if there is a failing check
  60071. */
  60072. emitErrors(): void;
  60073. }
  60074. }
  60075. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60076. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60077. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60078. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60079. /**
  60080. * Class used to store node based material build state
  60081. */
  60082. export class NodeMaterialBuildState {
  60083. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60084. supportUniformBuffers: boolean;
  60085. /**
  60086. * Gets the list of emitted attributes
  60087. */
  60088. attributes: string[];
  60089. /**
  60090. * Gets the list of emitted uniforms
  60091. */
  60092. uniforms: string[];
  60093. /**
  60094. * Gets the list of emitted constants
  60095. */
  60096. constants: string[];
  60097. /**
  60098. * Gets the list of emitted samplers
  60099. */
  60100. samplers: string[];
  60101. /**
  60102. * Gets the list of emitted functions
  60103. */
  60104. functions: {
  60105. [key: string]: string;
  60106. };
  60107. /**
  60108. * Gets the list of emitted extensions
  60109. */
  60110. extensions: {
  60111. [key: string]: string;
  60112. };
  60113. /**
  60114. * Gets the target of the compilation state
  60115. */
  60116. target: NodeMaterialBlockTargets;
  60117. /**
  60118. * Gets the list of emitted counters
  60119. */
  60120. counters: {
  60121. [key: string]: number;
  60122. };
  60123. /**
  60124. * Shared data between multiple NodeMaterialBuildState instances
  60125. */
  60126. sharedData: NodeMaterialBuildStateSharedData;
  60127. /** @hidden */
  60128. _vertexState: NodeMaterialBuildState;
  60129. /** @hidden */
  60130. _attributeDeclaration: string;
  60131. /** @hidden */
  60132. _uniformDeclaration: string;
  60133. /** @hidden */
  60134. _constantDeclaration: string;
  60135. /** @hidden */
  60136. _samplerDeclaration: string;
  60137. /** @hidden */
  60138. _varyingTransfer: string;
  60139. private _repeatableContentAnchorIndex;
  60140. /** @hidden */
  60141. _builtCompilationString: string;
  60142. /**
  60143. * Gets the emitted compilation strings
  60144. */
  60145. compilationString: string;
  60146. /**
  60147. * Finalize the compilation strings
  60148. * @param state defines the current compilation state
  60149. */
  60150. finalize(state: NodeMaterialBuildState): void;
  60151. /** @hidden */
  60152. get _repeatableContentAnchor(): string;
  60153. /** @hidden */
  60154. _getFreeVariableName(prefix: string): string;
  60155. /** @hidden */
  60156. _getFreeDefineName(prefix: string): string;
  60157. /** @hidden */
  60158. _excludeVariableName(name: string): void;
  60159. /** @hidden */
  60160. _emit2DSampler(name: string): void;
  60161. /** @hidden */
  60162. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60163. /** @hidden */
  60164. _emitExtension(name: string, extension: string): void;
  60165. /** @hidden */
  60166. _emitFunction(name: string, code: string, comments: string): void;
  60167. /** @hidden */
  60168. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60169. replaceStrings?: {
  60170. search: RegExp;
  60171. replace: string;
  60172. }[];
  60173. repeatKey?: string;
  60174. }): string;
  60175. /** @hidden */
  60176. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60177. repeatKey?: string;
  60178. removeAttributes?: boolean;
  60179. removeUniforms?: boolean;
  60180. removeVaryings?: boolean;
  60181. removeIfDef?: boolean;
  60182. replaceStrings?: {
  60183. search: RegExp;
  60184. replace: string;
  60185. }[];
  60186. }, storeKey?: string): void;
  60187. /** @hidden */
  60188. _registerTempVariable(name: string): boolean;
  60189. /** @hidden */
  60190. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60191. /** @hidden */
  60192. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60193. /** @hidden */
  60194. _emitFloat(value: number): string;
  60195. }
  60196. }
  60197. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60198. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60199. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60200. import { Nullable } from "babylonjs/types";
  60201. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60202. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60203. import { Effect } from "babylonjs/Materials/effect";
  60204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60205. import { Mesh } from "babylonjs/Meshes/mesh";
  60206. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60207. import { Scene } from "babylonjs/scene";
  60208. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60209. /**
  60210. * Defines a block that can be used inside a node based material
  60211. */
  60212. export class NodeMaterialBlock {
  60213. private _buildId;
  60214. private _buildTarget;
  60215. private _target;
  60216. private _isFinalMerger;
  60217. private _isInput;
  60218. protected _isUnique: boolean;
  60219. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60220. inputsAreExclusive: boolean;
  60221. /** @hidden */
  60222. _codeVariableName: string;
  60223. /** @hidden */
  60224. _inputs: NodeMaterialConnectionPoint[];
  60225. /** @hidden */
  60226. _outputs: NodeMaterialConnectionPoint[];
  60227. /** @hidden */
  60228. _preparationId: number;
  60229. /**
  60230. * Gets or sets the name of the block
  60231. */
  60232. name: string;
  60233. /**
  60234. * Gets or sets the unique id of the node
  60235. */
  60236. uniqueId: number;
  60237. /**
  60238. * Gets or sets the comments associated with this block
  60239. */
  60240. comments: string;
  60241. /**
  60242. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60243. */
  60244. get isUnique(): boolean;
  60245. /**
  60246. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60247. */
  60248. get isFinalMerger(): boolean;
  60249. /**
  60250. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60251. */
  60252. get isInput(): boolean;
  60253. /**
  60254. * Gets or sets the build Id
  60255. */
  60256. get buildId(): number;
  60257. set buildId(value: number);
  60258. /**
  60259. * Gets or sets the target of the block
  60260. */
  60261. get target(): NodeMaterialBlockTargets;
  60262. set target(value: NodeMaterialBlockTargets);
  60263. /**
  60264. * Gets the list of input points
  60265. */
  60266. get inputs(): NodeMaterialConnectionPoint[];
  60267. /** Gets the list of output points */
  60268. get outputs(): NodeMaterialConnectionPoint[];
  60269. /**
  60270. * Find an input by its name
  60271. * @param name defines the name of the input to look for
  60272. * @returns the input or null if not found
  60273. */
  60274. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60275. /**
  60276. * Find an output by its name
  60277. * @param name defines the name of the outputto look for
  60278. * @returns the output or null if not found
  60279. */
  60280. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60281. /**
  60282. * Creates a new NodeMaterialBlock
  60283. * @param name defines the block name
  60284. * @param target defines the target of that block (Vertex by default)
  60285. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60286. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60287. */
  60288. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60289. /**
  60290. * Initialize the block and prepare the context for build
  60291. * @param state defines the state that will be used for the build
  60292. */
  60293. initialize(state: NodeMaterialBuildState): void;
  60294. /**
  60295. * Bind data to effect. Will only be called for blocks with isBindable === true
  60296. * @param effect defines the effect to bind data to
  60297. * @param nodeMaterial defines the hosting NodeMaterial
  60298. * @param mesh defines the mesh that will be rendered
  60299. */
  60300. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60301. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60302. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60303. protected _writeFloat(value: number): string;
  60304. /**
  60305. * Gets the current class name e.g. "NodeMaterialBlock"
  60306. * @returns the class name
  60307. */
  60308. getClassName(): string;
  60309. /**
  60310. * Register a new input. Must be called inside a block constructor
  60311. * @param name defines the connection point name
  60312. * @param type defines the connection point type
  60313. * @param isOptional defines a boolean indicating that this input can be omitted
  60314. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60315. * @returns the current block
  60316. */
  60317. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60318. /**
  60319. * Register a new output. Must be called inside a block constructor
  60320. * @param name defines the connection point name
  60321. * @param type defines the connection point type
  60322. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60323. * @returns the current block
  60324. */
  60325. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60326. /**
  60327. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60328. * @param forOutput defines an optional connection point to check compatibility with
  60329. * @returns the first available input or null
  60330. */
  60331. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60332. /**
  60333. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60334. * @param forBlock defines an optional block to check compatibility with
  60335. * @returns the first available input or null
  60336. */
  60337. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60338. /**
  60339. * Gets the sibling of the given output
  60340. * @param current defines the current output
  60341. * @returns the next output in the list or null
  60342. */
  60343. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60344. /**
  60345. * Connect current block with another block
  60346. * @param other defines the block to connect with
  60347. * @param options define the various options to help pick the right connections
  60348. * @returns the current block
  60349. */
  60350. connectTo(other: NodeMaterialBlock, options?: {
  60351. input?: string;
  60352. output?: string;
  60353. outputSwizzle?: string;
  60354. }): this | undefined;
  60355. protected _buildBlock(state: NodeMaterialBuildState): void;
  60356. /**
  60357. * Add uniforms, samplers and uniform buffers at compilation time
  60358. * @param state defines the state to update
  60359. * @param nodeMaterial defines the node material requesting the update
  60360. * @param defines defines the material defines to update
  60361. * @param uniformBuffers defines the list of uniform buffer names
  60362. */
  60363. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60364. /**
  60365. * Add potential fallbacks if shader compilation fails
  60366. * @param mesh defines the mesh to be rendered
  60367. * @param fallbacks defines the current prioritized list of fallbacks
  60368. */
  60369. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60370. /**
  60371. * Initialize defines for shader compilation
  60372. * @param mesh defines the mesh to be rendered
  60373. * @param nodeMaterial defines the node material requesting the update
  60374. * @param defines defines the material defines to update
  60375. * @param useInstances specifies that instances should be used
  60376. */
  60377. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60378. /**
  60379. * Update defines for shader compilation
  60380. * @param mesh defines the mesh to be rendered
  60381. * @param nodeMaterial defines the node material requesting the update
  60382. * @param defines defines the material defines to update
  60383. * @param useInstances specifies that instances should be used
  60384. */
  60385. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60386. /**
  60387. * Lets the block try to connect some inputs automatically
  60388. * @param material defines the hosting NodeMaterial
  60389. */
  60390. autoConfigure(material: NodeMaterial): void;
  60391. /**
  60392. * Function called when a block is declared as repeatable content generator
  60393. * @param vertexShaderState defines the current compilation state for the vertex shader
  60394. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60395. * @param mesh defines the mesh to be rendered
  60396. * @param defines defines the material defines to update
  60397. */
  60398. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60399. /**
  60400. * Checks if the block is ready
  60401. * @param mesh defines the mesh to be rendered
  60402. * @param nodeMaterial defines the node material requesting the update
  60403. * @param defines defines the material defines to update
  60404. * @param useInstances specifies that instances should be used
  60405. * @returns true if the block is ready
  60406. */
  60407. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60408. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60409. private _processBuild;
  60410. /**
  60411. * Compile the current node and generate the shader code
  60412. * @param state defines the current compilation state (uniforms, samplers, current string)
  60413. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60414. * @returns true if already built
  60415. */
  60416. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60417. protected _inputRename(name: string): string;
  60418. protected _outputRename(name: string): string;
  60419. protected _dumpPropertiesCode(): string;
  60420. /** @hidden */
  60421. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60422. /** @hidden */
  60423. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60424. /**
  60425. * Clone the current block to a new identical block
  60426. * @param scene defines the hosting scene
  60427. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60428. * @returns a copy of the current block
  60429. */
  60430. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60431. /**
  60432. * Serializes this block in a JSON representation
  60433. * @returns the serialized block object
  60434. */
  60435. serialize(): any;
  60436. /** @hidden */
  60437. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60438. /**
  60439. * Release resources
  60440. */
  60441. dispose(): void;
  60442. }
  60443. }
  60444. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60445. /**
  60446. * Enum defining the type of animations supported by InputBlock
  60447. */
  60448. export enum AnimatedInputBlockTypes {
  60449. /** No animation */
  60450. None = 0,
  60451. /** Time based animation. Will only work for floats */
  60452. Time = 1
  60453. }
  60454. }
  60455. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60456. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60457. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60458. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60459. import { Nullable } from "babylonjs/types";
  60460. import { Effect } from "babylonjs/Materials/effect";
  60461. import { Matrix } from "babylonjs/Maths/math.vector";
  60462. import { Scene } from "babylonjs/scene";
  60463. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60464. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60465. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60466. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60467. import { Observable } from "babylonjs/Misc/observable";
  60468. /**
  60469. * Block used to expose an input value
  60470. */
  60471. export class InputBlock extends NodeMaterialBlock {
  60472. private _mode;
  60473. private _associatedVariableName;
  60474. private _storedValue;
  60475. private _valueCallback;
  60476. private _type;
  60477. private _animationType;
  60478. /** Gets or set a value used to limit the range of float values */
  60479. min: number;
  60480. /** Gets or set a value used to limit the range of float values */
  60481. max: number;
  60482. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60483. isBoolean: boolean;
  60484. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60485. matrixMode: number;
  60486. /** @hidden */
  60487. _systemValue: Nullable<NodeMaterialSystemValues>;
  60488. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60489. visibleInInspector: boolean;
  60490. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60491. isConstant: boolean;
  60492. /** Gets or sets the group to use to display this block in the Inspector */
  60493. groupInInspector: string;
  60494. /** Gets an observable raised when the value is changed */
  60495. onValueChangedObservable: Observable<InputBlock>;
  60496. /**
  60497. * Gets or sets the connection point type (default is float)
  60498. */
  60499. get type(): NodeMaterialBlockConnectionPointTypes;
  60500. /**
  60501. * Creates a new InputBlock
  60502. * @param name defines the block name
  60503. * @param target defines the target of that block (Vertex by default)
  60504. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60505. */
  60506. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60507. /**
  60508. * Gets the output component
  60509. */
  60510. get output(): NodeMaterialConnectionPoint;
  60511. /**
  60512. * Set the source of this connection point to a vertex attribute
  60513. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60514. * @returns the current connection point
  60515. */
  60516. setAsAttribute(attributeName?: string): InputBlock;
  60517. /**
  60518. * Set the source of this connection point to a system value
  60519. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60520. * @returns the current connection point
  60521. */
  60522. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60523. /**
  60524. * Gets or sets the value of that point.
  60525. * Please note that this value will be ignored if valueCallback is defined
  60526. */
  60527. get value(): any;
  60528. set value(value: any);
  60529. /**
  60530. * Gets or sets a callback used to get the value of that point.
  60531. * Please note that setting this value will force the connection point to ignore the value property
  60532. */
  60533. get valueCallback(): () => any;
  60534. set valueCallback(value: () => any);
  60535. /**
  60536. * Gets or sets the associated variable name in the shader
  60537. */
  60538. get associatedVariableName(): string;
  60539. set associatedVariableName(value: string);
  60540. /** Gets or sets the type of animation applied to the input */
  60541. get animationType(): AnimatedInputBlockTypes;
  60542. set animationType(value: AnimatedInputBlockTypes);
  60543. /**
  60544. * Gets a boolean indicating that this connection point not defined yet
  60545. */
  60546. get isUndefined(): boolean;
  60547. /**
  60548. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60549. * In this case the connection point name must be the name of the uniform to use.
  60550. * Can only be set on inputs
  60551. */
  60552. get isUniform(): boolean;
  60553. set isUniform(value: boolean);
  60554. /**
  60555. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60556. * In this case the connection point name must be the name of the attribute to use
  60557. * Can only be set on inputs
  60558. */
  60559. get isAttribute(): boolean;
  60560. set isAttribute(value: boolean);
  60561. /**
  60562. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60563. * Can only be set on exit points
  60564. */
  60565. get isVarying(): boolean;
  60566. set isVarying(value: boolean);
  60567. /**
  60568. * Gets a boolean indicating that the current connection point is a system value
  60569. */
  60570. get isSystemValue(): boolean;
  60571. /**
  60572. * Gets or sets the current well known value or null if not defined as a system value
  60573. */
  60574. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60575. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60576. /**
  60577. * Gets the current class name
  60578. * @returns the class name
  60579. */
  60580. getClassName(): string;
  60581. /**
  60582. * Animate the input if animationType !== None
  60583. * @param scene defines the rendering scene
  60584. */
  60585. animate(scene: Scene): void;
  60586. private _emitDefine;
  60587. initialize(state: NodeMaterialBuildState): void;
  60588. /**
  60589. * Set the input block to its default value (based on its type)
  60590. */
  60591. setDefaultValue(): void;
  60592. private _emitConstant;
  60593. private _emit;
  60594. /** @hidden */
  60595. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60596. /** @hidden */
  60597. _transmit(effect: Effect, scene: Scene): void;
  60598. protected _buildBlock(state: NodeMaterialBuildState): void;
  60599. protected _dumpPropertiesCode(): string;
  60600. dispose(): void;
  60601. serialize(): any;
  60602. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60603. }
  60604. }
  60605. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60606. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60607. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60608. import { Nullable } from "babylonjs/types";
  60609. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60610. import { Observable } from "babylonjs/Misc/observable";
  60611. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60612. /**
  60613. * Enum used to define the compatibility state between two connection points
  60614. */
  60615. export enum NodeMaterialConnectionPointCompatibilityStates {
  60616. /** Points are compatibles */
  60617. Compatible = 0,
  60618. /** Points are incompatible because of their types */
  60619. TypeIncompatible = 1,
  60620. /** Points are incompatible because of their targets (vertex vs fragment) */
  60621. TargetIncompatible = 2
  60622. }
  60623. /**
  60624. * Defines the direction of a connection point
  60625. */
  60626. export enum NodeMaterialConnectionPointDirection {
  60627. /** Input */
  60628. Input = 0,
  60629. /** Output */
  60630. Output = 1
  60631. }
  60632. /**
  60633. * Defines a connection point for a block
  60634. */
  60635. export class NodeMaterialConnectionPoint {
  60636. /** @hidden */
  60637. _ownerBlock: NodeMaterialBlock;
  60638. /** @hidden */
  60639. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60640. private _endpoints;
  60641. private _associatedVariableName;
  60642. private _direction;
  60643. /** @hidden */
  60644. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60645. /** @hidden */
  60646. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60647. private _type;
  60648. /** @hidden */
  60649. _enforceAssociatedVariableName: boolean;
  60650. /** Gets the direction of the point */
  60651. get direction(): NodeMaterialConnectionPointDirection;
  60652. /**
  60653. * Gets or sets the additional types supported by this connection point
  60654. */
  60655. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60656. /**
  60657. * Gets or sets the additional types excluded by this connection point
  60658. */
  60659. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60660. /**
  60661. * Observable triggered when this point is connected
  60662. */
  60663. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60664. /**
  60665. * Gets or sets the associated variable name in the shader
  60666. */
  60667. get associatedVariableName(): string;
  60668. set associatedVariableName(value: string);
  60669. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  60670. get innerType(): NodeMaterialBlockConnectionPointTypes;
  60671. /**
  60672. * Gets or sets the connection point type (default is float)
  60673. */
  60674. get type(): NodeMaterialBlockConnectionPointTypes;
  60675. set type(value: NodeMaterialBlockConnectionPointTypes);
  60676. /**
  60677. * Gets or sets the connection point name
  60678. */
  60679. name: string;
  60680. /**
  60681. * Gets or sets a boolean indicating that this connection point can be omitted
  60682. */
  60683. isOptional: boolean;
  60684. /**
  60685. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60686. */
  60687. define: string;
  60688. /** @hidden */
  60689. _prioritizeVertex: boolean;
  60690. private _target;
  60691. /** Gets or sets the target of that connection point */
  60692. get target(): NodeMaterialBlockTargets;
  60693. set target(value: NodeMaterialBlockTargets);
  60694. /**
  60695. * Gets a boolean indicating that the current point is connected
  60696. */
  60697. get isConnected(): boolean;
  60698. /**
  60699. * Gets a boolean indicating that the current point is connected to an input block
  60700. */
  60701. get isConnectedToInputBlock(): boolean;
  60702. /**
  60703. * Gets a the connected input block (if any)
  60704. */
  60705. get connectInputBlock(): Nullable<InputBlock>;
  60706. /** Get the other side of the connection (if any) */
  60707. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60708. /** Get the block that owns this connection point */
  60709. get ownerBlock(): NodeMaterialBlock;
  60710. /** Get the block connected on the other side of this connection (if any) */
  60711. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60712. /** Get the block connected on the endpoints of this connection (if any) */
  60713. get connectedBlocks(): Array<NodeMaterialBlock>;
  60714. /** Gets the list of connected endpoints */
  60715. get endpoints(): NodeMaterialConnectionPoint[];
  60716. /** Gets a boolean indicating if that output point is connected to at least one input */
  60717. get hasEndpoints(): boolean;
  60718. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60719. get isConnectedInVertexShader(): boolean;
  60720. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60721. get isConnectedInFragmentShader(): boolean;
  60722. /**
  60723. * Creates a new connection point
  60724. * @param name defines the connection point name
  60725. * @param ownerBlock defines the block hosting this connection point
  60726. * @param direction defines the direction of the connection point
  60727. */
  60728. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60729. /**
  60730. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60731. * @returns the class name
  60732. */
  60733. getClassName(): string;
  60734. /**
  60735. * Gets a boolean indicating if the current point can be connected to another point
  60736. * @param connectionPoint defines the other connection point
  60737. * @returns a boolean
  60738. */
  60739. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  60740. /**
  60741. * Gets a number indicating if the current point can be connected to another point
  60742. * @param connectionPoint defines the other connection point
  60743. * @returns a number defining the compatibility state
  60744. */
  60745. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60746. /**
  60747. * Connect this point to another connection point
  60748. * @param connectionPoint defines the other connection point
  60749. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  60750. * @returns the current connection point
  60751. */
  60752. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  60753. /**
  60754. * Disconnect this point from one of his endpoint
  60755. * @param endpoint defines the other connection point
  60756. * @returns the current connection point
  60757. */
  60758. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  60759. /**
  60760. * Serializes this point in a JSON representation
  60761. * @returns the serialized point object
  60762. */
  60763. serialize(): any;
  60764. /**
  60765. * Release resources
  60766. */
  60767. dispose(): void;
  60768. }
  60769. }
  60770. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  60771. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60772. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60773. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60774. import { Mesh } from "babylonjs/Meshes/mesh";
  60775. import { Effect } from "babylonjs/Materials/effect";
  60776. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60777. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60778. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60779. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60780. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60781. /**
  60782. * Block used to add support for vertex skinning (bones)
  60783. */
  60784. export class BonesBlock extends NodeMaterialBlock {
  60785. /**
  60786. * Creates a new BonesBlock
  60787. * @param name defines the block name
  60788. */
  60789. constructor(name: string);
  60790. /**
  60791. * Initialize the block and prepare the context for build
  60792. * @param state defines the state that will be used for the build
  60793. */
  60794. initialize(state: NodeMaterialBuildState): void;
  60795. /**
  60796. * Gets the current class name
  60797. * @returns the class name
  60798. */
  60799. getClassName(): string;
  60800. /**
  60801. * Gets the matrix indices input component
  60802. */
  60803. get matricesIndices(): NodeMaterialConnectionPoint;
  60804. /**
  60805. * Gets the matrix weights input component
  60806. */
  60807. get matricesWeights(): NodeMaterialConnectionPoint;
  60808. /**
  60809. * Gets the extra matrix indices input component
  60810. */
  60811. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60812. /**
  60813. * Gets the extra matrix weights input component
  60814. */
  60815. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60816. /**
  60817. * Gets the world input component
  60818. */
  60819. get world(): NodeMaterialConnectionPoint;
  60820. /**
  60821. * Gets the output component
  60822. */
  60823. get output(): NodeMaterialConnectionPoint;
  60824. autoConfigure(material: NodeMaterial): void;
  60825. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60826. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60827. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60828. protected _buildBlock(state: NodeMaterialBuildState): this;
  60829. }
  60830. }
  60831. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  60832. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60833. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60834. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60836. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60837. /**
  60838. * Block used to add support for instances
  60839. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60840. */
  60841. export class InstancesBlock extends NodeMaterialBlock {
  60842. /**
  60843. * Creates a new InstancesBlock
  60844. * @param name defines the block name
  60845. */
  60846. constructor(name: string);
  60847. /**
  60848. * Gets the current class name
  60849. * @returns the class name
  60850. */
  60851. getClassName(): string;
  60852. /**
  60853. * Gets the first world row input component
  60854. */
  60855. get world0(): NodeMaterialConnectionPoint;
  60856. /**
  60857. * Gets the second world row input component
  60858. */
  60859. get world1(): NodeMaterialConnectionPoint;
  60860. /**
  60861. * Gets the third world row input component
  60862. */
  60863. get world2(): NodeMaterialConnectionPoint;
  60864. /**
  60865. * Gets the forth world row input component
  60866. */
  60867. get world3(): NodeMaterialConnectionPoint;
  60868. /**
  60869. * Gets the world input component
  60870. */
  60871. get world(): NodeMaterialConnectionPoint;
  60872. /**
  60873. * Gets the output component
  60874. */
  60875. get output(): NodeMaterialConnectionPoint;
  60876. /**
  60877. * Gets the isntanceID component
  60878. */
  60879. get instanceID(): NodeMaterialConnectionPoint;
  60880. autoConfigure(material: NodeMaterial): void;
  60881. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60882. protected _buildBlock(state: NodeMaterialBuildState): this;
  60883. }
  60884. }
  60885. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  60886. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60887. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60888. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60890. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60891. import { Effect } from "babylonjs/Materials/effect";
  60892. import { Mesh } from "babylonjs/Meshes/mesh";
  60893. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60894. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60895. /**
  60896. * Block used to add morph targets support to vertex shader
  60897. */
  60898. export class MorphTargetsBlock extends NodeMaterialBlock {
  60899. private _repeatableContentAnchor;
  60900. /**
  60901. * Create a new MorphTargetsBlock
  60902. * @param name defines the block name
  60903. */
  60904. constructor(name: string);
  60905. /**
  60906. * Gets the current class name
  60907. * @returns the class name
  60908. */
  60909. getClassName(): string;
  60910. /**
  60911. * Gets the position input component
  60912. */
  60913. get position(): NodeMaterialConnectionPoint;
  60914. /**
  60915. * Gets the normal input component
  60916. */
  60917. get normal(): NodeMaterialConnectionPoint;
  60918. /**
  60919. * Gets the tangent input component
  60920. */
  60921. get tangent(): NodeMaterialConnectionPoint;
  60922. /**
  60923. * Gets the tangent input component
  60924. */
  60925. get uv(): NodeMaterialConnectionPoint;
  60926. /**
  60927. * Gets the position output component
  60928. */
  60929. get positionOutput(): NodeMaterialConnectionPoint;
  60930. /**
  60931. * Gets the normal output component
  60932. */
  60933. get normalOutput(): NodeMaterialConnectionPoint;
  60934. /**
  60935. * Gets the tangent output component
  60936. */
  60937. get tangentOutput(): NodeMaterialConnectionPoint;
  60938. /**
  60939. * Gets the tangent output component
  60940. */
  60941. get uvOutput(): NodeMaterialConnectionPoint;
  60942. initialize(state: NodeMaterialBuildState): void;
  60943. autoConfigure(material: NodeMaterial): void;
  60944. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60945. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60946. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60947. protected _buildBlock(state: NodeMaterialBuildState): this;
  60948. }
  60949. }
  60950. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  60951. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60952. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60953. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60954. import { Nullable } from "babylonjs/types";
  60955. import { Scene } from "babylonjs/scene";
  60956. import { Effect } from "babylonjs/Materials/effect";
  60957. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60958. import { Mesh } from "babylonjs/Meshes/mesh";
  60959. import { Light } from "babylonjs/Lights/light";
  60960. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60961. /**
  60962. * Block used to get data information from a light
  60963. */
  60964. export class LightInformationBlock extends NodeMaterialBlock {
  60965. private _lightDataUniformName;
  60966. private _lightColorUniformName;
  60967. private _lightTypeDefineName;
  60968. /**
  60969. * Gets or sets the light associated with this block
  60970. */
  60971. light: Nullable<Light>;
  60972. /**
  60973. * Creates a new LightInformationBlock
  60974. * @param name defines the block name
  60975. */
  60976. constructor(name: string);
  60977. /**
  60978. * Gets the current class name
  60979. * @returns the class name
  60980. */
  60981. getClassName(): string;
  60982. /**
  60983. * Gets the world position input component
  60984. */
  60985. get worldPosition(): NodeMaterialConnectionPoint;
  60986. /**
  60987. * Gets the direction output component
  60988. */
  60989. get direction(): NodeMaterialConnectionPoint;
  60990. /**
  60991. * Gets the direction output component
  60992. */
  60993. get color(): NodeMaterialConnectionPoint;
  60994. /**
  60995. * Gets the direction output component
  60996. */
  60997. get intensity(): NodeMaterialConnectionPoint;
  60998. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60999. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61000. protected _buildBlock(state: NodeMaterialBuildState): this;
  61001. serialize(): any;
  61002. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61003. }
  61004. }
  61005. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61006. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61007. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61008. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61009. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61010. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61011. }
  61012. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61013. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61014. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61015. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61016. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61017. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61018. import { Effect } from "babylonjs/Materials/effect";
  61019. import { Mesh } from "babylonjs/Meshes/mesh";
  61020. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61021. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61022. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61023. /**
  61024. * Block used to add image processing support to fragment shader
  61025. */
  61026. export class ImageProcessingBlock extends NodeMaterialBlock {
  61027. /**
  61028. * Create a new ImageProcessingBlock
  61029. * @param name defines the block name
  61030. */
  61031. constructor(name: string);
  61032. /**
  61033. * Gets the current class name
  61034. * @returns the class name
  61035. */
  61036. getClassName(): string;
  61037. /**
  61038. * Gets the color input component
  61039. */
  61040. get color(): NodeMaterialConnectionPoint;
  61041. /**
  61042. * Gets the output component
  61043. */
  61044. get output(): NodeMaterialConnectionPoint;
  61045. /**
  61046. * Initialize the block and prepare the context for build
  61047. * @param state defines the state that will be used for the build
  61048. */
  61049. initialize(state: NodeMaterialBuildState): void;
  61050. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61051. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61052. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61053. protected _buildBlock(state: NodeMaterialBuildState): this;
  61054. }
  61055. }
  61056. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61057. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61058. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61059. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61060. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61061. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61062. import { Effect } from "babylonjs/Materials/effect";
  61063. import { Mesh } from "babylonjs/Meshes/mesh";
  61064. import { Scene } from "babylonjs/scene";
  61065. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61066. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61067. /**
  61068. * Block used to pertub normals based on a normal map
  61069. */
  61070. export class PerturbNormalBlock extends NodeMaterialBlock {
  61071. private _tangentSpaceParameterName;
  61072. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61073. invertX: boolean;
  61074. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61075. invertY: boolean;
  61076. /**
  61077. * Create a new PerturbNormalBlock
  61078. * @param name defines the block name
  61079. */
  61080. constructor(name: string);
  61081. /**
  61082. * Gets the current class name
  61083. * @returns the class name
  61084. */
  61085. getClassName(): string;
  61086. /**
  61087. * Gets the world position input component
  61088. */
  61089. get worldPosition(): NodeMaterialConnectionPoint;
  61090. /**
  61091. * Gets the world normal input component
  61092. */
  61093. get worldNormal(): NodeMaterialConnectionPoint;
  61094. /**
  61095. * Gets the world tangent input component
  61096. */
  61097. get worldTangent(): NodeMaterialConnectionPoint;
  61098. /**
  61099. * Gets the uv input component
  61100. */
  61101. get uv(): NodeMaterialConnectionPoint;
  61102. /**
  61103. * Gets the normal map color input component
  61104. */
  61105. get normalMapColor(): NodeMaterialConnectionPoint;
  61106. /**
  61107. * Gets the strength input component
  61108. */
  61109. get strength(): NodeMaterialConnectionPoint;
  61110. /**
  61111. * Gets the output component
  61112. */
  61113. get output(): NodeMaterialConnectionPoint;
  61114. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61115. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61116. autoConfigure(material: NodeMaterial): void;
  61117. protected _buildBlock(state: NodeMaterialBuildState): this;
  61118. protected _dumpPropertiesCode(): string;
  61119. serialize(): any;
  61120. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61121. }
  61122. }
  61123. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61124. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61125. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61126. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61127. /**
  61128. * Block used to discard a pixel if a value is smaller than a cutoff
  61129. */
  61130. export class DiscardBlock extends NodeMaterialBlock {
  61131. /**
  61132. * Create a new DiscardBlock
  61133. * @param name defines the block name
  61134. */
  61135. constructor(name: string);
  61136. /**
  61137. * Gets the current class name
  61138. * @returns the class name
  61139. */
  61140. getClassName(): string;
  61141. /**
  61142. * Gets the color input component
  61143. */
  61144. get value(): NodeMaterialConnectionPoint;
  61145. /**
  61146. * Gets the cutoff input component
  61147. */
  61148. get cutoff(): NodeMaterialConnectionPoint;
  61149. protected _buildBlock(state: NodeMaterialBuildState): this;
  61150. }
  61151. }
  61152. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61153. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61154. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61155. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61156. /**
  61157. * Block used to test if the fragment shader is front facing
  61158. */
  61159. export class FrontFacingBlock extends NodeMaterialBlock {
  61160. /**
  61161. * Creates a new FrontFacingBlock
  61162. * @param name defines the block name
  61163. */
  61164. constructor(name: string);
  61165. /**
  61166. * Gets the current class name
  61167. * @returns the class name
  61168. */
  61169. getClassName(): string;
  61170. /**
  61171. * Gets the output component
  61172. */
  61173. get output(): NodeMaterialConnectionPoint;
  61174. protected _buildBlock(state: NodeMaterialBuildState): this;
  61175. }
  61176. }
  61177. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61178. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61179. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61180. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61181. /**
  61182. * Block used to get the derivative value on x and y of a given input
  61183. */
  61184. export class DerivativeBlock extends NodeMaterialBlock {
  61185. /**
  61186. * Create a new DerivativeBlock
  61187. * @param name defines the block name
  61188. */
  61189. constructor(name: string);
  61190. /**
  61191. * Gets the current class name
  61192. * @returns the class name
  61193. */
  61194. getClassName(): string;
  61195. /**
  61196. * Gets the input component
  61197. */
  61198. get input(): NodeMaterialConnectionPoint;
  61199. /**
  61200. * Gets the derivative output on x
  61201. */
  61202. get dx(): NodeMaterialConnectionPoint;
  61203. /**
  61204. * Gets the derivative output on y
  61205. */
  61206. get dy(): NodeMaterialConnectionPoint;
  61207. protected _buildBlock(state: NodeMaterialBuildState): this;
  61208. }
  61209. }
  61210. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61211. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61212. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61213. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61214. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61215. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61216. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61217. }
  61218. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61219. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61220. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61221. import { Mesh } from "babylonjs/Meshes/mesh";
  61222. import { Effect } from "babylonjs/Materials/effect";
  61223. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61225. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61226. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61227. /**
  61228. * Block used to add support for scene fog
  61229. */
  61230. export class FogBlock extends NodeMaterialBlock {
  61231. private _fogDistanceName;
  61232. private _fogParameters;
  61233. /**
  61234. * Create a new FogBlock
  61235. * @param name defines the block name
  61236. */
  61237. constructor(name: string);
  61238. /**
  61239. * Gets the current class name
  61240. * @returns the class name
  61241. */
  61242. getClassName(): string;
  61243. /**
  61244. * Gets the world position input component
  61245. */
  61246. get worldPosition(): NodeMaterialConnectionPoint;
  61247. /**
  61248. * Gets the view input component
  61249. */
  61250. get view(): NodeMaterialConnectionPoint;
  61251. /**
  61252. * Gets the color input component
  61253. */
  61254. get input(): NodeMaterialConnectionPoint;
  61255. /**
  61256. * Gets the fog color input component
  61257. */
  61258. get fogColor(): NodeMaterialConnectionPoint;
  61259. /**
  61260. * Gets the output component
  61261. */
  61262. get output(): NodeMaterialConnectionPoint;
  61263. autoConfigure(material: NodeMaterial): void;
  61264. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61265. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61266. protected _buildBlock(state: NodeMaterialBuildState): this;
  61267. }
  61268. }
  61269. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61270. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61271. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61272. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61273. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61274. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61275. import { Effect } from "babylonjs/Materials/effect";
  61276. import { Mesh } from "babylonjs/Meshes/mesh";
  61277. import { Light } from "babylonjs/Lights/light";
  61278. import { Nullable } from "babylonjs/types";
  61279. import { Scene } from "babylonjs/scene";
  61280. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61281. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61282. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61283. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61284. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61285. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61286. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61287. /**
  61288. * Block used to add light in the fragment shader
  61289. */
  61290. export class LightBlock extends NodeMaterialBlock {
  61291. private _lightId;
  61292. /**
  61293. * Gets or sets the light associated with this block
  61294. */
  61295. light: Nullable<Light>;
  61296. /**
  61297. * Create a new LightBlock
  61298. * @param name defines the block name
  61299. */
  61300. constructor(name: string);
  61301. /**
  61302. * Gets the current class name
  61303. * @returns the class name
  61304. */
  61305. getClassName(): string;
  61306. /**
  61307. * Gets the world position input component
  61308. */
  61309. get worldPosition(): NodeMaterialConnectionPoint;
  61310. /**
  61311. * Gets the world normal input component
  61312. */
  61313. get worldNormal(): NodeMaterialConnectionPoint;
  61314. /**
  61315. * Gets the camera (or eye) position component
  61316. */
  61317. get cameraPosition(): NodeMaterialConnectionPoint;
  61318. /**
  61319. * Gets the glossiness component
  61320. */
  61321. get glossiness(): NodeMaterialConnectionPoint;
  61322. /**
  61323. * Gets the glossinness power component
  61324. */
  61325. get glossPower(): NodeMaterialConnectionPoint;
  61326. /**
  61327. * Gets the diffuse color component
  61328. */
  61329. get diffuseColor(): NodeMaterialConnectionPoint;
  61330. /**
  61331. * Gets the specular color component
  61332. */
  61333. get specularColor(): NodeMaterialConnectionPoint;
  61334. /**
  61335. * Gets the diffuse output component
  61336. */
  61337. get diffuseOutput(): NodeMaterialConnectionPoint;
  61338. /**
  61339. * Gets the specular output component
  61340. */
  61341. get specularOutput(): NodeMaterialConnectionPoint;
  61342. /**
  61343. * Gets the shadow output component
  61344. */
  61345. get shadow(): NodeMaterialConnectionPoint;
  61346. autoConfigure(material: NodeMaterial): void;
  61347. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61348. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61349. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61350. private _injectVertexCode;
  61351. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61352. serialize(): any;
  61353. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61354. }
  61355. }
  61356. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61357. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61358. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61359. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61360. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61361. }
  61362. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61363. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61364. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61365. }
  61366. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61367. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61368. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61369. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61370. /**
  61371. * Block used to multiply 2 values
  61372. */
  61373. export class MultiplyBlock extends NodeMaterialBlock {
  61374. /**
  61375. * Creates a new MultiplyBlock
  61376. * @param name defines the block name
  61377. */
  61378. constructor(name: string);
  61379. /**
  61380. * Gets the current class name
  61381. * @returns the class name
  61382. */
  61383. getClassName(): string;
  61384. /**
  61385. * Gets the left operand input component
  61386. */
  61387. get left(): NodeMaterialConnectionPoint;
  61388. /**
  61389. * Gets the right operand input component
  61390. */
  61391. get right(): NodeMaterialConnectionPoint;
  61392. /**
  61393. * Gets the output component
  61394. */
  61395. get output(): NodeMaterialConnectionPoint;
  61396. protected _buildBlock(state: NodeMaterialBuildState): this;
  61397. }
  61398. }
  61399. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61400. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61401. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61402. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61403. /**
  61404. * Block used to add 2 vectors
  61405. */
  61406. export class AddBlock extends NodeMaterialBlock {
  61407. /**
  61408. * Creates a new AddBlock
  61409. * @param name defines the block name
  61410. */
  61411. constructor(name: string);
  61412. /**
  61413. * Gets the current class name
  61414. * @returns the class name
  61415. */
  61416. getClassName(): string;
  61417. /**
  61418. * Gets the left operand input component
  61419. */
  61420. get left(): NodeMaterialConnectionPoint;
  61421. /**
  61422. * Gets the right operand input component
  61423. */
  61424. get right(): NodeMaterialConnectionPoint;
  61425. /**
  61426. * Gets the output component
  61427. */
  61428. get output(): NodeMaterialConnectionPoint;
  61429. protected _buildBlock(state: NodeMaterialBuildState): this;
  61430. }
  61431. }
  61432. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61433. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61434. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61435. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61436. /**
  61437. * Block used to scale a vector by a float
  61438. */
  61439. export class ScaleBlock extends NodeMaterialBlock {
  61440. /**
  61441. * Creates a new ScaleBlock
  61442. * @param name defines the block name
  61443. */
  61444. constructor(name: string);
  61445. /**
  61446. * Gets the current class name
  61447. * @returns the class name
  61448. */
  61449. getClassName(): string;
  61450. /**
  61451. * Gets the input component
  61452. */
  61453. get input(): NodeMaterialConnectionPoint;
  61454. /**
  61455. * Gets the factor input component
  61456. */
  61457. get factor(): NodeMaterialConnectionPoint;
  61458. /**
  61459. * Gets the output component
  61460. */
  61461. get output(): NodeMaterialConnectionPoint;
  61462. protected _buildBlock(state: NodeMaterialBuildState): this;
  61463. }
  61464. }
  61465. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61466. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61467. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61468. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61469. import { Scene } from "babylonjs/scene";
  61470. /**
  61471. * Block used to clamp a float
  61472. */
  61473. export class ClampBlock extends NodeMaterialBlock {
  61474. /** Gets or sets the minimum range */
  61475. minimum: number;
  61476. /** Gets or sets the maximum range */
  61477. maximum: number;
  61478. /**
  61479. * Creates a new ClampBlock
  61480. * @param name defines the block name
  61481. */
  61482. constructor(name: string);
  61483. /**
  61484. * Gets the current class name
  61485. * @returns the class name
  61486. */
  61487. getClassName(): string;
  61488. /**
  61489. * Gets the value input component
  61490. */
  61491. get value(): NodeMaterialConnectionPoint;
  61492. /**
  61493. * Gets the output component
  61494. */
  61495. get output(): NodeMaterialConnectionPoint;
  61496. protected _buildBlock(state: NodeMaterialBuildState): this;
  61497. protected _dumpPropertiesCode(): string;
  61498. serialize(): any;
  61499. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61500. }
  61501. }
  61502. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61503. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61504. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61505. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61506. /**
  61507. * Block used to apply a cross product between 2 vectors
  61508. */
  61509. export class CrossBlock extends NodeMaterialBlock {
  61510. /**
  61511. * Creates a new CrossBlock
  61512. * @param name defines the block name
  61513. */
  61514. constructor(name: string);
  61515. /**
  61516. * Gets the current class name
  61517. * @returns the class name
  61518. */
  61519. getClassName(): string;
  61520. /**
  61521. * Gets the left operand input component
  61522. */
  61523. get left(): NodeMaterialConnectionPoint;
  61524. /**
  61525. * Gets the right operand input component
  61526. */
  61527. get right(): NodeMaterialConnectionPoint;
  61528. /**
  61529. * Gets the output component
  61530. */
  61531. get output(): NodeMaterialConnectionPoint;
  61532. protected _buildBlock(state: NodeMaterialBuildState): this;
  61533. }
  61534. }
  61535. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61536. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61537. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61538. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61539. /**
  61540. * Block used to apply a dot product between 2 vectors
  61541. */
  61542. export class DotBlock extends NodeMaterialBlock {
  61543. /**
  61544. * Creates a new DotBlock
  61545. * @param name defines the block name
  61546. */
  61547. constructor(name: string);
  61548. /**
  61549. * Gets the current class name
  61550. * @returns the class name
  61551. */
  61552. getClassName(): string;
  61553. /**
  61554. * Gets the left operand input component
  61555. */
  61556. get left(): NodeMaterialConnectionPoint;
  61557. /**
  61558. * Gets the right operand input component
  61559. */
  61560. get right(): NodeMaterialConnectionPoint;
  61561. /**
  61562. * Gets the output component
  61563. */
  61564. get output(): NodeMaterialConnectionPoint;
  61565. protected _buildBlock(state: NodeMaterialBuildState): this;
  61566. }
  61567. }
  61568. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61569. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61570. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61571. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61572. import { Vector2 } from "babylonjs/Maths/math.vector";
  61573. import { Scene } from "babylonjs/scene";
  61574. /**
  61575. * Block used to remap a float from a range to a new one
  61576. */
  61577. export class RemapBlock extends NodeMaterialBlock {
  61578. /**
  61579. * Gets or sets the source range
  61580. */
  61581. sourceRange: Vector2;
  61582. /**
  61583. * Gets or sets the target range
  61584. */
  61585. targetRange: Vector2;
  61586. /**
  61587. * Creates a new RemapBlock
  61588. * @param name defines the block name
  61589. */
  61590. constructor(name: string);
  61591. /**
  61592. * Gets the current class name
  61593. * @returns the class name
  61594. */
  61595. getClassName(): string;
  61596. /**
  61597. * Gets the input component
  61598. */
  61599. get input(): NodeMaterialConnectionPoint;
  61600. /**
  61601. * Gets the source min input component
  61602. */
  61603. get sourceMin(): NodeMaterialConnectionPoint;
  61604. /**
  61605. * Gets the source max input component
  61606. */
  61607. get sourceMax(): NodeMaterialConnectionPoint;
  61608. /**
  61609. * Gets the target min input component
  61610. */
  61611. get targetMin(): NodeMaterialConnectionPoint;
  61612. /**
  61613. * Gets the target max input component
  61614. */
  61615. get targetMax(): NodeMaterialConnectionPoint;
  61616. /**
  61617. * Gets the output component
  61618. */
  61619. get output(): NodeMaterialConnectionPoint;
  61620. protected _buildBlock(state: NodeMaterialBuildState): this;
  61621. protected _dumpPropertiesCode(): string;
  61622. serialize(): any;
  61623. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61624. }
  61625. }
  61626. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61627. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61628. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61629. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61630. /**
  61631. * Block used to normalize a vector
  61632. */
  61633. export class NormalizeBlock extends NodeMaterialBlock {
  61634. /**
  61635. * Creates a new NormalizeBlock
  61636. * @param name defines the block name
  61637. */
  61638. constructor(name: string);
  61639. /**
  61640. * Gets the current class name
  61641. * @returns the class name
  61642. */
  61643. getClassName(): string;
  61644. /**
  61645. * Gets the input component
  61646. */
  61647. get input(): NodeMaterialConnectionPoint;
  61648. /**
  61649. * Gets the output component
  61650. */
  61651. get output(): NodeMaterialConnectionPoint;
  61652. protected _buildBlock(state: NodeMaterialBuildState): this;
  61653. }
  61654. }
  61655. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61656. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61657. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61658. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61659. import { Scene } from "babylonjs/scene";
  61660. /**
  61661. * Operations supported by the Trigonometry block
  61662. */
  61663. export enum TrigonometryBlockOperations {
  61664. /** Cos */
  61665. Cos = 0,
  61666. /** Sin */
  61667. Sin = 1,
  61668. /** Abs */
  61669. Abs = 2,
  61670. /** Exp */
  61671. Exp = 3,
  61672. /** Exp2 */
  61673. Exp2 = 4,
  61674. /** Round */
  61675. Round = 5,
  61676. /** Floor */
  61677. Floor = 6,
  61678. /** Ceiling */
  61679. Ceiling = 7,
  61680. /** Square root */
  61681. Sqrt = 8,
  61682. /** Log */
  61683. Log = 9,
  61684. /** Tangent */
  61685. Tan = 10,
  61686. /** Arc tangent */
  61687. ArcTan = 11,
  61688. /** Arc cosinus */
  61689. ArcCos = 12,
  61690. /** Arc sinus */
  61691. ArcSin = 13,
  61692. /** Fraction */
  61693. Fract = 14,
  61694. /** Sign */
  61695. Sign = 15,
  61696. /** To radians (from degrees) */
  61697. Radians = 16,
  61698. /** To degrees (from radians) */
  61699. Degrees = 17
  61700. }
  61701. /**
  61702. * Block used to apply trigonometry operation to floats
  61703. */
  61704. export class TrigonometryBlock extends NodeMaterialBlock {
  61705. /**
  61706. * Gets or sets the operation applied by the block
  61707. */
  61708. operation: TrigonometryBlockOperations;
  61709. /**
  61710. * Creates a new TrigonometryBlock
  61711. * @param name defines the block name
  61712. */
  61713. constructor(name: string);
  61714. /**
  61715. * Gets the current class name
  61716. * @returns the class name
  61717. */
  61718. getClassName(): string;
  61719. /**
  61720. * Gets the input component
  61721. */
  61722. get input(): NodeMaterialConnectionPoint;
  61723. /**
  61724. * Gets the output component
  61725. */
  61726. get output(): NodeMaterialConnectionPoint;
  61727. protected _buildBlock(state: NodeMaterialBuildState): this;
  61728. serialize(): any;
  61729. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61730. protected _dumpPropertiesCode(): string;
  61731. }
  61732. }
  61733. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61734. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61735. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61736. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61737. /**
  61738. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61739. */
  61740. export class ColorMergerBlock extends NodeMaterialBlock {
  61741. /**
  61742. * Create a new ColorMergerBlock
  61743. * @param name defines the block name
  61744. */
  61745. constructor(name: string);
  61746. /**
  61747. * Gets the current class name
  61748. * @returns the class name
  61749. */
  61750. getClassName(): string;
  61751. /**
  61752. * Gets the rgb component (input)
  61753. */
  61754. get rgbIn(): NodeMaterialConnectionPoint;
  61755. /**
  61756. * Gets the r component (input)
  61757. */
  61758. get r(): NodeMaterialConnectionPoint;
  61759. /**
  61760. * Gets the g component (input)
  61761. */
  61762. get g(): NodeMaterialConnectionPoint;
  61763. /**
  61764. * Gets the b component (input)
  61765. */
  61766. get b(): NodeMaterialConnectionPoint;
  61767. /**
  61768. * Gets the a component (input)
  61769. */
  61770. get a(): NodeMaterialConnectionPoint;
  61771. /**
  61772. * Gets the rgba component (output)
  61773. */
  61774. get rgba(): NodeMaterialConnectionPoint;
  61775. /**
  61776. * Gets the rgb component (output)
  61777. */
  61778. get rgbOut(): NodeMaterialConnectionPoint;
  61779. /**
  61780. * Gets the rgb component (output)
  61781. * @deprecated Please use rgbOut instead.
  61782. */
  61783. get rgb(): NodeMaterialConnectionPoint;
  61784. protected _buildBlock(state: NodeMaterialBuildState): this;
  61785. }
  61786. }
  61787. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  61788. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61789. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61790. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61791. /**
  61792. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  61793. */
  61794. export class VectorMergerBlock extends NodeMaterialBlock {
  61795. /**
  61796. * Create a new VectorMergerBlock
  61797. * @param name defines the block name
  61798. */
  61799. constructor(name: string);
  61800. /**
  61801. * Gets the current class name
  61802. * @returns the class name
  61803. */
  61804. getClassName(): string;
  61805. /**
  61806. * Gets the xyz component (input)
  61807. */
  61808. get xyzIn(): NodeMaterialConnectionPoint;
  61809. /**
  61810. * Gets the xy component (input)
  61811. */
  61812. get xyIn(): NodeMaterialConnectionPoint;
  61813. /**
  61814. * Gets the x component (input)
  61815. */
  61816. get x(): NodeMaterialConnectionPoint;
  61817. /**
  61818. * Gets the y component (input)
  61819. */
  61820. get y(): NodeMaterialConnectionPoint;
  61821. /**
  61822. * Gets the z component (input)
  61823. */
  61824. get z(): NodeMaterialConnectionPoint;
  61825. /**
  61826. * Gets the w component (input)
  61827. */
  61828. get w(): NodeMaterialConnectionPoint;
  61829. /**
  61830. * Gets the xyzw component (output)
  61831. */
  61832. get xyzw(): NodeMaterialConnectionPoint;
  61833. /**
  61834. * Gets the xyz component (output)
  61835. */
  61836. get xyzOut(): NodeMaterialConnectionPoint;
  61837. /**
  61838. * Gets the xy component (output)
  61839. */
  61840. get xyOut(): NodeMaterialConnectionPoint;
  61841. /**
  61842. * Gets the xy component (output)
  61843. * @deprecated Please use xyOut instead.
  61844. */
  61845. get xy(): NodeMaterialConnectionPoint;
  61846. /**
  61847. * Gets the xyz component (output)
  61848. * @deprecated Please use xyzOut instead.
  61849. */
  61850. get xyz(): NodeMaterialConnectionPoint;
  61851. protected _buildBlock(state: NodeMaterialBuildState): this;
  61852. }
  61853. }
  61854. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  61855. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61856. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61857. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61858. /**
  61859. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  61860. */
  61861. export class ColorSplitterBlock extends NodeMaterialBlock {
  61862. /**
  61863. * Create a new ColorSplitterBlock
  61864. * @param name defines the block name
  61865. */
  61866. constructor(name: string);
  61867. /**
  61868. * Gets the current class name
  61869. * @returns the class name
  61870. */
  61871. getClassName(): string;
  61872. /**
  61873. * Gets the rgba component (input)
  61874. */
  61875. get rgba(): NodeMaterialConnectionPoint;
  61876. /**
  61877. * Gets the rgb component (input)
  61878. */
  61879. get rgbIn(): NodeMaterialConnectionPoint;
  61880. /**
  61881. * Gets the rgb component (output)
  61882. */
  61883. get rgbOut(): NodeMaterialConnectionPoint;
  61884. /**
  61885. * Gets the r component (output)
  61886. */
  61887. get r(): NodeMaterialConnectionPoint;
  61888. /**
  61889. * Gets the g component (output)
  61890. */
  61891. get g(): NodeMaterialConnectionPoint;
  61892. /**
  61893. * Gets the b component (output)
  61894. */
  61895. get b(): NodeMaterialConnectionPoint;
  61896. /**
  61897. * Gets the a component (output)
  61898. */
  61899. get a(): NodeMaterialConnectionPoint;
  61900. protected _inputRename(name: string): string;
  61901. protected _outputRename(name: string): string;
  61902. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61903. }
  61904. }
  61905. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  61906. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61907. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61908. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61909. /**
  61910. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  61911. */
  61912. export class VectorSplitterBlock extends NodeMaterialBlock {
  61913. /**
  61914. * Create a new VectorSplitterBlock
  61915. * @param name defines the block name
  61916. */
  61917. constructor(name: string);
  61918. /**
  61919. * Gets the current class name
  61920. * @returns the class name
  61921. */
  61922. getClassName(): string;
  61923. /**
  61924. * Gets the xyzw component (input)
  61925. */
  61926. get xyzw(): NodeMaterialConnectionPoint;
  61927. /**
  61928. * Gets the xyz component (input)
  61929. */
  61930. get xyzIn(): NodeMaterialConnectionPoint;
  61931. /**
  61932. * Gets the xy component (input)
  61933. */
  61934. get xyIn(): NodeMaterialConnectionPoint;
  61935. /**
  61936. * Gets the xyz component (output)
  61937. */
  61938. get xyzOut(): NodeMaterialConnectionPoint;
  61939. /**
  61940. * Gets the xy component (output)
  61941. */
  61942. get xyOut(): NodeMaterialConnectionPoint;
  61943. /**
  61944. * Gets the x component (output)
  61945. */
  61946. get x(): NodeMaterialConnectionPoint;
  61947. /**
  61948. * Gets the y component (output)
  61949. */
  61950. get y(): NodeMaterialConnectionPoint;
  61951. /**
  61952. * Gets the z component (output)
  61953. */
  61954. get z(): NodeMaterialConnectionPoint;
  61955. /**
  61956. * Gets the w component (output)
  61957. */
  61958. get w(): NodeMaterialConnectionPoint;
  61959. protected _inputRename(name: string): string;
  61960. protected _outputRename(name: string): string;
  61961. protected _buildBlock(state: NodeMaterialBuildState): this;
  61962. }
  61963. }
  61964. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  61965. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61966. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61967. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61968. /**
  61969. * Block used to lerp between 2 values
  61970. */
  61971. export class LerpBlock extends NodeMaterialBlock {
  61972. /**
  61973. * Creates a new LerpBlock
  61974. * @param name defines the block name
  61975. */
  61976. constructor(name: string);
  61977. /**
  61978. * Gets the current class name
  61979. * @returns the class name
  61980. */
  61981. getClassName(): string;
  61982. /**
  61983. * Gets the left operand input component
  61984. */
  61985. get left(): NodeMaterialConnectionPoint;
  61986. /**
  61987. * Gets the right operand input component
  61988. */
  61989. get right(): NodeMaterialConnectionPoint;
  61990. /**
  61991. * Gets the gradient operand input component
  61992. */
  61993. get gradient(): NodeMaterialConnectionPoint;
  61994. /**
  61995. * Gets the output component
  61996. */
  61997. get output(): NodeMaterialConnectionPoint;
  61998. protected _buildBlock(state: NodeMaterialBuildState): this;
  61999. }
  62000. }
  62001. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62002. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62003. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62004. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62005. /**
  62006. * Block used to divide 2 vectors
  62007. */
  62008. export class DivideBlock extends NodeMaterialBlock {
  62009. /**
  62010. * Creates a new DivideBlock
  62011. * @param name defines the block name
  62012. */
  62013. constructor(name: string);
  62014. /**
  62015. * Gets the current class name
  62016. * @returns the class name
  62017. */
  62018. getClassName(): string;
  62019. /**
  62020. * Gets the left operand input component
  62021. */
  62022. get left(): NodeMaterialConnectionPoint;
  62023. /**
  62024. * Gets the right operand input component
  62025. */
  62026. get right(): NodeMaterialConnectionPoint;
  62027. /**
  62028. * Gets the output component
  62029. */
  62030. get output(): NodeMaterialConnectionPoint;
  62031. protected _buildBlock(state: NodeMaterialBuildState): this;
  62032. }
  62033. }
  62034. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62035. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62036. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62037. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62038. /**
  62039. * Block used to subtract 2 vectors
  62040. */
  62041. export class SubtractBlock extends NodeMaterialBlock {
  62042. /**
  62043. * Creates a new SubtractBlock
  62044. * @param name defines the block name
  62045. */
  62046. constructor(name: string);
  62047. /**
  62048. * Gets the current class name
  62049. * @returns the class name
  62050. */
  62051. getClassName(): string;
  62052. /**
  62053. * Gets the left operand input component
  62054. */
  62055. get left(): NodeMaterialConnectionPoint;
  62056. /**
  62057. * Gets the right operand input component
  62058. */
  62059. get right(): NodeMaterialConnectionPoint;
  62060. /**
  62061. * Gets the output component
  62062. */
  62063. get output(): NodeMaterialConnectionPoint;
  62064. protected _buildBlock(state: NodeMaterialBuildState): this;
  62065. }
  62066. }
  62067. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62068. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62069. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62070. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62071. /**
  62072. * Block used to step a value
  62073. */
  62074. export class StepBlock extends NodeMaterialBlock {
  62075. /**
  62076. * Creates a new StepBlock
  62077. * @param name defines the block name
  62078. */
  62079. constructor(name: string);
  62080. /**
  62081. * Gets the current class name
  62082. * @returns the class name
  62083. */
  62084. getClassName(): string;
  62085. /**
  62086. * Gets the value operand input component
  62087. */
  62088. get value(): NodeMaterialConnectionPoint;
  62089. /**
  62090. * Gets the edge operand input component
  62091. */
  62092. get edge(): NodeMaterialConnectionPoint;
  62093. /**
  62094. * Gets the output component
  62095. */
  62096. get output(): NodeMaterialConnectionPoint;
  62097. protected _buildBlock(state: NodeMaterialBuildState): this;
  62098. }
  62099. }
  62100. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62101. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62102. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62103. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62104. /**
  62105. * Block used to get the opposite (1 - x) of a value
  62106. */
  62107. export class OneMinusBlock extends NodeMaterialBlock {
  62108. /**
  62109. * Creates a new OneMinusBlock
  62110. * @param name defines the block name
  62111. */
  62112. constructor(name: string);
  62113. /**
  62114. * Gets the current class name
  62115. * @returns the class name
  62116. */
  62117. getClassName(): string;
  62118. /**
  62119. * Gets the input component
  62120. */
  62121. get input(): NodeMaterialConnectionPoint;
  62122. /**
  62123. * Gets the output component
  62124. */
  62125. get output(): NodeMaterialConnectionPoint;
  62126. protected _buildBlock(state: NodeMaterialBuildState): this;
  62127. }
  62128. }
  62129. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62130. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62131. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62132. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62133. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62134. /**
  62135. * Block used to get the view direction
  62136. */
  62137. export class ViewDirectionBlock extends NodeMaterialBlock {
  62138. /**
  62139. * Creates a new ViewDirectionBlock
  62140. * @param name defines the block name
  62141. */
  62142. constructor(name: string);
  62143. /**
  62144. * Gets the current class name
  62145. * @returns the class name
  62146. */
  62147. getClassName(): string;
  62148. /**
  62149. * Gets the world position component
  62150. */
  62151. get worldPosition(): NodeMaterialConnectionPoint;
  62152. /**
  62153. * Gets the camera position component
  62154. */
  62155. get cameraPosition(): NodeMaterialConnectionPoint;
  62156. /**
  62157. * Gets the output component
  62158. */
  62159. get output(): NodeMaterialConnectionPoint;
  62160. autoConfigure(material: NodeMaterial): void;
  62161. protected _buildBlock(state: NodeMaterialBuildState): this;
  62162. }
  62163. }
  62164. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62165. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62166. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62167. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62168. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62169. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62170. /**
  62171. * Block used to compute fresnel value
  62172. */
  62173. export class FresnelBlock extends NodeMaterialBlock {
  62174. /**
  62175. * Create a new FresnelBlock
  62176. * @param name defines the block name
  62177. */
  62178. constructor(name: string);
  62179. /**
  62180. * Gets the current class name
  62181. * @returns the class name
  62182. */
  62183. getClassName(): string;
  62184. /**
  62185. * Gets the world normal input component
  62186. */
  62187. get worldNormal(): NodeMaterialConnectionPoint;
  62188. /**
  62189. * Gets the view direction input component
  62190. */
  62191. get viewDirection(): NodeMaterialConnectionPoint;
  62192. /**
  62193. * Gets the bias input component
  62194. */
  62195. get bias(): NodeMaterialConnectionPoint;
  62196. /**
  62197. * Gets the camera (or eye) position component
  62198. */
  62199. get power(): NodeMaterialConnectionPoint;
  62200. /**
  62201. * Gets the fresnel output component
  62202. */
  62203. get fresnel(): NodeMaterialConnectionPoint;
  62204. autoConfigure(material: NodeMaterial): void;
  62205. protected _buildBlock(state: NodeMaterialBuildState): this;
  62206. }
  62207. }
  62208. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62209. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62210. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62211. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62212. /**
  62213. * Block used to get the max of 2 values
  62214. */
  62215. export class MaxBlock extends NodeMaterialBlock {
  62216. /**
  62217. * Creates a new MaxBlock
  62218. * @param name defines the block name
  62219. */
  62220. constructor(name: string);
  62221. /**
  62222. * Gets the current class name
  62223. * @returns the class name
  62224. */
  62225. getClassName(): string;
  62226. /**
  62227. * Gets the left operand input component
  62228. */
  62229. get left(): NodeMaterialConnectionPoint;
  62230. /**
  62231. * Gets the right operand input component
  62232. */
  62233. get right(): NodeMaterialConnectionPoint;
  62234. /**
  62235. * Gets the output component
  62236. */
  62237. get output(): NodeMaterialConnectionPoint;
  62238. protected _buildBlock(state: NodeMaterialBuildState): this;
  62239. }
  62240. }
  62241. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62242. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62243. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62244. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62245. /**
  62246. * Block used to get the min of 2 values
  62247. */
  62248. export class MinBlock extends NodeMaterialBlock {
  62249. /**
  62250. * Creates a new MinBlock
  62251. * @param name defines the block name
  62252. */
  62253. constructor(name: string);
  62254. /**
  62255. * Gets the current class name
  62256. * @returns the class name
  62257. */
  62258. getClassName(): string;
  62259. /**
  62260. * Gets the left operand input component
  62261. */
  62262. get left(): NodeMaterialConnectionPoint;
  62263. /**
  62264. * Gets the right operand input component
  62265. */
  62266. get right(): NodeMaterialConnectionPoint;
  62267. /**
  62268. * Gets the output component
  62269. */
  62270. get output(): NodeMaterialConnectionPoint;
  62271. protected _buildBlock(state: NodeMaterialBuildState): this;
  62272. }
  62273. }
  62274. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62275. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62276. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62277. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62278. /**
  62279. * Block used to get the distance between 2 values
  62280. */
  62281. export class DistanceBlock extends NodeMaterialBlock {
  62282. /**
  62283. * Creates a new DistanceBlock
  62284. * @param name defines the block name
  62285. */
  62286. constructor(name: string);
  62287. /**
  62288. * Gets the current class name
  62289. * @returns the class name
  62290. */
  62291. getClassName(): string;
  62292. /**
  62293. * Gets the left operand input component
  62294. */
  62295. get left(): NodeMaterialConnectionPoint;
  62296. /**
  62297. * Gets the right operand input component
  62298. */
  62299. get right(): NodeMaterialConnectionPoint;
  62300. /**
  62301. * Gets the output component
  62302. */
  62303. get output(): NodeMaterialConnectionPoint;
  62304. protected _buildBlock(state: NodeMaterialBuildState): this;
  62305. }
  62306. }
  62307. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62308. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62309. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62310. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62311. /**
  62312. * Block used to get the length of a vector
  62313. */
  62314. export class LengthBlock extends NodeMaterialBlock {
  62315. /**
  62316. * Creates a new LengthBlock
  62317. * @param name defines the block name
  62318. */
  62319. constructor(name: string);
  62320. /**
  62321. * Gets the current class name
  62322. * @returns the class name
  62323. */
  62324. getClassName(): string;
  62325. /**
  62326. * Gets the value input component
  62327. */
  62328. get value(): NodeMaterialConnectionPoint;
  62329. /**
  62330. * Gets the output component
  62331. */
  62332. get output(): NodeMaterialConnectionPoint;
  62333. protected _buildBlock(state: NodeMaterialBuildState): this;
  62334. }
  62335. }
  62336. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62337. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62338. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62339. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62340. /**
  62341. * Block used to get negative version of a value (i.e. x * -1)
  62342. */
  62343. export class NegateBlock extends NodeMaterialBlock {
  62344. /**
  62345. * Creates a new NegateBlock
  62346. * @param name defines the block name
  62347. */
  62348. constructor(name: string);
  62349. /**
  62350. * Gets the current class name
  62351. * @returns the class name
  62352. */
  62353. getClassName(): string;
  62354. /**
  62355. * Gets the value input component
  62356. */
  62357. get value(): NodeMaterialConnectionPoint;
  62358. /**
  62359. * Gets the output component
  62360. */
  62361. get output(): NodeMaterialConnectionPoint;
  62362. protected _buildBlock(state: NodeMaterialBuildState): this;
  62363. }
  62364. }
  62365. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62366. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62367. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62368. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62369. /**
  62370. * Block used to get the value of the first parameter raised to the power of the second
  62371. */
  62372. export class PowBlock extends NodeMaterialBlock {
  62373. /**
  62374. * Creates a new PowBlock
  62375. * @param name defines the block name
  62376. */
  62377. constructor(name: string);
  62378. /**
  62379. * Gets the current class name
  62380. * @returns the class name
  62381. */
  62382. getClassName(): string;
  62383. /**
  62384. * Gets the value operand input component
  62385. */
  62386. get value(): NodeMaterialConnectionPoint;
  62387. /**
  62388. * Gets the power operand input component
  62389. */
  62390. get power(): NodeMaterialConnectionPoint;
  62391. /**
  62392. * Gets the output component
  62393. */
  62394. get output(): NodeMaterialConnectionPoint;
  62395. protected _buildBlock(state: NodeMaterialBuildState): this;
  62396. }
  62397. }
  62398. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62399. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62400. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62401. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62402. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62403. /**
  62404. * Block used to get a random number
  62405. */
  62406. export class RandomNumberBlock extends NodeMaterialBlock {
  62407. /**
  62408. * Creates a new RandomNumberBlock
  62409. * @param name defines the block name
  62410. */
  62411. constructor(name: string);
  62412. /**
  62413. * Gets the current class name
  62414. * @returns the class name
  62415. */
  62416. getClassName(): string;
  62417. /**
  62418. * Gets the seed input component
  62419. */
  62420. get seed(): NodeMaterialConnectionPoint;
  62421. /**
  62422. * Gets the output component
  62423. */
  62424. get output(): NodeMaterialConnectionPoint;
  62425. protected _buildBlock(state: NodeMaterialBuildState): this;
  62426. }
  62427. }
  62428. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62429. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62430. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62431. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62432. /**
  62433. * Block used to compute arc tangent of 2 values
  62434. */
  62435. export class ArcTan2Block extends NodeMaterialBlock {
  62436. /**
  62437. * Creates a new ArcTan2Block
  62438. * @param name defines the block name
  62439. */
  62440. constructor(name: string);
  62441. /**
  62442. * Gets the current class name
  62443. * @returns the class name
  62444. */
  62445. getClassName(): string;
  62446. /**
  62447. * Gets the x operand input component
  62448. */
  62449. get x(): NodeMaterialConnectionPoint;
  62450. /**
  62451. * Gets the y operand input component
  62452. */
  62453. get y(): NodeMaterialConnectionPoint;
  62454. /**
  62455. * Gets the output component
  62456. */
  62457. get output(): NodeMaterialConnectionPoint;
  62458. protected _buildBlock(state: NodeMaterialBuildState): this;
  62459. }
  62460. }
  62461. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62462. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62463. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62464. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62465. /**
  62466. * Block used to smooth step a value
  62467. */
  62468. export class SmoothStepBlock extends NodeMaterialBlock {
  62469. /**
  62470. * Creates a new SmoothStepBlock
  62471. * @param name defines the block name
  62472. */
  62473. constructor(name: string);
  62474. /**
  62475. * Gets the current class name
  62476. * @returns the class name
  62477. */
  62478. getClassName(): string;
  62479. /**
  62480. * Gets the value operand input component
  62481. */
  62482. get value(): NodeMaterialConnectionPoint;
  62483. /**
  62484. * Gets the first edge operand input component
  62485. */
  62486. get edge0(): NodeMaterialConnectionPoint;
  62487. /**
  62488. * Gets the second edge operand input component
  62489. */
  62490. get edge1(): NodeMaterialConnectionPoint;
  62491. /**
  62492. * Gets the output component
  62493. */
  62494. get output(): NodeMaterialConnectionPoint;
  62495. protected _buildBlock(state: NodeMaterialBuildState): this;
  62496. }
  62497. }
  62498. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62499. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62500. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62501. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62502. /**
  62503. * Block used to get the reciprocal (1 / x) of a value
  62504. */
  62505. export class ReciprocalBlock extends NodeMaterialBlock {
  62506. /**
  62507. * Creates a new ReciprocalBlock
  62508. * @param name defines the block name
  62509. */
  62510. constructor(name: string);
  62511. /**
  62512. * Gets the current class name
  62513. * @returns the class name
  62514. */
  62515. getClassName(): string;
  62516. /**
  62517. * Gets the input component
  62518. */
  62519. get input(): NodeMaterialConnectionPoint;
  62520. /**
  62521. * Gets the output component
  62522. */
  62523. get output(): NodeMaterialConnectionPoint;
  62524. protected _buildBlock(state: NodeMaterialBuildState): this;
  62525. }
  62526. }
  62527. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62528. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62529. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62530. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62531. /**
  62532. * Block used to replace a color by another one
  62533. */
  62534. export class ReplaceColorBlock extends NodeMaterialBlock {
  62535. /**
  62536. * Creates a new ReplaceColorBlock
  62537. * @param name defines the block name
  62538. */
  62539. constructor(name: string);
  62540. /**
  62541. * Gets the current class name
  62542. * @returns the class name
  62543. */
  62544. getClassName(): string;
  62545. /**
  62546. * Gets the value input component
  62547. */
  62548. get value(): NodeMaterialConnectionPoint;
  62549. /**
  62550. * Gets the reference input component
  62551. */
  62552. get reference(): NodeMaterialConnectionPoint;
  62553. /**
  62554. * Gets the distance input component
  62555. */
  62556. get distance(): NodeMaterialConnectionPoint;
  62557. /**
  62558. * Gets the replacement input component
  62559. */
  62560. get replacement(): NodeMaterialConnectionPoint;
  62561. /**
  62562. * Gets the output component
  62563. */
  62564. get output(): NodeMaterialConnectionPoint;
  62565. protected _buildBlock(state: NodeMaterialBuildState): this;
  62566. }
  62567. }
  62568. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62569. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62570. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62571. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62572. /**
  62573. * Block used to posterize a value
  62574. * @see https://en.wikipedia.org/wiki/Posterization
  62575. */
  62576. export class PosterizeBlock extends NodeMaterialBlock {
  62577. /**
  62578. * Creates a new PosterizeBlock
  62579. * @param name defines the block name
  62580. */
  62581. constructor(name: string);
  62582. /**
  62583. * Gets the current class name
  62584. * @returns the class name
  62585. */
  62586. getClassName(): string;
  62587. /**
  62588. * Gets the value input component
  62589. */
  62590. get value(): NodeMaterialConnectionPoint;
  62591. /**
  62592. * Gets the steps input component
  62593. */
  62594. get steps(): NodeMaterialConnectionPoint;
  62595. /**
  62596. * Gets the output component
  62597. */
  62598. get output(): NodeMaterialConnectionPoint;
  62599. protected _buildBlock(state: NodeMaterialBuildState): this;
  62600. }
  62601. }
  62602. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62603. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62604. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62605. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62606. import { Scene } from "babylonjs/scene";
  62607. /**
  62608. * Operations supported by the Wave block
  62609. */
  62610. export enum WaveBlockKind {
  62611. /** SawTooth */
  62612. SawTooth = 0,
  62613. /** Square */
  62614. Square = 1,
  62615. /** Triangle */
  62616. Triangle = 2
  62617. }
  62618. /**
  62619. * Block used to apply wave operation to floats
  62620. */
  62621. export class WaveBlock extends NodeMaterialBlock {
  62622. /**
  62623. * Gets or sets the kibnd of wave to be applied by the block
  62624. */
  62625. kind: WaveBlockKind;
  62626. /**
  62627. * Creates a new WaveBlock
  62628. * @param name defines the block name
  62629. */
  62630. constructor(name: string);
  62631. /**
  62632. * Gets the current class name
  62633. * @returns the class name
  62634. */
  62635. getClassName(): string;
  62636. /**
  62637. * Gets the input component
  62638. */
  62639. get input(): NodeMaterialConnectionPoint;
  62640. /**
  62641. * Gets the output component
  62642. */
  62643. get output(): NodeMaterialConnectionPoint;
  62644. protected _buildBlock(state: NodeMaterialBuildState): this;
  62645. serialize(): any;
  62646. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62647. }
  62648. }
  62649. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62650. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62651. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62652. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62653. import { Color3 } from "babylonjs/Maths/math.color";
  62654. import { Scene } from "babylonjs/scene";
  62655. /**
  62656. * Class used to store a color step for the GradientBlock
  62657. */
  62658. export class GradientBlockColorStep {
  62659. /**
  62660. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62661. */
  62662. step: number;
  62663. /**
  62664. * Gets or sets the color associated with this step
  62665. */
  62666. color: Color3;
  62667. /**
  62668. * Creates a new GradientBlockColorStep
  62669. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62670. * @param color defines the color associated with this step
  62671. */
  62672. constructor(
  62673. /**
  62674. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62675. */
  62676. step: number,
  62677. /**
  62678. * Gets or sets the color associated with this step
  62679. */
  62680. color: Color3);
  62681. }
  62682. /**
  62683. * Block used to return a color from a gradient based on an input value between 0 and 1
  62684. */
  62685. export class GradientBlock extends NodeMaterialBlock {
  62686. /**
  62687. * Gets or sets the list of color steps
  62688. */
  62689. colorSteps: GradientBlockColorStep[];
  62690. /**
  62691. * Creates a new GradientBlock
  62692. * @param name defines the block name
  62693. */
  62694. constructor(name: string);
  62695. /**
  62696. * Gets the current class name
  62697. * @returns the class name
  62698. */
  62699. getClassName(): string;
  62700. /**
  62701. * Gets the gradient input component
  62702. */
  62703. get gradient(): NodeMaterialConnectionPoint;
  62704. /**
  62705. * Gets the output component
  62706. */
  62707. get output(): NodeMaterialConnectionPoint;
  62708. private _writeColorConstant;
  62709. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62710. serialize(): any;
  62711. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62712. protected _dumpPropertiesCode(): string;
  62713. }
  62714. }
  62715. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62716. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62717. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62718. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62719. /**
  62720. * Block used to normalize lerp between 2 values
  62721. */
  62722. export class NLerpBlock extends NodeMaterialBlock {
  62723. /**
  62724. * Creates a new NLerpBlock
  62725. * @param name defines the block name
  62726. */
  62727. constructor(name: string);
  62728. /**
  62729. * Gets the current class name
  62730. * @returns the class name
  62731. */
  62732. getClassName(): string;
  62733. /**
  62734. * Gets the left operand input component
  62735. */
  62736. get left(): NodeMaterialConnectionPoint;
  62737. /**
  62738. * Gets the right operand input component
  62739. */
  62740. get right(): NodeMaterialConnectionPoint;
  62741. /**
  62742. * Gets the gradient operand input component
  62743. */
  62744. get gradient(): NodeMaterialConnectionPoint;
  62745. /**
  62746. * Gets the output component
  62747. */
  62748. get output(): NodeMaterialConnectionPoint;
  62749. protected _buildBlock(state: NodeMaterialBuildState): this;
  62750. }
  62751. }
  62752. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  62753. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62754. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62755. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62756. import { Scene } from "babylonjs/scene";
  62757. /**
  62758. * block used to Generate a Worley Noise 3D Noise Pattern
  62759. */
  62760. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62761. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62762. manhattanDistance: boolean;
  62763. /**
  62764. * Creates a new WorleyNoise3DBlock
  62765. * @param name defines the block name
  62766. */
  62767. constructor(name: string);
  62768. /**
  62769. * Gets the current class name
  62770. * @returns the class name
  62771. */
  62772. getClassName(): string;
  62773. /**
  62774. * Gets the seed input component
  62775. */
  62776. get seed(): NodeMaterialConnectionPoint;
  62777. /**
  62778. * Gets the jitter input component
  62779. */
  62780. get jitter(): NodeMaterialConnectionPoint;
  62781. /**
  62782. * Gets the output component
  62783. */
  62784. get output(): NodeMaterialConnectionPoint;
  62785. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62786. /**
  62787. * Exposes the properties to the UI?
  62788. */
  62789. protected _dumpPropertiesCode(): string;
  62790. /**
  62791. * Exposes the properties to the Seralize?
  62792. */
  62793. serialize(): any;
  62794. /**
  62795. * Exposes the properties to the deseralize?
  62796. */
  62797. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62798. }
  62799. }
  62800. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  62801. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62802. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62803. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62804. /**
  62805. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62806. */
  62807. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62808. /**
  62809. * Creates a new SimplexPerlin3DBlock
  62810. * @param name defines the block name
  62811. */
  62812. constructor(name: string);
  62813. /**
  62814. * Gets the current class name
  62815. * @returns the class name
  62816. */
  62817. getClassName(): string;
  62818. /**
  62819. * Gets the seed operand input component
  62820. */
  62821. get seed(): NodeMaterialConnectionPoint;
  62822. /**
  62823. * Gets the output component
  62824. */
  62825. get output(): NodeMaterialConnectionPoint;
  62826. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62827. }
  62828. }
  62829. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  62830. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62831. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62832. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62833. /**
  62834. * Block used to blend normals
  62835. */
  62836. export class NormalBlendBlock extends NodeMaterialBlock {
  62837. /**
  62838. * Creates a new NormalBlendBlock
  62839. * @param name defines the block name
  62840. */
  62841. constructor(name: string);
  62842. /**
  62843. * Gets the current class name
  62844. * @returns the class name
  62845. */
  62846. getClassName(): string;
  62847. /**
  62848. * Gets the first input component
  62849. */
  62850. get normalMap0(): NodeMaterialConnectionPoint;
  62851. /**
  62852. * Gets the second input component
  62853. */
  62854. get normalMap1(): NodeMaterialConnectionPoint;
  62855. /**
  62856. * Gets the output component
  62857. */
  62858. get output(): NodeMaterialConnectionPoint;
  62859. protected _buildBlock(state: NodeMaterialBuildState): this;
  62860. }
  62861. }
  62862. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  62863. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62864. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62865. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62866. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62867. /**
  62868. * Block used to rotate a 2d vector by a given angle
  62869. */
  62870. export class Rotate2dBlock extends NodeMaterialBlock {
  62871. /**
  62872. * Creates a new Rotate2dBlock
  62873. * @param name defines the block name
  62874. */
  62875. constructor(name: string);
  62876. /**
  62877. * Gets the current class name
  62878. * @returns the class name
  62879. */
  62880. getClassName(): string;
  62881. /**
  62882. * Gets the input vector
  62883. */
  62884. get input(): NodeMaterialConnectionPoint;
  62885. /**
  62886. * Gets the input angle
  62887. */
  62888. get angle(): NodeMaterialConnectionPoint;
  62889. /**
  62890. * Gets the output component
  62891. */
  62892. get output(): NodeMaterialConnectionPoint;
  62893. autoConfigure(material: NodeMaterial): void;
  62894. protected _buildBlock(state: NodeMaterialBuildState): this;
  62895. }
  62896. }
  62897. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  62898. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62899. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62900. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62901. /**
  62902. * Block used to get the reflected vector from a direction and a normal
  62903. */
  62904. export class ReflectBlock extends NodeMaterialBlock {
  62905. /**
  62906. * Creates a new ReflectBlock
  62907. * @param name defines the block name
  62908. */
  62909. constructor(name: string);
  62910. /**
  62911. * Gets the current class name
  62912. * @returns the class name
  62913. */
  62914. getClassName(): string;
  62915. /**
  62916. * Gets the incident component
  62917. */
  62918. get incident(): NodeMaterialConnectionPoint;
  62919. /**
  62920. * Gets the normal component
  62921. */
  62922. get normal(): NodeMaterialConnectionPoint;
  62923. /**
  62924. * Gets the output component
  62925. */
  62926. get output(): NodeMaterialConnectionPoint;
  62927. protected _buildBlock(state: NodeMaterialBuildState): this;
  62928. }
  62929. }
  62930. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  62931. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62932. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62933. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62934. /**
  62935. * Block used to get the refracted vector from a direction and a normal
  62936. */
  62937. export class RefractBlock extends NodeMaterialBlock {
  62938. /**
  62939. * Creates a new RefractBlock
  62940. * @param name defines the block name
  62941. */
  62942. constructor(name: string);
  62943. /**
  62944. * Gets the current class name
  62945. * @returns the class name
  62946. */
  62947. getClassName(): string;
  62948. /**
  62949. * Gets the incident component
  62950. */
  62951. get incident(): NodeMaterialConnectionPoint;
  62952. /**
  62953. * Gets the normal component
  62954. */
  62955. get normal(): NodeMaterialConnectionPoint;
  62956. /**
  62957. * Gets the index of refraction component
  62958. */
  62959. get ior(): NodeMaterialConnectionPoint;
  62960. /**
  62961. * Gets the output component
  62962. */
  62963. get output(): NodeMaterialConnectionPoint;
  62964. protected _buildBlock(state: NodeMaterialBuildState): this;
  62965. }
  62966. }
  62967. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  62968. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62969. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62970. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62971. /**
  62972. * Block used to desaturate a color
  62973. */
  62974. export class DesaturateBlock extends NodeMaterialBlock {
  62975. /**
  62976. * Creates a new DesaturateBlock
  62977. * @param name defines the block name
  62978. */
  62979. constructor(name: string);
  62980. /**
  62981. * Gets the current class name
  62982. * @returns the class name
  62983. */
  62984. getClassName(): string;
  62985. /**
  62986. * Gets the color operand input component
  62987. */
  62988. get color(): NodeMaterialConnectionPoint;
  62989. /**
  62990. * Gets the level operand input component
  62991. */
  62992. get level(): NodeMaterialConnectionPoint;
  62993. /**
  62994. * Gets the output component
  62995. */
  62996. get output(): NodeMaterialConnectionPoint;
  62997. protected _buildBlock(state: NodeMaterialBuildState): this;
  62998. }
  62999. }
  63000. declare module "babylonjs/Materials/Node/Blocks/index" {
  63001. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63002. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63003. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63004. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63005. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63006. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63007. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63008. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63009. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63010. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63011. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63012. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63013. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63014. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63015. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63016. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63017. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63018. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63019. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63020. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63021. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63022. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63023. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63024. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63025. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63026. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63027. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63028. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63029. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63030. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63031. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63032. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63033. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63034. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63035. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63036. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63037. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63038. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63039. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63040. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63041. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63042. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63043. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63044. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63045. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63046. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63047. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63048. }
  63049. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63050. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63051. }
  63052. declare module "babylonjs/Materials/Node/index" {
  63053. export * from "babylonjs/Materials/Node/Enums/index";
  63054. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63055. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63056. export * from "babylonjs/Materials/Node/nodeMaterial";
  63057. export * from "babylonjs/Materials/Node/Blocks/index";
  63058. export * from "babylonjs/Materials/Node/Optimizers/index";
  63059. }
  63060. declare module "babylonjs/Materials/effectRenderer" {
  63061. import { Nullable } from "babylonjs/types";
  63062. import { Texture } from "babylonjs/Materials/Textures/texture";
  63063. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63064. import { Viewport } from "babylonjs/Maths/math.viewport";
  63065. import { Observable } from "babylonjs/Misc/observable";
  63066. import { Effect } from "babylonjs/Materials/effect";
  63067. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63068. import "babylonjs/Shaders/postprocess.vertex";
  63069. /**
  63070. * Effect Render Options
  63071. */
  63072. export interface IEffectRendererOptions {
  63073. /**
  63074. * Defines the vertices positions.
  63075. */
  63076. positions?: number[];
  63077. /**
  63078. * Defines the indices.
  63079. */
  63080. indices?: number[];
  63081. }
  63082. /**
  63083. * Helper class to render one or more effects
  63084. */
  63085. export class EffectRenderer {
  63086. private engine;
  63087. private static _DefaultOptions;
  63088. private _vertexBuffers;
  63089. private _indexBuffer;
  63090. private _ringBufferIndex;
  63091. private _ringScreenBuffer;
  63092. private _fullscreenViewport;
  63093. private _getNextFrameBuffer;
  63094. /**
  63095. * Creates an effect renderer
  63096. * @param engine the engine to use for rendering
  63097. * @param options defines the options of the effect renderer
  63098. */
  63099. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63100. /**
  63101. * Sets the current viewport in normalized coordinates 0-1
  63102. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63103. */
  63104. setViewport(viewport?: Viewport): void;
  63105. /**
  63106. * Binds the embedded attributes buffer to the effect.
  63107. * @param effect Defines the effect to bind the attributes for
  63108. */
  63109. bindBuffers(effect: Effect): void;
  63110. /**
  63111. * Sets the current effect wrapper to use during draw.
  63112. * The effect needs to be ready before calling this api.
  63113. * This also sets the default full screen position attribute.
  63114. * @param effectWrapper Defines the effect to draw with
  63115. */
  63116. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63117. /**
  63118. * Draws a full screen quad.
  63119. */
  63120. draw(): void;
  63121. /**
  63122. * renders one or more effects to a specified texture
  63123. * @param effectWrappers list of effects to renderer
  63124. * @param outputTexture texture to draw to, if null it will render to the screen
  63125. */
  63126. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63127. /**
  63128. * Disposes of the effect renderer
  63129. */
  63130. dispose(): void;
  63131. }
  63132. /**
  63133. * Options to create an EffectWrapper
  63134. */
  63135. interface EffectWrapperCreationOptions {
  63136. /**
  63137. * Engine to use to create the effect
  63138. */
  63139. engine: ThinEngine;
  63140. /**
  63141. * Fragment shader for the effect
  63142. */
  63143. fragmentShader: string;
  63144. /**
  63145. * Vertex shader for the effect
  63146. */
  63147. vertexShader?: string;
  63148. /**
  63149. * Attributes to use in the shader
  63150. */
  63151. attributeNames?: Array<string>;
  63152. /**
  63153. * Uniforms to use in the shader
  63154. */
  63155. uniformNames?: Array<string>;
  63156. /**
  63157. * Texture sampler names to use in the shader
  63158. */
  63159. samplerNames?: Array<string>;
  63160. /**
  63161. * The friendly name of the effect displayed in Spector.
  63162. */
  63163. name?: string;
  63164. }
  63165. /**
  63166. * Wraps an effect to be used for rendering
  63167. */
  63168. export class EffectWrapper {
  63169. /**
  63170. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63171. */
  63172. onApplyObservable: Observable<{}>;
  63173. /**
  63174. * The underlying effect
  63175. */
  63176. effect: Effect;
  63177. /**
  63178. * Creates an effect to be renderer
  63179. * @param creationOptions options to create the effect
  63180. */
  63181. constructor(creationOptions: EffectWrapperCreationOptions);
  63182. /**
  63183. * Disposes of the effect wrapper
  63184. */
  63185. dispose(): void;
  63186. }
  63187. }
  63188. declare module "babylonjs/Materials/index" {
  63189. export * from "babylonjs/Materials/Background/index";
  63190. export * from "babylonjs/Materials/colorCurves";
  63191. export * from "babylonjs/Materials/iEffectFallbacks";
  63192. export * from "babylonjs/Materials/effectFallbacks";
  63193. export * from "babylonjs/Materials/effect";
  63194. export * from "babylonjs/Materials/fresnelParameters";
  63195. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63196. export * from "babylonjs/Materials/material";
  63197. export * from "babylonjs/Materials/materialDefines";
  63198. export * from "babylonjs/Materials/materialHelper";
  63199. export * from "babylonjs/Materials/multiMaterial";
  63200. export * from "babylonjs/Materials/PBR/index";
  63201. export * from "babylonjs/Materials/pushMaterial";
  63202. export * from "babylonjs/Materials/shaderMaterial";
  63203. export * from "babylonjs/Materials/standardMaterial";
  63204. export * from "babylonjs/Materials/Textures/index";
  63205. export * from "babylonjs/Materials/uniformBuffer";
  63206. export * from "babylonjs/Materials/materialFlags";
  63207. export * from "babylonjs/Materials/Node/index";
  63208. export * from "babylonjs/Materials/effectRenderer";
  63209. }
  63210. declare module "babylonjs/Maths/index" {
  63211. export * from "babylonjs/Maths/math.scalar";
  63212. export * from "babylonjs/Maths/math";
  63213. export * from "babylonjs/Maths/sphericalPolynomial";
  63214. }
  63215. declare module "babylonjs/Misc/workerPool" {
  63216. import { IDisposable } from "babylonjs/scene";
  63217. /**
  63218. * Helper class to push actions to a pool of workers.
  63219. */
  63220. export class WorkerPool implements IDisposable {
  63221. private _workerInfos;
  63222. private _pendingActions;
  63223. /**
  63224. * Constructor
  63225. * @param workers Array of workers to use for actions
  63226. */
  63227. constructor(workers: Array<Worker>);
  63228. /**
  63229. * Terminates all workers and clears any pending actions.
  63230. */
  63231. dispose(): void;
  63232. /**
  63233. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63234. * pended until a worker has completed its action.
  63235. * @param action The action to perform. Call onComplete when the action is complete.
  63236. */
  63237. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63238. private _execute;
  63239. }
  63240. }
  63241. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63242. import { IDisposable } from "babylonjs/scene";
  63243. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63244. /**
  63245. * Configuration for Draco compression
  63246. */
  63247. export interface IDracoCompressionConfiguration {
  63248. /**
  63249. * Configuration for the decoder.
  63250. */
  63251. decoder: {
  63252. /**
  63253. * The url to the WebAssembly module.
  63254. */
  63255. wasmUrl?: string;
  63256. /**
  63257. * The url to the WebAssembly binary.
  63258. */
  63259. wasmBinaryUrl?: string;
  63260. /**
  63261. * The url to the fallback JavaScript module.
  63262. */
  63263. fallbackUrl?: string;
  63264. };
  63265. }
  63266. /**
  63267. * Draco compression (https://google.github.io/draco/)
  63268. *
  63269. * This class wraps the Draco module.
  63270. *
  63271. * **Encoder**
  63272. *
  63273. * The encoder is not currently implemented.
  63274. *
  63275. * **Decoder**
  63276. *
  63277. * 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.
  63278. *
  63279. * To update the configuration, use the following code:
  63280. * ```javascript
  63281. * DracoCompression.Configuration = {
  63282. * decoder: {
  63283. * wasmUrl: "<url to the WebAssembly library>",
  63284. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63285. * fallbackUrl: "<url to the fallback JavaScript library>",
  63286. * }
  63287. * };
  63288. * ```
  63289. *
  63290. * 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.
  63291. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63292. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63293. *
  63294. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63295. * ```javascript
  63296. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63297. * ```
  63298. *
  63299. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63300. */
  63301. export class DracoCompression implements IDisposable {
  63302. private _workerPoolPromise?;
  63303. private _decoderModulePromise?;
  63304. /**
  63305. * The configuration. Defaults to the following urls:
  63306. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63307. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63308. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63309. */
  63310. static Configuration: IDracoCompressionConfiguration;
  63311. /**
  63312. * Returns true if the decoder configuration is available.
  63313. */
  63314. static get DecoderAvailable(): boolean;
  63315. /**
  63316. * Default number of workers to create when creating the draco compression object.
  63317. */
  63318. static DefaultNumWorkers: number;
  63319. private static GetDefaultNumWorkers;
  63320. private static _Default;
  63321. /**
  63322. * Default instance for the draco compression object.
  63323. */
  63324. static get Default(): DracoCompression;
  63325. /**
  63326. * Constructor
  63327. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63328. */
  63329. constructor(numWorkers?: number);
  63330. /**
  63331. * Stop all async operations and release resources.
  63332. */
  63333. dispose(): void;
  63334. /**
  63335. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63336. * @returns a promise that resolves when ready
  63337. */
  63338. whenReadyAsync(): Promise<void>;
  63339. /**
  63340. * Decode Draco compressed mesh data to vertex data.
  63341. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63342. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63343. * @returns A promise that resolves with the decoded vertex data
  63344. */
  63345. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63346. [kind: string]: number;
  63347. }): Promise<VertexData>;
  63348. }
  63349. }
  63350. declare module "babylonjs/Meshes/Compression/index" {
  63351. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63352. }
  63353. declare module "babylonjs/Meshes/csg" {
  63354. import { Nullable } from "babylonjs/types";
  63355. import { Scene } from "babylonjs/scene";
  63356. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63357. import { Mesh } from "babylonjs/Meshes/mesh";
  63358. import { Material } from "babylonjs/Materials/material";
  63359. /**
  63360. * Class for building Constructive Solid Geometry
  63361. */
  63362. export class CSG {
  63363. private polygons;
  63364. /**
  63365. * The world matrix
  63366. */
  63367. matrix: Matrix;
  63368. /**
  63369. * Stores the position
  63370. */
  63371. position: Vector3;
  63372. /**
  63373. * Stores the rotation
  63374. */
  63375. rotation: Vector3;
  63376. /**
  63377. * Stores the rotation quaternion
  63378. */
  63379. rotationQuaternion: Nullable<Quaternion>;
  63380. /**
  63381. * Stores the scaling vector
  63382. */
  63383. scaling: Vector3;
  63384. /**
  63385. * Convert the Mesh to CSG
  63386. * @param mesh The Mesh to convert to CSG
  63387. * @returns A new CSG from the Mesh
  63388. */
  63389. static FromMesh(mesh: Mesh): CSG;
  63390. /**
  63391. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63392. * @param polygons Polygons used to construct a CSG solid
  63393. */
  63394. private static FromPolygons;
  63395. /**
  63396. * Clones, or makes a deep copy, of the CSG
  63397. * @returns A new CSG
  63398. */
  63399. clone(): CSG;
  63400. /**
  63401. * Unions this CSG with another CSG
  63402. * @param csg The CSG to union against this CSG
  63403. * @returns The unioned CSG
  63404. */
  63405. union(csg: CSG): CSG;
  63406. /**
  63407. * Unions this CSG with another CSG in place
  63408. * @param csg The CSG to union against this CSG
  63409. */
  63410. unionInPlace(csg: CSG): void;
  63411. /**
  63412. * Subtracts this CSG with another CSG
  63413. * @param csg The CSG to subtract against this CSG
  63414. * @returns A new CSG
  63415. */
  63416. subtract(csg: CSG): CSG;
  63417. /**
  63418. * Subtracts this CSG with another CSG in place
  63419. * @param csg The CSG to subtact against this CSG
  63420. */
  63421. subtractInPlace(csg: CSG): void;
  63422. /**
  63423. * Intersect this CSG with another CSG
  63424. * @param csg The CSG to intersect against this CSG
  63425. * @returns A new CSG
  63426. */
  63427. intersect(csg: CSG): CSG;
  63428. /**
  63429. * Intersects this CSG with another CSG in place
  63430. * @param csg The CSG to intersect against this CSG
  63431. */
  63432. intersectInPlace(csg: CSG): void;
  63433. /**
  63434. * Return a new CSG solid with solid and empty space switched. This solid is
  63435. * not modified.
  63436. * @returns A new CSG solid with solid and empty space switched
  63437. */
  63438. inverse(): CSG;
  63439. /**
  63440. * Inverses the CSG in place
  63441. */
  63442. inverseInPlace(): void;
  63443. /**
  63444. * This is used to keep meshes transformations so they can be restored
  63445. * when we build back a Babylon Mesh
  63446. * NB : All CSG operations are performed in world coordinates
  63447. * @param csg The CSG to copy the transform attributes from
  63448. * @returns This CSG
  63449. */
  63450. copyTransformAttributes(csg: CSG): CSG;
  63451. /**
  63452. * Build Raw mesh from CSG
  63453. * Coordinates here are in world space
  63454. * @param name The name of the mesh geometry
  63455. * @param scene The Scene
  63456. * @param keepSubMeshes Specifies if the submeshes should be kept
  63457. * @returns A new Mesh
  63458. */
  63459. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63460. /**
  63461. * Build Mesh from CSG taking material and transforms into account
  63462. * @param name The name of the Mesh
  63463. * @param material The material of the Mesh
  63464. * @param scene The Scene
  63465. * @param keepSubMeshes Specifies if submeshes should be kept
  63466. * @returns The new Mesh
  63467. */
  63468. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63469. }
  63470. }
  63471. declare module "babylonjs/Meshes/trailMesh" {
  63472. import { Mesh } from "babylonjs/Meshes/mesh";
  63473. import { Scene } from "babylonjs/scene";
  63474. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63475. /**
  63476. * Class used to create a trail following a mesh
  63477. */
  63478. export class TrailMesh extends Mesh {
  63479. private _generator;
  63480. private _autoStart;
  63481. private _running;
  63482. private _diameter;
  63483. private _length;
  63484. private _sectionPolygonPointsCount;
  63485. private _sectionVectors;
  63486. private _sectionNormalVectors;
  63487. private _beforeRenderObserver;
  63488. /**
  63489. * @constructor
  63490. * @param name The value used by scene.getMeshByName() to do a lookup.
  63491. * @param generator The mesh or transform node to generate a trail.
  63492. * @param scene The scene to add this mesh to.
  63493. * @param diameter Diameter of trailing mesh. Default is 1.
  63494. * @param length Length of trailing mesh. Default is 60.
  63495. * @param autoStart Automatically start trailing mesh. Default true.
  63496. */
  63497. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63498. /**
  63499. * "TrailMesh"
  63500. * @returns "TrailMesh"
  63501. */
  63502. getClassName(): string;
  63503. private _createMesh;
  63504. /**
  63505. * Start trailing mesh.
  63506. */
  63507. start(): void;
  63508. /**
  63509. * Stop trailing mesh.
  63510. */
  63511. stop(): void;
  63512. /**
  63513. * Update trailing mesh geometry.
  63514. */
  63515. update(): void;
  63516. /**
  63517. * Returns a new TrailMesh object.
  63518. * @param name is a string, the name given to the new mesh
  63519. * @param newGenerator use new generator object for cloned trail mesh
  63520. * @returns a new mesh
  63521. */
  63522. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63523. /**
  63524. * Serializes this trail mesh
  63525. * @param serializationObject object to write serialization to
  63526. */
  63527. serialize(serializationObject: any): void;
  63528. /**
  63529. * Parses a serialized trail mesh
  63530. * @param parsedMesh the serialized mesh
  63531. * @param scene the scene to create the trail mesh in
  63532. * @returns the created trail mesh
  63533. */
  63534. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63535. }
  63536. }
  63537. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63538. import { Nullable } from "babylonjs/types";
  63539. import { Scene } from "babylonjs/scene";
  63540. import { Vector4 } from "babylonjs/Maths/math.vector";
  63541. import { Color4 } from "babylonjs/Maths/math.color";
  63542. import { Mesh } from "babylonjs/Meshes/mesh";
  63543. /**
  63544. * Class containing static functions to help procedurally build meshes
  63545. */
  63546. export class TiledBoxBuilder {
  63547. /**
  63548. * Creates a box mesh
  63549. * 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)
  63550. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63552. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63553. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63554. * @param name defines the name of the mesh
  63555. * @param options defines the options used to create the mesh
  63556. * @param scene defines the hosting scene
  63557. * @returns the box mesh
  63558. */
  63559. static CreateTiledBox(name: string, options: {
  63560. pattern?: number;
  63561. width?: number;
  63562. height?: number;
  63563. depth?: number;
  63564. tileSize?: number;
  63565. tileWidth?: number;
  63566. tileHeight?: number;
  63567. alignHorizontal?: number;
  63568. alignVertical?: number;
  63569. faceUV?: Vector4[];
  63570. faceColors?: Color4[];
  63571. sideOrientation?: number;
  63572. updatable?: boolean;
  63573. }, scene?: Nullable<Scene>): Mesh;
  63574. }
  63575. }
  63576. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63577. import { Vector4 } from "babylonjs/Maths/math.vector";
  63578. import { Mesh } from "babylonjs/Meshes/mesh";
  63579. /**
  63580. * Class containing static functions to help procedurally build meshes
  63581. */
  63582. export class TorusKnotBuilder {
  63583. /**
  63584. * Creates a torus knot mesh
  63585. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63586. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63587. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63588. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63590. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63592. * @param name defines the name of the mesh
  63593. * @param options defines the options used to create the mesh
  63594. * @param scene defines the hosting scene
  63595. * @returns the torus knot mesh
  63596. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63597. */
  63598. static CreateTorusKnot(name: string, options: {
  63599. radius?: number;
  63600. tube?: number;
  63601. radialSegments?: number;
  63602. tubularSegments?: number;
  63603. p?: number;
  63604. q?: number;
  63605. updatable?: boolean;
  63606. sideOrientation?: number;
  63607. frontUVs?: Vector4;
  63608. backUVs?: Vector4;
  63609. }, scene: any): Mesh;
  63610. }
  63611. }
  63612. declare module "babylonjs/Meshes/polygonMesh" {
  63613. import { Scene } from "babylonjs/scene";
  63614. import { Vector2 } from "babylonjs/Maths/math.vector";
  63615. import { Mesh } from "babylonjs/Meshes/mesh";
  63616. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63617. import { Path2 } from "babylonjs/Maths/math.path";
  63618. /**
  63619. * Polygon
  63620. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63621. */
  63622. export class Polygon {
  63623. /**
  63624. * Creates a rectangle
  63625. * @param xmin bottom X coord
  63626. * @param ymin bottom Y coord
  63627. * @param xmax top X coord
  63628. * @param ymax top Y coord
  63629. * @returns points that make the resulting rectation
  63630. */
  63631. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63632. /**
  63633. * Creates a circle
  63634. * @param radius radius of circle
  63635. * @param cx scale in x
  63636. * @param cy scale in y
  63637. * @param numberOfSides number of sides that make up the circle
  63638. * @returns points that make the resulting circle
  63639. */
  63640. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63641. /**
  63642. * Creates a polygon from input string
  63643. * @param input Input polygon data
  63644. * @returns the parsed points
  63645. */
  63646. static Parse(input: string): Vector2[];
  63647. /**
  63648. * Starts building a polygon from x and y coordinates
  63649. * @param x x coordinate
  63650. * @param y y coordinate
  63651. * @returns the started path2
  63652. */
  63653. static StartingAt(x: number, y: number): Path2;
  63654. }
  63655. /**
  63656. * Builds a polygon
  63657. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63658. */
  63659. export class PolygonMeshBuilder {
  63660. private _points;
  63661. private _outlinepoints;
  63662. private _holes;
  63663. private _name;
  63664. private _scene;
  63665. private _epoints;
  63666. private _eholes;
  63667. private _addToepoint;
  63668. /**
  63669. * Babylon reference to the earcut plugin.
  63670. */
  63671. bjsEarcut: any;
  63672. /**
  63673. * Creates a PolygonMeshBuilder
  63674. * @param name name of the builder
  63675. * @param contours Path of the polygon
  63676. * @param scene scene to add to when creating the mesh
  63677. * @param earcutInjection can be used to inject your own earcut reference
  63678. */
  63679. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63680. /**
  63681. * Adds a whole within the polygon
  63682. * @param hole Array of points defining the hole
  63683. * @returns this
  63684. */
  63685. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63686. /**
  63687. * Creates the polygon
  63688. * @param updatable If the mesh should be updatable
  63689. * @param depth The depth of the mesh created
  63690. * @returns the created mesh
  63691. */
  63692. build(updatable?: boolean, depth?: number): Mesh;
  63693. /**
  63694. * Creates the polygon
  63695. * @param depth The depth of the mesh created
  63696. * @returns the created VertexData
  63697. */
  63698. buildVertexData(depth?: number): VertexData;
  63699. /**
  63700. * Adds a side to the polygon
  63701. * @param positions points that make the polygon
  63702. * @param normals normals of the polygon
  63703. * @param uvs uvs of the polygon
  63704. * @param indices indices of the polygon
  63705. * @param bounds bounds of the polygon
  63706. * @param points points of the polygon
  63707. * @param depth depth of the polygon
  63708. * @param flip flip of the polygon
  63709. */
  63710. private addSide;
  63711. }
  63712. }
  63713. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63714. import { Scene } from "babylonjs/scene";
  63715. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63716. import { Color4 } from "babylonjs/Maths/math.color";
  63717. import { Mesh } from "babylonjs/Meshes/mesh";
  63718. import { Nullable } from "babylonjs/types";
  63719. /**
  63720. * Class containing static functions to help procedurally build meshes
  63721. */
  63722. export class PolygonBuilder {
  63723. /**
  63724. * Creates a polygon mesh
  63725. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63726. * * 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
  63727. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63729. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63730. * * Remember you can only change the shape positions, not their number when updating a polygon
  63731. * @param name defines the name of the mesh
  63732. * @param options defines the options used to create the mesh
  63733. * @param scene defines the hosting scene
  63734. * @param earcutInjection can be used to inject your own earcut reference
  63735. * @returns the polygon mesh
  63736. */
  63737. static CreatePolygon(name: string, options: {
  63738. shape: Vector3[];
  63739. holes?: Vector3[][];
  63740. depth?: number;
  63741. faceUV?: Vector4[];
  63742. faceColors?: Color4[];
  63743. updatable?: boolean;
  63744. sideOrientation?: number;
  63745. frontUVs?: Vector4;
  63746. backUVs?: Vector4;
  63747. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63748. /**
  63749. * Creates an extruded polygon mesh, with depth in the Y direction.
  63750. * * 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)
  63751. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63752. * @param name defines the name of the mesh
  63753. * @param options defines the options used to create the mesh
  63754. * @param scene defines the hosting scene
  63755. * @param earcutInjection can be used to inject your own earcut reference
  63756. * @returns the polygon mesh
  63757. */
  63758. static ExtrudePolygon(name: string, options: {
  63759. shape: Vector3[];
  63760. holes?: Vector3[][];
  63761. depth?: number;
  63762. faceUV?: Vector4[];
  63763. faceColors?: Color4[];
  63764. updatable?: boolean;
  63765. sideOrientation?: number;
  63766. frontUVs?: Vector4;
  63767. backUVs?: Vector4;
  63768. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63769. }
  63770. }
  63771. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  63772. import { Scene } from "babylonjs/scene";
  63773. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63774. import { Mesh } from "babylonjs/Meshes/mesh";
  63775. import { Nullable } from "babylonjs/types";
  63776. /**
  63777. * Class containing static functions to help procedurally build meshes
  63778. */
  63779. export class LatheBuilder {
  63780. /**
  63781. * Creates lathe mesh.
  63782. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63783. * * 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
  63784. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63785. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63786. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63787. * * 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
  63788. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63789. * * 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
  63790. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63791. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63792. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63794. * @param name defines the name of the mesh
  63795. * @param options defines the options used to create the mesh
  63796. * @param scene defines the hosting scene
  63797. * @returns the lathe mesh
  63798. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63799. */
  63800. static CreateLathe(name: string, options: {
  63801. shape: Vector3[];
  63802. radius?: number;
  63803. tessellation?: number;
  63804. clip?: number;
  63805. arc?: number;
  63806. closed?: boolean;
  63807. updatable?: boolean;
  63808. sideOrientation?: number;
  63809. frontUVs?: Vector4;
  63810. backUVs?: Vector4;
  63811. cap?: number;
  63812. invertUV?: boolean;
  63813. }, scene?: Nullable<Scene>): Mesh;
  63814. }
  63815. }
  63816. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  63817. import { Nullable } from "babylonjs/types";
  63818. import { Scene } from "babylonjs/scene";
  63819. import { Vector4 } from "babylonjs/Maths/math.vector";
  63820. import { Mesh } from "babylonjs/Meshes/mesh";
  63821. /**
  63822. * Class containing static functions to help procedurally build meshes
  63823. */
  63824. export class TiledPlaneBuilder {
  63825. /**
  63826. * Creates a tiled plane mesh
  63827. * * The parameter `pattern` will, depending on value, do nothing or
  63828. * * * flip (reflect about central vertical) alternate tiles across and up
  63829. * * * flip every tile on alternate rows
  63830. * * * rotate (180 degs) alternate tiles across and up
  63831. * * * rotate every tile on alternate rows
  63832. * * * flip and rotate alternate tiles across and up
  63833. * * * flip and rotate every tile on alternate rows
  63834. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63835. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63836. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63837. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63838. * * 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)
  63839. * * 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)
  63840. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63841. * @param name defines the name of the mesh
  63842. * @param options defines the options used to create the mesh
  63843. * @param scene defines the hosting scene
  63844. * @returns the box mesh
  63845. */
  63846. static CreateTiledPlane(name: string, options: {
  63847. pattern?: number;
  63848. tileSize?: number;
  63849. tileWidth?: number;
  63850. tileHeight?: number;
  63851. size?: number;
  63852. width?: number;
  63853. height?: number;
  63854. alignHorizontal?: number;
  63855. alignVertical?: number;
  63856. sideOrientation?: number;
  63857. frontUVs?: Vector4;
  63858. backUVs?: Vector4;
  63859. updatable?: boolean;
  63860. }, scene?: Nullable<Scene>): Mesh;
  63861. }
  63862. }
  63863. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  63864. import { Nullable } from "babylonjs/types";
  63865. import { Scene } from "babylonjs/scene";
  63866. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63867. import { Mesh } from "babylonjs/Meshes/mesh";
  63868. /**
  63869. * Class containing static functions to help procedurally build meshes
  63870. */
  63871. export class TubeBuilder {
  63872. /**
  63873. * Creates a tube mesh.
  63874. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63875. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63876. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63877. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63878. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63879. * * 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)
  63880. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63881. * * 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
  63882. * * 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
  63883. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63884. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63885. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63887. * @param name defines the name of the mesh
  63888. * @param options defines the options used to create the mesh
  63889. * @param scene defines the hosting scene
  63890. * @returns the tube mesh
  63891. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63892. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63893. */
  63894. static CreateTube(name: string, options: {
  63895. path: Vector3[];
  63896. radius?: number;
  63897. tessellation?: number;
  63898. radiusFunction?: {
  63899. (i: number, distance: number): number;
  63900. };
  63901. cap?: number;
  63902. arc?: number;
  63903. updatable?: boolean;
  63904. sideOrientation?: number;
  63905. frontUVs?: Vector4;
  63906. backUVs?: Vector4;
  63907. instance?: Mesh;
  63908. invertUV?: boolean;
  63909. }, scene?: Nullable<Scene>): Mesh;
  63910. }
  63911. }
  63912. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  63913. import { Scene } from "babylonjs/scene";
  63914. import { Vector4 } from "babylonjs/Maths/math.vector";
  63915. import { Mesh } from "babylonjs/Meshes/mesh";
  63916. import { Nullable } from "babylonjs/types";
  63917. /**
  63918. * Class containing static functions to help procedurally build meshes
  63919. */
  63920. export class IcoSphereBuilder {
  63921. /**
  63922. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  63923. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  63924. * * 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`)
  63925. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  63926. * * 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
  63927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63928. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63930. * @param name defines the name of the mesh
  63931. * @param options defines the options used to create the mesh
  63932. * @param scene defines the hosting scene
  63933. * @returns the icosahedron mesh
  63934. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  63935. */
  63936. static CreateIcoSphere(name: string, options: {
  63937. radius?: number;
  63938. radiusX?: number;
  63939. radiusY?: number;
  63940. radiusZ?: number;
  63941. flat?: boolean;
  63942. subdivisions?: number;
  63943. sideOrientation?: number;
  63944. frontUVs?: Vector4;
  63945. backUVs?: Vector4;
  63946. updatable?: boolean;
  63947. }, scene?: Nullable<Scene>): Mesh;
  63948. }
  63949. }
  63950. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  63951. import { Vector3 } from "babylonjs/Maths/math.vector";
  63952. import { Mesh } from "babylonjs/Meshes/mesh";
  63953. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63954. /**
  63955. * Class containing static functions to help procedurally build meshes
  63956. */
  63957. export class DecalBuilder {
  63958. /**
  63959. * Creates a decal mesh.
  63960. * 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
  63961. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  63962. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  63963. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  63964. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  63965. * @param name defines the name of the mesh
  63966. * @param sourceMesh defines the mesh where the decal must be applied
  63967. * @param options defines the options used to create the mesh
  63968. * @param scene defines the hosting scene
  63969. * @returns the decal mesh
  63970. * @see https://doc.babylonjs.com/how_to/decals
  63971. */
  63972. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  63973. position?: Vector3;
  63974. normal?: Vector3;
  63975. size?: Vector3;
  63976. angle?: number;
  63977. }): Mesh;
  63978. }
  63979. }
  63980. declare module "babylonjs/Meshes/meshBuilder" {
  63981. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  63982. import { Nullable } from "babylonjs/types";
  63983. import { Scene } from "babylonjs/scene";
  63984. import { Mesh } from "babylonjs/Meshes/mesh";
  63985. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  63986. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  63987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63988. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  63989. import { Plane } from "babylonjs/Maths/math.plane";
  63990. /**
  63991. * Class containing static functions to help procedurally build meshes
  63992. */
  63993. export class MeshBuilder {
  63994. /**
  63995. * Creates a box mesh
  63996. * * The parameter `size` sets the size (float) of each box side (default 1)
  63997. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  63998. * * 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)
  63999. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64001. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64003. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64004. * @param name defines the name of the mesh
  64005. * @param options defines the options used to create the mesh
  64006. * @param scene defines the hosting scene
  64007. * @returns the box mesh
  64008. */
  64009. static CreateBox(name: string, options: {
  64010. size?: number;
  64011. width?: number;
  64012. height?: number;
  64013. depth?: number;
  64014. faceUV?: Vector4[];
  64015. faceColors?: Color4[];
  64016. sideOrientation?: number;
  64017. frontUVs?: Vector4;
  64018. backUVs?: Vector4;
  64019. updatable?: boolean;
  64020. }, scene?: Nullable<Scene>): Mesh;
  64021. /**
  64022. * Creates a tiled box mesh
  64023. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64024. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64025. * @param name defines the name of the mesh
  64026. * @param options defines the options used to create the mesh
  64027. * @param scene defines the hosting scene
  64028. * @returns the tiled box mesh
  64029. */
  64030. static CreateTiledBox(name: string, options: {
  64031. pattern?: number;
  64032. size?: number;
  64033. width?: number;
  64034. height?: number;
  64035. depth: number;
  64036. tileSize?: number;
  64037. tileWidth?: number;
  64038. tileHeight?: number;
  64039. faceUV?: Vector4[];
  64040. faceColors?: Color4[];
  64041. alignHorizontal?: number;
  64042. alignVertical?: number;
  64043. sideOrientation?: number;
  64044. updatable?: boolean;
  64045. }, scene?: Nullable<Scene>): Mesh;
  64046. /**
  64047. * Creates a sphere mesh
  64048. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64049. * * 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`)
  64050. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64051. * * 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
  64052. * * 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)
  64053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64054. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64056. * @param name defines the name of the mesh
  64057. * @param options defines the options used to create the mesh
  64058. * @param scene defines the hosting scene
  64059. * @returns the sphere mesh
  64060. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64061. */
  64062. static CreateSphere(name: string, options: {
  64063. segments?: number;
  64064. diameter?: number;
  64065. diameterX?: number;
  64066. diameterY?: number;
  64067. diameterZ?: number;
  64068. arc?: number;
  64069. slice?: number;
  64070. sideOrientation?: number;
  64071. frontUVs?: Vector4;
  64072. backUVs?: Vector4;
  64073. updatable?: boolean;
  64074. }, scene?: Nullable<Scene>): Mesh;
  64075. /**
  64076. * Creates a plane polygonal mesh. By default, this is a disc
  64077. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64078. * * 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
  64079. * * 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
  64080. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64081. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64082. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64083. * @param name defines the name of the mesh
  64084. * @param options defines the options used to create the mesh
  64085. * @param scene defines the hosting scene
  64086. * @returns the plane polygonal mesh
  64087. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64088. */
  64089. static CreateDisc(name: string, options: {
  64090. radius?: number;
  64091. tessellation?: number;
  64092. arc?: number;
  64093. updatable?: boolean;
  64094. sideOrientation?: number;
  64095. frontUVs?: Vector4;
  64096. backUVs?: Vector4;
  64097. }, scene?: Nullable<Scene>): Mesh;
  64098. /**
  64099. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64100. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64101. * * 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`)
  64102. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64103. * * 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
  64104. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64105. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64106. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64107. * @param name defines the name of the mesh
  64108. * @param options defines the options used to create the mesh
  64109. * @param scene defines the hosting scene
  64110. * @returns the icosahedron mesh
  64111. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64112. */
  64113. static CreateIcoSphere(name: string, options: {
  64114. radius?: number;
  64115. radiusX?: number;
  64116. radiusY?: number;
  64117. radiusZ?: number;
  64118. flat?: boolean;
  64119. subdivisions?: number;
  64120. sideOrientation?: number;
  64121. frontUVs?: Vector4;
  64122. backUVs?: Vector4;
  64123. updatable?: boolean;
  64124. }, scene?: Nullable<Scene>): Mesh;
  64125. /**
  64126. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64127. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64128. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64129. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64130. * * 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
  64131. * * 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
  64132. * * 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
  64133. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64134. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64135. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64136. * * 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
  64137. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64138. * * 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
  64139. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64141. * @param name defines the name of the mesh
  64142. * @param options defines the options used to create the mesh
  64143. * @param scene defines the hosting scene
  64144. * @returns the ribbon mesh
  64145. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64146. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64147. */
  64148. static CreateRibbon(name: string, options: {
  64149. pathArray: Vector3[][];
  64150. closeArray?: boolean;
  64151. closePath?: boolean;
  64152. offset?: number;
  64153. updatable?: boolean;
  64154. sideOrientation?: number;
  64155. frontUVs?: Vector4;
  64156. backUVs?: Vector4;
  64157. instance?: Mesh;
  64158. invertUV?: boolean;
  64159. uvs?: Vector2[];
  64160. colors?: Color4[];
  64161. }, scene?: Nullable<Scene>): Mesh;
  64162. /**
  64163. * Creates a cylinder or a cone mesh
  64164. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64165. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64166. * * 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.
  64167. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64168. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64169. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64170. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64171. * * 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).
  64172. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64173. * * 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).
  64174. * * 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
  64175. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64176. * * 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
  64177. * * 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.
  64178. * * If `enclose` is false, a ring surface is one element.
  64179. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64180. * * 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
  64181. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64182. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64184. * @param name defines the name of the mesh
  64185. * @param options defines the options used to create the mesh
  64186. * @param scene defines the hosting scene
  64187. * @returns the cylinder mesh
  64188. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64189. */
  64190. static CreateCylinder(name: string, options: {
  64191. height?: number;
  64192. diameterTop?: number;
  64193. diameterBottom?: number;
  64194. diameter?: number;
  64195. tessellation?: number;
  64196. subdivisions?: number;
  64197. arc?: number;
  64198. faceColors?: Color4[];
  64199. faceUV?: Vector4[];
  64200. updatable?: boolean;
  64201. hasRings?: boolean;
  64202. enclose?: boolean;
  64203. cap?: number;
  64204. sideOrientation?: number;
  64205. frontUVs?: Vector4;
  64206. backUVs?: Vector4;
  64207. }, scene?: Nullable<Scene>): Mesh;
  64208. /**
  64209. * Creates a torus mesh
  64210. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64211. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64212. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64213. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64214. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64215. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64216. * @param name defines the name of the mesh
  64217. * @param options defines the options used to create the mesh
  64218. * @param scene defines the hosting scene
  64219. * @returns the torus mesh
  64220. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64221. */
  64222. static CreateTorus(name: string, options: {
  64223. diameter?: number;
  64224. thickness?: number;
  64225. tessellation?: number;
  64226. updatable?: boolean;
  64227. sideOrientation?: number;
  64228. frontUVs?: Vector4;
  64229. backUVs?: Vector4;
  64230. }, scene?: Nullable<Scene>): Mesh;
  64231. /**
  64232. * Creates a torus knot mesh
  64233. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64234. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64235. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64236. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64237. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64238. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64240. * @param name defines the name of the mesh
  64241. * @param options defines the options used to create the mesh
  64242. * @param scene defines the hosting scene
  64243. * @returns the torus knot mesh
  64244. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64245. */
  64246. static CreateTorusKnot(name: string, options: {
  64247. radius?: number;
  64248. tube?: number;
  64249. radialSegments?: number;
  64250. tubularSegments?: number;
  64251. p?: number;
  64252. q?: number;
  64253. updatable?: boolean;
  64254. sideOrientation?: number;
  64255. frontUVs?: Vector4;
  64256. backUVs?: Vector4;
  64257. }, scene?: Nullable<Scene>): Mesh;
  64258. /**
  64259. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64260. * * 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
  64261. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64262. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64263. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64264. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64265. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64266. * * 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
  64267. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64268. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64269. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64270. * @param name defines the name of the new line system
  64271. * @param options defines the options used to create the line system
  64272. * @param scene defines the hosting scene
  64273. * @returns a new line system mesh
  64274. */
  64275. static CreateLineSystem(name: string, options: {
  64276. lines: Vector3[][];
  64277. updatable?: boolean;
  64278. instance?: Nullable<LinesMesh>;
  64279. colors?: Nullable<Color4[][]>;
  64280. useVertexAlpha?: boolean;
  64281. }, scene: Nullable<Scene>): LinesMesh;
  64282. /**
  64283. * Creates a line mesh
  64284. * 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
  64285. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64286. * * The parameter `points` is an array successive Vector3
  64287. * * 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
  64288. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64289. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64290. * * When updating an instance, remember that only point positions can change, not the number of points
  64291. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64292. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64293. * @param name defines the name of the new line system
  64294. * @param options defines the options used to create the line system
  64295. * @param scene defines the hosting scene
  64296. * @returns a new line mesh
  64297. */
  64298. static CreateLines(name: string, options: {
  64299. points: Vector3[];
  64300. updatable?: boolean;
  64301. instance?: Nullable<LinesMesh>;
  64302. colors?: Color4[];
  64303. useVertexAlpha?: boolean;
  64304. }, scene?: Nullable<Scene>): LinesMesh;
  64305. /**
  64306. * Creates a dashed line mesh
  64307. * * 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
  64308. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64309. * * The parameter `points` is an array successive Vector3
  64310. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64311. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64312. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  64313. * * 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
  64314. * * When updating an instance, remember that only point positions can change, not the number of points
  64315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64316. * @param name defines the name of the mesh
  64317. * @param options defines the options used to create the mesh
  64318. * @param scene defines the hosting scene
  64319. * @returns the dashed line mesh
  64320. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64321. */
  64322. static CreateDashedLines(name: string, options: {
  64323. points: Vector3[];
  64324. dashSize?: number;
  64325. gapSize?: number;
  64326. dashNb?: number;
  64327. updatable?: boolean;
  64328. instance?: LinesMesh;
  64329. }, scene?: Nullable<Scene>): LinesMesh;
  64330. /**
  64331. * 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.
  64332. * * 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.
  64333. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64334. * * 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.
  64335. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64336. * * 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
  64337. * * 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
  64338. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64339. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64340. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64341. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64343. * @param name defines the name of the mesh
  64344. * @param options defines the options used to create the mesh
  64345. * @param scene defines the hosting scene
  64346. * @returns the extruded shape mesh
  64347. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64348. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64349. */
  64350. static ExtrudeShape(name: string, options: {
  64351. shape: Vector3[];
  64352. path: Vector3[];
  64353. scale?: number;
  64354. rotation?: number;
  64355. cap?: number;
  64356. updatable?: boolean;
  64357. sideOrientation?: number;
  64358. frontUVs?: Vector4;
  64359. backUVs?: Vector4;
  64360. instance?: Mesh;
  64361. invertUV?: boolean;
  64362. }, scene?: Nullable<Scene>): Mesh;
  64363. /**
  64364. * Creates an custom extruded shape mesh.
  64365. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64366. * * 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.
  64367. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64368. * * 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
  64369. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64370. * * 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
  64371. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64372. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64373. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64374. * * The parameter `cap` sets the way the extruded shape is capped. Possible values : BABYLON.Mesh.NO_CAP (default), BABYLON.Mesh.CAP_START, BABYLON.Mesh.CAP_END, BABYLON.Mesh.CAP_ALL
  64375. * * The optional parameter `instance` is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters : https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape
  64376. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64377. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64378. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64379. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64380. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64381. * @param name defines the name of the mesh
  64382. * @param options defines the options used to create the mesh
  64383. * @param scene defines the hosting scene
  64384. * @returns the custom extruded shape mesh
  64385. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64386. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64387. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64388. */
  64389. static ExtrudeShapeCustom(name: string, options: {
  64390. shape: Vector3[];
  64391. path: Vector3[];
  64392. scaleFunction?: any;
  64393. rotationFunction?: any;
  64394. ribbonCloseArray?: boolean;
  64395. ribbonClosePath?: boolean;
  64396. cap?: number;
  64397. updatable?: boolean;
  64398. sideOrientation?: number;
  64399. frontUVs?: Vector4;
  64400. backUVs?: Vector4;
  64401. instance?: Mesh;
  64402. invertUV?: boolean;
  64403. }, scene?: Nullable<Scene>): Mesh;
  64404. /**
  64405. * Creates lathe mesh.
  64406. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64407. * * 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
  64408. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64409. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64410. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64411. * * 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
  64412. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64413. * * 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
  64414. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64415. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64416. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64417. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64418. * @param name defines the name of the mesh
  64419. * @param options defines the options used to create the mesh
  64420. * @param scene defines the hosting scene
  64421. * @returns the lathe mesh
  64422. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64423. */
  64424. static CreateLathe(name: string, options: {
  64425. shape: Vector3[];
  64426. radius?: number;
  64427. tessellation?: number;
  64428. clip?: number;
  64429. arc?: number;
  64430. closed?: boolean;
  64431. updatable?: boolean;
  64432. sideOrientation?: number;
  64433. frontUVs?: Vector4;
  64434. backUVs?: Vector4;
  64435. cap?: number;
  64436. invertUV?: boolean;
  64437. }, scene?: Nullable<Scene>): Mesh;
  64438. /**
  64439. * Creates a tiled plane mesh
  64440. * * You can set a limited pattern arrangement with the tiles
  64441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64442. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64444. * @param name defines the name of the mesh
  64445. * @param options defines the options used to create the mesh
  64446. * @param scene defines the hosting scene
  64447. * @returns the plane mesh
  64448. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64449. */
  64450. static CreateTiledPlane(name: string, options: {
  64451. pattern?: number;
  64452. tileSize?: number;
  64453. tileWidth?: number;
  64454. tileHeight?: number;
  64455. size?: number;
  64456. width?: number;
  64457. height?: number;
  64458. alignHorizontal?: number;
  64459. alignVertical?: number;
  64460. sideOrientation?: number;
  64461. frontUVs?: Vector4;
  64462. backUVs?: Vector4;
  64463. updatable?: boolean;
  64464. }, scene?: Nullable<Scene>): Mesh;
  64465. /**
  64466. * Creates a plane mesh
  64467. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64468. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64469. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64470. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64471. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64472. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64473. * @param name defines the name of the mesh
  64474. * @param options defines the options used to create the mesh
  64475. * @param scene defines the hosting scene
  64476. * @returns the plane mesh
  64477. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64478. */
  64479. static CreatePlane(name: string, options: {
  64480. size?: number;
  64481. width?: number;
  64482. height?: number;
  64483. sideOrientation?: number;
  64484. frontUVs?: Vector4;
  64485. backUVs?: Vector4;
  64486. updatable?: boolean;
  64487. sourcePlane?: Plane;
  64488. }, scene?: Nullable<Scene>): Mesh;
  64489. /**
  64490. * Creates a ground mesh
  64491. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64492. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64494. * @param name defines the name of the mesh
  64495. * @param options defines the options used to create the mesh
  64496. * @param scene defines the hosting scene
  64497. * @returns the ground mesh
  64498. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64499. */
  64500. static CreateGround(name: string, options: {
  64501. width?: number;
  64502. height?: number;
  64503. subdivisions?: number;
  64504. subdivisionsX?: number;
  64505. subdivisionsY?: number;
  64506. updatable?: boolean;
  64507. }, scene?: Nullable<Scene>): Mesh;
  64508. /**
  64509. * Creates a tiled ground mesh
  64510. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64511. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64512. * * 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
  64513. * * 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
  64514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64515. * @param name defines the name of the mesh
  64516. * @param options defines the options used to create the mesh
  64517. * @param scene defines the hosting scene
  64518. * @returns the tiled ground mesh
  64519. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64520. */
  64521. static CreateTiledGround(name: string, options: {
  64522. xmin: number;
  64523. zmin: number;
  64524. xmax: number;
  64525. zmax: number;
  64526. subdivisions?: {
  64527. w: number;
  64528. h: number;
  64529. };
  64530. precision?: {
  64531. w: number;
  64532. h: number;
  64533. };
  64534. updatable?: boolean;
  64535. }, scene?: Nullable<Scene>): Mesh;
  64536. /**
  64537. * Creates a ground mesh from a height map
  64538. * * The parameter `url` sets the URL of the height map image resource.
  64539. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64540. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64541. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64542. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64543. * * 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.
  64544. * * 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).
  64545. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64547. * @param name defines the name of the mesh
  64548. * @param url defines the url to the height map
  64549. * @param options defines the options used to create the mesh
  64550. * @param scene defines the hosting scene
  64551. * @returns the ground mesh
  64552. * @see https://doc.babylonjs.com/babylon101/height_map
  64553. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64554. */
  64555. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64556. width?: number;
  64557. height?: number;
  64558. subdivisions?: number;
  64559. minHeight?: number;
  64560. maxHeight?: number;
  64561. colorFilter?: Color3;
  64562. alphaFilter?: number;
  64563. updatable?: boolean;
  64564. onReady?: (mesh: GroundMesh) => void;
  64565. }, scene?: Nullable<Scene>): GroundMesh;
  64566. /**
  64567. * Creates a polygon mesh
  64568. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64569. * * 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
  64570. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64572. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64573. * * Remember you can only change the shape positions, not their number when updating a polygon
  64574. * @param name defines the name of the mesh
  64575. * @param options defines the options used to create the mesh
  64576. * @param scene defines the hosting scene
  64577. * @param earcutInjection can be used to inject your own earcut reference
  64578. * @returns the polygon mesh
  64579. */
  64580. static CreatePolygon(name: string, options: {
  64581. shape: Vector3[];
  64582. holes?: Vector3[][];
  64583. depth?: number;
  64584. faceUV?: Vector4[];
  64585. faceColors?: Color4[];
  64586. updatable?: boolean;
  64587. sideOrientation?: number;
  64588. frontUVs?: Vector4;
  64589. backUVs?: Vector4;
  64590. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64591. /**
  64592. * Creates an extruded polygon mesh, with depth in the Y direction.
  64593. * * 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)
  64594. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64595. * @param name defines the name of the mesh
  64596. * @param options defines the options used to create the mesh
  64597. * @param scene defines the hosting scene
  64598. * @param earcutInjection can be used to inject your own earcut reference
  64599. * @returns the polygon mesh
  64600. */
  64601. static ExtrudePolygon(name: string, options: {
  64602. shape: Vector3[];
  64603. holes?: Vector3[][];
  64604. depth?: number;
  64605. faceUV?: Vector4[];
  64606. faceColors?: Color4[];
  64607. updatable?: boolean;
  64608. sideOrientation?: number;
  64609. frontUVs?: Vector4;
  64610. backUVs?: Vector4;
  64611. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64612. /**
  64613. * Creates a tube mesh.
  64614. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64615. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64616. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64617. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64618. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64619. * * 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)
  64620. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64621. * * 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
  64622. * * 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
  64623. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64624. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64625. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64627. * @param name defines the name of the mesh
  64628. * @param options defines the options used to create the mesh
  64629. * @param scene defines the hosting scene
  64630. * @returns the tube mesh
  64631. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64632. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64633. */
  64634. static CreateTube(name: string, options: {
  64635. path: Vector3[];
  64636. radius?: number;
  64637. tessellation?: number;
  64638. radiusFunction?: {
  64639. (i: number, distance: number): number;
  64640. };
  64641. cap?: number;
  64642. arc?: number;
  64643. updatable?: boolean;
  64644. sideOrientation?: number;
  64645. frontUVs?: Vector4;
  64646. backUVs?: Vector4;
  64647. instance?: Mesh;
  64648. invertUV?: boolean;
  64649. }, scene?: Nullable<Scene>): Mesh;
  64650. /**
  64651. * Creates a polyhedron mesh
  64652. * * 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
  64653. * * The parameter `size` (positive float, default 1) sets the polygon size
  64654. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64655. * * 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`
  64656. * * 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
  64657. * * 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)`)
  64658. * * 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
  64659. * * 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
  64660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64661. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64663. * @param name defines the name of the mesh
  64664. * @param options defines the options used to create the mesh
  64665. * @param scene defines the hosting scene
  64666. * @returns the polyhedron mesh
  64667. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64668. */
  64669. static CreatePolyhedron(name: string, options: {
  64670. type?: number;
  64671. size?: number;
  64672. sizeX?: number;
  64673. sizeY?: number;
  64674. sizeZ?: number;
  64675. custom?: any;
  64676. faceUV?: Vector4[];
  64677. faceColors?: Color4[];
  64678. flat?: boolean;
  64679. updatable?: boolean;
  64680. sideOrientation?: number;
  64681. frontUVs?: Vector4;
  64682. backUVs?: Vector4;
  64683. }, scene?: Nullable<Scene>): Mesh;
  64684. /**
  64685. * Creates a decal mesh.
  64686. * 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
  64687. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64688. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64689. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64690. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64691. * @param name defines the name of the mesh
  64692. * @param sourceMesh defines the mesh where the decal must be applied
  64693. * @param options defines the options used to create the mesh
  64694. * @param scene defines the hosting scene
  64695. * @returns the decal mesh
  64696. * @see https://doc.babylonjs.com/how_to/decals
  64697. */
  64698. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64699. position?: Vector3;
  64700. normal?: Vector3;
  64701. size?: Vector3;
  64702. angle?: number;
  64703. }): Mesh;
  64704. }
  64705. }
  64706. declare module "babylonjs/Meshes/meshSimplification" {
  64707. import { Mesh } from "babylonjs/Meshes/mesh";
  64708. /**
  64709. * A simplifier interface for future simplification implementations
  64710. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64711. */
  64712. export interface ISimplifier {
  64713. /**
  64714. * Simplification of a given mesh according to the given settings.
  64715. * Since this requires computation, it is assumed that the function runs async.
  64716. * @param settings The settings of the simplification, including quality and distance
  64717. * @param successCallback A callback that will be called after the mesh was simplified.
  64718. * @param errorCallback in case of an error, this callback will be called. optional.
  64719. */
  64720. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64721. }
  64722. /**
  64723. * Expected simplification settings.
  64724. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64725. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64726. */
  64727. export interface ISimplificationSettings {
  64728. /**
  64729. * Gets or sets the expected quality
  64730. */
  64731. quality: number;
  64732. /**
  64733. * Gets or sets the distance when this optimized version should be used
  64734. */
  64735. distance: number;
  64736. /**
  64737. * Gets an already optimized mesh
  64738. */
  64739. optimizeMesh?: boolean;
  64740. }
  64741. /**
  64742. * Class used to specify simplification options
  64743. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64744. */
  64745. export class SimplificationSettings implements ISimplificationSettings {
  64746. /** expected quality */
  64747. quality: number;
  64748. /** distance when this optimized version should be used */
  64749. distance: number;
  64750. /** already optimized mesh */
  64751. optimizeMesh?: boolean | undefined;
  64752. /**
  64753. * Creates a SimplificationSettings
  64754. * @param quality expected quality
  64755. * @param distance distance when this optimized version should be used
  64756. * @param optimizeMesh already optimized mesh
  64757. */
  64758. constructor(
  64759. /** expected quality */
  64760. quality: number,
  64761. /** distance when this optimized version should be used */
  64762. distance: number,
  64763. /** already optimized mesh */
  64764. optimizeMesh?: boolean | undefined);
  64765. }
  64766. /**
  64767. * Interface used to define a simplification task
  64768. */
  64769. export interface ISimplificationTask {
  64770. /**
  64771. * Array of settings
  64772. */
  64773. settings: Array<ISimplificationSettings>;
  64774. /**
  64775. * Simplification type
  64776. */
  64777. simplificationType: SimplificationType;
  64778. /**
  64779. * Mesh to simplify
  64780. */
  64781. mesh: Mesh;
  64782. /**
  64783. * Callback called on success
  64784. */
  64785. successCallback?: () => void;
  64786. /**
  64787. * Defines if parallel processing can be used
  64788. */
  64789. parallelProcessing: boolean;
  64790. }
  64791. /**
  64792. * Queue used to order the simplification tasks
  64793. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64794. */
  64795. export class SimplificationQueue {
  64796. private _simplificationArray;
  64797. /**
  64798. * Gets a boolean indicating that the process is still running
  64799. */
  64800. running: boolean;
  64801. /**
  64802. * Creates a new queue
  64803. */
  64804. constructor();
  64805. /**
  64806. * Adds a new simplification task
  64807. * @param task defines a task to add
  64808. */
  64809. addTask(task: ISimplificationTask): void;
  64810. /**
  64811. * Execute next task
  64812. */
  64813. executeNext(): void;
  64814. /**
  64815. * Execute a simplification task
  64816. * @param task defines the task to run
  64817. */
  64818. runSimplification(task: ISimplificationTask): void;
  64819. private getSimplifier;
  64820. }
  64821. /**
  64822. * The implemented types of simplification
  64823. * At the moment only Quadratic Error Decimation is implemented
  64824. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64825. */
  64826. export enum SimplificationType {
  64827. /** Quadratic error decimation */
  64828. QUADRATIC = 0
  64829. }
  64830. }
  64831. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  64832. import { Scene } from "babylonjs/scene";
  64833. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  64834. import { ISceneComponent } from "babylonjs/sceneComponent";
  64835. module "babylonjs/scene" {
  64836. interface Scene {
  64837. /** @hidden (Backing field) */
  64838. _simplificationQueue: SimplificationQueue;
  64839. /**
  64840. * Gets or sets the simplification queue attached to the scene
  64841. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64842. */
  64843. simplificationQueue: SimplificationQueue;
  64844. }
  64845. }
  64846. module "babylonjs/Meshes/mesh" {
  64847. interface Mesh {
  64848. /**
  64849. * Simplify the mesh according to the given array of settings.
  64850. * Function will return immediately and will simplify async
  64851. * @param settings a collection of simplification settings
  64852. * @param parallelProcessing should all levels calculate parallel or one after the other
  64853. * @param simplificationType the type of simplification to run
  64854. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64855. * @returns the current mesh
  64856. */
  64857. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64858. }
  64859. }
  64860. /**
  64861. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64862. * created in a scene
  64863. */
  64864. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64865. /**
  64866. * The component name helpfull to identify the component in the list of scene components.
  64867. */
  64868. readonly name: string;
  64869. /**
  64870. * The scene the component belongs to.
  64871. */
  64872. scene: Scene;
  64873. /**
  64874. * Creates a new instance of the component for the given scene
  64875. * @param scene Defines the scene to register the component in
  64876. */
  64877. constructor(scene: Scene);
  64878. /**
  64879. * Registers the component in a given scene
  64880. */
  64881. register(): void;
  64882. /**
  64883. * Rebuilds the elements related to this component in case of
  64884. * context lost for instance.
  64885. */
  64886. rebuild(): void;
  64887. /**
  64888. * Disposes the component and the associated ressources
  64889. */
  64890. dispose(): void;
  64891. private _beforeCameraUpdate;
  64892. }
  64893. }
  64894. declare module "babylonjs/Meshes/Builders/index" {
  64895. export * from "babylonjs/Meshes/Builders/boxBuilder";
  64896. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  64897. export * from "babylonjs/Meshes/Builders/discBuilder";
  64898. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  64899. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  64900. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  64901. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  64902. export * from "babylonjs/Meshes/Builders/torusBuilder";
  64903. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  64904. export * from "babylonjs/Meshes/Builders/linesBuilder";
  64905. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  64906. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  64907. export * from "babylonjs/Meshes/Builders/latheBuilder";
  64908. export * from "babylonjs/Meshes/Builders/planeBuilder";
  64909. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  64910. export * from "babylonjs/Meshes/Builders/groundBuilder";
  64911. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  64912. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  64913. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  64914. export * from "babylonjs/Meshes/Builders/decalBuilder";
  64915. }
  64916. declare module "babylonjs/Meshes/index" {
  64917. export * from "babylonjs/Meshes/abstractMesh";
  64918. export * from "babylonjs/Meshes/buffer";
  64919. export * from "babylonjs/Meshes/Compression/index";
  64920. export * from "babylonjs/Meshes/csg";
  64921. export * from "babylonjs/Meshes/geometry";
  64922. export * from "babylonjs/Meshes/groundMesh";
  64923. export * from "babylonjs/Meshes/trailMesh";
  64924. export * from "babylonjs/Meshes/instancedMesh";
  64925. export * from "babylonjs/Meshes/linesMesh";
  64926. export * from "babylonjs/Meshes/mesh";
  64927. export * from "babylonjs/Meshes/mesh.vertexData";
  64928. export * from "babylonjs/Meshes/meshBuilder";
  64929. export * from "babylonjs/Meshes/meshSimplification";
  64930. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  64931. export * from "babylonjs/Meshes/polygonMesh";
  64932. export * from "babylonjs/Meshes/subMesh";
  64933. export * from "babylonjs/Meshes/meshLODLevel";
  64934. export * from "babylonjs/Meshes/transformNode";
  64935. export * from "babylonjs/Meshes/Builders/index";
  64936. export * from "babylonjs/Meshes/dataBuffer";
  64937. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  64938. }
  64939. declare module "babylonjs/Morph/index" {
  64940. export * from "babylonjs/Morph/morphTarget";
  64941. export * from "babylonjs/Morph/morphTargetManager";
  64942. }
  64943. declare module "babylonjs/Navigation/INavigationEngine" {
  64944. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64945. import { Vector3 } from "babylonjs/Maths/math";
  64946. import { Mesh } from "babylonjs/Meshes/mesh";
  64947. import { Scene } from "babylonjs/scene";
  64948. /**
  64949. * Navigation plugin interface to add navigation constrained by a navigation mesh
  64950. */
  64951. export interface INavigationEnginePlugin {
  64952. /**
  64953. * plugin name
  64954. */
  64955. name: string;
  64956. /**
  64957. * Creates a navigation mesh
  64958. * @param meshes array of all the geometry used to compute the navigatio mesh
  64959. * @param parameters bunch of parameters used to filter geometry
  64960. */
  64961. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  64962. /**
  64963. * Create a navigation mesh debug mesh
  64964. * @param scene is where the mesh will be added
  64965. * @returns debug display mesh
  64966. */
  64967. createDebugNavMesh(scene: Scene): Mesh;
  64968. /**
  64969. * Get a navigation mesh constrained position, closest to the parameter position
  64970. * @param position world position
  64971. * @returns the closest point to position constrained by the navigation mesh
  64972. */
  64973. getClosestPoint(position: Vector3): Vector3;
  64974. /**
  64975. * Get a navigation mesh constrained position, within a particular radius
  64976. * @param position world position
  64977. * @param maxRadius the maximum distance to the constrained world position
  64978. * @returns the closest point to position constrained by the navigation mesh
  64979. */
  64980. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  64981. /**
  64982. * Compute the final position from a segment made of destination-position
  64983. * @param position world position
  64984. * @param destination world position
  64985. * @returns the resulting point along the navmesh
  64986. */
  64987. moveAlong(position: Vector3, destination: Vector3): Vector3;
  64988. /**
  64989. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  64990. * @param start world position
  64991. * @param end world position
  64992. * @returns array containing world position composing the path
  64993. */
  64994. computePath(start: Vector3, end: Vector3): Vector3[];
  64995. /**
  64996. * If this plugin is supported
  64997. * @returns true if plugin is supported
  64998. */
  64999. isSupported(): boolean;
  65000. /**
  65001. * Create a new Crowd so you can add agents
  65002. * @param maxAgents the maximum agent count in the crowd
  65003. * @param maxAgentRadius the maximum radius an agent can have
  65004. * @param scene to attach the crowd to
  65005. * @returns the crowd you can add agents to
  65006. */
  65007. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65008. /**
  65009. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65010. * The queries will try to find a solution within those bounds
  65011. * default is (1,1,1)
  65012. * @param extent x,y,z value that define the extent around the queries point of reference
  65013. */
  65014. setDefaultQueryExtent(extent: Vector3): void;
  65015. /**
  65016. * Get the Bounding box extent specified by setDefaultQueryExtent
  65017. * @returns the box extent values
  65018. */
  65019. getDefaultQueryExtent(): Vector3;
  65020. /**
  65021. * Release all resources
  65022. */
  65023. dispose(): void;
  65024. }
  65025. /**
  65026. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65027. */
  65028. export interface ICrowd {
  65029. /**
  65030. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65031. * You can attach anything to that node. The node position is updated in the scene update tick.
  65032. * @param pos world position that will be constrained by the navigation mesh
  65033. * @param parameters agent parameters
  65034. * @param transform hooked to the agent that will be update by the scene
  65035. * @returns agent index
  65036. */
  65037. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65038. /**
  65039. * Returns the agent position in world space
  65040. * @param index agent index returned by addAgent
  65041. * @returns world space position
  65042. */
  65043. getAgentPosition(index: number): Vector3;
  65044. /**
  65045. * Gets the agent velocity in world space
  65046. * @param index agent index returned by addAgent
  65047. * @returns world space velocity
  65048. */
  65049. getAgentVelocity(index: number): Vector3;
  65050. /**
  65051. * remove a particular agent previously created
  65052. * @param index agent index returned by addAgent
  65053. */
  65054. removeAgent(index: number): void;
  65055. /**
  65056. * get the list of all agents attached to this crowd
  65057. * @returns list of agent indices
  65058. */
  65059. getAgents(): number[];
  65060. /**
  65061. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65062. * @param deltaTime in seconds
  65063. */
  65064. update(deltaTime: number): void;
  65065. /**
  65066. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65067. * @param index agent index returned by addAgent
  65068. * @param destination targeted world position
  65069. */
  65070. agentGoto(index: number, destination: Vector3): void;
  65071. /**
  65072. * Teleport the agent to a new position
  65073. * @param index agent index returned by addAgent
  65074. * @param destination targeted world position
  65075. */
  65076. agentTeleport(index: number, destination: Vector3): void;
  65077. /**
  65078. * Update agent parameters
  65079. * @param index agent index returned by addAgent
  65080. * @param parameters agent parameters
  65081. */
  65082. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65083. /**
  65084. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65085. * The queries will try to find a solution within those bounds
  65086. * default is (1,1,1)
  65087. * @param extent x,y,z value that define the extent around the queries point of reference
  65088. */
  65089. setDefaultQueryExtent(extent: Vector3): void;
  65090. /**
  65091. * Get the Bounding box extent specified by setDefaultQueryExtent
  65092. * @returns the box extent values
  65093. */
  65094. getDefaultQueryExtent(): Vector3;
  65095. /**
  65096. * Release all resources
  65097. */
  65098. dispose(): void;
  65099. }
  65100. /**
  65101. * Configures an agent
  65102. */
  65103. export interface IAgentParameters {
  65104. /**
  65105. * Agent radius. [Limit: >= 0]
  65106. */
  65107. radius: number;
  65108. /**
  65109. * Agent height. [Limit: > 0]
  65110. */
  65111. height: number;
  65112. /**
  65113. * Maximum allowed acceleration. [Limit: >= 0]
  65114. */
  65115. maxAcceleration: number;
  65116. /**
  65117. * Maximum allowed speed. [Limit: >= 0]
  65118. */
  65119. maxSpeed: number;
  65120. /**
  65121. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65122. */
  65123. collisionQueryRange: number;
  65124. /**
  65125. * The path visibility optimization range. [Limit: > 0]
  65126. */
  65127. pathOptimizationRange: number;
  65128. /**
  65129. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65130. */
  65131. separationWeight: number;
  65132. }
  65133. /**
  65134. * Configures the navigation mesh creation
  65135. */
  65136. export interface INavMeshParameters {
  65137. /**
  65138. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65139. */
  65140. cs: number;
  65141. /**
  65142. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65143. */
  65144. ch: number;
  65145. /**
  65146. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65147. */
  65148. walkableSlopeAngle: number;
  65149. /**
  65150. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65151. * be considered walkable. [Limit: >= 3] [Units: vx]
  65152. */
  65153. walkableHeight: number;
  65154. /**
  65155. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65156. */
  65157. walkableClimb: number;
  65158. /**
  65159. * The distance to erode/shrink the walkable area of the heightfield away from
  65160. * obstructions. [Limit: >=0] [Units: vx]
  65161. */
  65162. walkableRadius: number;
  65163. /**
  65164. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65165. */
  65166. maxEdgeLen: number;
  65167. /**
  65168. * The maximum distance a simplfied contour's border edges should deviate
  65169. * the original raw contour. [Limit: >=0] [Units: vx]
  65170. */
  65171. maxSimplificationError: number;
  65172. /**
  65173. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65174. */
  65175. minRegionArea: number;
  65176. /**
  65177. * Any regions with a span count smaller than this value will, if possible,
  65178. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65179. */
  65180. mergeRegionArea: number;
  65181. /**
  65182. * The maximum number of vertices allowed for polygons generated during the
  65183. * contour to polygon conversion process. [Limit: >= 3]
  65184. */
  65185. maxVertsPerPoly: number;
  65186. /**
  65187. * Sets the sampling distance to use when generating the detail mesh.
  65188. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65189. */
  65190. detailSampleDist: number;
  65191. /**
  65192. * The maximum distance the detail mesh surface should deviate from heightfield
  65193. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65194. */
  65195. detailSampleMaxError: number;
  65196. }
  65197. }
  65198. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65199. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65200. import { Mesh } from "babylonjs/Meshes/mesh";
  65201. import { Scene } from "babylonjs/scene";
  65202. import { Vector3 } from "babylonjs/Maths/math";
  65203. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65204. /**
  65205. * RecastJS navigation plugin
  65206. */
  65207. export class RecastJSPlugin implements INavigationEnginePlugin {
  65208. /**
  65209. * Reference to the Recast library
  65210. */
  65211. bjsRECAST: any;
  65212. /**
  65213. * plugin name
  65214. */
  65215. name: string;
  65216. /**
  65217. * the first navmesh created. We might extend this to support multiple navmeshes
  65218. */
  65219. navMesh: any;
  65220. /**
  65221. * Initializes the recastJS plugin
  65222. * @param recastInjection can be used to inject your own recast reference
  65223. */
  65224. constructor(recastInjection?: any);
  65225. /**
  65226. * Creates a navigation mesh
  65227. * @param meshes array of all the geometry used to compute the navigatio mesh
  65228. * @param parameters bunch of parameters used to filter geometry
  65229. */
  65230. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65231. /**
  65232. * Create a navigation mesh debug mesh
  65233. * @param scene is where the mesh will be added
  65234. * @returns debug display mesh
  65235. */
  65236. createDebugNavMesh(scene: Scene): Mesh;
  65237. /**
  65238. * Get a navigation mesh constrained position, closest to the parameter position
  65239. * @param position world position
  65240. * @returns the closest point to position constrained by the navigation mesh
  65241. */
  65242. getClosestPoint(position: Vector3): Vector3;
  65243. /**
  65244. * Get a navigation mesh constrained position, within a particular radius
  65245. * @param position world position
  65246. * @param maxRadius the maximum distance to the constrained world position
  65247. * @returns the closest point to position constrained by the navigation mesh
  65248. */
  65249. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65250. /**
  65251. * Compute the final position from a segment made of destination-position
  65252. * @param position world position
  65253. * @param destination world position
  65254. * @returns the resulting point along the navmesh
  65255. */
  65256. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65257. /**
  65258. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65259. * @param start world position
  65260. * @param end world position
  65261. * @returns array containing world position composing the path
  65262. */
  65263. computePath(start: Vector3, end: Vector3): Vector3[];
  65264. /**
  65265. * Create a new Crowd so you can add agents
  65266. * @param maxAgents the maximum agent count in the crowd
  65267. * @param maxAgentRadius the maximum radius an agent can have
  65268. * @param scene to attach the crowd to
  65269. * @returns the crowd you can add agents to
  65270. */
  65271. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65272. /**
  65273. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65274. * The queries will try to find a solution within those bounds
  65275. * default is (1,1,1)
  65276. * @param extent x,y,z value that define the extent around the queries point of reference
  65277. */
  65278. setDefaultQueryExtent(extent: Vector3): void;
  65279. /**
  65280. * Get the Bounding box extent specified by setDefaultQueryExtent
  65281. * @returns the box extent values
  65282. */
  65283. getDefaultQueryExtent(): Vector3;
  65284. /**
  65285. * Disposes
  65286. */
  65287. dispose(): void;
  65288. /**
  65289. * If this plugin is supported
  65290. * @returns true if plugin is supported
  65291. */
  65292. isSupported(): boolean;
  65293. }
  65294. /**
  65295. * Recast detour crowd implementation
  65296. */
  65297. export class RecastJSCrowd implements ICrowd {
  65298. /**
  65299. * Recast/detour plugin
  65300. */
  65301. bjsRECASTPlugin: RecastJSPlugin;
  65302. /**
  65303. * Link to the detour crowd
  65304. */
  65305. recastCrowd: any;
  65306. /**
  65307. * One transform per agent
  65308. */
  65309. transforms: TransformNode[];
  65310. /**
  65311. * All agents created
  65312. */
  65313. agents: number[];
  65314. /**
  65315. * Link to the scene is kept to unregister the crowd from the scene
  65316. */
  65317. private _scene;
  65318. /**
  65319. * Observer for crowd updates
  65320. */
  65321. private _onBeforeAnimationsObserver;
  65322. /**
  65323. * Constructor
  65324. * @param plugin recastJS plugin
  65325. * @param maxAgents the maximum agent count in the crowd
  65326. * @param maxAgentRadius the maximum radius an agent can have
  65327. * @param scene to attach the crowd to
  65328. * @returns the crowd you can add agents to
  65329. */
  65330. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65331. /**
  65332. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65333. * You can attach anything to that node. The node position is updated in the scene update tick.
  65334. * @param pos world position that will be constrained by the navigation mesh
  65335. * @param parameters agent parameters
  65336. * @param transform hooked to the agent that will be update by the scene
  65337. * @returns agent index
  65338. */
  65339. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65340. /**
  65341. * Returns the agent position in world space
  65342. * @param index agent index returned by addAgent
  65343. * @returns world space position
  65344. */
  65345. getAgentPosition(index: number): Vector3;
  65346. /**
  65347. * Returns the agent velocity in world space
  65348. * @param index agent index returned by addAgent
  65349. * @returns world space velocity
  65350. */
  65351. getAgentVelocity(index: number): Vector3;
  65352. /**
  65353. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65354. * @param index agent index returned by addAgent
  65355. * @param destination targeted world position
  65356. */
  65357. agentGoto(index: number, destination: Vector3): void;
  65358. /**
  65359. * Teleport the agent to a new position
  65360. * @param index agent index returned by addAgent
  65361. * @param destination targeted world position
  65362. */
  65363. agentTeleport(index: number, destination: Vector3): void;
  65364. /**
  65365. * Update agent parameters
  65366. * @param index agent index returned by addAgent
  65367. * @param parameters agent parameters
  65368. */
  65369. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65370. /**
  65371. * remove a particular agent previously created
  65372. * @param index agent index returned by addAgent
  65373. */
  65374. removeAgent(index: number): void;
  65375. /**
  65376. * get the list of all agents attached to this crowd
  65377. * @returns list of agent indices
  65378. */
  65379. getAgents(): number[];
  65380. /**
  65381. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65382. * @param deltaTime in seconds
  65383. */
  65384. update(deltaTime: number): void;
  65385. /**
  65386. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65387. * The queries will try to find a solution within those bounds
  65388. * default is (1,1,1)
  65389. * @param extent x,y,z value that define the extent around the queries point of reference
  65390. */
  65391. setDefaultQueryExtent(extent: Vector3): void;
  65392. /**
  65393. * Get the Bounding box extent specified by setDefaultQueryExtent
  65394. * @returns the box extent values
  65395. */
  65396. getDefaultQueryExtent(): Vector3;
  65397. /**
  65398. * Release all resources
  65399. */
  65400. dispose(): void;
  65401. }
  65402. }
  65403. declare module "babylonjs/Navigation/Plugins/index" {
  65404. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65405. }
  65406. declare module "babylonjs/Navigation/index" {
  65407. export * from "babylonjs/Navigation/INavigationEngine";
  65408. export * from "babylonjs/Navigation/Plugins/index";
  65409. }
  65410. declare module "babylonjs/Offline/database" {
  65411. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65412. /**
  65413. * Class used to enable access to IndexedDB
  65414. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65415. */
  65416. export class Database implements IOfflineProvider {
  65417. private _callbackManifestChecked;
  65418. private _currentSceneUrl;
  65419. private _db;
  65420. private _enableSceneOffline;
  65421. private _enableTexturesOffline;
  65422. private _manifestVersionFound;
  65423. private _mustUpdateRessources;
  65424. private _hasReachedQuota;
  65425. private _isSupported;
  65426. private _idbFactory;
  65427. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65428. private static IsUASupportingBlobStorage;
  65429. /**
  65430. * Gets a boolean indicating if Database storate is enabled (off by default)
  65431. */
  65432. static IDBStorageEnabled: boolean;
  65433. /**
  65434. * Gets a boolean indicating if scene must be saved in the database
  65435. */
  65436. get enableSceneOffline(): boolean;
  65437. /**
  65438. * Gets a boolean indicating if textures must be saved in the database
  65439. */
  65440. get enableTexturesOffline(): boolean;
  65441. /**
  65442. * Creates a new Database
  65443. * @param urlToScene defines the url to load the scene
  65444. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65445. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65446. */
  65447. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65448. private static _ParseURL;
  65449. private static _ReturnFullUrlLocation;
  65450. private _checkManifestFile;
  65451. /**
  65452. * Open the database and make it available
  65453. * @param successCallback defines the callback to call on success
  65454. * @param errorCallback defines the callback to call on error
  65455. */
  65456. open(successCallback: () => void, errorCallback: () => void): void;
  65457. /**
  65458. * Loads an image from the database
  65459. * @param url defines the url to load from
  65460. * @param image defines the target DOM image
  65461. */
  65462. loadImage(url: string, image: HTMLImageElement): void;
  65463. private _loadImageFromDBAsync;
  65464. private _saveImageIntoDBAsync;
  65465. private _checkVersionFromDB;
  65466. private _loadVersionFromDBAsync;
  65467. private _saveVersionIntoDBAsync;
  65468. /**
  65469. * Loads a file from database
  65470. * @param url defines the URL to load from
  65471. * @param sceneLoaded defines a callback to call on success
  65472. * @param progressCallBack defines a callback to call when progress changed
  65473. * @param errorCallback defines a callback to call on error
  65474. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65475. */
  65476. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65477. private _loadFileAsync;
  65478. private _saveFileAsync;
  65479. /**
  65480. * Validates if xhr data is correct
  65481. * @param xhr defines the request to validate
  65482. * @param dataType defines the expected data type
  65483. * @returns true if data is correct
  65484. */
  65485. private static _ValidateXHRData;
  65486. }
  65487. }
  65488. declare module "babylonjs/Offline/index" {
  65489. export * from "babylonjs/Offline/database";
  65490. export * from "babylonjs/Offline/IOfflineProvider";
  65491. }
  65492. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65493. /** @hidden */
  65494. export var gpuUpdateParticlesPixelShader: {
  65495. name: string;
  65496. shader: string;
  65497. };
  65498. }
  65499. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65500. /** @hidden */
  65501. export var gpuUpdateParticlesVertexShader: {
  65502. name: string;
  65503. shader: string;
  65504. };
  65505. }
  65506. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65507. /** @hidden */
  65508. export var clipPlaneFragmentDeclaration2: {
  65509. name: string;
  65510. shader: string;
  65511. };
  65512. }
  65513. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65514. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65515. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65516. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65517. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65518. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65519. /** @hidden */
  65520. export var gpuRenderParticlesPixelShader: {
  65521. name: string;
  65522. shader: string;
  65523. };
  65524. }
  65525. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65526. /** @hidden */
  65527. export var clipPlaneVertexDeclaration2: {
  65528. name: string;
  65529. shader: string;
  65530. };
  65531. }
  65532. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65533. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65534. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65535. /** @hidden */
  65536. export var gpuRenderParticlesVertexShader: {
  65537. name: string;
  65538. shader: string;
  65539. };
  65540. }
  65541. declare module "babylonjs/Particles/gpuParticleSystem" {
  65542. import { Nullable } from "babylonjs/types";
  65543. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65544. import { Observable } from "babylonjs/Misc/observable";
  65545. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65546. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65547. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65548. import { Scene, IDisposable } from "babylonjs/scene";
  65549. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65550. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65551. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65552. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65553. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65554. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65555. /**
  65556. * This represents a GPU particle system in Babylon
  65557. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65558. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65559. */
  65560. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65561. /**
  65562. * The layer mask we are rendering the particles through.
  65563. */
  65564. layerMask: number;
  65565. private _capacity;
  65566. private _activeCount;
  65567. private _currentActiveCount;
  65568. private _accumulatedCount;
  65569. private _renderEffect;
  65570. private _updateEffect;
  65571. private _buffer0;
  65572. private _buffer1;
  65573. private _spriteBuffer;
  65574. private _updateVAO;
  65575. private _renderVAO;
  65576. private _targetIndex;
  65577. private _sourceBuffer;
  65578. private _targetBuffer;
  65579. private _engine;
  65580. private _currentRenderId;
  65581. private _started;
  65582. private _stopped;
  65583. private _timeDelta;
  65584. private _randomTexture;
  65585. private _randomTexture2;
  65586. private _attributesStrideSize;
  65587. private _updateEffectOptions;
  65588. private _randomTextureSize;
  65589. private _actualFrame;
  65590. private readonly _rawTextureWidth;
  65591. /**
  65592. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65593. */
  65594. static get IsSupported(): boolean;
  65595. /**
  65596. * An event triggered when the system is disposed.
  65597. */
  65598. onDisposeObservable: Observable<GPUParticleSystem>;
  65599. /**
  65600. * Gets the maximum number of particles active at the same time.
  65601. * @returns The max number of active particles.
  65602. */
  65603. getCapacity(): number;
  65604. /**
  65605. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65606. * to override the particles.
  65607. */
  65608. forceDepthWrite: boolean;
  65609. /**
  65610. * Gets or set the number of active particles
  65611. */
  65612. get activeParticleCount(): number;
  65613. set activeParticleCount(value: number);
  65614. private _preWarmDone;
  65615. /**
  65616. * Is this system ready to be used/rendered
  65617. * @return true if the system is ready
  65618. */
  65619. isReady(): boolean;
  65620. /**
  65621. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65622. * @returns True if it has been started, otherwise false.
  65623. */
  65624. isStarted(): boolean;
  65625. /**
  65626. * Starts the particle system and begins to emit
  65627. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65628. */
  65629. start(delay?: number): void;
  65630. /**
  65631. * Stops the particle system.
  65632. */
  65633. stop(): void;
  65634. /**
  65635. * Remove all active particles
  65636. */
  65637. reset(): void;
  65638. /**
  65639. * Returns the string "GPUParticleSystem"
  65640. * @returns a string containing the class name
  65641. */
  65642. getClassName(): string;
  65643. private _colorGradientsTexture;
  65644. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65645. /**
  65646. * Adds a new color gradient
  65647. * @param gradient defines the gradient to use (between 0 and 1)
  65648. * @param color1 defines the color to affect to the specified gradient
  65649. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65650. * @returns the current particle system
  65651. */
  65652. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65653. /**
  65654. * Remove a specific color gradient
  65655. * @param gradient defines the gradient to remove
  65656. * @returns the current particle system
  65657. */
  65658. removeColorGradient(gradient: number): GPUParticleSystem;
  65659. private _angularSpeedGradientsTexture;
  65660. private _sizeGradientsTexture;
  65661. private _velocityGradientsTexture;
  65662. private _limitVelocityGradientsTexture;
  65663. private _dragGradientsTexture;
  65664. private _addFactorGradient;
  65665. /**
  65666. * Adds a new size gradient
  65667. * @param gradient defines the gradient to use (between 0 and 1)
  65668. * @param factor defines the size factor to affect to the specified gradient
  65669. * @returns the current particle system
  65670. */
  65671. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65672. /**
  65673. * Remove a specific size gradient
  65674. * @param gradient defines the gradient to remove
  65675. * @returns the current particle system
  65676. */
  65677. removeSizeGradient(gradient: number): GPUParticleSystem;
  65678. /**
  65679. * Adds a new angular speed gradient
  65680. * @param gradient defines the gradient to use (between 0 and 1)
  65681. * @param factor defines the angular speed to affect to the specified gradient
  65682. * @returns the current particle system
  65683. */
  65684. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65685. /**
  65686. * Remove a specific angular speed gradient
  65687. * @param gradient defines the gradient to remove
  65688. * @returns the current particle system
  65689. */
  65690. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65691. /**
  65692. * Adds a new velocity gradient
  65693. * @param gradient defines the gradient to use (between 0 and 1)
  65694. * @param factor defines the velocity to affect to the specified gradient
  65695. * @returns the current particle system
  65696. */
  65697. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65698. /**
  65699. * Remove a specific velocity gradient
  65700. * @param gradient defines the gradient to remove
  65701. * @returns the current particle system
  65702. */
  65703. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65704. /**
  65705. * Adds a new limit velocity gradient
  65706. * @param gradient defines the gradient to use (between 0 and 1)
  65707. * @param factor defines the limit velocity value to affect to the specified gradient
  65708. * @returns the current particle system
  65709. */
  65710. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65711. /**
  65712. * Remove a specific limit velocity gradient
  65713. * @param gradient defines the gradient to remove
  65714. * @returns the current particle system
  65715. */
  65716. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65717. /**
  65718. * Adds a new drag gradient
  65719. * @param gradient defines the gradient to use (between 0 and 1)
  65720. * @param factor defines the drag value to affect to the specified gradient
  65721. * @returns the current particle system
  65722. */
  65723. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65724. /**
  65725. * Remove a specific drag gradient
  65726. * @param gradient defines the gradient to remove
  65727. * @returns the current particle system
  65728. */
  65729. removeDragGradient(gradient: number): GPUParticleSystem;
  65730. /**
  65731. * Not supported by GPUParticleSystem
  65732. * @param gradient defines the gradient to use (between 0 and 1)
  65733. * @param factor defines the emit rate value to affect to the specified gradient
  65734. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65735. * @returns the current particle system
  65736. */
  65737. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65738. /**
  65739. * Not supported by GPUParticleSystem
  65740. * @param gradient defines the gradient to remove
  65741. * @returns the current particle system
  65742. */
  65743. removeEmitRateGradient(gradient: number): IParticleSystem;
  65744. /**
  65745. * Not supported by GPUParticleSystem
  65746. * @param gradient defines the gradient to use (between 0 and 1)
  65747. * @param factor defines the start size value to affect to the specified gradient
  65748. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65749. * @returns the current particle system
  65750. */
  65751. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65752. /**
  65753. * Not supported by GPUParticleSystem
  65754. * @param gradient defines the gradient to remove
  65755. * @returns the current particle system
  65756. */
  65757. removeStartSizeGradient(gradient: number): IParticleSystem;
  65758. /**
  65759. * Not supported by GPUParticleSystem
  65760. * @param gradient defines the gradient to use (between 0 and 1)
  65761. * @param min defines the color remap minimal range
  65762. * @param max defines the color remap maximal range
  65763. * @returns the current particle system
  65764. */
  65765. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65766. /**
  65767. * Not supported by GPUParticleSystem
  65768. * @param gradient defines the gradient to remove
  65769. * @returns the current particle system
  65770. */
  65771. removeColorRemapGradient(): IParticleSystem;
  65772. /**
  65773. * Not supported by GPUParticleSystem
  65774. * @param gradient defines the gradient to use (between 0 and 1)
  65775. * @param min defines the alpha remap minimal range
  65776. * @param max defines the alpha remap maximal range
  65777. * @returns the current particle system
  65778. */
  65779. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65780. /**
  65781. * Not supported by GPUParticleSystem
  65782. * @param gradient defines the gradient to remove
  65783. * @returns the current particle system
  65784. */
  65785. removeAlphaRemapGradient(): IParticleSystem;
  65786. /**
  65787. * Not supported by GPUParticleSystem
  65788. * @param gradient defines the gradient to use (between 0 and 1)
  65789. * @param color defines the color to affect to the specified gradient
  65790. * @returns the current particle system
  65791. */
  65792. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65793. /**
  65794. * Not supported by GPUParticleSystem
  65795. * @param gradient defines the gradient to remove
  65796. * @returns the current particle system
  65797. */
  65798. removeRampGradient(): IParticleSystem;
  65799. /**
  65800. * Not supported by GPUParticleSystem
  65801. * @returns the list of ramp gradients
  65802. */
  65803. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65804. /**
  65805. * Not supported by GPUParticleSystem
  65806. * Gets or sets a boolean indicating that ramp gradients must be used
  65807. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65808. */
  65809. get useRampGradients(): boolean;
  65810. set useRampGradients(value: boolean);
  65811. /**
  65812. * Not supported by GPUParticleSystem
  65813. * @param gradient defines the gradient to use (between 0 and 1)
  65814. * @param factor defines the life time factor to affect to the specified gradient
  65815. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65816. * @returns the current particle system
  65817. */
  65818. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65819. /**
  65820. * Not supported by GPUParticleSystem
  65821. * @param gradient defines the gradient to remove
  65822. * @returns the current particle system
  65823. */
  65824. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65825. /**
  65826. * Instantiates a GPU particle system.
  65827. * 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.
  65828. * @param name The name of the particle system
  65829. * @param options The options used to create the system
  65830. * @param scene The scene the particle system belongs to
  65831. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65832. */
  65833. constructor(name: string, options: Partial<{
  65834. capacity: number;
  65835. randomTextureSize: number;
  65836. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  65837. protected _reset(): void;
  65838. private _createUpdateVAO;
  65839. private _createRenderVAO;
  65840. private _initialize;
  65841. /** @hidden */
  65842. _recreateUpdateEffect(): void;
  65843. /** @hidden */
  65844. _recreateRenderEffect(): void;
  65845. /**
  65846. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65847. * @param preWarm defines if we are in the pre-warmimg phase
  65848. */
  65849. animate(preWarm?: boolean): void;
  65850. private _createFactorGradientTexture;
  65851. private _createSizeGradientTexture;
  65852. private _createAngularSpeedGradientTexture;
  65853. private _createVelocityGradientTexture;
  65854. private _createLimitVelocityGradientTexture;
  65855. private _createDragGradientTexture;
  65856. private _createColorGradientTexture;
  65857. /**
  65858. * Renders the particle system in its current state
  65859. * @param preWarm defines if the system should only update the particles but not render them
  65860. * @returns the current number of particles
  65861. */
  65862. render(preWarm?: boolean): number;
  65863. /**
  65864. * Rebuilds the particle system
  65865. */
  65866. rebuild(): void;
  65867. private _releaseBuffers;
  65868. private _releaseVAOs;
  65869. /**
  65870. * Disposes the particle system and free the associated resources
  65871. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65872. */
  65873. dispose(disposeTexture?: boolean): void;
  65874. /**
  65875. * Clones the particle system.
  65876. * @param name The name of the cloned object
  65877. * @param newEmitter The new emitter to use
  65878. * @returns the cloned particle system
  65879. */
  65880. clone(name: string, newEmitter: any): GPUParticleSystem;
  65881. /**
  65882. * Serializes the particle system to a JSON object.
  65883. * @returns the JSON object
  65884. */
  65885. serialize(): any;
  65886. /**
  65887. * Parses a JSON object to create a GPU particle system.
  65888. * @param parsedParticleSystem The JSON object to parse
  65889. * @param scene The scene to create the particle system in
  65890. * @param rootUrl The root url to use to load external dependencies like texture
  65891. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65892. * @returns the parsed GPU particle system
  65893. */
  65894. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65895. }
  65896. }
  65897. declare module "babylonjs/Particles/particleSystemSet" {
  65898. import { Nullable } from "babylonjs/types";
  65899. import { Color3 } from "babylonjs/Maths/math.color";
  65900. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65902. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65903. import { Scene, IDisposable } from "babylonjs/scene";
  65904. /**
  65905. * Represents a set of particle systems working together to create a specific effect
  65906. */
  65907. export class ParticleSystemSet implements IDisposable {
  65908. /**
  65909. * Gets or sets base Assets URL
  65910. */
  65911. static BaseAssetsUrl: string;
  65912. private _emitterCreationOptions;
  65913. private _emitterNode;
  65914. /**
  65915. * Gets the particle system list
  65916. */
  65917. systems: IParticleSystem[];
  65918. /**
  65919. * Gets the emitter node used with this set
  65920. */
  65921. get emitterNode(): Nullable<TransformNode>;
  65922. /**
  65923. * Creates a new emitter mesh as a sphere
  65924. * @param options defines the options used to create the sphere
  65925. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  65926. * @param scene defines the hosting scene
  65927. */
  65928. setEmitterAsSphere(options: {
  65929. diameter: number;
  65930. segments: number;
  65931. color: Color3;
  65932. }, renderingGroupId: number, scene: Scene): void;
  65933. /**
  65934. * Starts all particle systems of the set
  65935. * @param emitter defines an optional mesh to use as emitter for the particle systems
  65936. */
  65937. start(emitter?: AbstractMesh): void;
  65938. /**
  65939. * Release all associated resources
  65940. */
  65941. dispose(): void;
  65942. /**
  65943. * Serialize the set into a JSON compatible object
  65944. * @returns a JSON compatible representation of the set
  65945. */
  65946. serialize(): any;
  65947. /**
  65948. * Parse a new ParticleSystemSet from a serialized source
  65949. * @param data defines a JSON compatible representation of the set
  65950. * @param scene defines the hosting scene
  65951. * @param gpu defines if we want GPU particles or CPU particles
  65952. * @returns a new ParticleSystemSet
  65953. */
  65954. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  65955. }
  65956. }
  65957. declare module "babylonjs/Particles/particleHelper" {
  65958. import { Nullable } from "babylonjs/types";
  65959. import { Scene } from "babylonjs/scene";
  65960. import { Vector3 } from "babylonjs/Maths/math.vector";
  65961. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65962. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65963. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  65964. /**
  65965. * This class is made for on one-liner static method to help creating particle system set.
  65966. */
  65967. export class ParticleHelper {
  65968. /**
  65969. * Gets or sets base Assets URL
  65970. */
  65971. static BaseAssetsUrl: string;
  65972. /**
  65973. * Create a default particle system that you can tweak
  65974. * @param emitter defines the emitter to use
  65975. * @param capacity defines the system capacity (default is 500 particles)
  65976. * @param scene defines the hosting scene
  65977. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  65978. * @returns the new Particle system
  65979. */
  65980. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  65981. /**
  65982. * This is the main static method (one-liner) of this helper to create different particle systems
  65983. * @param type This string represents the type to the particle system to create
  65984. * @param scene The scene where the particle system should live
  65985. * @param gpu If the system will use gpu
  65986. * @returns the ParticleSystemSet created
  65987. */
  65988. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  65989. /**
  65990. * Static function used to export a particle system to a ParticleSystemSet variable.
  65991. * Please note that the emitter shape is not exported
  65992. * @param systems defines the particle systems to export
  65993. * @returns the created particle system set
  65994. */
  65995. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  65996. }
  65997. }
  65998. declare module "babylonjs/Particles/particleSystemComponent" {
  65999. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66000. import { Effect } from "babylonjs/Materials/effect";
  66001. import "babylonjs/Shaders/particles.vertex";
  66002. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66003. module "babylonjs/Engines/engine" {
  66004. interface Engine {
  66005. /**
  66006. * Create an effect to use with particle systems.
  66007. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66008. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66009. * @param uniformsNames defines a list of attribute names
  66010. * @param samplers defines an array of string used to represent textures
  66011. * @param defines defines the string containing the defines to use to compile the shaders
  66012. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66013. * @param onCompiled defines a function to call when the effect creation is successful
  66014. * @param onError defines a function to call when the effect creation has failed
  66015. * @returns the new Effect
  66016. */
  66017. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66018. }
  66019. }
  66020. module "babylonjs/Meshes/mesh" {
  66021. interface Mesh {
  66022. /**
  66023. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66024. * @returns an array of IParticleSystem
  66025. */
  66026. getEmittedParticleSystems(): IParticleSystem[];
  66027. /**
  66028. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66029. * @returns an array of IParticleSystem
  66030. */
  66031. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66032. }
  66033. }
  66034. /**
  66035. * @hidden
  66036. */
  66037. export var _IDoNeedToBeInTheBuild: number;
  66038. }
  66039. declare module "babylonjs/Particles/pointsCloudSystem" {
  66040. import { Color4 } from "babylonjs/Maths/math";
  66041. import { Mesh } from "babylonjs/Meshes/mesh";
  66042. import { Scene, IDisposable } from "babylonjs/scene";
  66043. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66044. /** Defines the 4 color options */
  66045. export enum PointColor {
  66046. /** color value */
  66047. Color = 2,
  66048. /** uv value */
  66049. UV = 1,
  66050. /** random value */
  66051. Random = 0,
  66052. /** stated value */
  66053. Stated = 3
  66054. }
  66055. /**
  66056. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66057. * 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.
  66058. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66059. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66060. *
  66061. * Full documentation here : TO BE ENTERED
  66062. */
  66063. export class PointsCloudSystem implements IDisposable {
  66064. /**
  66065. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66066. * Example : var p = SPS.particles[i];
  66067. */
  66068. particles: CloudPoint[];
  66069. /**
  66070. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66071. */
  66072. nbParticles: number;
  66073. /**
  66074. * This a counter for your own usage. It's not set by any SPS functions.
  66075. */
  66076. counter: number;
  66077. /**
  66078. * The PCS name. This name is also given to the underlying mesh.
  66079. */
  66080. name: string;
  66081. /**
  66082. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66083. */
  66084. mesh: Mesh;
  66085. /**
  66086. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66087. * Please read :
  66088. */
  66089. vars: any;
  66090. /**
  66091. * @hidden
  66092. */
  66093. _size: number;
  66094. private _scene;
  66095. private _promises;
  66096. private _positions;
  66097. private _indices;
  66098. private _normals;
  66099. private _colors;
  66100. private _uvs;
  66101. private _indices32;
  66102. private _positions32;
  66103. private _colors32;
  66104. private _uvs32;
  66105. private _updatable;
  66106. private _isVisibilityBoxLocked;
  66107. private _alwaysVisible;
  66108. private _groups;
  66109. private _groupCounter;
  66110. private _computeParticleColor;
  66111. private _computeParticleTexture;
  66112. private _computeParticleRotation;
  66113. private _computeBoundingBox;
  66114. private _isReady;
  66115. /**
  66116. * Creates a PCS (Points Cloud System) object
  66117. * @param name (String) is the PCS name, this will be the underlying mesh name
  66118. * @param pointSize (number) is the size for each point
  66119. * @param scene (Scene) is the scene in which the PCS is added
  66120. * @param options defines the options of the PCS e.g.
  66121. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66122. */
  66123. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66124. updatable?: boolean;
  66125. });
  66126. /**
  66127. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66128. * If no points were added to the PCS, the returned mesh is just a single point.
  66129. * @returns a promise for the created mesh
  66130. */
  66131. buildMeshAsync(): Promise<Mesh>;
  66132. /**
  66133. * @hidden
  66134. */
  66135. private _buildMesh;
  66136. private _addParticle;
  66137. private _randomUnitVector;
  66138. private _getColorIndicesForCoord;
  66139. private _setPointsColorOrUV;
  66140. private _colorFromTexture;
  66141. private _calculateDensity;
  66142. /**
  66143. * Adds points to the PCS in random positions within a unit sphere
  66144. * @param nb (positive integer) the number of particles to be created from this model
  66145. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66146. * @returns the number of groups in the system
  66147. */
  66148. addPoints(nb: number, pointFunction?: any): number;
  66149. /**
  66150. * Adds points to the PCS from the surface of the model shape
  66151. * @param mesh is any Mesh object that will be used as a surface model for the points
  66152. * @param nb (positive integer) the number of particles to be created from this model
  66153. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66154. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66155. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66156. * @returns the number of groups in the system
  66157. */
  66158. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66159. /**
  66160. * Adds points to the PCS inside the model shape
  66161. * @param mesh is any Mesh object that will be used as a surface model for the points
  66162. * @param nb (positive integer) the number of particles to be created from this model
  66163. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66164. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66165. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66166. * @returns the number of groups in the system
  66167. */
  66168. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66169. /**
  66170. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66171. * This method calls `updateParticle()` for each particle of the SPS.
  66172. * For an animated SPS, it is usually called within the render loop.
  66173. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66174. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66175. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66176. * @returns the PCS.
  66177. */
  66178. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66179. /**
  66180. * Disposes the PCS.
  66181. */
  66182. dispose(): void;
  66183. /**
  66184. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66185. * doc :
  66186. * @returns the PCS.
  66187. */
  66188. refreshVisibleSize(): PointsCloudSystem;
  66189. /**
  66190. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66191. * @param size the size (float) of the visibility box
  66192. * note : this doesn't lock the PCS mesh bounding box.
  66193. * doc :
  66194. */
  66195. setVisibilityBox(size: number): void;
  66196. /**
  66197. * Gets whether the PCS is always visible or not
  66198. * doc :
  66199. */
  66200. get isAlwaysVisible(): boolean;
  66201. /**
  66202. * Sets the PCS as always visible or not
  66203. * doc :
  66204. */
  66205. set isAlwaysVisible(val: boolean);
  66206. /**
  66207. * Tells to `setParticles()` to compute the particle rotations or not
  66208. * Default value : false. The PCS is faster when it's set to false
  66209. * Note : particle rotations are only applied to parent particles
  66210. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66211. */
  66212. set computeParticleRotation(val: boolean);
  66213. /**
  66214. * Tells to `setParticles()` to compute the particle colors or not.
  66215. * Default value : true. The PCS is faster when it's set to false.
  66216. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66217. */
  66218. set computeParticleColor(val: boolean);
  66219. set computeParticleTexture(val: boolean);
  66220. /**
  66221. * Gets if `setParticles()` computes the particle colors or not.
  66222. * Default value : false. The PCS is faster when it's set to false.
  66223. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66224. */
  66225. get computeParticleColor(): boolean;
  66226. /**
  66227. * Gets if `setParticles()` computes the particle textures or not.
  66228. * Default value : false. The PCS is faster when it's set to false.
  66229. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66230. */
  66231. get computeParticleTexture(): boolean;
  66232. /**
  66233. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66234. */
  66235. set computeBoundingBox(val: boolean);
  66236. /**
  66237. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66238. */
  66239. get computeBoundingBox(): boolean;
  66240. /**
  66241. * This function does nothing. It may be overwritten to set all the particle first values.
  66242. * The PCS doesn't call this function, you may have to call it by your own.
  66243. * doc :
  66244. */
  66245. initParticles(): void;
  66246. /**
  66247. * This function does nothing. It may be overwritten to recycle a particle
  66248. * The PCS doesn't call this function, you can to call it
  66249. * doc :
  66250. * @param particle The particle to recycle
  66251. * @returns the recycled particle
  66252. */
  66253. recycleParticle(particle: CloudPoint): CloudPoint;
  66254. /**
  66255. * Updates a particle : this function should be overwritten by the user.
  66256. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66257. * doc :
  66258. * @example : just set a particle position or velocity and recycle conditions
  66259. * @param particle The particle to update
  66260. * @returns the updated particle
  66261. */
  66262. updateParticle(particle: CloudPoint): CloudPoint;
  66263. /**
  66264. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66265. * This does nothing and may be overwritten by the user.
  66266. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66267. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66268. * @param update the boolean update value actually passed to setParticles()
  66269. */
  66270. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66271. /**
  66272. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66273. * This will be passed three parameters.
  66274. * This does nothing and may be overwritten by the user.
  66275. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66276. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66277. * @param update the boolean update value actually passed to setParticles()
  66278. */
  66279. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66280. }
  66281. }
  66282. declare module "babylonjs/Particles/cloudPoint" {
  66283. import { Nullable } from "babylonjs/types";
  66284. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66285. import { Mesh } from "babylonjs/Meshes/mesh";
  66286. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66287. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66288. /**
  66289. * Represents one particle of a points cloud system.
  66290. */
  66291. export class CloudPoint {
  66292. /**
  66293. * particle global index
  66294. */
  66295. idx: number;
  66296. /**
  66297. * The color of the particle
  66298. */
  66299. color: Nullable<Color4>;
  66300. /**
  66301. * The world space position of the particle.
  66302. */
  66303. position: Vector3;
  66304. /**
  66305. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66306. */
  66307. rotation: Vector3;
  66308. /**
  66309. * The world space rotation quaternion of the particle.
  66310. */
  66311. rotationQuaternion: Nullable<Quaternion>;
  66312. /**
  66313. * The uv of the particle.
  66314. */
  66315. uv: Nullable<Vector2>;
  66316. /**
  66317. * The current speed of the particle.
  66318. */
  66319. velocity: Vector3;
  66320. /**
  66321. * The pivot point in the particle local space.
  66322. */
  66323. pivot: Vector3;
  66324. /**
  66325. * Must the particle be translated from its pivot point in its local space ?
  66326. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66327. * Default : false
  66328. */
  66329. translateFromPivot: boolean;
  66330. /**
  66331. * Index of this particle in the global "positions" array (Internal use)
  66332. * @hidden
  66333. */
  66334. _pos: number;
  66335. /**
  66336. * @hidden Index of this particle in the global "indices" array (Internal use)
  66337. */
  66338. _ind: number;
  66339. /**
  66340. * Group this particle belongs to
  66341. */
  66342. _group: PointsGroup;
  66343. /**
  66344. * Group id of this particle
  66345. */
  66346. groupId: number;
  66347. /**
  66348. * Index of the particle in its group id (Internal use)
  66349. */
  66350. idxInGroup: number;
  66351. /**
  66352. * @hidden Particle BoundingInfo object (Internal use)
  66353. */
  66354. _boundingInfo: BoundingInfo;
  66355. /**
  66356. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66357. */
  66358. _pcs: PointsCloudSystem;
  66359. /**
  66360. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66361. */
  66362. _stillInvisible: boolean;
  66363. /**
  66364. * @hidden Last computed particle rotation matrix
  66365. */
  66366. _rotationMatrix: number[];
  66367. /**
  66368. * Parent particle Id, if any.
  66369. * Default null.
  66370. */
  66371. parentId: Nullable<number>;
  66372. /**
  66373. * @hidden Internal global position in the PCS.
  66374. */
  66375. _globalPosition: Vector3;
  66376. /**
  66377. * Creates a Point Cloud object.
  66378. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66379. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66380. * @param group (PointsGroup) is the group the particle belongs to
  66381. * @param groupId (integer) is the group identifier in the PCS.
  66382. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66383. * @param pcs defines the PCS it is associated to
  66384. */
  66385. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66386. /**
  66387. * get point size
  66388. */
  66389. get size(): Vector3;
  66390. /**
  66391. * Set point size
  66392. */
  66393. set size(scale: Vector3);
  66394. /**
  66395. * Legacy support, changed quaternion to rotationQuaternion
  66396. */
  66397. get quaternion(): Nullable<Quaternion>;
  66398. /**
  66399. * Legacy support, changed quaternion to rotationQuaternion
  66400. */
  66401. set quaternion(q: Nullable<Quaternion>);
  66402. /**
  66403. * Returns a boolean. True if the particle intersects a mesh, else false
  66404. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66405. * @param target is the object (point or mesh) what the intersection is computed against
  66406. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66407. * @returns true if it intersects
  66408. */
  66409. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66410. /**
  66411. * get the rotation matrix of the particle
  66412. * @hidden
  66413. */
  66414. getRotationMatrix(m: Matrix): void;
  66415. }
  66416. /**
  66417. * Represents a group of points in a points cloud system
  66418. * * PCS internal tool, don't use it manually.
  66419. */
  66420. export class PointsGroup {
  66421. /**
  66422. * The group id
  66423. * @hidden
  66424. */
  66425. groupID: number;
  66426. /**
  66427. * image data for group (internal use)
  66428. * @hidden
  66429. */
  66430. _groupImageData: Nullable<ArrayBufferView>;
  66431. /**
  66432. * Image Width (internal use)
  66433. * @hidden
  66434. */
  66435. _groupImgWidth: number;
  66436. /**
  66437. * Image Height (internal use)
  66438. * @hidden
  66439. */
  66440. _groupImgHeight: number;
  66441. /**
  66442. * Custom position function (internal use)
  66443. * @hidden
  66444. */
  66445. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66446. /**
  66447. * density per facet for surface points
  66448. * @hidden
  66449. */
  66450. _groupDensity: number[];
  66451. /**
  66452. * Only when points are colored by texture carries pointer to texture list array
  66453. * @hidden
  66454. */
  66455. _textureNb: number;
  66456. /**
  66457. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66458. * PCS internal tool, don't use it manually.
  66459. * @hidden
  66460. */
  66461. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66462. }
  66463. }
  66464. declare module "babylonjs/Particles/index" {
  66465. export * from "babylonjs/Particles/baseParticleSystem";
  66466. export * from "babylonjs/Particles/EmitterTypes/index";
  66467. export * from "babylonjs/Particles/gpuParticleSystem";
  66468. export * from "babylonjs/Particles/IParticleSystem";
  66469. export * from "babylonjs/Particles/particle";
  66470. export * from "babylonjs/Particles/particleHelper";
  66471. export * from "babylonjs/Particles/particleSystem";
  66472. export * from "babylonjs/Particles/particleSystemComponent";
  66473. export * from "babylonjs/Particles/particleSystemSet";
  66474. export * from "babylonjs/Particles/solidParticle";
  66475. export * from "babylonjs/Particles/solidParticleSystem";
  66476. export * from "babylonjs/Particles/cloudPoint";
  66477. export * from "babylonjs/Particles/pointsCloudSystem";
  66478. export * from "babylonjs/Particles/subEmitter";
  66479. }
  66480. declare module "babylonjs/Physics/physicsEngineComponent" {
  66481. import { Nullable } from "babylonjs/types";
  66482. import { Observable, Observer } from "babylonjs/Misc/observable";
  66483. import { Vector3 } from "babylonjs/Maths/math.vector";
  66484. import { Mesh } from "babylonjs/Meshes/mesh";
  66485. import { ISceneComponent } from "babylonjs/sceneComponent";
  66486. import { Scene } from "babylonjs/scene";
  66487. import { Node } from "babylonjs/node";
  66488. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66489. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66490. module "babylonjs/scene" {
  66491. interface Scene {
  66492. /** @hidden (Backing field) */
  66493. _physicsEngine: Nullable<IPhysicsEngine>;
  66494. /** @hidden */
  66495. _physicsTimeAccumulator: number;
  66496. /**
  66497. * Gets the current physics engine
  66498. * @returns a IPhysicsEngine or null if none attached
  66499. */
  66500. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66501. /**
  66502. * Enables physics to the current scene
  66503. * @param gravity defines the scene's gravity for the physics engine
  66504. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66505. * @return a boolean indicating if the physics engine was initialized
  66506. */
  66507. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66508. /**
  66509. * Disables and disposes the physics engine associated with the scene
  66510. */
  66511. disablePhysicsEngine(): void;
  66512. /**
  66513. * Gets a boolean indicating if there is an active physics engine
  66514. * @returns a boolean indicating if there is an active physics engine
  66515. */
  66516. isPhysicsEnabled(): boolean;
  66517. /**
  66518. * Deletes a physics compound impostor
  66519. * @param compound defines the compound to delete
  66520. */
  66521. deleteCompoundImpostor(compound: any): void;
  66522. /**
  66523. * An event triggered when physic simulation is about to be run
  66524. */
  66525. onBeforePhysicsObservable: Observable<Scene>;
  66526. /**
  66527. * An event triggered when physic simulation has been done
  66528. */
  66529. onAfterPhysicsObservable: Observable<Scene>;
  66530. }
  66531. }
  66532. module "babylonjs/Meshes/abstractMesh" {
  66533. interface AbstractMesh {
  66534. /** @hidden */
  66535. _physicsImpostor: Nullable<PhysicsImpostor>;
  66536. /**
  66537. * Gets or sets impostor used for physic simulation
  66538. * @see http://doc.babylonjs.com/features/physics_engine
  66539. */
  66540. physicsImpostor: Nullable<PhysicsImpostor>;
  66541. /**
  66542. * Gets the current physics impostor
  66543. * @see http://doc.babylonjs.com/features/physics_engine
  66544. * @returns a physics impostor or null
  66545. */
  66546. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66547. /** Apply a physic impulse to the mesh
  66548. * @param force defines the force to apply
  66549. * @param contactPoint defines where to apply the force
  66550. * @returns the current mesh
  66551. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66552. */
  66553. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66554. /**
  66555. * Creates a physic joint between two meshes
  66556. * @param otherMesh defines the other mesh to use
  66557. * @param pivot1 defines the pivot to use on this mesh
  66558. * @param pivot2 defines the pivot to use on the other mesh
  66559. * @param options defines additional options (can be plugin dependent)
  66560. * @returns the current mesh
  66561. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66562. */
  66563. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66564. /** @hidden */
  66565. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66566. }
  66567. }
  66568. /**
  66569. * Defines the physics engine scene component responsible to manage a physics engine
  66570. */
  66571. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66572. /**
  66573. * The component name helpful to identify the component in the list of scene components.
  66574. */
  66575. readonly name: string;
  66576. /**
  66577. * The scene the component belongs to.
  66578. */
  66579. scene: Scene;
  66580. /**
  66581. * Creates a new instance of the component for the given scene
  66582. * @param scene Defines the scene to register the component in
  66583. */
  66584. constructor(scene: Scene);
  66585. /**
  66586. * Registers the component in a given scene
  66587. */
  66588. register(): void;
  66589. /**
  66590. * Rebuilds the elements related to this component in case of
  66591. * context lost for instance.
  66592. */
  66593. rebuild(): void;
  66594. /**
  66595. * Disposes the component and the associated ressources
  66596. */
  66597. dispose(): void;
  66598. }
  66599. }
  66600. declare module "babylonjs/Physics/physicsHelper" {
  66601. import { Nullable } from "babylonjs/types";
  66602. import { Vector3 } from "babylonjs/Maths/math.vector";
  66603. import { Mesh } from "babylonjs/Meshes/mesh";
  66604. import { Scene } from "babylonjs/scene";
  66605. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66606. /**
  66607. * A helper for physics simulations
  66608. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66609. */
  66610. export class PhysicsHelper {
  66611. private _scene;
  66612. private _physicsEngine;
  66613. /**
  66614. * Initializes the Physics helper
  66615. * @param scene Babylon.js scene
  66616. */
  66617. constructor(scene: Scene);
  66618. /**
  66619. * Applies a radial explosion impulse
  66620. * @param origin the origin of the explosion
  66621. * @param radiusOrEventOptions the radius or the options of radial explosion
  66622. * @param strength the explosion strength
  66623. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66624. * @returns A physics radial explosion event, or null
  66625. */
  66626. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66627. /**
  66628. * Applies a radial explosion force
  66629. * @param origin the origin of the explosion
  66630. * @param radiusOrEventOptions the radius or the options of radial explosion
  66631. * @param strength the explosion strength
  66632. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66633. * @returns A physics radial explosion event, or null
  66634. */
  66635. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66636. /**
  66637. * Creates a gravitational field
  66638. * @param origin the origin of the explosion
  66639. * @param radiusOrEventOptions the radius or the options of radial explosion
  66640. * @param strength the explosion strength
  66641. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66642. * @returns A physics gravitational field event, or null
  66643. */
  66644. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66645. /**
  66646. * Creates a physics updraft event
  66647. * @param origin the origin of the updraft
  66648. * @param radiusOrEventOptions the radius or the options of the updraft
  66649. * @param strength the strength of the updraft
  66650. * @param height the height of the updraft
  66651. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66652. * @returns A physics updraft event, or null
  66653. */
  66654. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66655. /**
  66656. * Creates a physics vortex event
  66657. * @param origin the of the vortex
  66658. * @param radiusOrEventOptions the radius or the options of the vortex
  66659. * @param strength the strength of the vortex
  66660. * @param height the height of the vortex
  66661. * @returns a Physics vortex event, or null
  66662. * A physics vortex event or null
  66663. */
  66664. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66665. }
  66666. /**
  66667. * Represents a physics radial explosion event
  66668. */
  66669. class PhysicsRadialExplosionEvent {
  66670. private _scene;
  66671. private _options;
  66672. private _sphere;
  66673. private _dataFetched;
  66674. /**
  66675. * Initializes a radial explosioin event
  66676. * @param _scene BabylonJS scene
  66677. * @param _options The options for the vortex event
  66678. */
  66679. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66680. /**
  66681. * Returns the data related to the radial explosion event (sphere).
  66682. * @returns The radial explosion event data
  66683. */
  66684. getData(): PhysicsRadialExplosionEventData;
  66685. /**
  66686. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66687. * @param impostor A physics imposter
  66688. * @param origin the origin of the explosion
  66689. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66690. */
  66691. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66692. /**
  66693. * Triggers affecterd impostors callbacks
  66694. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66695. */
  66696. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66697. /**
  66698. * Disposes the sphere.
  66699. * @param force Specifies if the sphere should be disposed by force
  66700. */
  66701. dispose(force?: boolean): void;
  66702. /*** Helpers ***/
  66703. private _prepareSphere;
  66704. private _intersectsWithSphere;
  66705. }
  66706. /**
  66707. * Represents a gravitational field event
  66708. */
  66709. class PhysicsGravitationalFieldEvent {
  66710. private _physicsHelper;
  66711. private _scene;
  66712. private _origin;
  66713. private _options;
  66714. private _tickCallback;
  66715. private _sphere;
  66716. private _dataFetched;
  66717. /**
  66718. * Initializes the physics gravitational field event
  66719. * @param _physicsHelper A physics helper
  66720. * @param _scene BabylonJS scene
  66721. * @param _origin The origin position of the gravitational field event
  66722. * @param _options The options for the vortex event
  66723. */
  66724. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66725. /**
  66726. * Returns the data related to the gravitational field event (sphere).
  66727. * @returns A gravitational field event
  66728. */
  66729. getData(): PhysicsGravitationalFieldEventData;
  66730. /**
  66731. * Enables the gravitational field.
  66732. */
  66733. enable(): void;
  66734. /**
  66735. * Disables the gravitational field.
  66736. */
  66737. disable(): void;
  66738. /**
  66739. * Disposes the sphere.
  66740. * @param force The force to dispose from the gravitational field event
  66741. */
  66742. dispose(force?: boolean): void;
  66743. private _tick;
  66744. }
  66745. /**
  66746. * Represents a physics updraft event
  66747. */
  66748. class PhysicsUpdraftEvent {
  66749. private _scene;
  66750. private _origin;
  66751. private _options;
  66752. private _physicsEngine;
  66753. private _originTop;
  66754. private _originDirection;
  66755. private _tickCallback;
  66756. private _cylinder;
  66757. private _cylinderPosition;
  66758. private _dataFetched;
  66759. /**
  66760. * Initializes the physics updraft event
  66761. * @param _scene BabylonJS scene
  66762. * @param _origin The origin position of the updraft
  66763. * @param _options The options for the updraft event
  66764. */
  66765. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66766. /**
  66767. * Returns the data related to the updraft event (cylinder).
  66768. * @returns A physics updraft event
  66769. */
  66770. getData(): PhysicsUpdraftEventData;
  66771. /**
  66772. * Enables the updraft.
  66773. */
  66774. enable(): void;
  66775. /**
  66776. * Disables the updraft.
  66777. */
  66778. disable(): void;
  66779. /**
  66780. * Disposes the cylinder.
  66781. * @param force Specifies if the updraft should be disposed by force
  66782. */
  66783. dispose(force?: boolean): void;
  66784. private getImpostorHitData;
  66785. private _tick;
  66786. /*** Helpers ***/
  66787. private _prepareCylinder;
  66788. private _intersectsWithCylinder;
  66789. }
  66790. /**
  66791. * Represents a physics vortex event
  66792. */
  66793. class PhysicsVortexEvent {
  66794. private _scene;
  66795. private _origin;
  66796. private _options;
  66797. private _physicsEngine;
  66798. private _originTop;
  66799. private _tickCallback;
  66800. private _cylinder;
  66801. private _cylinderPosition;
  66802. private _dataFetched;
  66803. /**
  66804. * Initializes the physics vortex event
  66805. * @param _scene The BabylonJS scene
  66806. * @param _origin The origin position of the vortex
  66807. * @param _options The options for the vortex event
  66808. */
  66809. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66810. /**
  66811. * Returns the data related to the vortex event (cylinder).
  66812. * @returns The physics vortex event data
  66813. */
  66814. getData(): PhysicsVortexEventData;
  66815. /**
  66816. * Enables the vortex.
  66817. */
  66818. enable(): void;
  66819. /**
  66820. * Disables the cortex.
  66821. */
  66822. disable(): void;
  66823. /**
  66824. * Disposes the sphere.
  66825. * @param force
  66826. */
  66827. dispose(force?: boolean): void;
  66828. private getImpostorHitData;
  66829. private _tick;
  66830. /*** Helpers ***/
  66831. private _prepareCylinder;
  66832. private _intersectsWithCylinder;
  66833. }
  66834. /**
  66835. * Options fot the radial explosion event
  66836. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66837. */
  66838. export class PhysicsRadialExplosionEventOptions {
  66839. /**
  66840. * The radius of the sphere for the radial explosion.
  66841. */
  66842. radius: number;
  66843. /**
  66844. * The strenth of the explosion.
  66845. */
  66846. strength: number;
  66847. /**
  66848. * The strenght of the force in correspondence to the distance of the affected object
  66849. */
  66850. falloff: PhysicsRadialImpulseFalloff;
  66851. /**
  66852. * Sphere options for the radial explosion.
  66853. */
  66854. sphere: {
  66855. segments: number;
  66856. diameter: number;
  66857. };
  66858. /**
  66859. * Sphere options for the radial explosion.
  66860. */
  66861. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66862. }
  66863. /**
  66864. * Options fot the updraft event
  66865. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66866. */
  66867. export class PhysicsUpdraftEventOptions {
  66868. /**
  66869. * The radius of the cylinder for the vortex
  66870. */
  66871. radius: number;
  66872. /**
  66873. * The strenth of the updraft.
  66874. */
  66875. strength: number;
  66876. /**
  66877. * The height of the cylinder for the updraft.
  66878. */
  66879. height: number;
  66880. /**
  66881. * The mode for the the updraft.
  66882. */
  66883. updraftMode: PhysicsUpdraftMode;
  66884. }
  66885. /**
  66886. * Options fot the vortex event
  66887. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66888. */
  66889. export class PhysicsVortexEventOptions {
  66890. /**
  66891. * The radius of the cylinder for the vortex
  66892. */
  66893. radius: number;
  66894. /**
  66895. * The strenth of the vortex.
  66896. */
  66897. strength: number;
  66898. /**
  66899. * The height of the cylinder for the vortex.
  66900. */
  66901. height: number;
  66902. /**
  66903. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  66904. */
  66905. centripetalForceThreshold: number;
  66906. /**
  66907. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  66908. */
  66909. centripetalForceMultiplier: number;
  66910. /**
  66911. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  66912. */
  66913. centrifugalForceMultiplier: number;
  66914. /**
  66915. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  66916. */
  66917. updraftForceMultiplier: number;
  66918. }
  66919. /**
  66920. * The strenght of the force in correspondence to the distance of the affected object
  66921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66922. */
  66923. export enum PhysicsRadialImpulseFalloff {
  66924. /** Defines that impulse is constant in strength across it's whole radius */
  66925. Constant = 0,
  66926. /** Defines that impulse gets weaker if it's further from the origin */
  66927. Linear = 1
  66928. }
  66929. /**
  66930. * The strength of the force in correspondence to the distance of the affected object
  66931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66932. */
  66933. export enum PhysicsUpdraftMode {
  66934. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  66935. Center = 0,
  66936. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  66937. Perpendicular = 1
  66938. }
  66939. /**
  66940. * Interface for a physics hit data
  66941. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66942. */
  66943. export interface PhysicsHitData {
  66944. /**
  66945. * The force applied at the contact point
  66946. */
  66947. force: Vector3;
  66948. /**
  66949. * The contact point
  66950. */
  66951. contactPoint: Vector3;
  66952. /**
  66953. * The distance from the origin to the contact point
  66954. */
  66955. distanceFromOrigin: number;
  66956. }
  66957. /**
  66958. * Interface for radial explosion event data
  66959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66960. */
  66961. export interface PhysicsRadialExplosionEventData {
  66962. /**
  66963. * A sphere used for the radial explosion event
  66964. */
  66965. sphere: Mesh;
  66966. }
  66967. /**
  66968. * Interface for gravitational field event data
  66969. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66970. */
  66971. export interface PhysicsGravitationalFieldEventData {
  66972. /**
  66973. * A sphere mesh used for the gravitational field event
  66974. */
  66975. sphere: Mesh;
  66976. }
  66977. /**
  66978. * Interface for updraft event data
  66979. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66980. */
  66981. export interface PhysicsUpdraftEventData {
  66982. /**
  66983. * A cylinder used for the updraft event
  66984. */
  66985. cylinder: Mesh;
  66986. }
  66987. /**
  66988. * Interface for vortex event data
  66989. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66990. */
  66991. export interface PhysicsVortexEventData {
  66992. /**
  66993. * A cylinder used for the vortex event
  66994. */
  66995. cylinder: Mesh;
  66996. }
  66997. /**
  66998. * Interface for an affected physics impostor
  66999. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67000. */
  67001. export interface PhysicsAffectedImpostorWithData {
  67002. /**
  67003. * The impostor affected by the effect
  67004. */
  67005. impostor: PhysicsImpostor;
  67006. /**
  67007. * The data about the hit/horce from the explosion
  67008. */
  67009. hitData: PhysicsHitData;
  67010. }
  67011. }
  67012. declare module "babylonjs/Physics/Plugins/index" {
  67013. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67014. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67015. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67016. }
  67017. declare module "babylonjs/Physics/index" {
  67018. export * from "babylonjs/Physics/IPhysicsEngine";
  67019. export * from "babylonjs/Physics/physicsEngine";
  67020. export * from "babylonjs/Physics/physicsEngineComponent";
  67021. export * from "babylonjs/Physics/physicsHelper";
  67022. export * from "babylonjs/Physics/physicsImpostor";
  67023. export * from "babylonjs/Physics/physicsJoint";
  67024. export * from "babylonjs/Physics/Plugins/index";
  67025. }
  67026. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67027. /** @hidden */
  67028. export var blackAndWhitePixelShader: {
  67029. name: string;
  67030. shader: string;
  67031. };
  67032. }
  67033. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67034. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67035. import { Camera } from "babylonjs/Cameras/camera";
  67036. import { Engine } from "babylonjs/Engines/engine";
  67037. import "babylonjs/Shaders/blackAndWhite.fragment";
  67038. /**
  67039. * Post process used to render in black and white
  67040. */
  67041. export class BlackAndWhitePostProcess extends PostProcess {
  67042. /**
  67043. * Linear about to convert he result to black and white (default: 1)
  67044. */
  67045. degree: number;
  67046. /**
  67047. * Creates a black and white post process
  67048. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67049. * @param name The name of the effect.
  67050. * @param options The required width/height ratio to downsize to before computing the render pass.
  67051. * @param camera The camera to apply the render pass to.
  67052. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67053. * @param engine The engine which the post process will be applied. (default: current engine)
  67054. * @param reusable If the post process can be reused on the same frame. (default: false)
  67055. */
  67056. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67057. }
  67058. }
  67059. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67060. import { Nullable } from "babylonjs/types";
  67061. import { Camera } from "babylonjs/Cameras/camera";
  67062. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67063. import { Engine } from "babylonjs/Engines/engine";
  67064. /**
  67065. * This represents a set of one or more post processes in Babylon.
  67066. * A post process can be used to apply a shader to a texture after it is rendered.
  67067. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67068. */
  67069. export class PostProcessRenderEffect {
  67070. private _postProcesses;
  67071. private _getPostProcesses;
  67072. private _singleInstance;
  67073. private _cameras;
  67074. private _indicesForCamera;
  67075. /**
  67076. * Name of the effect
  67077. * @hidden
  67078. */
  67079. _name: string;
  67080. /**
  67081. * Instantiates a post process render effect.
  67082. * A post process can be used to apply a shader to a texture after it is rendered.
  67083. * @param engine The engine the effect is tied to
  67084. * @param name The name of the effect
  67085. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67086. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67087. */
  67088. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67089. /**
  67090. * Checks if all the post processes in the effect are supported.
  67091. */
  67092. get isSupported(): boolean;
  67093. /**
  67094. * Updates the current state of the effect
  67095. * @hidden
  67096. */
  67097. _update(): void;
  67098. /**
  67099. * Attaches the effect on cameras
  67100. * @param cameras The camera to attach to.
  67101. * @hidden
  67102. */
  67103. _attachCameras(cameras: Camera): void;
  67104. /**
  67105. * Attaches the effect on cameras
  67106. * @param cameras The camera to attach to.
  67107. * @hidden
  67108. */
  67109. _attachCameras(cameras: Camera[]): void;
  67110. /**
  67111. * Detaches the effect on cameras
  67112. * @param cameras The camera to detatch from.
  67113. * @hidden
  67114. */
  67115. _detachCameras(cameras: Camera): void;
  67116. /**
  67117. * Detatches the effect on cameras
  67118. * @param cameras The camera to detatch from.
  67119. * @hidden
  67120. */
  67121. _detachCameras(cameras: Camera[]): void;
  67122. /**
  67123. * Enables the effect on given cameras
  67124. * @param cameras The camera to enable.
  67125. * @hidden
  67126. */
  67127. _enable(cameras: Camera): void;
  67128. /**
  67129. * Enables the effect on given cameras
  67130. * @param cameras The camera to enable.
  67131. * @hidden
  67132. */
  67133. _enable(cameras: Nullable<Camera[]>): void;
  67134. /**
  67135. * Disables the effect on the given cameras
  67136. * @param cameras The camera to disable.
  67137. * @hidden
  67138. */
  67139. _disable(cameras: Camera): void;
  67140. /**
  67141. * Disables the effect on the given cameras
  67142. * @param cameras The camera to disable.
  67143. * @hidden
  67144. */
  67145. _disable(cameras: Nullable<Camera[]>): void;
  67146. /**
  67147. * Gets a list of the post processes contained in the effect.
  67148. * @param camera The camera to get the post processes on.
  67149. * @returns The list of the post processes in the effect.
  67150. */
  67151. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67152. }
  67153. }
  67154. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67155. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67156. /** @hidden */
  67157. export var extractHighlightsPixelShader: {
  67158. name: string;
  67159. shader: string;
  67160. };
  67161. }
  67162. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67163. import { Nullable } from "babylonjs/types";
  67164. import { Camera } from "babylonjs/Cameras/camera";
  67165. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67166. import { Engine } from "babylonjs/Engines/engine";
  67167. import "babylonjs/Shaders/extractHighlights.fragment";
  67168. /**
  67169. * 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.
  67170. */
  67171. export class ExtractHighlightsPostProcess extends PostProcess {
  67172. /**
  67173. * The luminance threshold, pixels below this value will be set to black.
  67174. */
  67175. threshold: number;
  67176. /** @hidden */
  67177. _exposure: number;
  67178. /**
  67179. * Post process which has the input texture to be used when performing highlight extraction
  67180. * @hidden
  67181. */
  67182. _inputPostProcess: Nullable<PostProcess>;
  67183. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67184. }
  67185. }
  67186. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67187. /** @hidden */
  67188. export var bloomMergePixelShader: {
  67189. name: string;
  67190. shader: string;
  67191. };
  67192. }
  67193. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67194. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67195. import { Nullable } from "babylonjs/types";
  67196. import { Engine } from "babylonjs/Engines/engine";
  67197. import { Camera } from "babylonjs/Cameras/camera";
  67198. import "babylonjs/Shaders/bloomMerge.fragment";
  67199. /**
  67200. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67201. */
  67202. export class BloomMergePostProcess extends PostProcess {
  67203. /** Weight of the bloom to be added to the original input. */
  67204. weight: number;
  67205. /**
  67206. * Creates a new instance of @see BloomMergePostProcess
  67207. * @param name The name of the effect.
  67208. * @param originalFromInput Post process which's input will be used for the merge.
  67209. * @param blurred Blurred highlights post process which's output will be used.
  67210. * @param weight Weight of the bloom to be added to the original input.
  67211. * @param options The required width/height ratio to downsize to before computing the render pass.
  67212. * @param camera The camera to apply the render pass to.
  67213. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67214. * @param engine The engine which the post process will be applied. (default: current engine)
  67215. * @param reusable If the post process can be reused on the same frame. (default: false)
  67216. * @param textureType Type of textures used when performing the post process. (default: 0)
  67217. * @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)
  67218. */
  67219. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67220. /** Weight of the bloom to be added to the original input. */
  67221. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67222. }
  67223. }
  67224. declare module "babylonjs/PostProcesses/bloomEffect" {
  67225. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67226. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67227. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67228. import { Camera } from "babylonjs/Cameras/camera";
  67229. import { Scene } from "babylonjs/scene";
  67230. /**
  67231. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67232. */
  67233. export class BloomEffect extends PostProcessRenderEffect {
  67234. private bloomScale;
  67235. /**
  67236. * @hidden Internal
  67237. */
  67238. _effects: Array<PostProcess>;
  67239. /**
  67240. * @hidden Internal
  67241. */
  67242. _downscale: ExtractHighlightsPostProcess;
  67243. private _blurX;
  67244. private _blurY;
  67245. private _merge;
  67246. /**
  67247. * The luminance threshold to find bright areas of the image to bloom.
  67248. */
  67249. get threshold(): number;
  67250. set threshold(value: number);
  67251. /**
  67252. * The strength of the bloom.
  67253. */
  67254. get weight(): number;
  67255. set weight(value: number);
  67256. /**
  67257. * Specifies the size of the bloom blur kernel, relative to the final output size
  67258. */
  67259. get kernel(): number;
  67260. set kernel(value: number);
  67261. /**
  67262. * Creates a new instance of @see BloomEffect
  67263. * @param scene The scene the effect belongs to.
  67264. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67265. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67266. * @param bloomWeight The the strength of bloom.
  67267. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67268. * @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)
  67269. */
  67270. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67271. /**
  67272. * Disposes each of the internal effects for a given camera.
  67273. * @param camera The camera to dispose the effect on.
  67274. */
  67275. disposeEffects(camera: Camera): void;
  67276. /**
  67277. * @hidden Internal
  67278. */
  67279. _updateEffects(): void;
  67280. /**
  67281. * Internal
  67282. * @returns if all the contained post processes are ready.
  67283. * @hidden
  67284. */
  67285. _isReady(): boolean;
  67286. }
  67287. }
  67288. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67289. /** @hidden */
  67290. export var chromaticAberrationPixelShader: {
  67291. name: string;
  67292. shader: string;
  67293. };
  67294. }
  67295. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67296. import { Vector2 } from "babylonjs/Maths/math.vector";
  67297. import { Nullable } from "babylonjs/types";
  67298. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67299. import { Camera } from "babylonjs/Cameras/camera";
  67300. import { Engine } from "babylonjs/Engines/engine";
  67301. import "babylonjs/Shaders/chromaticAberration.fragment";
  67302. /**
  67303. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67304. */
  67305. export class ChromaticAberrationPostProcess extends PostProcess {
  67306. /**
  67307. * The amount of seperation of rgb channels (default: 30)
  67308. */
  67309. aberrationAmount: number;
  67310. /**
  67311. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67312. */
  67313. radialIntensity: number;
  67314. /**
  67315. * 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))
  67316. */
  67317. direction: Vector2;
  67318. /**
  67319. * 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))
  67320. */
  67321. centerPosition: Vector2;
  67322. /**
  67323. * Creates a new instance ChromaticAberrationPostProcess
  67324. * @param name The name of the effect.
  67325. * @param screenWidth The width of the screen to apply the effect on.
  67326. * @param screenHeight The height of the screen to apply the effect on.
  67327. * @param options The required width/height ratio to downsize to before computing the render pass.
  67328. * @param camera The camera to apply the render pass to.
  67329. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67330. * @param engine The engine which the post process will be applied. (default: current engine)
  67331. * @param reusable If the post process can be reused on the same frame. (default: false)
  67332. * @param textureType Type of textures used when performing the post process. (default: 0)
  67333. * @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)
  67334. */
  67335. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67336. }
  67337. }
  67338. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67339. /** @hidden */
  67340. export var circleOfConfusionPixelShader: {
  67341. name: string;
  67342. shader: string;
  67343. };
  67344. }
  67345. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67346. import { Nullable } from "babylonjs/types";
  67347. import { Engine } from "babylonjs/Engines/engine";
  67348. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67349. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67350. import { Camera } from "babylonjs/Cameras/camera";
  67351. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67352. /**
  67353. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67354. */
  67355. export class CircleOfConfusionPostProcess extends PostProcess {
  67356. /**
  67357. * 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.
  67358. */
  67359. lensSize: number;
  67360. /**
  67361. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67362. */
  67363. fStop: number;
  67364. /**
  67365. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67366. */
  67367. focusDistance: number;
  67368. /**
  67369. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67370. */
  67371. focalLength: number;
  67372. private _depthTexture;
  67373. /**
  67374. * Creates a new instance CircleOfConfusionPostProcess
  67375. * @param name The name of the effect.
  67376. * @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.
  67377. * @param options The required width/height ratio to downsize to before computing the render pass.
  67378. * @param camera The camera to apply the render pass to.
  67379. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67380. * @param engine The engine which the post process will be applied. (default: current engine)
  67381. * @param reusable If the post process can be reused on the same frame. (default: false)
  67382. * @param textureType Type of textures used when performing the post process. (default: 0)
  67383. * @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)
  67384. */
  67385. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67386. /**
  67387. * 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.
  67388. */
  67389. set depthTexture(value: RenderTargetTexture);
  67390. }
  67391. }
  67392. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67393. /** @hidden */
  67394. export var colorCorrectionPixelShader: {
  67395. name: string;
  67396. shader: string;
  67397. };
  67398. }
  67399. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67400. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67401. import { Engine } from "babylonjs/Engines/engine";
  67402. import { Camera } from "babylonjs/Cameras/camera";
  67403. import "babylonjs/Shaders/colorCorrection.fragment";
  67404. /**
  67405. *
  67406. * This post-process allows the modification of rendered colors by using
  67407. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67408. *
  67409. * The object needs to be provided an url to a texture containing the color
  67410. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67411. * Use an image editing software to tweak the LUT to match your needs.
  67412. *
  67413. * For an example of a color LUT, see here:
  67414. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67415. * For explanations on color grading, see here:
  67416. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67417. *
  67418. */
  67419. export class ColorCorrectionPostProcess extends PostProcess {
  67420. private _colorTableTexture;
  67421. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67422. }
  67423. }
  67424. declare module "babylonjs/Shaders/convolution.fragment" {
  67425. /** @hidden */
  67426. export var convolutionPixelShader: {
  67427. name: string;
  67428. shader: string;
  67429. };
  67430. }
  67431. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67432. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67433. import { Nullable } from "babylonjs/types";
  67434. import { Camera } from "babylonjs/Cameras/camera";
  67435. import { Engine } from "babylonjs/Engines/engine";
  67436. import "babylonjs/Shaders/convolution.fragment";
  67437. /**
  67438. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67439. * input texture to perform effects such as edge detection or sharpening
  67440. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67441. */
  67442. export class ConvolutionPostProcess extends PostProcess {
  67443. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67444. kernel: number[];
  67445. /**
  67446. * Creates a new instance ConvolutionPostProcess
  67447. * @param name The name of the effect.
  67448. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67449. * @param options The required width/height ratio to downsize to before computing the render pass.
  67450. * @param camera The camera to apply the render pass to.
  67451. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67452. * @param engine The engine which the post process will be applied. (default: current engine)
  67453. * @param reusable If the post process can be reused on the same frame. (default: false)
  67454. * @param textureType Type of textures used when performing the post process. (default: 0)
  67455. */
  67456. constructor(name: string,
  67457. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67458. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67459. /**
  67460. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67461. */
  67462. static EdgeDetect0Kernel: number[];
  67463. /**
  67464. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67465. */
  67466. static EdgeDetect1Kernel: number[];
  67467. /**
  67468. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67469. */
  67470. static EdgeDetect2Kernel: number[];
  67471. /**
  67472. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67473. */
  67474. static SharpenKernel: number[];
  67475. /**
  67476. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67477. */
  67478. static EmbossKernel: number[];
  67479. /**
  67480. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67481. */
  67482. static GaussianKernel: number[];
  67483. }
  67484. }
  67485. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67486. import { Nullable } from "babylonjs/types";
  67487. import { Vector2 } from "babylonjs/Maths/math.vector";
  67488. import { Camera } from "babylonjs/Cameras/camera";
  67489. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67490. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67491. import { Engine } from "babylonjs/Engines/engine";
  67492. import { Scene } from "babylonjs/scene";
  67493. /**
  67494. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67495. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67496. * based on samples that have a large difference in distance than the center pixel.
  67497. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67498. */
  67499. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67500. direction: Vector2;
  67501. /**
  67502. * Creates a new instance CircleOfConfusionPostProcess
  67503. * @param name The name of the effect.
  67504. * @param scene The scene the effect belongs to.
  67505. * @param direction The direction the blur should be applied.
  67506. * @param kernel The size of the kernel used to blur.
  67507. * @param options The required width/height ratio to downsize to before computing the render pass.
  67508. * @param camera The camera to apply the render pass to.
  67509. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67510. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67511. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67512. * @param engine The engine which the post process will be applied. (default: current engine)
  67513. * @param reusable If the post process can be reused on the same frame. (default: false)
  67514. * @param textureType Type of textures used when performing the post process. (default: 0)
  67515. * @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)
  67516. */
  67517. 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);
  67518. }
  67519. }
  67520. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67521. /** @hidden */
  67522. export var depthOfFieldMergePixelShader: {
  67523. name: string;
  67524. shader: string;
  67525. };
  67526. }
  67527. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67528. import { Nullable } from "babylonjs/types";
  67529. import { Camera } from "babylonjs/Cameras/camera";
  67530. import { Effect } from "babylonjs/Materials/effect";
  67531. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67532. import { Engine } from "babylonjs/Engines/engine";
  67533. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67534. /**
  67535. * Options to be set when merging outputs from the default pipeline.
  67536. */
  67537. export class DepthOfFieldMergePostProcessOptions {
  67538. /**
  67539. * The original image to merge on top of
  67540. */
  67541. originalFromInput: PostProcess;
  67542. /**
  67543. * Parameters to perform the merge of the depth of field effect
  67544. */
  67545. depthOfField?: {
  67546. circleOfConfusion: PostProcess;
  67547. blurSteps: Array<PostProcess>;
  67548. };
  67549. /**
  67550. * Parameters to perform the merge of bloom effect
  67551. */
  67552. bloom?: {
  67553. blurred: PostProcess;
  67554. weight: number;
  67555. };
  67556. }
  67557. /**
  67558. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67559. */
  67560. export class DepthOfFieldMergePostProcess extends PostProcess {
  67561. private blurSteps;
  67562. /**
  67563. * Creates a new instance of DepthOfFieldMergePostProcess
  67564. * @param name The name of the effect.
  67565. * @param originalFromInput Post process which's input will be used for the merge.
  67566. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67567. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67568. * @param options The required width/height ratio to downsize to before computing the render pass.
  67569. * @param camera The camera to apply the render pass to.
  67570. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67571. * @param engine The engine which the post process will be applied. (default: current engine)
  67572. * @param reusable If the post process can be reused on the same frame. (default: false)
  67573. * @param textureType Type of textures used when performing the post process. (default: 0)
  67574. * @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)
  67575. */
  67576. 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);
  67577. /**
  67578. * Updates the effect with the current post process compile time values and recompiles the shader.
  67579. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67580. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67581. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67582. * @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
  67583. * @param onCompiled Called when the shader has been compiled.
  67584. * @param onError Called if there is an error when compiling a shader.
  67585. */
  67586. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67587. }
  67588. }
  67589. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67590. import { Nullable } from "babylonjs/types";
  67591. import { Camera } from "babylonjs/Cameras/camera";
  67592. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67593. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67594. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67595. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67596. import { Scene } from "babylonjs/scene";
  67597. /**
  67598. * Specifies the level of max blur that should be applied when using the depth of field effect
  67599. */
  67600. export enum DepthOfFieldEffectBlurLevel {
  67601. /**
  67602. * Subtle blur
  67603. */
  67604. Low = 0,
  67605. /**
  67606. * Medium blur
  67607. */
  67608. Medium = 1,
  67609. /**
  67610. * Large blur
  67611. */
  67612. High = 2
  67613. }
  67614. /**
  67615. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67616. */
  67617. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67618. private _circleOfConfusion;
  67619. /**
  67620. * @hidden Internal, blurs from high to low
  67621. */
  67622. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67623. private _depthOfFieldBlurY;
  67624. private _dofMerge;
  67625. /**
  67626. * @hidden Internal post processes in depth of field effect
  67627. */
  67628. _effects: Array<PostProcess>;
  67629. /**
  67630. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67631. */
  67632. set focalLength(value: number);
  67633. get focalLength(): number;
  67634. /**
  67635. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67636. */
  67637. set fStop(value: number);
  67638. get fStop(): number;
  67639. /**
  67640. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67641. */
  67642. set focusDistance(value: number);
  67643. get focusDistance(): number;
  67644. /**
  67645. * 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.
  67646. */
  67647. set lensSize(value: number);
  67648. get lensSize(): number;
  67649. /**
  67650. * Creates a new instance DepthOfFieldEffect
  67651. * @param scene The scene the effect belongs to.
  67652. * @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.
  67653. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67654. * @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)
  67655. */
  67656. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67657. /**
  67658. * Get the current class name of the current effet
  67659. * @returns "DepthOfFieldEffect"
  67660. */
  67661. getClassName(): string;
  67662. /**
  67663. * 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.
  67664. */
  67665. set depthTexture(value: RenderTargetTexture);
  67666. /**
  67667. * Disposes each of the internal effects for a given camera.
  67668. * @param camera The camera to dispose the effect on.
  67669. */
  67670. disposeEffects(camera: Camera): void;
  67671. /**
  67672. * @hidden Internal
  67673. */
  67674. _updateEffects(): void;
  67675. /**
  67676. * Internal
  67677. * @returns if all the contained post processes are ready.
  67678. * @hidden
  67679. */
  67680. _isReady(): boolean;
  67681. }
  67682. }
  67683. declare module "babylonjs/Shaders/displayPass.fragment" {
  67684. /** @hidden */
  67685. export var displayPassPixelShader: {
  67686. name: string;
  67687. shader: string;
  67688. };
  67689. }
  67690. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  67691. import { Nullable } from "babylonjs/types";
  67692. import { Camera } from "babylonjs/Cameras/camera";
  67693. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67694. import { Engine } from "babylonjs/Engines/engine";
  67695. import "babylonjs/Shaders/displayPass.fragment";
  67696. /**
  67697. * DisplayPassPostProcess which produces an output the same as it's input
  67698. */
  67699. export class DisplayPassPostProcess extends PostProcess {
  67700. /**
  67701. * Creates the DisplayPassPostProcess
  67702. * @param name The name of the effect.
  67703. * @param options The required width/height ratio to downsize to before computing the render pass.
  67704. * @param camera The camera to apply the render pass to.
  67705. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67706. * @param engine The engine which the post process will be applied. (default: current engine)
  67707. * @param reusable If the post process can be reused on the same frame. (default: false)
  67708. */
  67709. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67710. }
  67711. }
  67712. declare module "babylonjs/Shaders/filter.fragment" {
  67713. /** @hidden */
  67714. export var filterPixelShader: {
  67715. name: string;
  67716. shader: string;
  67717. };
  67718. }
  67719. declare module "babylonjs/PostProcesses/filterPostProcess" {
  67720. import { Nullable } from "babylonjs/types";
  67721. import { Matrix } from "babylonjs/Maths/math.vector";
  67722. import { Camera } from "babylonjs/Cameras/camera";
  67723. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67724. import { Engine } from "babylonjs/Engines/engine";
  67725. import "babylonjs/Shaders/filter.fragment";
  67726. /**
  67727. * Applies a kernel filter to the image
  67728. */
  67729. export class FilterPostProcess extends PostProcess {
  67730. /** The matrix to be applied to the image */
  67731. kernelMatrix: Matrix;
  67732. /**
  67733. *
  67734. * @param name The name of the effect.
  67735. * @param kernelMatrix The matrix to be applied to the image
  67736. * @param options The required width/height ratio to downsize to before computing the render pass.
  67737. * @param camera The camera to apply the render pass to.
  67738. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67739. * @param engine The engine which the post process will be applied. (default: current engine)
  67740. * @param reusable If the post process can be reused on the same frame. (default: false)
  67741. */
  67742. constructor(name: string,
  67743. /** The matrix to be applied to the image */
  67744. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67745. }
  67746. }
  67747. declare module "babylonjs/Shaders/fxaa.fragment" {
  67748. /** @hidden */
  67749. export var fxaaPixelShader: {
  67750. name: string;
  67751. shader: string;
  67752. };
  67753. }
  67754. declare module "babylonjs/Shaders/fxaa.vertex" {
  67755. /** @hidden */
  67756. export var fxaaVertexShader: {
  67757. name: string;
  67758. shader: string;
  67759. };
  67760. }
  67761. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  67762. import { Nullable } from "babylonjs/types";
  67763. import { Camera } from "babylonjs/Cameras/camera";
  67764. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67765. import { Engine } from "babylonjs/Engines/engine";
  67766. import "babylonjs/Shaders/fxaa.fragment";
  67767. import "babylonjs/Shaders/fxaa.vertex";
  67768. /**
  67769. * Fxaa post process
  67770. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67771. */
  67772. export class FxaaPostProcess extends PostProcess {
  67773. /** @hidden */
  67774. texelWidth: number;
  67775. /** @hidden */
  67776. texelHeight: number;
  67777. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67778. private _getDefines;
  67779. }
  67780. }
  67781. declare module "babylonjs/Shaders/grain.fragment" {
  67782. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67783. /** @hidden */
  67784. export var grainPixelShader: {
  67785. name: string;
  67786. shader: string;
  67787. };
  67788. }
  67789. declare module "babylonjs/PostProcesses/grainPostProcess" {
  67790. import { Nullable } from "babylonjs/types";
  67791. import { Camera } from "babylonjs/Cameras/camera";
  67792. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67793. import { Engine } from "babylonjs/Engines/engine";
  67794. import "babylonjs/Shaders/grain.fragment";
  67795. /**
  67796. * The GrainPostProcess adds noise to the image at mid luminance levels
  67797. */
  67798. export class GrainPostProcess extends PostProcess {
  67799. /**
  67800. * The intensity of the grain added (default: 30)
  67801. */
  67802. intensity: number;
  67803. /**
  67804. * If the grain should be randomized on every frame
  67805. */
  67806. animated: boolean;
  67807. /**
  67808. * Creates a new instance of @see GrainPostProcess
  67809. * @param name The name of the effect.
  67810. * @param options The required width/height ratio to downsize to before computing the render pass.
  67811. * @param camera The camera to apply the render pass to.
  67812. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67813. * @param engine The engine which the post process will be applied. (default: current engine)
  67814. * @param reusable If the post process can be reused on the same frame. (default: false)
  67815. * @param textureType Type of textures used when performing the post process. (default: 0)
  67816. * @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)
  67817. */
  67818. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67819. }
  67820. }
  67821. declare module "babylonjs/Shaders/highlights.fragment" {
  67822. /** @hidden */
  67823. export var highlightsPixelShader: {
  67824. name: string;
  67825. shader: string;
  67826. };
  67827. }
  67828. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  67829. import { Nullable } from "babylonjs/types";
  67830. import { Camera } from "babylonjs/Cameras/camera";
  67831. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67832. import { Engine } from "babylonjs/Engines/engine";
  67833. import "babylonjs/Shaders/highlights.fragment";
  67834. /**
  67835. * Extracts highlights from the image
  67836. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67837. */
  67838. export class HighlightsPostProcess extends PostProcess {
  67839. /**
  67840. * Extracts highlights from the image
  67841. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67842. * @param name The name of the effect.
  67843. * @param options The required width/height ratio to downsize to before computing the render pass.
  67844. * @param camera The camera to apply the render pass to.
  67845. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67846. * @param engine The engine which the post process will be applied. (default: current engine)
  67847. * @param reusable If the post process can be reused on the same frame. (default: false)
  67848. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67849. */
  67850. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67851. }
  67852. }
  67853. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  67854. /** @hidden */
  67855. export var mrtFragmentDeclaration: {
  67856. name: string;
  67857. shader: string;
  67858. };
  67859. }
  67860. declare module "babylonjs/Shaders/geometry.fragment" {
  67861. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  67862. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67863. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67864. /** @hidden */
  67865. export var geometryPixelShader: {
  67866. name: string;
  67867. shader: string;
  67868. };
  67869. }
  67870. declare module "babylonjs/Shaders/geometry.vertex" {
  67871. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67872. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67873. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67874. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67875. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67876. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67877. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67878. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  67879. /** @hidden */
  67880. export var geometryVertexShader: {
  67881. name: string;
  67882. shader: string;
  67883. };
  67884. }
  67885. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  67886. import { Matrix } from "babylonjs/Maths/math.vector";
  67887. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67888. import { Mesh } from "babylonjs/Meshes/mesh";
  67889. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  67890. import { Effect } from "babylonjs/Materials/effect";
  67891. import { Scene } from "babylonjs/scene";
  67892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67893. import "babylonjs/Shaders/geometry.fragment";
  67894. import "babylonjs/Shaders/geometry.vertex";
  67895. /** @hidden */
  67896. interface ISavedTransformationMatrix {
  67897. world: Matrix;
  67898. viewProjection: Matrix;
  67899. }
  67900. /**
  67901. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  67902. */
  67903. export class GeometryBufferRenderer {
  67904. /**
  67905. * Constant used to retrieve the position texture index in the G-Buffer textures array
  67906. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  67907. */
  67908. static readonly POSITION_TEXTURE_TYPE: number;
  67909. /**
  67910. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  67911. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  67912. */
  67913. static readonly VELOCITY_TEXTURE_TYPE: number;
  67914. /**
  67915. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  67916. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  67917. */
  67918. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  67919. /**
  67920. * Dictionary used to store the previous transformation matrices of each rendered mesh
  67921. * in order to compute objects velocities when enableVelocity is set to "true"
  67922. * @hidden
  67923. */
  67924. _previousTransformationMatrices: {
  67925. [index: number]: ISavedTransformationMatrix;
  67926. };
  67927. /**
  67928. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  67929. * in order to compute objects velocities when enableVelocity is set to "true"
  67930. * @hidden
  67931. */
  67932. _previousBonesTransformationMatrices: {
  67933. [index: number]: Float32Array;
  67934. };
  67935. /**
  67936. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  67937. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  67938. */
  67939. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  67940. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  67941. renderTransparentMeshes: boolean;
  67942. private _scene;
  67943. private _multiRenderTarget;
  67944. private _ratio;
  67945. private _enablePosition;
  67946. private _enableVelocity;
  67947. private _enableReflectivity;
  67948. private _positionIndex;
  67949. private _velocityIndex;
  67950. private _reflectivityIndex;
  67951. protected _effect: Effect;
  67952. protected _cachedDefines: string;
  67953. /**
  67954. * Set the render list (meshes to be rendered) used in the G buffer.
  67955. */
  67956. set renderList(meshes: Mesh[]);
  67957. /**
  67958. * Gets wether or not G buffer are supported by the running hardware.
  67959. * This requires draw buffer supports
  67960. */
  67961. get isSupported(): boolean;
  67962. /**
  67963. * Returns the index of the given texture type in the G-Buffer textures array
  67964. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  67965. * @returns the index of the given texture type in the G-Buffer textures array
  67966. */
  67967. getTextureIndex(textureType: number): number;
  67968. /**
  67969. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  67970. */
  67971. get enablePosition(): boolean;
  67972. /**
  67973. * Sets whether or not objects positions are enabled for the G buffer.
  67974. */
  67975. set enablePosition(enable: boolean);
  67976. /**
  67977. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  67978. */
  67979. get enableVelocity(): boolean;
  67980. /**
  67981. * Sets wether or not objects velocities are enabled for the G buffer.
  67982. */
  67983. set enableVelocity(enable: boolean);
  67984. /**
  67985. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  67986. */
  67987. get enableReflectivity(): boolean;
  67988. /**
  67989. * Sets wether or not objects roughness are enabled for the G buffer.
  67990. */
  67991. set enableReflectivity(enable: boolean);
  67992. /**
  67993. * Gets the scene associated with the buffer.
  67994. */
  67995. get scene(): Scene;
  67996. /**
  67997. * Gets the ratio used by the buffer during its creation.
  67998. * How big is the buffer related to the main canvas.
  67999. */
  68000. get ratio(): number;
  68001. /** @hidden */
  68002. static _SceneComponentInitialization: (scene: Scene) => void;
  68003. /**
  68004. * Creates a new G Buffer for the scene
  68005. * @param scene The scene the buffer belongs to
  68006. * @param ratio How big is the buffer related to the main canvas.
  68007. */
  68008. constructor(scene: Scene, ratio?: number);
  68009. /**
  68010. * Checks wether everything is ready to render a submesh to the G buffer.
  68011. * @param subMesh the submesh to check readiness for
  68012. * @param useInstances is the mesh drawn using instance or not
  68013. * @returns true if ready otherwise false
  68014. */
  68015. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68016. /**
  68017. * Gets the current underlying G Buffer.
  68018. * @returns the buffer
  68019. */
  68020. getGBuffer(): MultiRenderTarget;
  68021. /**
  68022. * Gets the number of samples used to render the buffer (anti aliasing).
  68023. */
  68024. get samples(): number;
  68025. /**
  68026. * Sets the number of samples used to render the buffer (anti aliasing).
  68027. */
  68028. set samples(value: number);
  68029. /**
  68030. * Disposes the renderer and frees up associated resources.
  68031. */
  68032. dispose(): void;
  68033. protected _createRenderTargets(): void;
  68034. private _copyBonesTransformationMatrices;
  68035. }
  68036. }
  68037. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68038. import { Nullable } from "babylonjs/types";
  68039. import { Scene } from "babylonjs/scene";
  68040. import { ISceneComponent } from "babylonjs/sceneComponent";
  68041. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68042. module "babylonjs/scene" {
  68043. interface Scene {
  68044. /** @hidden (Backing field) */
  68045. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68046. /**
  68047. * Gets or Sets the current geometry buffer associated to the scene.
  68048. */
  68049. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68050. /**
  68051. * Enables a GeometryBufferRender and associates it with the scene
  68052. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68053. * @returns the GeometryBufferRenderer
  68054. */
  68055. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68056. /**
  68057. * Disables the GeometryBufferRender associated with the scene
  68058. */
  68059. disableGeometryBufferRenderer(): void;
  68060. }
  68061. }
  68062. /**
  68063. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68064. * in several rendering techniques.
  68065. */
  68066. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68067. /**
  68068. * The component name helpful to identify the component in the list of scene components.
  68069. */
  68070. readonly name: string;
  68071. /**
  68072. * The scene the component belongs to.
  68073. */
  68074. scene: Scene;
  68075. /**
  68076. * Creates a new instance of the component for the given scene
  68077. * @param scene Defines the scene to register the component in
  68078. */
  68079. constructor(scene: Scene);
  68080. /**
  68081. * Registers the component in a given scene
  68082. */
  68083. register(): void;
  68084. /**
  68085. * Rebuilds the elements related to this component in case of
  68086. * context lost for instance.
  68087. */
  68088. rebuild(): void;
  68089. /**
  68090. * Disposes the component and the associated ressources
  68091. */
  68092. dispose(): void;
  68093. private _gatherRenderTargets;
  68094. }
  68095. }
  68096. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68097. /** @hidden */
  68098. export var motionBlurPixelShader: {
  68099. name: string;
  68100. shader: string;
  68101. };
  68102. }
  68103. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68104. import { Nullable } from "babylonjs/types";
  68105. import { Camera } from "babylonjs/Cameras/camera";
  68106. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68107. import { Scene } from "babylonjs/scene";
  68108. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68109. import "babylonjs/Animations/animatable";
  68110. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68111. import "babylonjs/Shaders/motionBlur.fragment";
  68112. import { Engine } from "babylonjs/Engines/engine";
  68113. /**
  68114. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68115. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68116. * As an example, all you have to do is to create the post-process:
  68117. * var mb = new BABYLON.MotionBlurPostProcess(
  68118. * 'mb', // The name of the effect.
  68119. * scene, // The scene containing the objects to blur according to their velocity.
  68120. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68121. * camera // The camera to apply the render pass to.
  68122. * );
  68123. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68124. */
  68125. export class MotionBlurPostProcess extends PostProcess {
  68126. /**
  68127. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68128. */
  68129. motionStrength: number;
  68130. /**
  68131. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68132. */
  68133. get motionBlurSamples(): number;
  68134. /**
  68135. * Sets the number of iterations to be used for motion blur quality
  68136. */
  68137. set motionBlurSamples(samples: number);
  68138. private _motionBlurSamples;
  68139. private _geometryBufferRenderer;
  68140. /**
  68141. * Creates a new instance MotionBlurPostProcess
  68142. * @param name The name of the effect.
  68143. * @param scene The scene containing the objects to blur according to their velocity.
  68144. * @param options The required width/height ratio to downsize to before computing the render pass.
  68145. * @param camera The camera to apply the render pass to.
  68146. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68147. * @param engine The engine which the post process will be applied. (default: current engine)
  68148. * @param reusable If the post process can be reused on the same frame. (default: false)
  68149. * @param textureType Type of textures used when performing the post process. (default: 0)
  68150. * @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)
  68151. */
  68152. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68153. /**
  68154. * Excludes the given skinned mesh from computing bones velocities.
  68155. * 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.
  68156. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68157. */
  68158. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68159. /**
  68160. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68161. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68162. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68163. */
  68164. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68165. /**
  68166. * Disposes the post process.
  68167. * @param camera The camera to dispose the post process on.
  68168. */
  68169. dispose(camera?: Camera): void;
  68170. }
  68171. }
  68172. declare module "babylonjs/Shaders/refraction.fragment" {
  68173. /** @hidden */
  68174. export var refractionPixelShader: {
  68175. name: string;
  68176. shader: string;
  68177. };
  68178. }
  68179. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68180. import { Color3 } from "babylonjs/Maths/math.color";
  68181. import { Camera } from "babylonjs/Cameras/camera";
  68182. import { Texture } from "babylonjs/Materials/Textures/texture";
  68183. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68184. import { Engine } from "babylonjs/Engines/engine";
  68185. import "babylonjs/Shaders/refraction.fragment";
  68186. /**
  68187. * Post process which applies a refractin texture
  68188. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68189. */
  68190. export class RefractionPostProcess extends PostProcess {
  68191. /** the base color of the refraction (used to taint the rendering) */
  68192. color: Color3;
  68193. /** simulated refraction depth */
  68194. depth: number;
  68195. /** the coefficient of the base color (0 to remove base color tainting) */
  68196. colorLevel: number;
  68197. private _refTexture;
  68198. private _ownRefractionTexture;
  68199. /**
  68200. * Gets or sets the refraction texture
  68201. * Please note that you are responsible for disposing the texture if you set it manually
  68202. */
  68203. get refractionTexture(): Texture;
  68204. set refractionTexture(value: Texture);
  68205. /**
  68206. * Initializes the RefractionPostProcess
  68207. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68208. * @param name The name of the effect.
  68209. * @param refractionTextureUrl Url of the refraction texture to use
  68210. * @param color the base color of the refraction (used to taint the rendering)
  68211. * @param depth simulated refraction depth
  68212. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68213. * @param camera The camera to apply the render pass to.
  68214. * @param options The required width/height ratio to downsize to before computing the render pass.
  68215. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68216. * @param engine The engine which the post process will be applied. (default: current engine)
  68217. * @param reusable If the post process can be reused on the same frame. (default: false)
  68218. */
  68219. constructor(name: string, refractionTextureUrl: string,
  68220. /** the base color of the refraction (used to taint the rendering) */
  68221. color: Color3,
  68222. /** simulated refraction depth */
  68223. depth: number,
  68224. /** the coefficient of the base color (0 to remove base color tainting) */
  68225. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68226. /**
  68227. * Disposes of the post process
  68228. * @param camera Camera to dispose post process on
  68229. */
  68230. dispose(camera: Camera): void;
  68231. }
  68232. }
  68233. declare module "babylonjs/Shaders/sharpen.fragment" {
  68234. /** @hidden */
  68235. export var sharpenPixelShader: {
  68236. name: string;
  68237. shader: string;
  68238. };
  68239. }
  68240. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68241. import { Nullable } from "babylonjs/types";
  68242. import { Camera } from "babylonjs/Cameras/camera";
  68243. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68244. import "babylonjs/Shaders/sharpen.fragment";
  68245. import { Engine } from "babylonjs/Engines/engine";
  68246. /**
  68247. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68248. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68249. */
  68250. export class SharpenPostProcess extends PostProcess {
  68251. /**
  68252. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68253. */
  68254. colorAmount: number;
  68255. /**
  68256. * How much sharpness should be applied (default: 0.3)
  68257. */
  68258. edgeAmount: number;
  68259. /**
  68260. * Creates a new instance ConvolutionPostProcess
  68261. * @param name The name of the effect.
  68262. * @param options The required width/height ratio to downsize to before computing the render pass.
  68263. * @param camera The camera to apply the render pass to.
  68264. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68265. * @param engine The engine which the post process will be applied. (default: current engine)
  68266. * @param reusable If the post process can be reused on the same frame. (default: false)
  68267. * @param textureType Type of textures used when performing the post process. (default: 0)
  68268. * @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)
  68269. */
  68270. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68271. }
  68272. }
  68273. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68274. import { Nullable } from "babylonjs/types";
  68275. import { Camera } from "babylonjs/Cameras/camera";
  68276. import { Engine } from "babylonjs/Engines/engine";
  68277. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68278. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68279. /**
  68280. * PostProcessRenderPipeline
  68281. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68282. */
  68283. export class PostProcessRenderPipeline {
  68284. private engine;
  68285. private _renderEffects;
  68286. private _renderEffectsForIsolatedPass;
  68287. /**
  68288. * List of inspectable custom properties (used by the Inspector)
  68289. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68290. */
  68291. inspectableCustomProperties: IInspectable[];
  68292. /**
  68293. * @hidden
  68294. */
  68295. protected _cameras: Camera[];
  68296. /** @hidden */
  68297. _name: string;
  68298. /**
  68299. * Gets pipeline name
  68300. */
  68301. get name(): string;
  68302. /** Gets the list of attached cameras */
  68303. get cameras(): Camera[];
  68304. /**
  68305. * Initializes a PostProcessRenderPipeline
  68306. * @param engine engine to add the pipeline to
  68307. * @param name name of the pipeline
  68308. */
  68309. constructor(engine: Engine, name: string);
  68310. /**
  68311. * Gets the class name
  68312. * @returns "PostProcessRenderPipeline"
  68313. */
  68314. getClassName(): string;
  68315. /**
  68316. * If all the render effects in the pipeline are supported
  68317. */
  68318. get isSupported(): boolean;
  68319. /**
  68320. * Adds an effect to the pipeline
  68321. * @param renderEffect the effect to add
  68322. */
  68323. addEffect(renderEffect: PostProcessRenderEffect): void;
  68324. /** @hidden */
  68325. _rebuild(): void;
  68326. /** @hidden */
  68327. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68328. /** @hidden */
  68329. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68330. /** @hidden */
  68331. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68332. /** @hidden */
  68333. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68334. /** @hidden */
  68335. _attachCameras(cameras: Camera, unique: boolean): void;
  68336. /** @hidden */
  68337. _attachCameras(cameras: Camera[], unique: boolean): void;
  68338. /** @hidden */
  68339. _detachCameras(cameras: Camera): void;
  68340. /** @hidden */
  68341. _detachCameras(cameras: Nullable<Camera[]>): void;
  68342. /** @hidden */
  68343. _update(): void;
  68344. /** @hidden */
  68345. _reset(): void;
  68346. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68347. /**
  68348. * Disposes of the pipeline
  68349. */
  68350. dispose(): void;
  68351. }
  68352. }
  68353. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68354. import { Camera } from "babylonjs/Cameras/camera";
  68355. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68356. /**
  68357. * PostProcessRenderPipelineManager class
  68358. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68359. */
  68360. export class PostProcessRenderPipelineManager {
  68361. private _renderPipelines;
  68362. /**
  68363. * Initializes a PostProcessRenderPipelineManager
  68364. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68365. */
  68366. constructor();
  68367. /**
  68368. * Gets the list of supported render pipelines
  68369. */
  68370. get supportedPipelines(): PostProcessRenderPipeline[];
  68371. /**
  68372. * Adds a pipeline to the manager
  68373. * @param renderPipeline The pipeline to add
  68374. */
  68375. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68376. /**
  68377. * Attaches a camera to the pipeline
  68378. * @param renderPipelineName The name of the pipeline to attach to
  68379. * @param cameras the camera to attach
  68380. * @param unique if the camera can be attached multiple times to the pipeline
  68381. */
  68382. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68383. /**
  68384. * Detaches a camera from the pipeline
  68385. * @param renderPipelineName The name of the pipeline to detach from
  68386. * @param cameras the camera to detach
  68387. */
  68388. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68389. /**
  68390. * Enables an effect by name on a pipeline
  68391. * @param renderPipelineName the name of the pipeline to enable the effect in
  68392. * @param renderEffectName the name of the effect to enable
  68393. * @param cameras the cameras that the effect should be enabled on
  68394. */
  68395. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68396. /**
  68397. * Disables an effect by name on a pipeline
  68398. * @param renderPipelineName the name of the pipeline to disable the effect in
  68399. * @param renderEffectName the name of the effect to disable
  68400. * @param cameras the cameras that the effect should be disabled on
  68401. */
  68402. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68403. /**
  68404. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68405. */
  68406. update(): void;
  68407. /** @hidden */
  68408. _rebuild(): void;
  68409. /**
  68410. * Disposes of the manager and pipelines
  68411. */
  68412. dispose(): void;
  68413. }
  68414. }
  68415. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68416. import { ISceneComponent } from "babylonjs/sceneComponent";
  68417. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68418. import { Scene } from "babylonjs/scene";
  68419. module "babylonjs/scene" {
  68420. interface Scene {
  68421. /** @hidden (Backing field) */
  68422. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68423. /**
  68424. * Gets the postprocess render pipeline manager
  68425. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68426. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68427. */
  68428. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68429. }
  68430. }
  68431. /**
  68432. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68433. */
  68434. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68435. /**
  68436. * The component name helpfull to identify the component in the list of scene components.
  68437. */
  68438. readonly name: string;
  68439. /**
  68440. * The scene the component belongs to.
  68441. */
  68442. scene: Scene;
  68443. /**
  68444. * Creates a new instance of the component for the given scene
  68445. * @param scene Defines the scene to register the component in
  68446. */
  68447. constructor(scene: Scene);
  68448. /**
  68449. * Registers the component in a given scene
  68450. */
  68451. register(): void;
  68452. /**
  68453. * Rebuilds the elements related to this component in case of
  68454. * context lost for instance.
  68455. */
  68456. rebuild(): void;
  68457. /**
  68458. * Disposes the component and the associated ressources
  68459. */
  68460. dispose(): void;
  68461. private _gatherRenderTargets;
  68462. }
  68463. }
  68464. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68465. import { Nullable } from "babylonjs/types";
  68466. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68467. import { Camera } from "babylonjs/Cameras/camera";
  68468. import { IDisposable } from "babylonjs/scene";
  68469. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68470. import { Scene } from "babylonjs/scene";
  68471. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68472. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68473. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68474. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68475. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68476. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68477. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68478. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68479. import { Animation } from "babylonjs/Animations/animation";
  68480. /**
  68481. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68482. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68483. */
  68484. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68485. private _scene;
  68486. private _camerasToBeAttached;
  68487. /**
  68488. * ID of the sharpen post process,
  68489. */
  68490. private readonly SharpenPostProcessId;
  68491. /**
  68492. * @ignore
  68493. * ID of the image processing post process;
  68494. */
  68495. readonly ImageProcessingPostProcessId: string;
  68496. /**
  68497. * @ignore
  68498. * ID of the Fast Approximate Anti-Aliasing post process;
  68499. */
  68500. readonly FxaaPostProcessId: string;
  68501. /**
  68502. * ID of the chromatic aberration post process,
  68503. */
  68504. private readonly ChromaticAberrationPostProcessId;
  68505. /**
  68506. * ID of the grain post process
  68507. */
  68508. private readonly GrainPostProcessId;
  68509. /**
  68510. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68511. */
  68512. sharpen: SharpenPostProcess;
  68513. private _sharpenEffect;
  68514. private bloom;
  68515. /**
  68516. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68517. */
  68518. depthOfField: DepthOfFieldEffect;
  68519. /**
  68520. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68521. */
  68522. fxaa: FxaaPostProcess;
  68523. /**
  68524. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68525. */
  68526. imageProcessing: ImageProcessingPostProcess;
  68527. /**
  68528. * Chromatic aberration post process which will shift rgb colors in the image
  68529. */
  68530. chromaticAberration: ChromaticAberrationPostProcess;
  68531. private _chromaticAberrationEffect;
  68532. /**
  68533. * Grain post process which add noise to the image
  68534. */
  68535. grain: GrainPostProcess;
  68536. private _grainEffect;
  68537. /**
  68538. * Glow post process which adds a glow to emissive areas of the image
  68539. */
  68540. private _glowLayer;
  68541. /**
  68542. * Animations which can be used to tweak settings over a period of time
  68543. */
  68544. animations: Animation[];
  68545. private _imageProcessingConfigurationObserver;
  68546. private _sharpenEnabled;
  68547. private _bloomEnabled;
  68548. private _depthOfFieldEnabled;
  68549. private _depthOfFieldBlurLevel;
  68550. private _fxaaEnabled;
  68551. private _imageProcessingEnabled;
  68552. private _defaultPipelineTextureType;
  68553. private _bloomScale;
  68554. private _chromaticAberrationEnabled;
  68555. private _grainEnabled;
  68556. private _buildAllowed;
  68557. /**
  68558. * Gets active scene
  68559. */
  68560. get scene(): Scene;
  68561. /**
  68562. * Enable or disable the sharpen process from the pipeline
  68563. */
  68564. set sharpenEnabled(enabled: boolean);
  68565. get sharpenEnabled(): boolean;
  68566. private _resizeObserver;
  68567. private _hardwareScaleLevel;
  68568. private _bloomKernel;
  68569. /**
  68570. * Specifies the size of the bloom blur kernel, relative to the final output size
  68571. */
  68572. get bloomKernel(): number;
  68573. set bloomKernel(value: number);
  68574. /**
  68575. * Specifies the weight of the bloom in the final rendering
  68576. */
  68577. private _bloomWeight;
  68578. /**
  68579. * Specifies the luma threshold for the area that will be blurred by the bloom
  68580. */
  68581. private _bloomThreshold;
  68582. private _hdr;
  68583. /**
  68584. * The strength of the bloom.
  68585. */
  68586. set bloomWeight(value: number);
  68587. get bloomWeight(): number;
  68588. /**
  68589. * The strength of the bloom.
  68590. */
  68591. set bloomThreshold(value: number);
  68592. get bloomThreshold(): number;
  68593. /**
  68594. * The scale of the bloom, lower value will provide better performance.
  68595. */
  68596. set bloomScale(value: number);
  68597. get bloomScale(): number;
  68598. /**
  68599. * Enable or disable the bloom from the pipeline
  68600. */
  68601. set bloomEnabled(enabled: boolean);
  68602. get bloomEnabled(): boolean;
  68603. private _rebuildBloom;
  68604. /**
  68605. * If the depth of field is enabled.
  68606. */
  68607. get depthOfFieldEnabled(): boolean;
  68608. set depthOfFieldEnabled(enabled: boolean);
  68609. /**
  68610. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68611. */
  68612. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68613. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68614. /**
  68615. * If the anti aliasing is enabled.
  68616. */
  68617. set fxaaEnabled(enabled: boolean);
  68618. get fxaaEnabled(): boolean;
  68619. private _samples;
  68620. /**
  68621. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68622. */
  68623. set samples(sampleCount: number);
  68624. get samples(): number;
  68625. /**
  68626. * If image processing is enabled.
  68627. */
  68628. set imageProcessingEnabled(enabled: boolean);
  68629. get imageProcessingEnabled(): boolean;
  68630. /**
  68631. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68632. */
  68633. set glowLayerEnabled(enabled: boolean);
  68634. get glowLayerEnabled(): boolean;
  68635. /**
  68636. * Gets the glow layer (or null if not defined)
  68637. */
  68638. get glowLayer(): Nullable<GlowLayer>;
  68639. /**
  68640. * Enable or disable the chromaticAberration process from the pipeline
  68641. */
  68642. set chromaticAberrationEnabled(enabled: boolean);
  68643. get chromaticAberrationEnabled(): boolean;
  68644. /**
  68645. * Enable or disable the grain process from the pipeline
  68646. */
  68647. set grainEnabled(enabled: boolean);
  68648. get grainEnabled(): boolean;
  68649. /**
  68650. * @constructor
  68651. * @param name - The rendering pipeline name (default: "")
  68652. * @param hdr - If high dynamic range textures should be used (default: true)
  68653. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68654. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68655. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68656. */
  68657. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68658. /**
  68659. * Get the class name
  68660. * @returns "DefaultRenderingPipeline"
  68661. */
  68662. getClassName(): string;
  68663. /**
  68664. * Force the compilation of the entire pipeline.
  68665. */
  68666. prepare(): void;
  68667. private _hasCleared;
  68668. private _prevPostProcess;
  68669. private _prevPrevPostProcess;
  68670. private _setAutoClearAndTextureSharing;
  68671. private _depthOfFieldSceneObserver;
  68672. private _buildPipeline;
  68673. private _disposePostProcesses;
  68674. /**
  68675. * Adds a camera to the pipeline
  68676. * @param camera the camera to be added
  68677. */
  68678. addCamera(camera: Camera): void;
  68679. /**
  68680. * Removes a camera from the pipeline
  68681. * @param camera the camera to remove
  68682. */
  68683. removeCamera(camera: Camera): void;
  68684. /**
  68685. * Dispose of the pipeline and stop all post processes
  68686. */
  68687. dispose(): void;
  68688. /**
  68689. * Serialize the rendering pipeline (Used when exporting)
  68690. * @returns the serialized object
  68691. */
  68692. serialize(): any;
  68693. /**
  68694. * Parse the serialized pipeline
  68695. * @param source Source pipeline.
  68696. * @param scene The scene to load the pipeline to.
  68697. * @param rootUrl The URL of the serialized pipeline.
  68698. * @returns An instantiated pipeline from the serialized object.
  68699. */
  68700. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68701. }
  68702. }
  68703. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  68704. /** @hidden */
  68705. export var lensHighlightsPixelShader: {
  68706. name: string;
  68707. shader: string;
  68708. };
  68709. }
  68710. declare module "babylonjs/Shaders/depthOfField.fragment" {
  68711. /** @hidden */
  68712. export var depthOfFieldPixelShader: {
  68713. name: string;
  68714. shader: string;
  68715. };
  68716. }
  68717. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  68718. import { Camera } from "babylonjs/Cameras/camera";
  68719. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68720. import { Scene } from "babylonjs/scene";
  68721. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68722. import "babylonjs/Shaders/chromaticAberration.fragment";
  68723. import "babylonjs/Shaders/lensHighlights.fragment";
  68724. import "babylonjs/Shaders/depthOfField.fragment";
  68725. /**
  68726. * BABYLON.JS Chromatic Aberration GLSL Shader
  68727. * Author: Olivier Guyot
  68728. * Separates very slightly R, G and B colors on the edges of the screen
  68729. * Inspired by Francois Tarlier & Martins Upitis
  68730. */
  68731. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68732. /**
  68733. * @ignore
  68734. * The chromatic aberration PostProcess id in the pipeline
  68735. */
  68736. LensChromaticAberrationEffect: string;
  68737. /**
  68738. * @ignore
  68739. * The highlights enhancing PostProcess id in the pipeline
  68740. */
  68741. HighlightsEnhancingEffect: string;
  68742. /**
  68743. * @ignore
  68744. * The depth-of-field PostProcess id in the pipeline
  68745. */
  68746. LensDepthOfFieldEffect: string;
  68747. private _scene;
  68748. private _depthTexture;
  68749. private _grainTexture;
  68750. private _chromaticAberrationPostProcess;
  68751. private _highlightsPostProcess;
  68752. private _depthOfFieldPostProcess;
  68753. private _edgeBlur;
  68754. private _grainAmount;
  68755. private _chromaticAberration;
  68756. private _distortion;
  68757. private _highlightsGain;
  68758. private _highlightsThreshold;
  68759. private _dofDistance;
  68760. private _dofAperture;
  68761. private _dofDarken;
  68762. private _dofPentagon;
  68763. private _blurNoise;
  68764. /**
  68765. * @constructor
  68766. *
  68767. * Effect parameters are as follow:
  68768. * {
  68769. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68770. * edge_blur: number; // from 0 to x (1 for realism)
  68771. * distortion: number; // from 0 to x (1 for realism)
  68772. * grain_amount: number; // from 0 to 1
  68773. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68774. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68775. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68776. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68777. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68778. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68779. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68780. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68781. * }
  68782. * Note: if an effect parameter is unset, effect is disabled
  68783. *
  68784. * @param name The rendering pipeline name
  68785. * @param parameters - An object containing all parameters (see above)
  68786. * @param scene The scene linked to this pipeline
  68787. * @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)
  68788. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68789. */
  68790. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68791. /**
  68792. * Get the class name
  68793. * @returns "LensRenderingPipeline"
  68794. */
  68795. getClassName(): string;
  68796. /**
  68797. * Gets associated scene
  68798. */
  68799. get scene(): Scene;
  68800. /**
  68801. * Gets or sets the edge blur
  68802. */
  68803. get edgeBlur(): number;
  68804. set edgeBlur(value: number);
  68805. /**
  68806. * Gets or sets the grain amount
  68807. */
  68808. get grainAmount(): number;
  68809. set grainAmount(value: number);
  68810. /**
  68811. * Gets or sets the chromatic aberration amount
  68812. */
  68813. get chromaticAberration(): number;
  68814. set chromaticAberration(value: number);
  68815. /**
  68816. * Gets or sets the depth of field aperture
  68817. */
  68818. get dofAperture(): number;
  68819. set dofAperture(value: number);
  68820. /**
  68821. * Gets or sets the edge distortion
  68822. */
  68823. get edgeDistortion(): number;
  68824. set edgeDistortion(value: number);
  68825. /**
  68826. * Gets or sets the depth of field distortion
  68827. */
  68828. get dofDistortion(): number;
  68829. set dofDistortion(value: number);
  68830. /**
  68831. * Gets or sets the darken out of focus amount
  68832. */
  68833. get darkenOutOfFocus(): number;
  68834. set darkenOutOfFocus(value: number);
  68835. /**
  68836. * Gets or sets a boolean indicating if blur noise is enabled
  68837. */
  68838. get blurNoise(): boolean;
  68839. set blurNoise(value: boolean);
  68840. /**
  68841. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68842. */
  68843. get pentagonBokeh(): boolean;
  68844. set pentagonBokeh(value: boolean);
  68845. /**
  68846. * Gets or sets the highlight grain amount
  68847. */
  68848. get highlightsGain(): number;
  68849. set highlightsGain(value: number);
  68850. /**
  68851. * Gets or sets the highlight threshold
  68852. */
  68853. get highlightsThreshold(): number;
  68854. set highlightsThreshold(value: number);
  68855. /**
  68856. * Sets the amount of blur at the edges
  68857. * @param amount blur amount
  68858. */
  68859. setEdgeBlur(amount: number): void;
  68860. /**
  68861. * Sets edge blur to 0
  68862. */
  68863. disableEdgeBlur(): void;
  68864. /**
  68865. * Sets the amout of grain
  68866. * @param amount Amount of grain
  68867. */
  68868. setGrainAmount(amount: number): void;
  68869. /**
  68870. * Set grain amount to 0
  68871. */
  68872. disableGrain(): void;
  68873. /**
  68874. * Sets the chromatic aberration amount
  68875. * @param amount amount of chromatic aberration
  68876. */
  68877. setChromaticAberration(amount: number): void;
  68878. /**
  68879. * Sets chromatic aberration amount to 0
  68880. */
  68881. disableChromaticAberration(): void;
  68882. /**
  68883. * Sets the EdgeDistortion amount
  68884. * @param amount amount of EdgeDistortion
  68885. */
  68886. setEdgeDistortion(amount: number): void;
  68887. /**
  68888. * Sets edge distortion to 0
  68889. */
  68890. disableEdgeDistortion(): void;
  68891. /**
  68892. * Sets the FocusDistance amount
  68893. * @param amount amount of FocusDistance
  68894. */
  68895. setFocusDistance(amount: number): void;
  68896. /**
  68897. * Disables depth of field
  68898. */
  68899. disableDepthOfField(): void;
  68900. /**
  68901. * Sets the Aperture amount
  68902. * @param amount amount of Aperture
  68903. */
  68904. setAperture(amount: number): void;
  68905. /**
  68906. * Sets the DarkenOutOfFocus amount
  68907. * @param amount amount of DarkenOutOfFocus
  68908. */
  68909. setDarkenOutOfFocus(amount: number): void;
  68910. private _pentagonBokehIsEnabled;
  68911. /**
  68912. * Creates a pentagon bokeh effect
  68913. */
  68914. enablePentagonBokeh(): void;
  68915. /**
  68916. * Disables the pentagon bokeh effect
  68917. */
  68918. disablePentagonBokeh(): void;
  68919. /**
  68920. * Enables noise blur
  68921. */
  68922. enableNoiseBlur(): void;
  68923. /**
  68924. * Disables noise blur
  68925. */
  68926. disableNoiseBlur(): void;
  68927. /**
  68928. * Sets the HighlightsGain amount
  68929. * @param amount amount of HighlightsGain
  68930. */
  68931. setHighlightsGain(amount: number): void;
  68932. /**
  68933. * Sets the HighlightsThreshold amount
  68934. * @param amount amount of HighlightsThreshold
  68935. */
  68936. setHighlightsThreshold(amount: number): void;
  68937. /**
  68938. * Disables highlights
  68939. */
  68940. disableHighlights(): void;
  68941. /**
  68942. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  68943. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  68944. */
  68945. dispose(disableDepthRender?: boolean): void;
  68946. private _createChromaticAberrationPostProcess;
  68947. private _createHighlightsPostProcess;
  68948. private _createDepthOfFieldPostProcess;
  68949. private _createGrainTexture;
  68950. }
  68951. }
  68952. declare module "babylonjs/Shaders/ssao2.fragment" {
  68953. /** @hidden */
  68954. export var ssao2PixelShader: {
  68955. name: string;
  68956. shader: string;
  68957. };
  68958. }
  68959. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  68960. /** @hidden */
  68961. export var ssaoCombinePixelShader: {
  68962. name: string;
  68963. shader: string;
  68964. };
  68965. }
  68966. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  68967. import { Camera } from "babylonjs/Cameras/camera";
  68968. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68969. import { Scene } from "babylonjs/scene";
  68970. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68971. import "babylonjs/Shaders/ssao2.fragment";
  68972. import "babylonjs/Shaders/ssaoCombine.fragment";
  68973. /**
  68974. * Render pipeline to produce ssao effect
  68975. */
  68976. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  68977. /**
  68978. * @ignore
  68979. * The PassPostProcess id in the pipeline that contains the original scene color
  68980. */
  68981. SSAOOriginalSceneColorEffect: string;
  68982. /**
  68983. * @ignore
  68984. * The SSAO PostProcess id in the pipeline
  68985. */
  68986. SSAORenderEffect: string;
  68987. /**
  68988. * @ignore
  68989. * The horizontal blur PostProcess id in the pipeline
  68990. */
  68991. SSAOBlurHRenderEffect: string;
  68992. /**
  68993. * @ignore
  68994. * The vertical blur PostProcess id in the pipeline
  68995. */
  68996. SSAOBlurVRenderEffect: string;
  68997. /**
  68998. * @ignore
  68999. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69000. */
  69001. SSAOCombineRenderEffect: string;
  69002. /**
  69003. * The output strength of the SSAO post-process. Default value is 1.0.
  69004. */
  69005. totalStrength: number;
  69006. /**
  69007. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69008. */
  69009. maxZ: number;
  69010. /**
  69011. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69012. */
  69013. minZAspect: number;
  69014. private _samples;
  69015. /**
  69016. * Number of samples used for the SSAO calculations. Default value is 8
  69017. */
  69018. set samples(n: number);
  69019. get samples(): number;
  69020. private _textureSamples;
  69021. /**
  69022. * Number of samples to use for antialiasing
  69023. */
  69024. set textureSamples(n: number);
  69025. get textureSamples(): number;
  69026. /**
  69027. * Ratio object used for SSAO ratio and blur ratio
  69028. */
  69029. private _ratio;
  69030. /**
  69031. * Dynamically generated sphere sampler.
  69032. */
  69033. private _sampleSphere;
  69034. /**
  69035. * Blur filter offsets
  69036. */
  69037. private _samplerOffsets;
  69038. private _expensiveBlur;
  69039. /**
  69040. * If bilateral blur should be used
  69041. */
  69042. set expensiveBlur(b: boolean);
  69043. get expensiveBlur(): boolean;
  69044. /**
  69045. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69046. */
  69047. radius: number;
  69048. /**
  69049. * The base color of the SSAO post-process
  69050. * The final result is "base + ssao" between [0, 1]
  69051. */
  69052. base: number;
  69053. /**
  69054. * Support test.
  69055. */
  69056. static get IsSupported(): boolean;
  69057. private _scene;
  69058. private _depthTexture;
  69059. private _normalTexture;
  69060. private _randomTexture;
  69061. private _originalColorPostProcess;
  69062. private _ssaoPostProcess;
  69063. private _blurHPostProcess;
  69064. private _blurVPostProcess;
  69065. private _ssaoCombinePostProcess;
  69066. /**
  69067. * Gets active scene
  69068. */
  69069. get scene(): Scene;
  69070. /**
  69071. * @constructor
  69072. * @param name The rendering pipeline name
  69073. * @param scene The scene linked to this pipeline
  69074. * @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 }
  69075. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69076. */
  69077. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69078. /**
  69079. * Get the class name
  69080. * @returns "SSAO2RenderingPipeline"
  69081. */
  69082. getClassName(): string;
  69083. /**
  69084. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69085. */
  69086. dispose(disableGeometryBufferRenderer?: boolean): void;
  69087. private _createBlurPostProcess;
  69088. /** @hidden */
  69089. _rebuild(): void;
  69090. private _bits;
  69091. private _radicalInverse_VdC;
  69092. private _hammersley;
  69093. private _hemisphereSample_uniform;
  69094. private _generateHemisphere;
  69095. private _createSSAOPostProcess;
  69096. private _createSSAOCombinePostProcess;
  69097. private _createRandomTexture;
  69098. /**
  69099. * Serialize the rendering pipeline (Used when exporting)
  69100. * @returns the serialized object
  69101. */
  69102. serialize(): any;
  69103. /**
  69104. * Parse the serialized pipeline
  69105. * @param source Source pipeline.
  69106. * @param scene The scene to load the pipeline to.
  69107. * @param rootUrl The URL of the serialized pipeline.
  69108. * @returns An instantiated pipeline from the serialized object.
  69109. */
  69110. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69111. }
  69112. }
  69113. declare module "babylonjs/Shaders/ssao.fragment" {
  69114. /** @hidden */
  69115. export var ssaoPixelShader: {
  69116. name: string;
  69117. shader: string;
  69118. };
  69119. }
  69120. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69121. import { Camera } from "babylonjs/Cameras/camera";
  69122. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69123. import { Scene } from "babylonjs/scene";
  69124. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69125. import "babylonjs/Shaders/ssao.fragment";
  69126. import "babylonjs/Shaders/ssaoCombine.fragment";
  69127. /**
  69128. * Render pipeline to produce ssao effect
  69129. */
  69130. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69131. /**
  69132. * @ignore
  69133. * The PassPostProcess id in the pipeline that contains the original scene color
  69134. */
  69135. SSAOOriginalSceneColorEffect: string;
  69136. /**
  69137. * @ignore
  69138. * The SSAO PostProcess id in the pipeline
  69139. */
  69140. SSAORenderEffect: string;
  69141. /**
  69142. * @ignore
  69143. * The horizontal blur PostProcess id in the pipeline
  69144. */
  69145. SSAOBlurHRenderEffect: string;
  69146. /**
  69147. * @ignore
  69148. * The vertical blur PostProcess id in the pipeline
  69149. */
  69150. SSAOBlurVRenderEffect: string;
  69151. /**
  69152. * @ignore
  69153. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69154. */
  69155. SSAOCombineRenderEffect: string;
  69156. /**
  69157. * The output strength of the SSAO post-process. Default value is 1.0.
  69158. */
  69159. totalStrength: number;
  69160. /**
  69161. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69162. */
  69163. radius: number;
  69164. /**
  69165. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69166. * Must not be equal to fallOff and superior to fallOff.
  69167. * Default value is 0.0075
  69168. */
  69169. area: number;
  69170. /**
  69171. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69172. * Must not be equal to area and inferior to area.
  69173. * Default value is 0.000001
  69174. */
  69175. fallOff: number;
  69176. /**
  69177. * The base color of the SSAO post-process
  69178. * The final result is "base + ssao" between [0, 1]
  69179. */
  69180. base: number;
  69181. private _scene;
  69182. private _depthTexture;
  69183. private _randomTexture;
  69184. private _originalColorPostProcess;
  69185. private _ssaoPostProcess;
  69186. private _blurHPostProcess;
  69187. private _blurVPostProcess;
  69188. private _ssaoCombinePostProcess;
  69189. private _firstUpdate;
  69190. /**
  69191. * Gets active scene
  69192. */
  69193. get scene(): Scene;
  69194. /**
  69195. * @constructor
  69196. * @param name - The rendering pipeline name
  69197. * @param scene - The scene linked to this pipeline
  69198. * @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 }
  69199. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69200. */
  69201. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69202. /**
  69203. * Get the class name
  69204. * @returns "SSAORenderingPipeline"
  69205. */
  69206. getClassName(): string;
  69207. /**
  69208. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69209. */
  69210. dispose(disableDepthRender?: boolean): void;
  69211. private _createBlurPostProcess;
  69212. /** @hidden */
  69213. _rebuild(): void;
  69214. private _createSSAOPostProcess;
  69215. private _createSSAOCombinePostProcess;
  69216. private _createRandomTexture;
  69217. }
  69218. }
  69219. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  69220. /** @hidden */
  69221. export var screenSpaceReflectionPixelShader: {
  69222. name: string;
  69223. shader: string;
  69224. };
  69225. }
  69226. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  69227. import { Nullable } from "babylonjs/types";
  69228. import { Camera } from "babylonjs/Cameras/camera";
  69229. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69230. import { Scene } from "babylonjs/scene";
  69231. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  69232. import { Engine } from "babylonjs/Engines/engine";
  69233. /**
  69234. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69235. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69236. */
  69237. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69238. /**
  69239. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69240. */
  69241. threshold: number;
  69242. /**
  69243. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69244. */
  69245. strength: number;
  69246. /**
  69247. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69248. */
  69249. reflectionSpecularFalloffExponent: number;
  69250. /**
  69251. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  69252. */
  69253. step: number;
  69254. /**
  69255. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69256. */
  69257. roughnessFactor: number;
  69258. private _geometryBufferRenderer;
  69259. private _enableSmoothReflections;
  69260. private _reflectionSamples;
  69261. private _smoothSteps;
  69262. /**
  69263. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69264. * @param name The name of the effect.
  69265. * @param scene The scene containing the objects to calculate reflections.
  69266. * @param options The required width/height ratio to downsize to before computing the render pass.
  69267. * @param camera The camera to apply the render pass to.
  69268. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69269. * @param engine The engine which the post process will be applied. (default: current engine)
  69270. * @param reusable If the post process can be reused on the same frame. (default: false)
  69271. * @param textureType Type of textures used when performing the post process. (default: 0)
  69272. * @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)
  69273. */
  69274. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69275. /**
  69276. * Gets wether or not smoothing reflections is enabled.
  69277. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69278. */
  69279. get enableSmoothReflections(): boolean;
  69280. /**
  69281. * Sets wether or not smoothing reflections is enabled.
  69282. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69283. */
  69284. set enableSmoothReflections(enabled: boolean);
  69285. /**
  69286. * Gets the number of samples taken while computing reflections. More samples count is high,
  69287. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69288. */
  69289. get reflectionSamples(): number;
  69290. /**
  69291. * Sets the number of samples taken while computing reflections. More samples count is high,
  69292. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69293. */
  69294. set reflectionSamples(samples: number);
  69295. /**
  69296. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69297. * more the post-process will require GPU power and can generate a drop in FPS.
  69298. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69299. */
  69300. get smoothSteps(): number;
  69301. set smoothSteps(steps: number);
  69302. private _updateEffectDefines;
  69303. }
  69304. }
  69305. declare module "babylonjs/Shaders/standard.fragment" {
  69306. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69307. /** @hidden */
  69308. export var standardPixelShader: {
  69309. name: string;
  69310. shader: string;
  69311. };
  69312. }
  69313. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69314. import { Nullable } from "babylonjs/types";
  69315. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69316. import { Camera } from "babylonjs/Cameras/camera";
  69317. import { Texture } from "babylonjs/Materials/Textures/texture";
  69318. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69319. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69320. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69321. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69322. import { IDisposable } from "babylonjs/scene";
  69323. import { SpotLight } from "babylonjs/Lights/spotLight";
  69324. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69325. import { Scene } from "babylonjs/scene";
  69326. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69327. import { Animation } from "babylonjs/Animations/animation";
  69328. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69329. import "babylonjs/Shaders/standard.fragment";
  69330. /**
  69331. * Standard rendering pipeline
  69332. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69333. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69334. */
  69335. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69336. /**
  69337. * Public members
  69338. */
  69339. /**
  69340. * Post-process which contains the original scene color before the pipeline applies all the effects
  69341. */
  69342. originalPostProcess: Nullable<PostProcess>;
  69343. /**
  69344. * Post-process used to down scale an image x4
  69345. */
  69346. downSampleX4PostProcess: Nullable<PostProcess>;
  69347. /**
  69348. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69349. */
  69350. brightPassPostProcess: Nullable<PostProcess>;
  69351. /**
  69352. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69353. */
  69354. blurHPostProcesses: PostProcess[];
  69355. /**
  69356. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69357. */
  69358. blurVPostProcesses: PostProcess[];
  69359. /**
  69360. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69361. */
  69362. textureAdderPostProcess: Nullable<PostProcess>;
  69363. /**
  69364. * Post-process used to create volumetric lighting effect
  69365. */
  69366. volumetricLightPostProcess: Nullable<PostProcess>;
  69367. /**
  69368. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69369. */
  69370. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69371. /**
  69372. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69373. */
  69374. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69375. /**
  69376. * Post-process used to merge the volumetric light effect and the real scene color
  69377. */
  69378. volumetricLightMergePostProces: Nullable<PostProcess>;
  69379. /**
  69380. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69381. */
  69382. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69383. /**
  69384. * Base post-process used to calculate the average luminance of the final image for HDR
  69385. */
  69386. luminancePostProcess: Nullable<PostProcess>;
  69387. /**
  69388. * Post-processes used to create down sample post-processes in order to get
  69389. * the average luminance of the final image for HDR
  69390. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69391. */
  69392. luminanceDownSamplePostProcesses: PostProcess[];
  69393. /**
  69394. * Post-process used to create a HDR effect (light adaptation)
  69395. */
  69396. hdrPostProcess: Nullable<PostProcess>;
  69397. /**
  69398. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69399. */
  69400. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69401. /**
  69402. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69403. */
  69404. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69405. /**
  69406. * Post-process used to merge the final HDR post-process and the real scene color
  69407. */
  69408. hdrFinalPostProcess: Nullable<PostProcess>;
  69409. /**
  69410. * Post-process used to create a lens flare effect
  69411. */
  69412. lensFlarePostProcess: Nullable<PostProcess>;
  69413. /**
  69414. * Post-process that merges the result of the lens flare post-process and the real scene color
  69415. */
  69416. lensFlareComposePostProcess: Nullable<PostProcess>;
  69417. /**
  69418. * Post-process used to create a motion blur effect
  69419. */
  69420. motionBlurPostProcess: Nullable<PostProcess>;
  69421. /**
  69422. * Post-process used to create a depth of field effect
  69423. */
  69424. depthOfFieldPostProcess: Nullable<PostProcess>;
  69425. /**
  69426. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69427. */
  69428. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69429. /**
  69430. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69431. */
  69432. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69433. /**
  69434. * Represents the brightness threshold in order to configure the illuminated surfaces
  69435. */
  69436. brightThreshold: number;
  69437. /**
  69438. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69439. */
  69440. blurWidth: number;
  69441. /**
  69442. * Sets if the blur for highlighted surfaces must be only horizontal
  69443. */
  69444. horizontalBlur: boolean;
  69445. /**
  69446. * Gets the overall exposure used by the pipeline
  69447. */
  69448. get exposure(): number;
  69449. /**
  69450. * Sets the overall exposure used by the pipeline
  69451. */
  69452. set exposure(value: number);
  69453. /**
  69454. * Texture used typically to simulate "dirty" on camera lens
  69455. */
  69456. lensTexture: Nullable<Texture>;
  69457. /**
  69458. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69459. */
  69460. volumetricLightCoefficient: number;
  69461. /**
  69462. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69463. */
  69464. volumetricLightPower: number;
  69465. /**
  69466. * Used the set the blur intensity to smooth the volumetric lights
  69467. */
  69468. volumetricLightBlurScale: number;
  69469. /**
  69470. * Light (spot or directional) used to generate the volumetric lights rays
  69471. * The source light must have a shadow generate so the pipeline can get its
  69472. * depth map
  69473. */
  69474. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69475. /**
  69476. * For eye adaptation, represents the minimum luminance the eye can see
  69477. */
  69478. hdrMinimumLuminance: number;
  69479. /**
  69480. * For eye adaptation, represents the decrease luminance speed
  69481. */
  69482. hdrDecreaseRate: number;
  69483. /**
  69484. * For eye adaptation, represents the increase luminance speed
  69485. */
  69486. hdrIncreaseRate: number;
  69487. /**
  69488. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69489. */
  69490. get hdrAutoExposure(): boolean;
  69491. /**
  69492. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69493. */
  69494. set hdrAutoExposure(value: boolean);
  69495. /**
  69496. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69497. */
  69498. lensColorTexture: Nullable<Texture>;
  69499. /**
  69500. * The overall strengh for the lens flare effect
  69501. */
  69502. lensFlareStrength: number;
  69503. /**
  69504. * Dispersion coefficient for lens flare ghosts
  69505. */
  69506. lensFlareGhostDispersal: number;
  69507. /**
  69508. * Main lens flare halo width
  69509. */
  69510. lensFlareHaloWidth: number;
  69511. /**
  69512. * Based on the lens distortion effect, defines how much the lens flare result
  69513. * is distorted
  69514. */
  69515. lensFlareDistortionStrength: number;
  69516. /**
  69517. * Configures the blur intensity used for for lens flare (halo)
  69518. */
  69519. lensFlareBlurWidth: number;
  69520. /**
  69521. * Lens star texture must be used to simulate rays on the flares and is available
  69522. * in the documentation
  69523. */
  69524. lensStarTexture: Nullable<Texture>;
  69525. /**
  69526. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69527. * flare effect by taking account of the dirt texture
  69528. */
  69529. lensFlareDirtTexture: Nullable<Texture>;
  69530. /**
  69531. * Represents the focal length for the depth of field effect
  69532. */
  69533. depthOfFieldDistance: number;
  69534. /**
  69535. * Represents the blur intensity for the blurred part of the depth of field effect
  69536. */
  69537. depthOfFieldBlurWidth: number;
  69538. /**
  69539. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69540. */
  69541. get motionStrength(): number;
  69542. /**
  69543. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69544. */
  69545. set motionStrength(strength: number);
  69546. /**
  69547. * Gets wether or not the motion blur post-process is object based or screen based.
  69548. */
  69549. get objectBasedMotionBlur(): boolean;
  69550. /**
  69551. * Sets wether or not the motion blur post-process should be object based or screen based
  69552. */
  69553. set objectBasedMotionBlur(value: boolean);
  69554. /**
  69555. * List of animations for the pipeline (IAnimatable implementation)
  69556. */
  69557. animations: Animation[];
  69558. /**
  69559. * Private members
  69560. */
  69561. private _scene;
  69562. private _currentDepthOfFieldSource;
  69563. private _basePostProcess;
  69564. private _fixedExposure;
  69565. private _currentExposure;
  69566. private _hdrAutoExposure;
  69567. private _hdrCurrentLuminance;
  69568. private _motionStrength;
  69569. private _isObjectBasedMotionBlur;
  69570. private _floatTextureType;
  69571. private _camerasToBeAttached;
  69572. private _ratio;
  69573. private _bloomEnabled;
  69574. private _depthOfFieldEnabled;
  69575. private _vlsEnabled;
  69576. private _lensFlareEnabled;
  69577. private _hdrEnabled;
  69578. private _motionBlurEnabled;
  69579. private _fxaaEnabled;
  69580. private _screenSpaceReflectionsEnabled;
  69581. private _motionBlurSamples;
  69582. private _volumetricLightStepsCount;
  69583. private _samples;
  69584. /**
  69585. * @ignore
  69586. * Specifies if the bloom pipeline is enabled
  69587. */
  69588. get BloomEnabled(): boolean;
  69589. set BloomEnabled(enabled: boolean);
  69590. /**
  69591. * @ignore
  69592. * Specifies if the depth of field pipeline is enabed
  69593. */
  69594. get DepthOfFieldEnabled(): boolean;
  69595. set DepthOfFieldEnabled(enabled: boolean);
  69596. /**
  69597. * @ignore
  69598. * Specifies if the lens flare pipeline is enabed
  69599. */
  69600. get LensFlareEnabled(): boolean;
  69601. set LensFlareEnabled(enabled: boolean);
  69602. /**
  69603. * @ignore
  69604. * Specifies if the HDR pipeline is enabled
  69605. */
  69606. get HDREnabled(): boolean;
  69607. set HDREnabled(enabled: boolean);
  69608. /**
  69609. * @ignore
  69610. * Specifies if the volumetric lights scattering effect is enabled
  69611. */
  69612. get VLSEnabled(): boolean;
  69613. set VLSEnabled(enabled: boolean);
  69614. /**
  69615. * @ignore
  69616. * Specifies if the motion blur effect is enabled
  69617. */
  69618. get MotionBlurEnabled(): boolean;
  69619. set MotionBlurEnabled(enabled: boolean);
  69620. /**
  69621. * Specifies if anti-aliasing is enabled
  69622. */
  69623. get fxaaEnabled(): boolean;
  69624. set fxaaEnabled(enabled: boolean);
  69625. /**
  69626. * Specifies if screen space reflections are enabled.
  69627. */
  69628. get screenSpaceReflectionsEnabled(): boolean;
  69629. set screenSpaceReflectionsEnabled(enabled: boolean);
  69630. /**
  69631. * Specifies the number of steps used to calculate the volumetric lights
  69632. * Typically in interval [50, 200]
  69633. */
  69634. get volumetricLightStepsCount(): number;
  69635. set volumetricLightStepsCount(count: number);
  69636. /**
  69637. * Specifies the number of samples used for the motion blur effect
  69638. * Typically in interval [16, 64]
  69639. */
  69640. get motionBlurSamples(): number;
  69641. set motionBlurSamples(samples: number);
  69642. /**
  69643. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69644. */
  69645. get samples(): number;
  69646. set samples(sampleCount: number);
  69647. /**
  69648. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69649. * @constructor
  69650. * @param name The rendering pipeline name
  69651. * @param scene The scene linked to this pipeline
  69652. * @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)
  69653. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69654. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69655. */
  69656. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69657. private _buildPipeline;
  69658. private _createDownSampleX4PostProcess;
  69659. private _createBrightPassPostProcess;
  69660. private _createBlurPostProcesses;
  69661. private _createTextureAdderPostProcess;
  69662. private _createVolumetricLightPostProcess;
  69663. private _createLuminancePostProcesses;
  69664. private _createHdrPostProcess;
  69665. private _createLensFlarePostProcess;
  69666. private _createDepthOfFieldPostProcess;
  69667. private _createMotionBlurPostProcess;
  69668. private _getDepthTexture;
  69669. private _disposePostProcesses;
  69670. /**
  69671. * Dispose of the pipeline and stop all post processes
  69672. */
  69673. dispose(): void;
  69674. /**
  69675. * Serialize the rendering pipeline (Used when exporting)
  69676. * @returns the serialized object
  69677. */
  69678. serialize(): any;
  69679. /**
  69680. * Parse the serialized pipeline
  69681. * @param source Source pipeline.
  69682. * @param scene The scene to load the pipeline to.
  69683. * @param rootUrl The URL of the serialized pipeline.
  69684. * @returns An instantiated pipeline from the serialized object.
  69685. */
  69686. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69687. /**
  69688. * Luminance steps
  69689. */
  69690. static LuminanceSteps: number;
  69691. }
  69692. }
  69693. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  69694. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  69695. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  69696. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  69697. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  69698. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  69699. }
  69700. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  69701. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  69702. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69703. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69704. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69705. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69706. }
  69707. declare module "babylonjs/Shaders/tonemap.fragment" {
  69708. /** @hidden */
  69709. export var tonemapPixelShader: {
  69710. name: string;
  69711. shader: string;
  69712. };
  69713. }
  69714. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  69715. import { Camera } from "babylonjs/Cameras/camera";
  69716. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69717. import "babylonjs/Shaders/tonemap.fragment";
  69718. import { Engine } from "babylonjs/Engines/engine";
  69719. /** Defines operator used for tonemapping */
  69720. export enum TonemappingOperator {
  69721. /** Hable */
  69722. Hable = 0,
  69723. /** Reinhard */
  69724. Reinhard = 1,
  69725. /** HejiDawson */
  69726. HejiDawson = 2,
  69727. /** Photographic */
  69728. Photographic = 3
  69729. }
  69730. /**
  69731. * Defines a post process to apply tone mapping
  69732. */
  69733. export class TonemapPostProcess extends PostProcess {
  69734. private _operator;
  69735. /** Defines the required exposure adjustement */
  69736. exposureAdjustment: number;
  69737. /**
  69738. * Creates a new TonemapPostProcess
  69739. * @param name defines the name of the postprocess
  69740. * @param _operator defines the operator to use
  69741. * @param exposureAdjustment defines the required exposure adjustement
  69742. * @param camera defines the camera to use (can be null)
  69743. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69744. * @param engine defines the hosting engine (can be ignore if camera is set)
  69745. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69746. */
  69747. constructor(name: string, _operator: TonemappingOperator,
  69748. /** Defines the required exposure adjustement */
  69749. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69750. }
  69751. }
  69752. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  69753. /** @hidden */
  69754. export var volumetricLightScatteringPixelShader: {
  69755. name: string;
  69756. shader: string;
  69757. };
  69758. }
  69759. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  69760. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69761. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69762. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69763. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69764. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69765. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69766. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69767. /** @hidden */
  69768. export var volumetricLightScatteringPassVertexShader: {
  69769. name: string;
  69770. shader: string;
  69771. };
  69772. }
  69773. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  69774. /** @hidden */
  69775. export var volumetricLightScatteringPassPixelShader: {
  69776. name: string;
  69777. shader: string;
  69778. };
  69779. }
  69780. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  69781. import { Vector3 } from "babylonjs/Maths/math.vector";
  69782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69783. import { Mesh } from "babylonjs/Meshes/mesh";
  69784. import { Camera } from "babylonjs/Cameras/camera";
  69785. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69786. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69787. import { Scene } from "babylonjs/scene";
  69788. import "babylonjs/Meshes/Builders/planeBuilder";
  69789. import "babylonjs/Shaders/depth.vertex";
  69790. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  69791. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  69792. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  69793. import { Engine } from "babylonjs/Engines/engine";
  69794. /**
  69795. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69796. */
  69797. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69798. private _volumetricLightScatteringPass;
  69799. private _volumetricLightScatteringRTT;
  69800. private _viewPort;
  69801. private _screenCoordinates;
  69802. private _cachedDefines;
  69803. /**
  69804. * If not undefined, the mesh position is computed from the attached node position
  69805. */
  69806. attachedNode: {
  69807. position: Vector3;
  69808. };
  69809. /**
  69810. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69811. */
  69812. customMeshPosition: Vector3;
  69813. /**
  69814. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69815. */
  69816. useCustomMeshPosition: boolean;
  69817. /**
  69818. * If the post-process should inverse the light scattering direction
  69819. */
  69820. invert: boolean;
  69821. /**
  69822. * The internal mesh used by the post-process
  69823. */
  69824. mesh: Mesh;
  69825. /**
  69826. * @hidden
  69827. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69828. */
  69829. get useDiffuseColor(): boolean;
  69830. set useDiffuseColor(useDiffuseColor: boolean);
  69831. /**
  69832. * Array containing the excluded meshes not rendered in the internal pass
  69833. */
  69834. excludedMeshes: AbstractMesh[];
  69835. /**
  69836. * Controls the overall intensity of the post-process
  69837. */
  69838. exposure: number;
  69839. /**
  69840. * Dissipates each sample's contribution in range [0, 1]
  69841. */
  69842. decay: number;
  69843. /**
  69844. * Controls the overall intensity of each sample
  69845. */
  69846. weight: number;
  69847. /**
  69848. * Controls the density of each sample
  69849. */
  69850. density: number;
  69851. /**
  69852. * @constructor
  69853. * @param name The post-process name
  69854. * @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)
  69855. * @param camera The camera that the post-process will be attached to
  69856. * @param mesh The mesh used to create the light scattering
  69857. * @param samples The post-process quality, default 100
  69858. * @param samplingModeThe post-process filtering mode
  69859. * @param engine The babylon engine
  69860. * @param reusable If the post-process is reusable
  69861. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69862. */
  69863. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69864. /**
  69865. * Returns the string "VolumetricLightScatteringPostProcess"
  69866. * @returns "VolumetricLightScatteringPostProcess"
  69867. */
  69868. getClassName(): string;
  69869. private _isReady;
  69870. /**
  69871. * Sets the new light position for light scattering effect
  69872. * @param position The new custom light position
  69873. */
  69874. setCustomMeshPosition(position: Vector3): void;
  69875. /**
  69876. * Returns the light position for light scattering effect
  69877. * @return Vector3 The custom light position
  69878. */
  69879. getCustomMeshPosition(): Vector3;
  69880. /**
  69881. * Disposes the internal assets and detaches the post-process from the camera
  69882. */
  69883. dispose(camera: Camera): void;
  69884. /**
  69885. * Returns the render target texture used by the post-process
  69886. * @return the render target texture used by the post-process
  69887. */
  69888. getPass(): RenderTargetTexture;
  69889. private _meshExcluded;
  69890. private _createPass;
  69891. private _updateMeshScreenCoordinates;
  69892. /**
  69893. * Creates a default mesh for the Volumeric Light Scattering post-process
  69894. * @param name The mesh name
  69895. * @param scene The scene where to create the mesh
  69896. * @return the default mesh
  69897. */
  69898. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69899. }
  69900. }
  69901. declare module "babylonjs/PostProcesses/index" {
  69902. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  69903. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  69904. export * from "babylonjs/PostProcesses/bloomEffect";
  69905. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  69906. export * from "babylonjs/PostProcesses/blurPostProcess";
  69907. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  69908. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  69909. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  69910. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  69911. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  69912. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  69913. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  69914. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  69915. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  69916. export * from "babylonjs/PostProcesses/filterPostProcess";
  69917. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  69918. export * from "babylonjs/PostProcesses/grainPostProcess";
  69919. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  69920. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  69921. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  69922. export * from "babylonjs/PostProcesses/passPostProcess";
  69923. export * from "babylonjs/PostProcesses/postProcess";
  69924. export * from "babylonjs/PostProcesses/postProcessManager";
  69925. export * from "babylonjs/PostProcesses/refractionPostProcess";
  69926. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  69927. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  69928. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  69929. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  69930. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  69931. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  69932. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  69933. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69934. }
  69935. declare module "babylonjs/Probes/index" {
  69936. export * from "babylonjs/Probes/reflectionProbe";
  69937. }
  69938. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  69939. import { Scene } from "babylonjs/scene";
  69940. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69941. import { SmartArray } from "babylonjs/Misc/smartArray";
  69942. import { ISceneComponent } from "babylonjs/sceneComponent";
  69943. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  69944. import "babylonjs/Meshes/Builders/boxBuilder";
  69945. import "babylonjs/Shaders/color.fragment";
  69946. import "babylonjs/Shaders/color.vertex";
  69947. import { Color3 } from "babylonjs/Maths/math.color";
  69948. module "babylonjs/scene" {
  69949. interface Scene {
  69950. /** @hidden (Backing field) */
  69951. _boundingBoxRenderer: BoundingBoxRenderer;
  69952. /** @hidden (Backing field) */
  69953. _forceShowBoundingBoxes: boolean;
  69954. /**
  69955. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  69956. */
  69957. forceShowBoundingBoxes: boolean;
  69958. /**
  69959. * Gets the bounding box renderer associated with the scene
  69960. * @returns a BoundingBoxRenderer
  69961. */
  69962. getBoundingBoxRenderer(): BoundingBoxRenderer;
  69963. }
  69964. }
  69965. module "babylonjs/Meshes/abstractMesh" {
  69966. interface AbstractMesh {
  69967. /** @hidden (Backing field) */
  69968. _showBoundingBox: boolean;
  69969. /**
  69970. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  69971. */
  69972. showBoundingBox: boolean;
  69973. }
  69974. }
  69975. /**
  69976. * Component responsible of rendering the bounding box of the meshes in a scene.
  69977. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  69978. */
  69979. export class BoundingBoxRenderer implements ISceneComponent {
  69980. /**
  69981. * The component name helpfull to identify the component in the list of scene components.
  69982. */
  69983. readonly name: string;
  69984. /**
  69985. * The scene the component belongs to.
  69986. */
  69987. scene: Scene;
  69988. /**
  69989. * Color of the bounding box lines placed in front of an object
  69990. */
  69991. frontColor: Color3;
  69992. /**
  69993. * Color of the bounding box lines placed behind an object
  69994. */
  69995. backColor: Color3;
  69996. /**
  69997. * Defines if the renderer should show the back lines or not
  69998. */
  69999. showBackLines: boolean;
  70000. /**
  70001. * @hidden
  70002. */
  70003. renderList: SmartArray<BoundingBox>;
  70004. private _colorShader;
  70005. private _vertexBuffers;
  70006. private _indexBuffer;
  70007. private _fillIndexBuffer;
  70008. private _fillIndexData;
  70009. /**
  70010. * Instantiates a new bounding box renderer in a scene.
  70011. * @param scene the scene the renderer renders in
  70012. */
  70013. constructor(scene: Scene);
  70014. /**
  70015. * Registers the component in a given scene
  70016. */
  70017. register(): void;
  70018. private _evaluateSubMesh;
  70019. private _activeMesh;
  70020. private _prepareRessources;
  70021. private _createIndexBuffer;
  70022. /**
  70023. * Rebuilds the elements related to this component in case of
  70024. * context lost for instance.
  70025. */
  70026. rebuild(): void;
  70027. /**
  70028. * @hidden
  70029. */
  70030. reset(): void;
  70031. /**
  70032. * Render the bounding boxes of a specific rendering group
  70033. * @param renderingGroupId defines the rendering group to render
  70034. */
  70035. render(renderingGroupId: number): void;
  70036. /**
  70037. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70038. * @param mesh Define the mesh to render the occlusion bounding box for
  70039. */
  70040. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70041. /**
  70042. * Dispose and release the resources attached to this renderer.
  70043. */
  70044. dispose(): void;
  70045. }
  70046. }
  70047. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70048. import { Nullable } from "babylonjs/types";
  70049. import { Scene } from "babylonjs/scene";
  70050. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70051. import { Camera } from "babylonjs/Cameras/camera";
  70052. import { ISceneComponent } from "babylonjs/sceneComponent";
  70053. module "babylonjs/scene" {
  70054. interface Scene {
  70055. /** @hidden (Backing field) */
  70056. _depthRenderer: {
  70057. [id: string]: DepthRenderer;
  70058. };
  70059. /**
  70060. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70061. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70062. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70063. * @returns the created depth renderer
  70064. */
  70065. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70066. /**
  70067. * Disables a depth renderer for a given camera
  70068. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70069. */
  70070. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70071. }
  70072. }
  70073. /**
  70074. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70075. * in several rendering techniques.
  70076. */
  70077. export class DepthRendererSceneComponent implements ISceneComponent {
  70078. /**
  70079. * The component name helpfull to identify the component in the list of scene components.
  70080. */
  70081. readonly name: string;
  70082. /**
  70083. * The scene the component belongs to.
  70084. */
  70085. scene: Scene;
  70086. /**
  70087. * Creates a new instance of the component for the given scene
  70088. * @param scene Defines the scene to register the component in
  70089. */
  70090. constructor(scene: Scene);
  70091. /**
  70092. * Registers the component in a given scene
  70093. */
  70094. register(): void;
  70095. /**
  70096. * Rebuilds the elements related to this component in case of
  70097. * context lost for instance.
  70098. */
  70099. rebuild(): void;
  70100. /**
  70101. * Disposes the component and the associated ressources
  70102. */
  70103. dispose(): void;
  70104. private _gatherRenderTargets;
  70105. private _gatherActiveCameraRenderTargets;
  70106. }
  70107. }
  70108. declare module "babylonjs/Shaders/outline.fragment" {
  70109. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70110. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70111. /** @hidden */
  70112. export var outlinePixelShader: {
  70113. name: string;
  70114. shader: string;
  70115. };
  70116. }
  70117. declare module "babylonjs/Shaders/outline.vertex" {
  70118. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70119. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70120. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70121. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70122. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70123. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70124. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70125. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70126. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70127. /** @hidden */
  70128. export var outlineVertexShader: {
  70129. name: string;
  70130. shader: string;
  70131. };
  70132. }
  70133. declare module "babylonjs/Rendering/outlineRenderer" {
  70134. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70135. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70136. import { Scene } from "babylonjs/scene";
  70137. import { ISceneComponent } from "babylonjs/sceneComponent";
  70138. import "babylonjs/Shaders/outline.fragment";
  70139. import "babylonjs/Shaders/outline.vertex";
  70140. module "babylonjs/scene" {
  70141. interface Scene {
  70142. /** @hidden */
  70143. _outlineRenderer: OutlineRenderer;
  70144. /**
  70145. * Gets the outline renderer associated with the scene
  70146. * @returns a OutlineRenderer
  70147. */
  70148. getOutlineRenderer(): OutlineRenderer;
  70149. }
  70150. }
  70151. module "babylonjs/Meshes/abstractMesh" {
  70152. interface AbstractMesh {
  70153. /** @hidden (Backing field) */
  70154. _renderOutline: boolean;
  70155. /**
  70156. * Gets or sets a boolean indicating if the outline must be rendered as well
  70157. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70158. */
  70159. renderOutline: boolean;
  70160. /** @hidden (Backing field) */
  70161. _renderOverlay: boolean;
  70162. /**
  70163. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70164. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70165. */
  70166. renderOverlay: boolean;
  70167. }
  70168. }
  70169. /**
  70170. * This class is responsible to draw bothe outline/overlay of meshes.
  70171. * It should not be used directly but through the available method on mesh.
  70172. */
  70173. export class OutlineRenderer implements ISceneComponent {
  70174. /**
  70175. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70176. */
  70177. private static _StencilReference;
  70178. /**
  70179. * The name of the component. Each component must have a unique name.
  70180. */
  70181. name: string;
  70182. /**
  70183. * The scene the component belongs to.
  70184. */
  70185. scene: Scene;
  70186. /**
  70187. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70188. */
  70189. zOffset: number;
  70190. private _engine;
  70191. private _effect;
  70192. private _cachedDefines;
  70193. private _savedDepthWrite;
  70194. /**
  70195. * Instantiates a new outline renderer. (There could be only one per scene).
  70196. * @param scene Defines the scene it belongs to
  70197. */
  70198. constructor(scene: Scene);
  70199. /**
  70200. * Register the component to one instance of a scene.
  70201. */
  70202. register(): void;
  70203. /**
  70204. * Rebuilds the elements related to this component in case of
  70205. * context lost for instance.
  70206. */
  70207. rebuild(): void;
  70208. /**
  70209. * Disposes the component and the associated ressources.
  70210. */
  70211. dispose(): void;
  70212. /**
  70213. * Renders the outline in the canvas.
  70214. * @param subMesh Defines the sumesh to render
  70215. * @param batch Defines the batch of meshes in case of instances
  70216. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70217. */
  70218. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70219. /**
  70220. * Returns whether or not the outline renderer is ready for a given submesh.
  70221. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70222. * @param subMesh Defines the submesh to check readyness for
  70223. * @param useInstances Defines wheter wee are trying to render instances or not
  70224. * @returns true if ready otherwise false
  70225. */
  70226. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70227. private _beforeRenderingMesh;
  70228. private _afterRenderingMesh;
  70229. }
  70230. }
  70231. declare module "babylonjs/Rendering/index" {
  70232. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70233. export * from "babylonjs/Rendering/depthRenderer";
  70234. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70235. export * from "babylonjs/Rendering/edgesRenderer";
  70236. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70237. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70238. export * from "babylonjs/Rendering/outlineRenderer";
  70239. export * from "babylonjs/Rendering/renderingGroup";
  70240. export * from "babylonjs/Rendering/renderingManager";
  70241. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70242. }
  70243. declare module "babylonjs/Sprites/ISprites" {
  70244. /**
  70245. * Defines the basic options interface of a Sprite Frame Source Size.
  70246. */
  70247. export interface ISpriteJSONSpriteSourceSize {
  70248. /**
  70249. * number of the original width of the Frame
  70250. */
  70251. w: number;
  70252. /**
  70253. * number of the original height of the Frame
  70254. */
  70255. h: number;
  70256. }
  70257. /**
  70258. * Defines the basic options interface of a Sprite Frame Data.
  70259. */
  70260. export interface ISpriteJSONSpriteFrameData {
  70261. /**
  70262. * number of the x offset of the Frame
  70263. */
  70264. x: number;
  70265. /**
  70266. * number of the y offset of the Frame
  70267. */
  70268. y: number;
  70269. /**
  70270. * number of the width of the Frame
  70271. */
  70272. w: number;
  70273. /**
  70274. * number of the height of the Frame
  70275. */
  70276. h: number;
  70277. }
  70278. /**
  70279. * Defines the basic options interface of a JSON Sprite.
  70280. */
  70281. export interface ISpriteJSONSprite {
  70282. /**
  70283. * string name of the Frame
  70284. */
  70285. filename: string;
  70286. /**
  70287. * ISpriteJSONSpriteFrame basic object of the frame data
  70288. */
  70289. frame: ISpriteJSONSpriteFrameData;
  70290. /**
  70291. * boolean to flag is the frame was rotated.
  70292. */
  70293. rotated: boolean;
  70294. /**
  70295. * boolean to flag is the frame was trimmed.
  70296. */
  70297. trimmed: boolean;
  70298. /**
  70299. * ISpriteJSONSpriteFrame basic object of the source data
  70300. */
  70301. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70302. /**
  70303. * ISpriteJSONSpriteFrame basic object of the source data
  70304. */
  70305. sourceSize: ISpriteJSONSpriteSourceSize;
  70306. }
  70307. /**
  70308. * Defines the basic options interface of a JSON atlas.
  70309. */
  70310. export interface ISpriteJSONAtlas {
  70311. /**
  70312. * Array of objects that contain the frame data.
  70313. */
  70314. frames: Array<ISpriteJSONSprite>;
  70315. /**
  70316. * object basic object containing the sprite meta data.
  70317. */
  70318. meta?: object;
  70319. }
  70320. }
  70321. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70322. /** @hidden */
  70323. export var spriteMapPixelShader: {
  70324. name: string;
  70325. shader: string;
  70326. };
  70327. }
  70328. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70329. /** @hidden */
  70330. export var spriteMapVertexShader: {
  70331. name: string;
  70332. shader: string;
  70333. };
  70334. }
  70335. declare module "babylonjs/Sprites/spriteMap" {
  70336. import { IDisposable, Scene } from "babylonjs/scene";
  70337. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70338. import { Texture } from "babylonjs/Materials/Textures/texture";
  70339. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70340. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70341. import "babylonjs/Meshes/Builders/planeBuilder";
  70342. import "babylonjs/Shaders/spriteMap.fragment";
  70343. import "babylonjs/Shaders/spriteMap.vertex";
  70344. /**
  70345. * Defines the basic options interface of a SpriteMap
  70346. */
  70347. export interface ISpriteMapOptions {
  70348. /**
  70349. * Vector2 of the number of cells in the grid.
  70350. */
  70351. stageSize?: Vector2;
  70352. /**
  70353. * Vector2 of the size of the output plane in World Units.
  70354. */
  70355. outputSize?: Vector2;
  70356. /**
  70357. * Vector3 of the position of the output plane in World Units.
  70358. */
  70359. outputPosition?: Vector3;
  70360. /**
  70361. * Vector3 of the rotation of the output plane.
  70362. */
  70363. outputRotation?: Vector3;
  70364. /**
  70365. * number of layers that the system will reserve in resources.
  70366. */
  70367. layerCount?: number;
  70368. /**
  70369. * number of max animation frames a single cell will reserve in resources.
  70370. */
  70371. maxAnimationFrames?: number;
  70372. /**
  70373. * number cell index of the base tile when the system compiles.
  70374. */
  70375. baseTile?: number;
  70376. /**
  70377. * boolean flip the sprite after its been repositioned by the framing data.
  70378. */
  70379. flipU?: boolean;
  70380. /**
  70381. * Vector3 scalar of the global RGB values of the SpriteMap.
  70382. */
  70383. colorMultiply?: Vector3;
  70384. }
  70385. /**
  70386. * Defines the IDisposable interface in order to be cleanable from resources.
  70387. */
  70388. export interface ISpriteMap extends IDisposable {
  70389. /**
  70390. * String name of the SpriteMap.
  70391. */
  70392. name: string;
  70393. /**
  70394. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70395. */
  70396. atlasJSON: ISpriteJSONAtlas;
  70397. /**
  70398. * Texture of the SpriteMap.
  70399. */
  70400. spriteSheet: Texture;
  70401. /**
  70402. * The parameters to initialize the SpriteMap with.
  70403. */
  70404. options: ISpriteMapOptions;
  70405. }
  70406. /**
  70407. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70408. */
  70409. export class SpriteMap implements ISpriteMap {
  70410. /** The Name of the spriteMap */
  70411. name: string;
  70412. /** The JSON file with the frame and meta data */
  70413. atlasJSON: ISpriteJSONAtlas;
  70414. /** The systems Sprite Sheet Texture */
  70415. spriteSheet: Texture;
  70416. /** Arguments passed with the Constructor */
  70417. options: ISpriteMapOptions;
  70418. /** Public Sprite Storage array, parsed from atlasJSON */
  70419. sprites: Array<ISpriteJSONSprite>;
  70420. /** Returns the Number of Sprites in the System */
  70421. get spriteCount(): number;
  70422. /** Returns the Position of Output Plane*/
  70423. get position(): Vector3;
  70424. /** Returns the Position of Output Plane*/
  70425. set position(v: Vector3);
  70426. /** Returns the Rotation of Output Plane*/
  70427. get rotation(): Vector3;
  70428. /** Returns the Rotation of Output Plane*/
  70429. set rotation(v: Vector3);
  70430. /** Sets the AnimationMap*/
  70431. get animationMap(): RawTexture;
  70432. /** Sets the AnimationMap*/
  70433. set animationMap(v: RawTexture);
  70434. /** Scene that the SpriteMap was created in */
  70435. private _scene;
  70436. /** Texture Buffer of Float32 that holds tile frame data*/
  70437. private _frameMap;
  70438. /** Texture Buffers of Float32 that holds tileMap data*/
  70439. private _tileMaps;
  70440. /** Texture Buffer of Float32 that holds Animation Data*/
  70441. private _animationMap;
  70442. /** Custom ShaderMaterial Central to the System*/
  70443. private _material;
  70444. /** Custom ShaderMaterial Central to the System*/
  70445. private _output;
  70446. /** Systems Time Ticker*/
  70447. private _time;
  70448. /**
  70449. * Creates a new SpriteMap
  70450. * @param name defines the SpriteMaps Name
  70451. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70452. * @param spriteSheet is the Texture that the Sprites are on.
  70453. * @param options a basic deployment configuration
  70454. * @param scene The Scene that the map is deployed on
  70455. */
  70456. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70457. /**
  70458. * Returns tileID location
  70459. * @returns Vector2 the cell position ID
  70460. */
  70461. getTileID(): Vector2;
  70462. /**
  70463. * Gets the UV location of the mouse over the SpriteMap.
  70464. * @returns Vector2 the UV position of the mouse interaction
  70465. */
  70466. getMousePosition(): Vector2;
  70467. /**
  70468. * Creates the "frame" texture Buffer
  70469. * -------------------------------------
  70470. * Structure of frames
  70471. * "filename": "Falling-Water-2.png",
  70472. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70473. * "rotated": true,
  70474. * "trimmed": true,
  70475. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70476. * "sourceSize": {"w":32,"h":32}
  70477. * @returns RawTexture of the frameMap
  70478. */
  70479. private _createFrameBuffer;
  70480. /**
  70481. * Creates the tileMap texture Buffer
  70482. * @param buffer normally and array of numbers, or a false to generate from scratch
  70483. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70484. * @returns RawTexture of the tileMap
  70485. */
  70486. private _createTileBuffer;
  70487. /**
  70488. * Modifies the data of the tileMaps
  70489. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70490. * @param pos is the iVector2 Coordinates of the Tile
  70491. * @param tile The SpriteIndex of the new Tile
  70492. */
  70493. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70494. /**
  70495. * Creates the animationMap texture Buffer
  70496. * @param buffer normally and array of numbers, or a false to generate from scratch
  70497. * @returns RawTexture of the animationMap
  70498. */
  70499. private _createTileAnimationBuffer;
  70500. /**
  70501. * Modifies the data of the animationMap
  70502. * @param cellID is the Index of the Sprite
  70503. * @param _frame is the target Animation frame
  70504. * @param toCell is the Target Index of the next frame of the animation
  70505. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70506. * @param speed is a global scalar of the time variable on the map.
  70507. */
  70508. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70509. /**
  70510. * Exports the .tilemaps file
  70511. */
  70512. saveTileMaps(): void;
  70513. /**
  70514. * Imports the .tilemaps file
  70515. * @param url of the .tilemaps file
  70516. */
  70517. loadTileMaps(url: string): void;
  70518. /**
  70519. * Release associated resources
  70520. */
  70521. dispose(): void;
  70522. }
  70523. }
  70524. declare module "babylonjs/Sprites/spritePackedManager" {
  70525. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70526. import { Scene } from "babylonjs/scene";
  70527. /**
  70528. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70529. * @see http://doc.babylonjs.com/babylon101/sprites
  70530. */
  70531. export class SpritePackedManager extends SpriteManager {
  70532. /** defines the packed manager's name */
  70533. name: string;
  70534. /**
  70535. * Creates a new sprite manager from a packed sprite sheet
  70536. * @param name defines the manager's name
  70537. * @param imgUrl defines the sprite sheet url
  70538. * @param capacity defines the maximum allowed number of sprites
  70539. * @param scene defines the hosting scene
  70540. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70541. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70542. * @param samplingMode defines the smapling mode to use with spritesheet
  70543. * @param fromPacked set to true; do not alter
  70544. */
  70545. constructor(
  70546. /** defines the packed manager's name */
  70547. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70548. }
  70549. }
  70550. declare module "babylonjs/Sprites/index" {
  70551. export * from "babylonjs/Sprites/sprite";
  70552. export * from "babylonjs/Sprites/ISprites";
  70553. export * from "babylonjs/Sprites/spriteManager";
  70554. export * from "babylonjs/Sprites/spriteMap";
  70555. export * from "babylonjs/Sprites/spritePackedManager";
  70556. export * from "babylonjs/Sprites/spriteSceneComponent";
  70557. }
  70558. declare module "babylonjs/States/index" {
  70559. export * from "babylonjs/States/alphaCullingState";
  70560. export * from "babylonjs/States/depthCullingState";
  70561. export * from "babylonjs/States/stencilState";
  70562. }
  70563. declare module "babylonjs/Misc/assetsManager" {
  70564. import { Scene } from "babylonjs/scene";
  70565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70566. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70567. import { Skeleton } from "babylonjs/Bones/skeleton";
  70568. import { Observable } from "babylonjs/Misc/observable";
  70569. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70570. import { Texture } from "babylonjs/Materials/Textures/texture";
  70571. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70572. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70573. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70574. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70575. /**
  70576. * Defines the list of states available for a task inside a AssetsManager
  70577. */
  70578. export enum AssetTaskState {
  70579. /**
  70580. * Initialization
  70581. */
  70582. INIT = 0,
  70583. /**
  70584. * Running
  70585. */
  70586. RUNNING = 1,
  70587. /**
  70588. * Done
  70589. */
  70590. DONE = 2,
  70591. /**
  70592. * Error
  70593. */
  70594. ERROR = 3
  70595. }
  70596. /**
  70597. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70598. */
  70599. export abstract class AbstractAssetTask {
  70600. /**
  70601. * Task name
  70602. */ name: string;
  70603. /**
  70604. * Callback called when the task is successful
  70605. */
  70606. onSuccess: (task: any) => void;
  70607. /**
  70608. * Callback called when the task is not successful
  70609. */
  70610. onError: (task: any, message?: string, exception?: any) => void;
  70611. /**
  70612. * Creates a new AssetsManager
  70613. * @param name defines the name of the task
  70614. */
  70615. constructor(
  70616. /**
  70617. * Task name
  70618. */ name: string);
  70619. private _isCompleted;
  70620. private _taskState;
  70621. private _errorObject;
  70622. /**
  70623. * Get if the task is completed
  70624. */
  70625. get isCompleted(): boolean;
  70626. /**
  70627. * Gets the current state of the task
  70628. */
  70629. get taskState(): AssetTaskState;
  70630. /**
  70631. * Gets the current error object (if task is in error)
  70632. */
  70633. get errorObject(): {
  70634. message?: string;
  70635. exception?: any;
  70636. };
  70637. /**
  70638. * Internal only
  70639. * @hidden
  70640. */
  70641. _setErrorObject(message?: string, exception?: any): void;
  70642. /**
  70643. * Execute the current task
  70644. * @param scene defines the scene where you want your assets to be loaded
  70645. * @param onSuccess is a callback called when the task is successfully executed
  70646. * @param onError is a callback called if an error occurs
  70647. */
  70648. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70649. /**
  70650. * Execute the current task
  70651. * @param scene defines the scene where you want your assets to be loaded
  70652. * @param onSuccess is a callback called when the task is successfully executed
  70653. * @param onError is a callback called if an error occurs
  70654. */
  70655. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70656. /**
  70657. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70658. * This can be used with failed tasks that have the reason for failure fixed.
  70659. */
  70660. reset(): void;
  70661. private onErrorCallback;
  70662. private onDoneCallback;
  70663. }
  70664. /**
  70665. * Define the interface used by progress events raised during assets loading
  70666. */
  70667. export interface IAssetsProgressEvent {
  70668. /**
  70669. * Defines the number of remaining tasks to process
  70670. */
  70671. remainingCount: number;
  70672. /**
  70673. * Defines the total number of tasks
  70674. */
  70675. totalCount: number;
  70676. /**
  70677. * Defines the task that was just processed
  70678. */
  70679. task: AbstractAssetTask;
  70680. }
  70681. /**
  70682. * Class used to share progress information about assets loading
  70683. */
  70684. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70685. /**
  70686. * Defines the number of remaining tasks to process
  70687. */
  70688. remainingCount: number;
  70689. /**
  70690. * Defines the total number of tasks
  70691. */
  70692. totalCount: number;
  70693. /**
  70694. * Defines the task that was just processed
  70695. */
  70696. task: AbstractAssetTask;
  70697. /**
  70698. * Creates a AssetsProgressEvent
  70699. * @param remainingCount defines the number of remaining tasks to process
  70700. * @param totalCount defines the total number of tasks
  70701. * @param task defines the task that was just processed
  70702. */
  70703. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70704. }
  70705. /**
  70706. * Define a task used by AssetsManager to load meshes
  70707. */
  70708. export class MeshAssetTask extends AbstractAssetTask {
  70709. /**
  70710. * Defines the name of the task
  70711. */
  70712. name: string;
  70713. /**
  70714. * Defines the list of mesh's names you want to load
  70715. */
  70716. meshesNames: any;
  70717. /**
  70718. * Defines the root url to use as a base to load your meshes and associated resources
  70719. */
  70720. rootUrl: string;
  70721. /**
  70722. * Defines the filename of the scene to load from
  70723. */
  70724. sceneFilename: string;
  70725. /**
  70726. * Gets the list of loaded meshes
  70727. */
  70728. loadedMeshes: Array<AbstractMesh>;
  70729. /**
  70730. * Gets the list of loaded particle systems
  70731. */
  70732. loadedParticleSystems: Array<IParticleSystem>;
  70733. /**
  70734. * Gets the list of loaded skeletons
  70735. */
  70736. loadedSkeletons: Array<Skeleton>;
  70737. /**
  70738. * Gets the list of loaded animation groups
  70739. */
  70740. loadedAnimationGroups: Array<AnimationGroup>;
  70741. /**
  70742. * Callback called when the task is successful
  70743. */
  70744. onSuccess: (task: MeshAssetTask) => void;
  70745. /**
  70746. * Callback called when the task is successful
  70747. */
  70748. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70749. /**
  70750. * Creates a new MeshAssetTask
  70751. * @param name defines the name of the task
  70752. * @param meshesNames defines the list of mesh's names you want to load
  70753. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70754. * @param sceneFilename defines the filename of the scene to load from
  70755. */
  70756. constructor(
  70757. /**
  70758. * Defines the name of the task
  70759. */
  70760. name: string,
  70761. /**
  70762. * Defines the list of mesh's names you want to load
  70763. */
  70764. meshesNames: any,
  70765. /**
  70766. * Defines the root url to use as a base to load your meshes and associated resources
  70767. */
  70768. rootUrl: string,
  70769. /**
  70770. * Defines the filename of the scene to load from
  70771. */
  70772. sceneFilename: string);
  70773. /**
  70774. * Execute the current task
  70775. * @param scene defines the scene where you want your assets to be loaded
  70776. * @param onSuccess is a callback called when the task is successfully executed
  70777. * @param onError is a callback called if an error occurs
  70778. */
  70779. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70780. }
  70781. /**
  70782. * Define a task used by AssetsManager to load text content
  70783. */
  70784. export class TextFileAssetTask extends AbstractAssetTask {
  70785. /**
  70786. * Defines the name of the task
  70787. */
  70788. name: string;
  70789. /**
  70790. * Defines the location of the file to load
  70791. */
  70792. url: string;
  70793. /**
  70794. * Gets the loaded text string
  70795. */
  70796. text: string;
  70797. /**
  70798. * Callback called when the task is successful
  70799. */
  70800. onSuccess: (task: TextFileAssetTask) => void;
  70801. /**
  70802. * Callback called when the task is successful
  70803. */
  70804. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70805. /**
  70806. * Creates a new TextFileAssetTask object
  70807. * @param name defines the name of the task
  70808. * @param url defines the location of the file to load
  70809. */
  70810. constructor(
  70811. /**
  70812. * Defines the name of the task
  70813. */
  70814. name: string,
  70815. /**
  70816. * Defines the location of the file to load
  70817. */
  70818. url: string);
  70819. /**
  70820. * Execute the current task
  70821. * @param scene defines the scene where you want your assets to be loaded
  70822. * @param onSuccess is a callback called when the task is successfully executed
  70823. * @param onError is a callback called if an error occurs
  70824. */
  70825. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70826. }
  70827. /**
  70828. * Define a task used by AssetsManager to load binary data
  70829. */
  70830. export class BinaryFileAssetTask extends AbstractAssetTask {
  70831. /**
  70832. * Defines the name of the task
  70833. */
  70834. name: string;
  70835. /**
  70836. * Defines the location of the file to load
  70837. */
  70838. url: string;
  70839. /**
  70840. * Gets the lodaded data (as an array buffer)
  70841. */
  70842. data: ArrayBuffer;
  70843. /**
  70844. * Callback called when the task is successful
  70845. */
  70846. onSuccess: (task: BinaryFileAssetTask) => void;
  70847. /**
  70848. * Callback called when the task is successful
  70849. */
  70850. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70851. /**
  70852. * Creates a new BinaryFileAssetTask object
  70853. * @param name defines the name of the new task
  70854. * @param url defines the location of the file to load
  70855. */
  70856. constructor(
  70857. /**
  70858. * Defines the name of the task
  70859. */
  70860. name: string,
  70861. /**
  70862. * Defines the location of the file to load
  70863. */
  70864. url: string);
  70865. /**
  70866. * Execute the current task
  70867. * @param scene defines the scene where you want your assets to be loaded
  70868. * @param onSuccess is a callback called when the task is successfully executed
  70869. * @param onError is a callback called if an error occurs
  70870. */
  70871. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70872. }
  70873. /**
  70874. * Define a task used by AssetsManager to load images
  70875. */
  70876. export class ImageAssetTask extends AbstractAssetTask {
  70877. /**
  70878. * Defines the name of the task
  70879. */
  70880. name: string;
  70881. /**
  70882. * Defines the location of the image to load
  70883. */
  70884. url: string;
  70885. /**
  70886. * Gets the loaded images
  70887. */
  70888. image: HTMLImageElement;
  70889. /**
  70890. * Callback called when the task is successful
  70891. */
  70892. onSuccess: (task: ImageAssetTask) => void;
  70893. /**
  70894. * Callback called when the task is successful
  70895. */
  70896. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70897. /**
  70898. * Creates a new ImageAssetTask
  70899. * @param name defines the name of the task
  70900. * @param url defines the location of the image to load
  70901. */
  70902. constructor(
  70903. /**
  70904. * Defines the name of the task
  70905. */
  70906. name: string,
  70907. /**
  70908. * Defines the location of the image to load
  70909. */
  70910. url: string);
  70911. /**
  70912. * Execute the current task
  70913. * @param scene defines the scene where you want your assets to be loaded
  70914. * @param onSuccess is a callback called when the task is successfully executed
  70915. * @param onError is a callback called if an error occurs
  70916. */
  70917. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70918. }
  70919. /**
  70920. * Defines the interface used by texture loading tasks
  70921. */
  70922. export interface ITextureAssetTask<TEX extends BaseTexture> {
  70923. /**
  70924. * Gets the loaded texture
  70925. */
  70926. texture: TEX;
  70927. }
  70928. /**
  70929. * Define a task used by AssetsManager to load 2D textures
  70930. */
  70931. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  70932. /**
  70933. * Defines the name of the task
  70934. */
  70935. name: string;
  70936. /**
  70937. * Defines the location of the file to load
  70938. */
  70939. url: string;
  70940. /**
  70941. * Defines if mipmap should not be generated (default is false)
  70942. */
  70943. noMipmap?: boolean | undefined;
  70944. /**
  70945. * Defines if texture must be inverted on Y axis (default is false)
  70946. */
  70947. invertY?: boolean | undefined;
  70948. /**
  70949. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70950. */
  70951. samplingMode: number;
  70952. /**
  70953. * Gets the loaded texture
  70954. */
  70955. texture: Texture;
  70956. /**
  70957. * Callback called when the task is successful
  70958. */
  70959. onSuccess: (task: TextureAssetTask) => void;
  70960. /**
  70961. * Callback called when the task is successful
  70962. */
  70963. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  70964. /**
  70965. * Creates a new TextureAssetTask object
  70966. * @param name defines the name of the task
  70967. * @param url defines the location of the file to load
  70968. * @param noMipmap defines if mipmap should not be generated (default is false)
  70969. * @param invertY defines if texture must be inverted on Y axis (default is false)
  70970. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70971. */
  70972. constructor(
  70973. /**
  70974. * Defines the name of the task
  70975. */
  70976. name: string,
  70977. /**
  70978. * Defines the location of the file to load
  70979. */
  70980. url: string,
  70981. /**
  70982. * Defines if mipmap should not be generated (default is false)
  70983. */
  70984. noMipmap?: boolean | undefined,
  70985. /**
  70986. * Defines if texture must be inverted on Y axis (default is false)
  70987. */
  70988. invertY?: boolean | undefined,
  70989. /**
  70990. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  70991. */
  70992. samplingMode?: number);
  70993. /**
  70994. * Execute the current task
  70995. * @param scene defines the scene where you want your assets to be loaded
  70996. * @param onSuccess is a callback called when the task is successfully executed
  70997. * @param onError is a callback called if an error occurs
  70998. */
  70999. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71000. }
  71001. /**
  71002. * Define a task used by AssetsManager to load cube textures
  71003. */
  71004. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71005. /**
  71006. * Defines the name of the task
  71007. */
  71008. name: string;
  71009. /**
  71010. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71011. */
  71012. url: string;
  71013. /**
  71014. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71015. */
  71016. extensions?: string[] | undefined;
  71017. /**
  71018. * Defines if mipmaps should not be generated (default is false)
  71019. */
  71020. noMipmap?: boolean | undefined;
  71021. /**
  71022. * Defines the explicit list of files (undefined by default)
  71023. */
  71024. files?: string[] | undefined;
  71025. /**
  71026. * Gets the loaded texture
  71027. */
  71028. texture: CubeTexture;
  71029. /**
  71030. * Callback called when the task is successful
  71031. */
  71032. onSuccess: (task: CubeTextureAssetTask) => void;
  71033. /**
  71034. * Callback called when the task is successful
  71035. */
  71036. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71037. /**
  71038. * Creates a new CubeTextureAssetTask
  71039. * @param name defines the name of the task
  71040. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71041. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71042. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71043. * @param files defines the explicit list of files (undefined by default)
  71044. */
  71045. constructor(
  71046. /**
  71047. * Defines the name of the task
  71048. */
  71049. name: string,
  71050. /**
  71051. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71052. */
  71053. url: string,
  71054. /**
  71055. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71056. */
  71057. extensions?: string[] | undefined,
  71058. /**
  71059. * Defines if mipmaps should not be generated (default is false)
  71060. */
  71061. noMipmap?: boolean | undefined,
  71062. /**
  71063. * Defines the explicit list of files (undefined by default)
  71064. */
  71065. files?: string[] | undefined);
  71066. /**
  71067. * Execute the current task
  71068. * @param scene defines the scene where you want your assets to be loaded
  71069. * @param onSuccess is a callback called when the task is successfully executed
  71070. * @param onError is a callback called if an error occurs
  71071. */
  71072. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71073. }
  71074. /**
  71075. * Define a task used by AssetsManager to load HDR cube textures
  71076. */
  71077. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71078. /**
  71079. * Defines the name of the task
  71080. */
  71081. name: string;
  71082. /**
  71083. * Defines the location of the file to load
  71084. */
  71085. url: string;
  71086. /**
  71087. * Defines the desired size (the more it increases the longer the generation will be)
  71088. */
  71089. size: number;
  71090. /**
  71091. * Defines if mipmaps should not be generated (default is false)
  71092. */
  71093. noMipmap: boolean;
  71094. /**
  71095. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71096. */
  71097. generateHarmonics: boolean;
  71098. /**
  71099. * 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)
  71100. */
  71101. gammaSpace: boolean;
  71102. /**
  71103. * Internal Use Only
  71104. */
  71105. reserved: boolean;
  71106. /**
  71107. * Gets the loaded texture
  71108. */
  71109. texture: HDRCubeTexture;
  71110. /**
  71111. * Callback called when the task is successful
  71112. */
  71113. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71114. /**
  71115. * Callback called when the task is successful
  71116. */
  71117. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71118. /**
  71119. * Creates a new HDRCubeTextureAssetTask object
  71120. * @param name defines the name of the task
  71121. * @param url defines the location of the file to load
  71122. * @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.
  71123. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71124. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71125. * @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)
  71126. * @param reserved Internal use only
  71127. */
  71128. constructor(
  71129. /**
  71130. * Defines the name of the task
  71131. */
  71132. name: string,
  71133. /**
  71134. * Defines the location of the file to load
  71135. */
  71136. url: string,
  71137. /**
  71138. * Defines the desired size (the more it increases the longer the generation will be)
  71139. */
  71140. size: number,
  71141. /**
  71142. * Defines if mipmaps should not be generated (default is false)
  71143. */
  71144. noMipmap?: boolean,
  71145. /**
  71146. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71147. */
  71148. generateHarmonics?: boolean,
  71149. /**
  71150. * 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)
  71151. */
  71152. gammaSpace?: boolean,
  71153. /**
  71154. * Internal Use Only
  71155. */
  71156. reserved?: boolean);
  71157. /**
  71158. * Execute the current task
  71159. * @param scene defines the scene where you want your assets to be loaded
  71160. * @param onSuccess is a callback called when the task is successfully executed
  71161. * @param onError is a callback called if an error occurs
  71162. */
  71163. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71164. }
  71165. /**
  71166. * Define a task used by AssetsManager to load Equirectangular cube textures
  71167. */
  71168. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71169. /**
  71170. * Defines the name of the task
  71171. */
  71172. name: string;
  71173. /**
  71174. * Defines the location of the file to load
  71175. */
  71176. url: string;
  71177. /**
  71178. * Defines the desired size (the more it increases the longer the generation will be)
  71179. */
  71180. size: number;
  71181. /**
  71182. * Defines if mipmaps should not be generated (default is false)
  71183. */
  71184. noMipmap: boolean;
  71185. /**
  71186. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71187. * but the standard material would require them in Gamma space) (default is true)
  71188. */
  71189. gammaSpace: boolean;
  71190. /**
  71191. * Gets the loaded texture
  71192. */
  71193. texture: EquiRectangularCubeTexture;
  71194. /**
  71195. * Callback called when the task is successful
  71196. */
  71197. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71198. /**
  71199. * Callback called when the task is successful
  71200. */
  71201. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71202. /**
  71203. * Creates a new EquiRectangularCubeTextureAssetTask object
  71204. * @param name defines the name of the task
  71205. * @param url defines the location of the file to load
  71206. * @param size defines the desired size (the more it increases the longer the generation will be)
  71207. * If the size is omitted this implies you are using a preprocessed cubemap.
  71208. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71209. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71210. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71211. * (default is true)
  71212. */
  71213. constructor(
  71214. /**
  71215. * Defines the name of the task
  71216. */
  71217. name: string,
  71218. /**
  71219. * Defines the location of the file to load
  71220. */
  71221. url: string,
  71222. /**
  71223. * Defines the desired size (the more it increases the longer the generation will be)
  71224. */
  71225. size: number,
  71226. /**
  71227. * Defines if mipmaps should not be generated (default is false)
  71228. */
  71229. noMipmap?: boolean,
  71230. /**
  71231. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71232. * but the standard material would require them in Gamma space) (default is true)
  71233. */
  71234. gammaSpace?: boolean);
  71235. /**
  71236. * Execute the current task
  71237. * @param scene defines the scene where you want your assets to be loaded
  71238. * @param onSuccess is a callback called when the task is successfully executed
  71239. * @param onError is a callback called if an error occurs
  71240. */
  71241. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71242. }
  71243. /**
  71244. * This class can be used to easily import assets into a scene
  71245. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71246. */
  71247. export class AssetsManager {
  71248. private _scene;
  71249. private _isLoading;
  71250. protected _tasks: AbstractAssetTask[];
  71251. protected _waitingTasksCount: number;
  71252. protected _totalTasksCount: number;
  71253. /**
  71254. * Callback called when all tasks are processed
  71255. */
  71256. onFinish: (tasks: AbstractAssetTask[]) => void;
  71257. /**
  71258. * Callback called when a task is successful
  71259. */
  71260. onTaskSuccess: (task: AbstractAssetTask) => void;
  71261. /**
  71262. * Callback called when a task had an error
  71263. */
  71264. onTaskError: (task: AbstractAssetTask) => void;
  71265. /**
  71266. * Callback called when a task is done (whatever the result is)
  71267. */
  71268. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71269. /**
  71270. * Observable called when all tasks are processed
  71271. */
  71272. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71273. /**
  71274. * Observable called when a task had an error
  71275. */
  71276. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71277. /**
  71278. * Observable called when all tasks were executed
  71279. */
  71280. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71281. /**
  71282. * Observable called when a task is done (whatever the result is)
  71283. */
  71284. onProgressObservable: Observable<IAssetsProgressEvent>;
  71285. /**
  71286. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71287. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71288. */
  71289. useDefaultLoadingScreen: boolean;
  71290. /**
  71291. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71292. * when all assets have been downloaded.
  71293. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71294. */
  71295. autoHideLoadingUI: boolean;
  71296. /**
  71297. * Creates a new AssetsManager
  71298. * @param scene defines the scene to work on
  71299. */
  71300. constructor(scene: Scene);
  71301. /**
  71302. * Add a MeshAssetTask to the list of active tasks
  71303. * @param taskName defines the name of the new task
  71304. * @param meshesNames defines the name of meshes to load
  71305. * @param rootUrl defines the root url to use to locate files
  71306. * @param sceneFilename defines the filename of the scene file
  71307. * @returns a new MeshAssetTask object
  71308. */
  71309. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71310. /**
  71311. * Add a TextFileAssetTask to the list of active tasks
  71312. * @param taskName defines the name of the new task
  71313. * @param url defines the url of the file to load
  71314. * @returns a new TextFileAssetTask object
  71315. */
  71316. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71317. /**
  71318. * Add a BinaryFileAssetTask to the list of active tasks
  71319. * @param taskName defines the name of the new task
  71320. * @param url defines the url of the file to load
  71321. * @returns a new BinaryFileAssetTask object
  71322. */
  71323. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71324. /**
  71325. * Add a ImageAssetTask to the list of active tasks
  71326. * @param taskName defines the name of the new task
  71327. * @param url defines the url of the file to load
  71328. * @returns a new ImageAssetTask object
  71329. */
  71330. addImageTask(taskName: string, url: string): ImageAssetTask;
  71331. /**
  71332. * Add a TextureAssetTask to the list of active tasks
  71333. * @param taskName defines the name of the new task
  71334. * @param url defines the url of the file to load
  71335. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71336. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71337. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71338. * @returns a new TextureAssetTask object
  71339. */
  71340. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71341. /**
  71342. * Add a CubeTextureAssetTask to the list of active tasks
  71343. * @param taskName defines the name of the new task
  71344. * @param url defines the url of the file to load
  71345. * @param extensions defines the extension to use to load the cube map (can be null)
  71346. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71347. * @param files defines the list of files to load (can be null)
  71348. * @returns a new CubeTextureAssetTask object
  71349. */
  71350. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71351. /**
  71352. *
  71353. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71354. * @param taskName defines the name of the new task
  71355. * @param url defines the url of the file to load
  71356. * @param size defines the size you want for the cubemap (can be null)
  71357. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71358. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71359. * @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)
  71360. * @param reserved Internal use only
  71361. * @returns a new HDRCubeTextureAssetTask object
  71362. */
  71363. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71364. /**
  71365. *
  71366. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71367. * @param taskName defines the name of the new task
  71368. * @param url defines the url of the file to load
  71369. * @param size defines the size you want for the cubemap (can be null)
  71370. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71371. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71372. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71373. * @returns a new EquiRectangularCubeTextureAssetTask object
  71374. */
  71375. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71376. /**
  71377. * Remove a task from the assets manager.
  71378. * @param task the task to remove
  71379. */
  71380. removeTask(task: AbstractAssetTask): void;
  71381. private _decreaseWaitingTasksCount;
  71382. private _runTask;
  71383. /**
  71384. * Reset the AssetsManager and remove all tasks
  71385. * @return the current instance of the AssetsManager
  71386. */
  71387. reset(): AssetsManager;
  71388. /**
  71389. * Start the loading process
  71390. * @return the current instance of the AssetsManager
  71391. */
  71392. load(): AssetsManager;
  71393. /**
  71394. * Start the loading process as an async operation
  71395. * @return a promise returning the list of failed tasks
  71396. */
  71397. loadAsync(): Promise<void>;
  71398. }
  71399. }
  71400. declare module "babylonjs/Misc/deferred" {
  71401. /**
  71402. * Wrapper class for promise with external resolve and reject.
  71403. */
  71404. export class Deferred<T> {
  71405. /**
  71406. * The promise associated with this deferred object.
  71407. */
  71408. readonly promise: Promise<T>;
  71409. private _resolve;
  71410. private _reject;
  71411. /**
  71412. * The resolve method of the promise associated with this deferred object.
  71413. */
  71414. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71415. /**
  71416. * The reject method of the promise associated with this deferred object.
  71417. */
  71418. get reject(): (reason?: any) => void;
  71419. /**
  71420. * Constructor for this deferred object.
  71421. */
  71422. constructor();
  71423. }
  71424. }
  71425. declare module "babylonjs/Misc/meshExploder" {
  71426. import { Mesh } from "babylonjs/Meshes/mesh";
  71427. /**
  71428. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71429. */
  71430. export class MeshExploder {
  71431. private _centerMesh;
  71432. private _meshes;
  71433. private _meshesOrigins;
  71434. private _toCenterVectors;
  71435. private _scaledDirection;
  71436. private _newPosition;
  71437. private _centerPosition;
  71438. /**
  71439. * Explodes meshes from a center mesh.
  71440. * @param meshes The meshes to explode.
  71441. * @param centerMesh The mesh to be center of explosion.
  71442. */
  71443. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71444. private _setCenterMesh;
  71445. /**
  71446. * Get class name
  71447. * @returns "MeshExploder"
  71448. */
  71449. getClassName(): string;
  71450. /**
  71451. * "Exploded meshes"
  71452. * @returns Array of meshes with the centerMesh at index 0.
  71453. */
  71454. getMeshes(): Array<Mesh>;
  71455. /**
  71456. * Explodes meshes giving a specific direction
  71457. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71458. */
  71459. explode(direction?: number): void;
  71460. }
  71461. }
  71462. declare module "babylonjs/Misc/filesInput" {
  71463. import { Engine } from "babylonjs/Engines/engine";
  71464. import { Scene } from "babylonjs/scene";
  71465. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71466. /**
  71467. * Class used to help managing file picking and drag'n'drop
  71468. */
  71469. export class FilesInput {
  71470. /**
  71471. * List of files ready to be loaded
  71472. */
  71473. static get FilesToLoad(): {
  71474. [key: string]: File;
  71475. };
  71476. /**
  71477. * Callback called when a file is processed
  71478. */
  71479. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71480. private _engine;
  71481. private _currentScene;
  71482. private _sceneLoadedCallback;
  71483. private _progressCallback;
  71484. private _additionalRenderLoopLogicCallback;
  71485. private _textureLoadingCallback;
  71486. private _startingProcessingFilesCallback;
  71487. private _onReloadCallback;
  71488. private _errorCallback;
  71489. private _elementToMonitor;
  71490. private _sceneFileToLoad;
  71491. private _filesToLoad;
  71492. /**
  71493. * Creates a new FilesInput
  71494. * @param engine defines the rendering engine
  71495. * @param scene defines the hosting scene
  71496. * @param sceneLoadedCallback callback called when scene is loaded
  71497. * @param progressCallback callback called to track progress
  71498. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71499. * @param textureLoadingCallback callback called when a texture is loading
  71500. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71501. * @param onReloadCallback callback called when a reload is requested
  71502. * @param errorCallback callback call if an error occurs
  71503. */
  71504. 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);
  71505. private _dragEnterHandler;
  71506. private _dragOverHandler;
  71507. private _dropHandler;
  71508. /**
  71509. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71510. * @param elementToMonitor defines the DOM element to track
  71511. */
  71512. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71513. /**
  71514. * Release all associated resources
  71515. */
  71516. dispose(): void;
  71517. private renderFunction;
  71518. private drag;
  71519. private drop;
  71520. private _traverseFolder;
  71521. private _processFiles;
  71522. /**
  71523. * Load files from a drop event
  71524. * @param event defines the drop event to use as source
  71525. */
  71526. loadFiles(event: any): void;
  71527. private _processReload;
  71528. /**
  71529. * Reload the current scene from the loaded files
  71530. */
  71531. reload(): void;
  71532. }
  71533. }
  71534. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71535. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71536. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71537. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71538. }
  71539. declare module "babylonjs/Misc/sceneOptimizer" {
  71540. import { Scene, IDisposable } from "babylonjs/scene";
  71541. import { Observable } from "babylonjs/Misc/observable";
  71542. /**
  71543. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71544. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71545. */
  71546. export class SceneOptimization {
  71547. /**
  71548. * Defines the priority of this optimization (0 by default which means first in the list)
  71549. */
  71550. priority: number;
  71551. /**
  71552. * Gets a string describing the action executed by the current optimization
  71553. * @returns description string
  71554. */
  71555. getDescription(): string;
  71556. /**
  71557. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71558. * @param scene defines the current scene where to apply this optimization
  71559. * @param optimizer defines the current optimizer
  71560. * @returns true if everything that can be done was applied
  71561. */
  71562. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71563. /**
  71564. * Creates the SceneOptimization object
  71565. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71566. * @param desc defines the description associated with the optimization
  71567. */
  71568. constructor(
  71569. /**
  71570. * Defines the priority of this optimization (0 by default which means first in the list)
  71571. */
  71572. priority?: number);
  71573. }
  71574. /**
  71575. * Defines an optimization used to reduce the size of render target textures
  71576. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71577. */
  71578. export class TextureOptimization extends SceneOptimization {
  71579. /**
  71580. * Defines the priority of this optimization (0 by default which means first in the list)
  71581. */
  71582. priority: number;
  71583. /**
  71584. * 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
  71585. */
  71586. maximumSize: number;
  71587. /**
  71588. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71589. */
  71590. step: number;
  71591. /**
  71592. * Gets a string describing the action executed by the current optimization
  71593. * @returns description string
  71594. */
  71595. getDescription(): string;
  71596. /**
  71597. * Creates the TextureOptimization object
  71598. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71599. * @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
  71600. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71601. */
  71602. constructor(
  71603. /**
  71604. * Defines the priority of this optimization (0 by default which means first in the list)
  71605. */
  71606. priority?: number,
  71607. /**
  71608. * 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
  71609. */
  71610. maximumSize?: number,
  71611. /**
  71612. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71613. */
  71614. step?: number);
  71615. /**
  71616. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71617. * @param scene defines the current scene where to apply this optimization
  71618. * @param optimizer defines the current optimizer
  71619. * @returns true if everything that can be done was applied
  71620. */
  71621. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71622. }
  71623. /**
  71624. * Defines an optimization used to increase or decrease the rendering resolution
  71625. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71626. */
  71627. export class HardwareScalingOptimization extends SceneOptimization {
  71628. /**
  71629. * Defines the priority of this optimization (0 by default which means first in the list)
  71630. */
  71631. priority: number;
  71632. /**
  71633. * Defines the maximum scale to use (2 by default)
  71634. */
  71635. maximumScale: number;
  71636. /**
  71637. * Defines the step to use between two passes (0.5 by default)
  71638. */
  71639. step: number;
  71640. private _currentScale;
  71641. private _directionOffset;
  71642. /**
  71643. * Gets a string describing the action executed by the current optimization
  71644. * @return description string
  71645. */
  71646. getDescription(): string;
  71647. /**
  71648. * Creates the HardwareScalingOptimization object
  71649. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71650. * @param maximumScale defines the maximum scale to use (2 by default)
  71651. * @param step defines the step to use between two passes (0.5 by default)
  71652. */
  71653. constructor(
  71654. /**
  71655. * Defines the priority of this optimization (0 by default which means first in the list)
  71656. */
  71657. priority?: number,
  71658. /**
  71659. * Defines the maximum scale to use (2 by default)
  71660. */
  71661. maximumScale?: number,
  71662. /**
  71663. * Defines the step to use between two passes (0.5 by default)
  71664. */
  71665. step?: number);
  71666. /**
  71667. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71668. * @param scene defines the current scene where to apply this optimization
  71669. * @param optimizer defines the current optimizer
  71670. * @returns true if everything that can be done was applied
  71671. */
  71672. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71673. }
  71674. /**
  71675. * Defines an optimization used to remove shadows
  71676. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71677. */
  71678. export class ShadowsOptimization extends SceneOptimization {
  71679. /**
  71680. * Gets a string describing the action executed by the current optimization
  71681. * @return description string
  71682. */
  71683. getDescription(): string;
  71684. /**
  71685. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71686. * @param scene defines the current scene where to apply this optimization
  71687. * @param optimizer defines the current optimizer
  71688. * @returns true if everything that can be done was applied
  71689. */
  71690. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71691. }
  71692. /**
  71693. * Defines an optimization used to turn post-processes off
  71694. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71695. */
  71696. export class PostProcessesOptimization extends SceneOptimization {
  71697. /**
  71698. * Gets a string describing the action executed by the current optimization
  71699. * @return description string
  71700. */
  71701. getDescription(): string;
  71702. /**
  71703. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71704. * @param scene defines the current scene where to apply this optimization
  71705. * @param optimizer defines the current optimizer
  71706. * @returns true if everything that can be done was applied
  71707. */
  71708. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71709. }
  71710. /**
  71711. * Defines an optimization used to turn lens flares off
  71712. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71713. */
  71714. export class LensFlaresOptimization extends SceneOptimization {
  71715. /**
  71716. * Gets a string describing the action executed by the current optimization
  71717. * @return description string
  71718. */
  71719. getDescription(): string;
  71720. /**
  71721. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71722. * @param scene defines the current scene where to apply this optimization
  71723. * @param optimizer defines the current optimizer
  71724. * @returns true if everything that can be done was applied
  71725. */
  71726. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71727. }
  71728. /**
  71729. * Defines an optimization based on user defined callback.
  71730. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71731. */
  71732. export class CustomOptimization extends SceneOptimization {
  71733. /**
  71734. * Callback called to apply the custom optimization.
  71735. */
  71736. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71737. /**
  71738. * Callback called to get custom description
  71739. */
  71740. onGetDescription: () => string;
  71741. /**
  71742. * Gets a string describing the action executed by the current optimization
  71743. * @returns description string
  71744. */
  71745. getDescription(): string;
  71746. /**
  71747. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71748. * @param scene defines the current scene where to apply this optimization
  71749. * @param optimizer defines the current optimizer
  71750. * @returns true if everything that can be done was applied
  71751. */
  71752. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71753. }
  71754. /**
  71755. * Defines an optimization used to turn particles off
  71756. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71757. */
  71758. export class ParticlesOptimization extends SceneOptimization {
  71759. /**
  71760. * Gets a string describing the action executed by the current optimization
  71761. * @return description string
  71762. */
  71763. getDescription(): string;
  71764. /**
  71765. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71766. * @param scene defines the current scene where to apply this optimization
  71767. * @param optimizer defines the current optimizer
  71768. * @returns true if everything that can be done was applied
  71769. */
  71770. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71771. }
  71772. /**
  71773. * Defines an optimization used to turn render targets off
  71774. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71775. */
  71776. export class RenderTargetsOptimization extends SceneOptimization {
  71777. /**
  71778. * Gets a string describing the action executed by the current optimization
  71779. * @return description string
  71780. */
  71781. getDescription(): string;
  71782. /**
  71783. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71784. * @param scene defines the current scene where to apply this optimization
  71785. * @param optimizer defines the current optimizer
  71786. * @returns true if everything that can be done was applied
  71787. */
  71788. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71789. }
  71790. /**
  71791. * Defines an optimization used to merge meshes with compatible materials
  71792. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71793. */
  71794. export class MergeMeshesOptimization extends SceneOptimization {
  71795. private static _UpdateSelectionTree;
  71796. /**
  71797. * Gets or sets a boolean which defines if optimization octree has to be updated
  71798. */
  71799. static get UpdateSelectionTree(): boolean;
  71800. /**
  71801. * Gets or sets a boolean which defines if optimization octree has to be updated
  71802. */
  71803. static set UpdateSelectionTree(value: boolean);
  71804. /**
  71805. * Gets a string describing the action executed by the current optimization
  71806. * @return description string
  71807. */
  71808. getDescription(): string;
  71809. private _canBeMerged;
  71810. /**
  71811. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71812. * @param scene defines the current scene where to apply this optimization
  71813. * @param optimizer defines the current optimizer
  71814. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71815. * @returns true if everything that can be done was applied
  71816. */
  71817. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71818. }
  71819. /**
  71820. * Defines a list of options used by SceneOptimizer
  71821. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71822. */
  71823. export class SceneOptimizerOptions {
  71824. /**
  71825. * Defines the target frame rate to reach (60 by default)
  71826. */
  71827. targetFrameRate: number;
  71828. /**
  71829. * Defines the interval between two checkes (2000ms by default)
  71830. */
  71831. trackerDuration: number;
  71832. /**
  71833. * Gets the list of optimizations to apply
  71834. */
  71835. optimizations: SceneOptimization[];
  71836. /**
  71837. * Creates a new list of options used by SceneOptimizer
  71838. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71839. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71840. */
  71841. constructor(
  71842. /**
  71843. * Defines the target frame rate to reach (60 by default)
  71844. */
  71845. targetFrameRate?: number,
  71846. /**
  71847. * Defines the interval between two checkes (2000ms by default)
  71848. */
  71849. trackerDuration?: number);
  71850. /**
  71851. * Add a new optimization
  71852. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71853. * @returns the current SceneOptimizerOptions
  71854. */
  71855. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71856. /**
  71857. * Add a new custom optimization
  71858. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71859. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71860. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71861. * @returns the current SceneOptimizerOptions
  71862. */
  71863. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71864. /**
  71865. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71866. * @param targetFrameRate defines the target frame rate (60 by default)
  71867. * @returns a SceneOptimizerOptions object
  71868. */
  71869. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71870. /**
  71871. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71872. * @param targetFrameRate defines the target frame rate (60 by default)
  71873. * @returns a SceneOptimizerOptions object
  71874. */
  71875. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71876. /**
  71877. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71878. * @param targetFrameRate defines the target frame rate (60 by default)
  71879. * @returns a SceneOptimizerOptions object
  71880. */
  71881. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71882. }
  71883. /**
  71884. * Class used to run optimizations in order to reach a target frame rate
  71885. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71886. */
  71887. export class SceneOptimizer implements IDisposable {
  71888. private _isRunning;
  71889. private _options;
  71890. private _scene;
  71891. private _currentPriorityLevel;
  71892. private _targetFrameRate;
  71893. private _trackerDuration;
  71894. private _currentFrameRate;
  71895. private _sceneDisposeObserver;
  71896. private _improvementMode;
  71897. /**
  71898. * Defines an observable called when the optimizer reaches the target frame rate
  71899. */
  71900. onSuccessObservable: Observable<SceneOptimizer>;
  71901. /**
  71902. * Defines an observable called when the optimizer enables an optimization
  71903. */
  71904. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  71905. /**
  71906. * Defines an observable called when the optimizer is not able to reach the target frame rate
  71907. */
  71908. onFailureObservable: Observable<SceneOptimizer>;
  71909. /**
  71910. * Gets a boolean indicating if the optimizer is in improvement mode
  71911. */
  71912. get isInImprovementMode(): boolean;
  71913. /**
  71914. * Gets the current priority level (0 at start)
  71915. */
  71916. get currentPriorityLevel(): number;
  71917. /**
  71918. * Gets the current frame rate checked by the SceneOptimizer
  71919. */
  71920. get currentFrameRate(): number;
  71921. /**
  71922. * Gets or sets the current target frame rate (60 by default)
  71923. */
  71924. get targetFrameRate(): number;
  71925. /**
  71926. * Gets or sets the current target frame rate (60 by default)
  71927. */
  71928. set targetFrameRate(value: number);
  71929. /**
  71930. * Gets or sets the current interval between two checks (every 2000ms by default)
  71931. */
  71932. get trackerDuration(): number;
  71933. /**
  71934. * Gets or sets the current interval between two checks (every 2000ms by default)
  71935. */
  71936. set trackerDuration(value: number);
  71937. /**
  71938. * Gets the list of active optimizations
  71939. */
  71940. get optimizations(): SceneOptimization[];
  71941. /**
  71942. * Creates a new SceneOptimizer
  71943. * @param scene defines the scene to work on
  71944. * @param options defines the options to use with the SceneOptimizer
  71945. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  71946. * @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)
  71947. */
  71948. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  71949. /**
  71950. * Stops the current optimizer
  71951. */
  71952. stop(): void;
  71953. /**
  71954. * Reset the optimizer to initial step (current priority level = 0)
  71955. */
  71956. reset(): void;
  71957. /**
  71958. * Start the optimizer. By default it will try to reach a specific framerate
  71959. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  71960. */
  71961. start(): void;
  71962. private _checkCurrentState;
  71963. /**
  71964. * Release all resources
  71965. */
  71966. dispose(): void;
  71967. /**
  71968. * Helper function to create a SceneOptimizer with one single line of code
  71969. * @param scene defines the scene to work on
  71970. * @param options defines the options to use with the SceneOptimizer
  71971. * @param onSuccess defines a callback to call on success
  71972. * @param onFailure defines a callback to call on failure
  71973. * @returns the new SceneOptimizer object
  71974. */
  71975. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  71976. }
  71977. }
  71978. declare module "babylonjs/Misc/sceneSerializer" {
  71979. import { Scene } from "babylonjs/scene";
  71980. /**
  71981. * Class used to serialize a scene into a string
  71982. */
  71983. export class SceneSerializer {
  71984. /**
  71985. * Clear cache used by a previous serialization
  71986. */
  71987. static ClearCache(): void;
  71988. /**
  71989. * Serialize a scene into a JSON compatible object
  71990. * @param scene defines the scene to serialize
  71991. * @returns a JSON compatible object
  71992. */
  71993. static Serialize(scene: Scene): any;
  71994. /**
  71995. * Serialize a mesh into a JSON compatible object
  71996. * @param toSerialize defines the mesh to serialize
  71997. * @param withParents defines if parents must be serialized as well
  71998. * @param withChildren defines if children must be serialized as well
  71999. * @returns a JSON compatible object
  72000. */
  72001. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72002. }
  72003. }
  72004. declare module "babylonjs/Misc/textureTools" {
  72005. import { Texture } from "babylonjs/Materials/Textures/texture";
  72006. /**
  72007. * Class used to host texture specific utilities
  72008. */
  72009. export class TextureTools {
  72010. /**
  72011. * Uses the GPU to create a copy texture rescaled at a given size
  72012. * @param texture Texture to copy from
  72013. * @param width defines the desired width
  72014. * @param height defines the desired height
  72015. * @param useBilinearMode defines if bilinear mode has to be used
  72016. * @return the generated texture
  72017. */
  72018. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72019. }
  72020. }
  72021. declare module "babylonjs/Misc/videoRecorder" {
  72022. import { Nullable } from "babylonjs/types";
  72023. import { Engine } from "babylonjs/Engines/engine";
  72024. /**
  72025. * This represents the different options available for the video capture.
  72026. */
  72027. export interface VideoRecorderOptions {
  72028. /** Defines the mime type of the video. */
  72029. mimeType: string;
  72030. /** Defines the FPS the video should be recorded at. */
  72031. fps: number;
  72032. /** Defines the chunk size for the recording data. */
  72033. recordChunckSize: number;
  72034. /** The audio tracks to attach to the recording. */
  72035. audioTracks?: MediaStreamTrack[];
  72036. }
  72037. /**
  72038. * This can help with recording videos from BabylonJS.
  72039. * This is based on the available WebRTC functionalities of the browser.
  72040. *
  72041. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72042. */
  72043. export class VideoRecorder {
  72044. private static readonly _defaultOptions;
  72045. /**
  72046. * Returns whether or not the VideoRecorder is available in your browser.
  72047. * @param engine Defines the Babylon Engine.
  72048. * @returns true if supported otherwise false.
  72049. */
  72050. static IsSupported(engine: Engine): boolean;
  72051. private readonly _options;
  72052. private _canvas;
  72053. private _mediaRecorder;
  72054. private _recordedChunks;
  72055. private _fileName;
  72056. private _resolve;
  72057. private _reject;
  72058. /**
  72059. * True when a recording is already in progress.
  72060. */
  72061. get isRecording(): boolean;
  72062. /**
  72063. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72064. * @param engine Defines the BabylonJS Engine you wish to record.
  72065. * @param options Defines options that can be used to customize the capture.
  72066. */
  72067. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72068. /**
  72069. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72070. */
  72071. stopRecording(): void;
  72072. /**
  72073. * Starts recording the canvas for a max duration specified in parameters.
  72074. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72075. * If null no automatic download will start and you can rely on the promise to get the data back.
  72076. * @param maxDuration Defines the maximum recording time in seconds.
  72077. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72078. * @return A promise callback at the end of the recording with the video data in Blob.
  72079. */
  72080. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72081. /**
  72082. * Releases internal resources used during the recording.
  72083. */
  72084. dispose(): void;
  72085. private _handleDataAvailable;
  72086. private _handleError;
  72087. private _handleStop;
  72088. }
  72089. }
  72090. declare module "babylonjs/Misc/screenshotTools" {
  72091. import { Camera } from "babylonjs/Cameras/camera";
  72092. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72093. import { Engine } from "babylonjs/Engines/engine";
  72094. /**
  72095. * Class containing a set of static utilities functions for screenshots
  72096. */
  72097. export class ScreenshotTools {
  72098. /**
  72099. * Captures a screenshot of the current rendering
  72100. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72101. * @param engine defines the rendering engine
  72102. * @param camera defines the source camera
  72103. * @param size This parameter can be set to a single number or to an object with the
  72104. * following (optional) properties: precision, width, height. If a single number is passed,
  72105. * it will be used for both width and height. If an object is passed, the screenshot size
  72106. * will be derived from the parameters. The precision property is a multiplier allowing
  72107. * rendering at a higher or lower resolution
  72108. * @param successCallback defines the callback receives a single parameter which contains the
  72109. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72110. * src parameter of an <img> to display it
  72111. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72112. * Check your browser for supported MIME types
  72113. */
  72114. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72115. /**
  72116. * Captures a screenshot of the current rendering
  72117. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72118. * @param engine defines the rendering engine
  72119. * @param camera defines the source camera
  72120. * @param size This parameter can be set to a single number or to an object with the
  72121. * following (optional) properties: precision, width, height. If a single number is passed,
  72122. * it will be used for both width and height. If an object is passed, the screenshot size
  72123. * will be derived from the parameters. The precision property is a multiplier allowing
  72124. * rendering at a higher or lower resolution
  72125. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72126. * Check your browser for supported MIME types
  72127. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72128. * to the src parameter of an <img> to display it
  72129. */
  72130. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72131. /**
  72132. * Generates an image screenshot from the specified camera.
  72133. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72134. * @param engine The engine to use for rendering
  72135. * @param camera The camera to use for rendering
  72136. * @param size This parameter can be set to a single number or to an object with the
  72137. * following (optional) properties: precision, width, height. If a single number is passed,
  72138. * it will be used for both width and height. If an object is passed, the screenshot size
  72139. * will be derived from the parameters. The precision property is a multiplier allowing
  72140. * rendering at a higher or lower resolution
  72141. * @param successCallback The callback receives a single parameter which contains the
  72142. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72143. * src parameter of an <img> to display it
  72144. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72145. * Check your browser for supported MIME types
  72146. * @param samples Texture samples (default: 1)
  72147. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72148. * @param fileName A name for for the downloaded file.
  72149. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72150. */
  72151. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72152. /**
  72153. * Generates an image screenshot from the specified camera.
  72154. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72155. * @param engine The engine to use for rendering
  72156. * @param camera The camera to use for rendering
  72157. * @param size This parameter can be set to a single number or to an object with the
  72158. * following (optional) properties: precision, width, height. If a single number is passed,
  72159. * it will be used for both width and height. If an object is passed, the screenshot size
  72160. * will be derived from the parameters. The precision property is a multiplier allowing
  72161. * rendering at a higher or lower resolution
  72162. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72163. * Check your browser for supported MIME types
  72164. * @param samples Texture samples (default: 1)
  72165. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72166. * @param fileName A name for for the downloaded file.
  72167. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72168. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72169. * to the src parameter of an <img> to display it
  72170. */
  72171. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72172. /**
  72173. * Gets height and width for screenshot size
  72174. * @private
  72175. */
  72176. private static _getScreenshotSize;
  72177. }
  72178. }
  72179. declare module "babylonjs/Misc/dataReader" {
  72180. /**
  72181. * Interface for a data buffer
  72182. */
  72183. export interface IDataBuffer {
  72184. /**
  72185. * Reads bytes from the data buffer.
  72186. * @param byteOffset The byte offset to read
  72187. * @param byteLength The byte length to read
  72188. * @returns A promise that resolves when the bytes are read
  72189. */
  72190. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72191. /**
  72192. * The byte length of the buffer.
  72193. */
  72194. readonly byteLength: number;
  72195. }
  72196. /**
  72197. * Utility class for reading from a data buffer
  72198. */
  72199. export class DataReader {
  72200. /**
  72201. * The data buffer associated with this data reader.
  72202. */
  72203. readonly buffer: IDataBuffer;
  72204. /**
  72205. * The current byte offset from the beginning of the data buffer.
  72206. */
  72207. byteOffset: number;
  72208. private _dataView;
  72209. private _dataByteOffset;
  72210. /**
  72211. * Constructor
  72212. * @param buffer The buffer to read
  72213. */
  72214. constructor(buffer: IDataBuffer);
  72215. /**
  72216. * Loads the given byte length.
  72217. * @param byteLength The byte length to load
  72218. * @returns A promise that resolves when the load is complete
  72219. */
  72220. loadAsync(byteLength: number): Promise<void>;
  72221. /**
  72222. * Read a unsigned 32-bit integer from the currently loaded data range.
  72223. * @returns The 32-bit integer read
  72224. */
  72225. readUint32(): number;
  72226. /**
  72227. * Read a byte array from the currently loaded data range.
  72228. * @param byteLength The byte length to read
  72229. * @returns The byte array read
  72230. */
  72231. readUint8Array(byteLength: number): Uint8Array;
  72232. /**
  72233. * Read a string from the currently loaded data range.
  72234. * @param byteLength The byte length to read
  72235. * @returns The string read
  72236. */
  72237. readString(byteLength: number): string;
  72238. /**
  72239. * Skips the given byte length the currently loaded data range.
  72240. * @param byteLength The byte length to skip
  72241. */
  72242. skipBytes(byteLength: number): void;
  72243. }
  72244. }
  72245. declare module "babylonjs/Misc/index" {
  72246. export * from "babylonjs/Misc/andOrNotEvaluator";
  72247. export * from "babylonjs/Misc/assetsManager";
  72248. export * from "babylonjs/Misc/basis";
  72249. export * from "babylonjs/Misc/dds";
  72250. export * from "babylonjs/Misc/decorators";
  72251. export * from "babylonjs/Misc/deferred";
  72252. export * from "babylonjs/Misc/environmentTextureTools";
  72253. export * from "babylonjs/Misc/meshExploder";
  72254. export * from "babylonjs/Misc/filesInput";
  72255. export * from "babylonjs/Misc/HighDynamicRange/index";
  72256. export * from "babylonjs/Misc/khronosTextureContainer";
  72257. export * from "babylonjs/Misc/observable";
  72258. export * from "babylonjs/Misc/performanceMonitor";
  72259. export * from "babylonjs/Misc/promise";
  72260. export * from "babylonjs/Misc/sceneOptimizer";
  72261. export * from "babylonjs/Misc/sceneSerializer";
  72262. export * from "babylonjs/Misc/smartArray";
  72263. export * from "babylonjs/Misc/stringDictionary";
  72264. export * from "babylonjs/Misc/tags";
  72265. export * from "babylonjs/Misc/textureTools";
  72266. export * from "babylonjs/Misc/tga";
  72267. export * from "babylonjs/Misc/tools";
  72268. export * from "babylonjs/Misc/videoRecorder";
  72269. export * from "babylonjs/Misc/virtualJoystick";
  72270. export * from "babylonjs/Misc/workerPool";
  72271. export * from "babylonjs/Misc/logger";
  72272. export * from "babylonjs/Misc/typeStore";
  72273. export * from "babylonjs/Misc/filesInputStore";
  72274. export * from "babylonjs/Misc/deepCopier";
  72275. export * from "babylonjs/Misc/pivotTools";
  72276. export * from "babylonjs/Misc/precisionDate";
  72277. export * from "babylonjs/Misc/screenshotTools";
  72278. export * from "babylonjs/Misc/typeStore";
  72279. export * from "babylonjs/Misc/webRequest";
  72280. export * from "babylonjs/Misc/iInspectable";
  72281. export * from "babylonjs/Misc/brdfTextureTools";
  72282. export * from "babylonjs/Misc/rgbdTextureTools";
  72283. export * from "babylonjs/Misc/gradients";
  72284. export * from "babylonjs/Misc/perfCounter";
  72285. export * from "babylonjs/Misc/fileRequest";
  72286. export * from "babylonjs/Misc/customAnimationFrameRequester";
  72287. export * from "babylonjs/Misc/retryStrategy";
  72288. export * from "babylonjs/Misc/interfaces/screenshotSize";
  72289. export * from "babylonjs/Misc/canvasGenerator";
  72290. export * from "babylonjs/Misc/fileTools";
  72291. export * from "babylonjs/Misc/stringTools";
  72292. export * from "babylonjs/Misc/dataReader";
  72293. export * from "babylonjs/Misc/minMaxReducer";
  72294. export * from "babylonjs/Misc/depthReducer";
  72295. }
  72296. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  72297. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72298. import { Observable } from "babylonjs/Misc/observable";
  72299. import { Matrix } from "babylonjs/Maths/math.vector";
  72300. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72301. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72302. /**
  72303. * Options used for hit testing
  72304. */
  72305. export interface IWebXRHitTestOptions {
  72306. /**
  72307. * Only test when user interacted with the scene. Default - hit test every frame
  72308. */
  72309. testOnPointerDownOnly?: boolean;
  72310. /**
  72311. * The node to use to transform the local results to world coordinates
  72312. */
  72313. worldParentNode?: TransformNode;
  72314. }
  72315. /**
  72316. * Interface defining the babylon result of raycasting/hit-test
  72317. */
  72318. export interface IWebXRHitResult {
  72319. /**
  72320. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72321. */
  72322. transformationMatrix: Matrix;
  72323. /**
  72324. * The native hit test result
  72325. */
  72326. xrHitResult: XRHitResult;
  72327. }
  72328. /**
  72329. * The currently-working hit-test module.
  72330. * Hit test (or Ray-casting) is used to interact with the real world.
  72331. * For further information read here - https://github.com/immersive-web/hit-test
  72332. */
  72333. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  72334. /**
  72335. * options to use when constructing this feature
  72336. */
  72337. readonly options: IWebXRHitTestOptions;
  72338. private _direction;
  72339. private _mat;
  72340. private _onSelectEnabled;
  72341. private _origin;
  72342. /**
  72343. * The module's name
  72344. */
  72345. static readonly Name: string;
  72346. /**
  72347. * The (Babylon) version of this module.
  72348. * This is an integer representing the implementation version.
  72349. * This number does not correspond to the WebXR specs version
  72350. */
  72351. static readonly Version: number;
  72352. /**
  72353. * Populated with the last native XR Hit Results
  72354. */
  72355. lastNativeXRHitResults: XRHitResult[];
  72356. /**
  72357. * Triggered when new babylon (transformed) hit test results are available
  72358. */
  72359. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72360. /**
  72361. * Creates a new instance of the (legacy version) hit test feature
  72362. * @param _xrSessionManager an instance of WebXRSessionManager
  72363. * @param options options to use when constructing this feature
  72364. */
  72365. constructor(_xrSessionManager: WebXRSessionManager,
  72366. /**
  72367. * options to use when constructing this feature
  72368. */
  72369. options?: IWebXRHitTestOptions);
  72370. /**
  72371. * execute a hit test with an XR Ray
  72372. *
  72373. * @param xrSession a native xrSession that will execute this hit test
  72374. * @param xrRay the ray (position and direction) to use for ray-casting
  72375. * @param referenceSpace native XR reference space to use for the hit-test
  72376. * @param filter filter function that will filter the results
  72377. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72378. */
  72379. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72380. /**
  72381. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72382. * @param event the (select) event to use to select with
  72383. * @param referenceSpace the reference space to use for this hit test
  72384. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72385. */
  72386. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72387. /**
  72388. * attach this feature
  72389. * Will usually be called by the features manager
  72390. *
  72391. * @returns true if successful.
  72392. */
  72393. attach(): boolean;
  72394. /**
  72395. * detach this feature.
  72396. * Will usually be called by the features manager
  72397. *
  72398. * @returns true if successful.
  72399. */
  72400. detach(): boolean;
  72401. /**
  72402. * Dispose this feature and all of the resources attached
  72403. */
  72404. dispose(): void;
  72405. protected _onXRFrame(frame: XRFrame): void;
  72406. private _onHitTestResults;
  72407. private _onSelect;
  72408. }
  72409. }
  72410. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  72411. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72412. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72413. import { Observable } from "babylonjs/Misc/observable";
  72414. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  72415. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72416. /**
  72417. * Options used in the plane detector module
  72418. */
  72419. export interface IWebXRPlaneDetectorOptions {
  72420. /**
  72421. * The node to use to transform the local results to world coordinates
  72422. */
  72423. worldParentNode?: TransformNode;
  72424. }
  72425. /**
  72426. * A babylon interface for a WebXR plane.
  72427. * A Plane is actually a polygon, built from N points in space
  72428. *
  72429. * Supported in chrome 79, not supported in canary 81 ATM
  72430. */
  72431. export interface IWebXRPlane {
  72432. /**
  72433. * a babylon-assigned ID for this polygon
  72434. */
  72435. id: number;
  72436. /**
  72437. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72438. */
  72439. polygonDefinition: Array<Vector3>;
  72440. /**
  72441. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72442. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72443. */
  72444. transformationMatrix: Matrix;
  72445. /**
  72446. * the native xr-plane object
  72447. */
  72448. xrPlane: XRPlane;
  72449. }
  72450. /**
  72451. * The plane detector is used to detect planes in the real world when in AR
  72452. * For more information see https://github.com/immersive-web/real-world-geometry/
  72453. */
  72454. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72455. private _options;
  72456. private _detectedPlanes;
  72457. private _enabled;
  72458. private _lastFrameDetected;
  72459. /**
  72460. * The module's name
  72461. */
  72462. static readonly Name: string;
  72463. /**
  72464. * The (Babylon) version of this module.
  72465. * This is an integer representing the implementation version.
  72466. * This number does not correspond to the WebXR specs version
  72467. */
  72468. static readonly Version: number;
  72469. /**
  72470. * Observers registered here will be executed when a new plane was added to the session
  72471. */
  72472. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72473. /**
  72474. * Observers registered here will be executed when a plane is no longer detected in the session
  72475. */
  72476. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72477. /**
  72478. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72479. * This can execute N times every frame
  72480. */
  72481. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72482. /**
  72483. * construct a new Plane Detector
  72484. * @param _xrSessionManager an instance of xr Session manager
  72485. * @param _options configuration to use when constructing this feature
  72486. */
  72487. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72488. /**
  72489. * Dispose this feature and all of the resources attached
  72490. */
  72491. dispose(): void;
  72492. protected _onXRFrame(frame: XRFrame): void;
  72493. private _init;
  72494. private _updatePlaneWithXRPlane;
  72495. /**
  72496. * avoiding using Array.find for global support.
  72497. * @param xrPlane the plane to find in the array
  72498. */
  72499. private findIndexInPlaneArray;
  72500. }
  72501. }
  72502. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  72503. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72504. import { Observable } from "babylonjs/Misc/observable";
  72505. import { Matrix } from "babylonjs/Maths/math.vector";
  72506. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72507. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  72508. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  72509. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72510. /**
  72511. * Configuration options of the anchor system
  72512. */
  72513. export interface IWebXRAnchorSystemOptions {
  72514. /**
  72515. * Should a new anchor be added every time a select event is triggered
  72516. */
  72517. addAnchorOnSelect?: boolean;
  72518. /**
  72519. * should the anchor system use plane detection.
  72520. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72521. */
  72522. usePlaneDetection?: boolean;
  72523. /**
  72524. * a node that will be used to convert local to world coordinates
  72525. */
  72526. worldParentNode?: TransformNode;
  72527. }
  72528. /**
  72529. * A babylon container for an XR Anchor
  72530. */
  72531. export interface IWebXRAnchor {
  72532. /**
  72533. * A babylon-assigned ID for this anchor
  72534. */
  72535. id: number;
  72536. /**
  72537. * Transformation matrix to apply to an object attached to this anchor
  72538. */
  72539. transformationMatrix: Matrix;
  72540. /**
  72541. * The native anchor object
  72542. */
  72543. xrAnchor: XRAnchor;
  72544. }
  72545. /**
  72546. * An implementation of the anchor system of WebXR.
  72547. * Note that the current documented implementation is not available in any browser. Future implementations
  72548. * will use the frame to create an anchor and not the session or a detected plane
  72549. * For further information see https://github.com/immersive-web/anchors/
  72550. */
  72551. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72552. private _options;
  72553. private _enabled;
  72554. private _hitTestModule;
  72555. private _lastFrameDetected;
  72556. private _onSelect;
  72557. private _planeDetector;
  72558. private _trackedAnchors;
  72559. /**
  72560. * The module's name
  72561. */
  72562. static readonly Name: string;
  72563. /**
  72564. * The (Babylon) version of this module.
  72565. * This is an integer representing the implementation version.
  72566. * This number does not correspond to the WebXR specs version
  72567. */
  72568. static readonly Version: number;
  72569. /**
  72570. * Observers registered here will be executed when a new anchor was added to the session
  72571. */
  72572. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72573. /**
  72574. * Observers registered here will be executed when an anchor was removed from the session
  72575. */
  72576. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72577. /**
  72578. * Observers registered here will be executed when an existing anchor updates
  72579. * This can execute N times every frame
  72580. */
  72581. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72582. /**
  72583. * constructs a new anchor system
  72584. * @param _xrSessionManager an instance of WebXRSessionManager
  72585. * @param _options configuration object for this feature
  72586. */
  72587. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72588. /**
  72589. * Add anchor at a specific XR point.
  72590. *
  72591. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72592. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72593. * @returns a promise the fulfills when the anchor was created
  72594. */
  72595. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72596. /**
  72597. * attach this feature
  72598. * Will usually be called by the features manager
  72599. *
  72600. * @returns true if successful.
  72601. */
  72602. attach(): boolean;
  72603. /**
  72604. * detach this feature.
  72605. * Will usually be called by the features manager
  72606. *
  72607. * @returns true if successful.
  72608. */
  72609. detach(): boolean;
  72610. /**
  72611. * Dispose this feature and all of the resources attached
  72612. */
  72613. dispose(): void;
  72614. /**
  72615. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72616. * @param hitTestModule the hit-test module to use.
  72617. */
  72618. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72619. /**
  72620. * set the plane detector to use in order to create anchors from frames
  72621. * @param planeDetector the plane-detector module to use
  72622. * @param enable enable plane-anchors. default is true
  72623. */
  72624. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72625. protected _onXRFrame(frame: XRFrame): void;
  72626. /**
  72627. * avoiding using Array.find for global support.
  72628. * @param xrAnchor the plane to find in the array
  72629. */
  72630. private _findIndexInAnchorArray;
  72631. private _updateAnchorWithXRFrame;
  72632. }
  72633. }
  72634. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  72635. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72637. import { Observable } from "babylonjs/Misc/observable";
  72638. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72639. /**
  72640. * Options interface for the background remover plugin
  72641. */
  72642. export interface IWebXRBackgroundRemoverOptions {
  72643. /**
  72644. * Further background meshes to disable when entering AR
  72645. */
  72646. backgroundMeshes?: AbstractMesh[];
  72647. /**
  72648. * flags to configure the removal of the environment helper.
  72649. * If not set, the entire background will be removed. If set, flags should be set as well.
  72650. */
  72651. environmentHelperRemovalFlags?: {
  72652. /**
  72653. * Should the skybox be removed (default false)
  72654. */
  72655. skyBox?: boolean;
  72656. /**
  72657. * Should the ground be removed (default false)
  72658. */
  72659. ground?: boolean;
  72660. };
  72661. /**
  72662. * don't disable the environment helper
  72663. */
  72664. ignoreEnvironmentHelper?: boolean;
  72665. }
  72666. /**
  72667. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72668. */
  72669. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72670. /**
  72671. * read-only options to be used in this module
  72672. */
  72673. readonly options: IWebXRBackgroundRemoverOptions;
  72674. /**
  72675. * The module's name
  72676. */
  72677. static readonly Name: string;
  72678. /**
  72679. * The (Babylon) version of this module.
  72680. * This is an integer representing the implementation version.
  72681. * This number does not correspond to the WebXR specs version
  72682. */
  72683. static readonly Version: number;
  72684. /**
  72685. * registered observers will be triggered when the background state changes
  72686. */
  72687. onBackgroundStateChangedObservable: Observable<boolean>;
  72688. /**
  72689. * constructs a new background remover module
  72690. * @param _xrSessionManager the session manager for this module
  72691. * @param options read-only options to be used in this module
  72692. */
  72693. constructor(_xrSessionManager: WebXRSessionManager,
  72694. /**
  72695. * read-only options to be used in this module
  72696. */
  72697. options?: IWebXRBackgroundRemoverOptions);
  72698. /**
  72699. * attach this feature
  72700. * Will usually be called by the features manager
  72701. *
  72702. * @returns true if successful.
  72703. */
  72704. attach(): boolean;
  72705. /**
  72706. * detach this feature.
  72707. * Will usually be called by the features manager
  72708. *
  72709. * @returns true if successful.
  72710. */
  72711. detach(): boolean;
  72712. /**
  72713. * Dispose this feature and all of the resources attached
  72714. */
  72715. dispose(): void;
  72716. protected _onXRFrame(_xrFrame: XRFrame): void;
  72717. private _setBackgroundState;
  72718. }
  72719. }
  72720. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  72721. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72722. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  72723. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72724. import { WebXRInput } from "babylonjs/XR/webXRInput";
  72725. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72726. import { Nullable } from "babylonjs/types";
  72727. /**
  72728. * Options for the controller physics feature
  72729. */
  72730. export class IWebXRControllerPhysicsOptions {
  72731. /**
  72732. * Should the headset get its own impostor
  72733. */
  72734. enableHeadsetImpostor?: boolean;
  72735. /**
  72736. * Optional parameters for the headset impostor
  72737. */
  72738. headsetImpostorParams?: {
  72739. /**
  72740. * The type of impostor to create. Default is sphere
  72741. */
  72742. impostorType: number;
  72743. /**
  72744. * the size of the impostor. Defaults to 10cm
  72745. */
  72746. impostorSize?: number | {
  72747. width: number;
  72748. height: number;
  72749. depth: number;
  72750. };
  72751. /**
  72752. * Friction definitions
  72753. */
  72754. friction?: number;
  72755. /**
  72756. * Restitution
  72757. */
  72758. restitution?: number;
  72759. };
  72760. /**
  72761. * The physics properties of the future impostors
  72762. */
  72763. physicsProperties?: {
  72764. /**
  72765. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72766. * Note that this requires a physics engine that supports mesh impostors!
  72767. */
  72768. useControllerMesh?: boolean;
  72769. /**
  72770. * The type of impostor to create. Default is sphere
  72771. */
  72772. impostorType?: number;
  72773. /**
  72774. * the size of the impostor. Defaults to 10cm
  72775. */
  72776. impostorSize?: number | {
  72777. width: number;
  72778. height: number;
  72779. depth: number;
  72780. };
  72781. /**
  72782. * Friction definitions
  72783. */
  72784. friction?: number;
  72785. /**
  72786. * Restitution
  72787. */
  72788. restitution?: number;
  72789. };
  72790. /**
  72791. * the xr input to use with this pointer selection
  72792. */
  72793. xrInput: WebXRInput;
  72794. }
  72795. /**
  72796. * Add physics impostor to your webxr controllers,
  72797. * including naive calculation of their linear and angular velocity
  72798. */
  72799. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72800. private readonly _options;
  72801. private _attachController;
  72802. private _controllers;
  72803. private _debugMode;
  72804. private _delta;
  72805. private _headsetImpostor?;
  72806. private _headsetMesh?;
  72807. private _lastTimestamp;
  72808. private _tmpQuaternion;
  72809. private _tmpVector;
  72810. /**
  72811. * The module's name
  72812. */
  72813. static readonly Name: string;
  72814. /**
  72815. * The (Babylon) version of this module.
  72816. * This is an integer representing the implementation version.
  72817. * This number does not correspond to the webxr specs version
  72818. */
  72819. static readonly Version: number;
  72820. /**
  72821. * Construct a new Controller Physics Feature
  72822. * @param _xrSessionManager the corresponding xr session manager
  72823. * @param _options options to create this feature with
  72824. */
  72825. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72826. /**
  72827. * @hidden
  72828. * enable debugging - will show console outputs and the impostor mesh
  72829. */
  72830. _enablePhysicsDebug(): void;
  72831. /**
  72832. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72833. * @param xrController the controller to add
  72834. */
  72835. addController(xrController: WebXRInputSource): void;
  72836. /**
  72837. * attach this feature
  72838. * Will usually be called by the features manager
  72839. *
  72840. * @returns true if successful.
  72841. */
  72842. attach(): boolean;
  72843. /**
  72844. * detach this feature.
  72845. * Will usually be called by the features manager
  72846. *
  72847. * @returns true if successful.
  72848. */
  72849. detach(): boolean;
  72850. /**
  72851. * Get the headset impostor, if enabled
  72852. * @returns the impostor
  72853. */
  72854. getHeadsetImpostor(): PhysicsImpostor | undefined;
  72855. /**
  72856. * Get the physics impostor of a specific controller.
  72857. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  72858. * @param controller the controller or the controller id of which to get the impostor
  72859. * @returns the impostor or null
  72860. */
  72861. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  72862. /**
  72863. * Update the physics properties provided in the constructor
  72864. * @param newProperties the new properties object
  72865. */
  72866. setPhysicsProperties(newProperties: {
  72867. impostorType?: number;
  72868. impostorSize?: number | {
  72869. width: number;
  72870. height: number;
  72871. depth: number;
  72872. };
  72873. friction?: number;
  72874. restitution?: number;
  72875. }): void;
  72876. protected _onXRFrame(_xrFrame: any): void;
  72877. private _detachController;
  72878. }
  72879. }
  72880. declare module "babylonjs/XR/features/index" {
  72881. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  72882. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  72883. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  72884. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  72885. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  72886. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  72887. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  72888. }
  72889. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  72890. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  72891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72892. import { Scene } from "babylonjs/scene";
  72893. /**
  72894. * The motion controller class for all microsoft mixed reality controllers
  72895. */
  72896. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  72897. protected readonly _mapping: {
  72898. defaultButton: {
  72899. "valueNodeName": string;
  72900. "unpressedNodeName": string;
  72901. "pressedNodeName": string;
  72902. };
  72903. defaultAxis: {
  72904. "valueNodeName": string;
  72905. "minNodeName": string;
  72906. "maxNodeName": string;
  72907. };
  72908. buttons: {
  72909. "xr-standard-trigger": {
  72910. "rootNodeName": string;
  72911. "componentProperty": string;
  72912. "states": string[];
  72913. };
  72914. "xr-standard-squeeze": {
  72915. "rootNodeName": string;
  72916. "componentProperty": string;
  72917. "states": string[];
  72918. };
  72919. "xr-standard-touchpad": {
  72920. "rootNodeName": string;
  72921. "labelAnchorNodeName": string;
  72922. "touchPointNodeName": string;
  72923. };
  72924. "xr-standard-thumbstick": {
  72925. "rootNodeName": string;
  72926. "componentProperty": string;
  72927. "states": string[];
  72928. };
  72929. };
  72930. axes: {
  72931. "xr-standard-touchpad": {
  72932. "x-axis": {
  72933. "rootNodeName": string;
  72934. };
  72935. "y-axis": {
  72936. "rootNodeName": string;
  72937. };
  72938. };
  72939. "xr-standard-thumbstick": {
  72940. "x-axis": {
  72941. "rootNodeName": string;
  72942. };
  72943. "y-axis": {
  72944. "rootNodeName": string;
  72945. };
  72946. };
  72947. };
  72948. };
  72949. /**
  72950. * The base url used to load the left and right controller models
  72951. */
  72952. static MODEL_BASE_URL: string;
  72953. /**
  72954. * The name of the left controller model file
  72955. */
  72956. static MODEL_LEFT_FILENAME: string;
  72957. /**
  72958. * The name of the right controller model file
  72959. */
  72960. static MODEL_RIGHT_FILENAME: string;
  72961. profileId: string;
  72962. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  72963. protected _getFilenameAndPath(): {
  72964. filename: string;
  72965. path: string;
  72966. };
  72967. protected _getModelLoadingConstraints(): boolean;
  72968. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  72969. protected _setRootMesh(meshes: AbstractMesh[]): void;
  72970. protected _updateModel(): void;
  72971. }
  72972. }
  72973. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  72974. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  72975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72976. import { Scene } from "babylonjs/scene";
  72977. /**
  72978. * The motion controller class for oculus touch (quest, rift).
  72979. * This class supports legacy mapping as well the standard xr mapping
  72980. */
  72981. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  72982. private _forceLegacyControllers;
  72983. private _modelRootNode;
  72984. /**
  72985. * The base url used to load the left and right controller models
  72986. */
  72987. static MODEL_BASE_URL: string;
  72988. /**
  72989. * The name of the left controller model file
  72990. */
  72991. static MODEL_LEFT_FILENAME: string;
  72992. /**
  72993. * The name of the right controller model file
  72994. */
  72995. static MODEL_RIGHT_FILENAME: string;
  72996. /**
  72997. * Base Url for the Quest controller model.
  72998. */
  72999. static QUEST_MODEL_BASE_URL: string;
  73000. profileId: string;
  73001. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73002. protected _getFilenameAndPath(): {
  73003. filename: string;
  73004. path: string;
  73005. };
  73006. protected _getModelLoadingConstraints(): boolean;
  73007. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73008. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73009. protected _updateModel(): void;
  73010. /**
  73011. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73012. * between the touch and touch 2.
  73013. */
  73014. private _isQuest;
  73015. }
  73016. }
  73017. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  73018. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73019. import { Scene } from "babylonjs/scene";
  73020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73021. /**
  73022. * The motion controller class for the standard HTC-Vive controllers
  73023. */
  73024. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73025. private _modelRootNode;
  73026. /**
  73027. * The base url used to load the left and right controller models
  73028. */
  73029. static MODEL_BASE_URL: string;
  73030. /**
  73031. * File name for the controller model.
  73032. */
  73033. static MODEL_FILENAME: string;
  73034. profileId: string;
  73035. /**
  73036. * Create a new Vive motion controller object
  73037. * @param scene the scene to use to create this controller
  73038. * @param gamepadObject the corresponding gamepad object
  73039. * @param handness the handness of the controller
  73040. */
  73041. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73042. protected _getFilenameAndPath(): {
  73043. filename: string;
  73044. path: string;
  73045. };
  73046. protected _getModelLoadingConstraints(): boolean;
  73047. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73048. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73049. protected _updateModel(): void;
  73050. }
  73051. }
  73052. declare module "babylonjs/XR/motionController/index" {
  73053. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73054. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  73055. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  73056. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  73057. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  73058. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  73059. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  73060. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  73061. }
  73062. declare module "babylonjs/XR/index" {
  73063. export * from "babylonjs/XR/webXRCamera";
  73064. export * from "babylonjs/XR/webXREnterExitUI";
  73065. export * from "babylonjs/XR/webXRExperienceHelper";
  73066. export * from "babylonjs/XR/webXRInput";
  73067. export * from "babylonjs/XR/webXRInputSource";
  73068. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  73069. export * from "babylonjs/XR/webXRTypes";
  73070. export * from "babylonjs/XR/webXRSessionManager";
  73071. export * from "babylonjs/XR/webXRDefaultExperience";
  73072. export * from "babylonjs/XR/webXRFeaturesManager";
  73073. export * from "babylonjs/XR/features/index";
  73074. export * from "babylonjs/XR/motionController/index";
  73075. }
  73076. declare module "babylonjs/index" {
  73077. export * from "babylonjs/abstractScene";
  73078. export * from "babylonjs/Actions/index";
  73079. export * from "babylonjs/Animations/index";
  73080. export * from "babylonjs/assetContainer";
  73081. export * from "babylonjs/Audio/index";
  73082. export * from "babylonjs/Behaviors/index";
  73083. export * from "babylonjs/Bones/index";
  73084. export * from "babylonjs/Cameras/index";
  73085. export * from "babylonjs/Collisions/index";
  73086. export * from "babylonjs/Culling/index";
  73087. export * from "babylonjs/Debug/index";
  73088. export * from "babylonjs/Engines/index";
  73089. export * from "babylonjs/Events/index";
  73090. export * from "babylonjs/Gamepads/index";
  73091. export * from "babylonjs/Gizmos/index";
  73092. export * from "babylonjs/Helpers/index";
  73093. export * from "babylonjs/Instrumentation/index";
  73094. export * from "babylonjs/Layers/index";
  73095. export * from "babylonjs/LensFlares/index";
  73096. export * from "babylonjs/Lights/index";
  73097. export * from "babylonjs/Loading/index";
  73098. export * from "babylonjs/Materials/index";
  73099. export * from "babylonjs/Maths/index";
  73100. export * from "babylonjs/Meshes/index";
  73101. export * from "babylonjs/Morph/index";
  73102. export * from "babylonjs/Navigation/index";
  73103. export * from "babylonjs/node";
  73104. export * from "babylonjs/Offline/index";
  73105. export * from "babylonjs/Particles/index";
  73106. export * from "babylonjs/Physics/index";
  73107. export * from "babylonjs/PostProcesses/index";
  73108. export * from "babylonjs/Probes/index";
  73109. export * from "babylonjs/Rendering/index";
  73110. export * from "babylonjs/scene";
  73111. export * from "babylonjs/sceneComponent";
  73112. export * from "babylonjs/Sprites/index";
  73113. export * from "babylonjs/States/index";
  73114. export * from "babylonjs/Misc/index";
  73115. export * from "babylonjs/XR/index";
  73116. export * from "babylonjs/types";
  73117. }
  73118. declare module "babylonjs/Animations/pathCursor" {
  73119. import { Vector3 } from "babylonjs/Maths/math.vector";
  73120. import { Path2 } from "babylonjs/Maths/math.path";
  73121. /**
  73122. * A cursor which tracks a point on a path
  73123. */
  73124. export class PathCursor {
  73125. private path;
  73126. /**
  73127. * Stores path cursor callbacks for when an onchange event is triggered
  73128. */
  73129. private _onchange;
  73130. /**
  73131. * The value of the path cursor
  73132. */
  73133. value: number;
  73134. /**
  73135. * The animation array of the path cursor
  73136. */
  73137. animations: Animation[];
  73138. /**
  73139. * Initializes the path cursor
  73140. * @param path The path to track
  73141. */
  73142. constructor(path: Path2);
  73143. /**
  73144. * Gets the cursor point on the path
  73145. * @returns A point on the path cursor at the cursor location
  73146. */
  73147. getPoint(): Vector3;
  73148. /**
  73149. * Moves the cursor ahead by the step amount
  73150. * @param step The amount to move the cursor forward
  73151. * @returns This path cursor
  73152. */
  73153. moveAhead(step?: number): PathCursor;
  73154. /**
  73155. * Moves the cursor behind by the step amount
  73156. * @param step The amount to move the cursor back
  73157. * @returns This path cursor
  73158. */
  73159. moveBack(step?: number): PathCursor;
  73160. /**
  73161. * Moves the cursor by the step amount
  73162. * If the step amount is greater than one, an exception is thrown
  73163. * @param step The amount to move the cursor
  73164. * @returns This path cursor
  73165. */
  73166. move(step: number): PathCursor;
  73167. /**
  73168. * Ensures that the value is limited between zero and one
  73169. * @returns This path cursor
  73170. */
  73171. private ensureLimits;
  73172. /**
  73173. * Runs onchange callbacks on change (used by the animation engine)
  73174. * @returns This path cursor
  73175. */
  73176. private raiseOnChange;
  73177. /**
  73178. * Executes a function on change
  73179. * @param f A path cursor onchange callback
  73180. * @returns This path cursor
  73181. */
  73182. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73183. }
  73184. }
  73185. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  73186. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  73187. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  73188. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  73189. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  73190. }
  73191. declare module "babylonjs/Engines/Processors/Expressions/index" {
  73192. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  73193. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  73194. }
  73195. declare module "babylonjs/Engines/Processors/index" {
  73196. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  73197. export * from "babylonjs/Engines/Processors/Expressions/index";
  73198. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  73199. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  73200. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  73201. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  73202. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  73203. export * from "babylonjs/Engines/Processors/shaderProcessor";
  73204. }
  73205. declare module "babylonjs/Legacy/legacy" {
  73206. import * as Babylon from "babylonjs/index";
  73207. export * from "babylonjs/index";
  73208. }
  73209. declare module "babylonjs/Shaders/blur.fragment" {
  73210. /** @hidden */
  73211. export var blurPixelShader: {
  73212. name: string;
  73213. shader: string;
  73214. };
  73215. }
  73216. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  73217. /** @hidden */
  73218. export var pointCloudVertexDeclaration: {
  73219. name: string;
  73220. shader: string;
  73221. };
  73222. }
  73223. declare module "babylonjs" {
  73224. export * from "babylonjs/Legacy/legacy";
  73225. }
  73226. declare module BABYLON {
  73227. /** Alias type for value that can be null */
  73228. export type Nullable<T> = T | null;
  73229. /**
  73230. * Alias type for number that are floats
  73231. * @ignorenaming
  73232. */
  73233. export type float = number;
  73234. /**
  73235. * Alias type for number that are doubles.
  73236. * @ignorenaming
  73237. */
  73238. export type double = number;
  73239. /**
  73240. * Alias type for number that are integer
  73241. * @ignorenaming
  73242. */
  73243. export type int = number;
  73244. /** Alias type for number array or Float32Array */
  73245. export type FloatArray = number[] | Float32Array;
  73246. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  73247. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  73248. /**
  73249. * Alias for types that can be used by a Buffer or VertexBuffer.
  73250. */
  73251. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  73252. /**
  73253. * Alias type for primitive types
  73254. * @ignorenaming
  73255. */
  73256. type Primitive = undefined | null | boolean | string | number | Function;
  73257. /**
  73258. * Type modifier to make all the properties of an object Readonly
  73259. */
  73260. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  73261. /**
  73262. * Type modifier to make all the properties of an object Readonly recursively
  73263. */
  73264. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  73265. /**
  73266. * Type modifier to make object properties readonly.
  73267. */
  73268. export type DeepImmutableObject<T> = {
  73269. readonly [K in keyof T]: DeepImmutable<T[K]>;
  73270. };
  73271. /** @hidden */
  73272. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  73273. }
  73274. }
  73275. declare module BABYLON {
  73276. /**
  73277. * A class serves as a medium between the observable and its observers
  73278. */
  73279. export class EventState {
  73280. /**
  73281. * Create a new EventState
  73282. * @param mask defines the mask associated with this state
  73283. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73284. * @param target defines the original target of the state
  73285. * @param currentTarget defines the current target of the state
  73286. */
  73287. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  73288. /**
  73289. * Initialize the current event state
  73290. * @param mask defines the mask associated with this state
  73291. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73292. * @param target defines the original target of the state
  73293. * @param currentTarget defines the current target of the state
  73294. * @returns the current event state
  73295. */
  73296. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73297. /**
  73298. * An Observer can set this property to true to prevent subsequent observers of being notified
  73299. */
  73300. skipNextObservers: boolean;
  73301. /**
  73302. * Get the mask value that were used to trigger the event corresponding to this EventState object
  73303. */
  73304. mask: number;
  73305. /**
  73306. * The object that originally notified the event
  73307. */
  73308. target?: any;
  73309. /**
  73310. * The current object in the bubbling phase
  73311. */
  73312. currentTarget?: any;
  73313. /**
  73314. * This will be populated with the return value of the last function that was executed.
  73315. * If it is the first function in the callback chain it will be the event data.
  73316. */
  73317. lastReturnValue?: any;
  73318. }
  73319. /**
  73320. * Represent an Observer registered to a given Observable object.
  73321. */
  73322. export class Observer<T> {
  73323. /**
  73324. * Defines the callback to call when the observer is notified
  73325. */
  73326. callback: (eventData: T, eventState: EventState) => void;
  73327. /**
  73328. * Defines the mask of the observer (used to filter notifications)
  73329. */
  73330. mask: number;
  73331. /**
  73332. * Defines the current scope used to restore the JS context
  73333. */
  73334. scope: any;
  73335. /** @hidden */
  73336. _willBeUnregistered: boolean;
  73337. /**
  73338. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  73339. */
  73340. unregisterOnNextCall: boolean;
  73341. /**
  73342. * Creates a new observer
  73343. * @param callback defines the callback to call when the observer is notified
  73344. * @param mask defines the mask of the observer (used to filter notifications)
  73345. * @param scope defines the current scope used to restore the JS context
  73346. */
  73347. constructor(
  73348. /**
  73349. * Defines the callback to call when the observer is notified
  73350. */
  73351. callback: (eventData: T, eventState: EventState) => void,
  73352. /**
  73353. * Defines the mask of the observer (used to filter notifications)
  73354. */
  73355. mask: number,
  73356. /**
  73357. * Defines the current scope used to restore the JS context
  73358. */
  73359. scope?: any);
  73360. }
  73361. /**
  73362. * Represent a list of observers registered to multiple Observables object.
  73363. */
  73364. export class MultiObserver<T> {
  73365. private _observers;
  73366. private _observables;
  73367. /**
  73368. * Release associated resources
  73369. */
  73370. dispose(): void;
  73371. /**
  73372. * Raise a callback when one of the observable will notify
  73373. * @param observables defines a list of observables to watch
  73374. * @param callback defines the callback to call on notification
  73375. * @param mask defines the mask used to filter notifications
  73376. * @param scope defines the current scope used to restore the JS context
  73377. * @returns the new MultiObserver
  73378. */
  73379. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  73380. }
  73381. /**
  73382. * The Observable class is a simple implementation of the Observable pattern.
  73383. *
  73384. * 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.
  73385. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  73386. * 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).
  73387. * 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.
  73388. */
  73389. export class Observable<T> {
  73390. private _observers;
  73391. private _eventState;
  73392. private _onObserverAdded;
  73393. /**
  73394. * Gets the list of observers
  73395. */
  73396. get observers(): Array<Observer<T>>;
  73397. /**
  73398. * Creates a new observable
  73399. * @param onObserverAdded defines a callback to call when a new observer is added
  73400. */
  73401. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  73402. /**
  73403. * Create a new Observer with the specified callback
  73404. * @param callback the callback that will be executed for that Observer
  73405. * @param mask the mask used to filter observers
  73406. * @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.
  73407. * @param scope optional scope for the callback to be called from
  73408. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  73409. * @returns the new observer created for the callback
  73410. */
  73411. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  73412. /**
  73413. * Create a new Observer with the specified callback and unregisters after the next notification
  73414. * @param callback the callback that will be executed for that Observer
  73415. * @returns the new observer created for the callback
  73416. */
  73417. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  73418. /**
  73419. * Remove an Observer from the Observable object
  73420. * @param observer the instance of the Observer to remove
  73421. * @returns false if it doesn't belong to this Observable
  73422. */
  73423. remove(observer: Nullable<Observer<T>>): boolean;
  73424. /**
  73425. * Remove a callback from the Observable object
  73426. * @param callback the callback to remove
  73427. * @param scope optional scope. If used only the callbacks with this scope will be removed
  73428. * @returns false if it doesn't belong to this Observable
  73429. */
  73430. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  73431. private _deferUnregister;
  73432. private _remove;
  73433. /**
  73434. * Moves the observable to the top of the observer list making it get called first when notified
  73435. * @param observer the observer to move
  73436. */
  73437. makeObserverTopPriority(observer: Observer<T>): void;
  73438. /**
  73439. * Moves the observable to the bottom of the observer list making it get called last when notified
  73440. * @param observer the observer to move
  73441. */
  73442. makeObserverBottomPriority(observer: Observer<T>): void;
  73443. /**
  73444. * Notify all Observers by calling their respective callback with the given data
  73445. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  73446. * @param eventData defines the data to send to all observers
  73447. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  73448. * @param target defines the original target of the state
  73449. * @param currentTarget defines the current target of the state
  73450. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  73451. */
  73452. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  73453. /**
  73454. * Calling this will execute each callback, expecting it to be a promise or return a value.
  73455. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  73456. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  73457. * and it is crucial that all callbacks will be executed.
  73458. * The order of the callbacks is kept, callbacks are not executed parallel.
  73459. *
  73460. * @param eventData The data to be sent to each callback
  73461. * @param mask is used to filter observers defaults to -1
  73462. * @param target defines the callback target (see EventState)
  73463. * @param currentTarget defines he current object in the bubbling phase
  73464. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  73465. */
  73466. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  73467. /**
  73468. * Notify a specific observer
  73469. * @param observer defines the observer to notify
  73470. * @param eventData defines the data to be sent to each callback
  73471. * @param mask is used to filter observers defaults to -1
  73472. */
  73473. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  73474. /**
  73475. * Gets a boolean indicating if the observable has at least one observer
  73476. * @returns true is the Observable has at least one Observer registered
  73477. */
  73478. hasObservers(): boolean;
  73479. /**
  73480. * Clear the list of observers
  73481. */
  73482. clear(): void;
  73483. /**
  73484. * Clone the current observable
  73485. * @returns a new observable
  73486. */
  73487. clone(): Observable<T>;
  73488. /**
  73489. * Does this observable handles observer registered with a given mask
  73490. * @param mask defines the mask to be tested
  73491. * @return whether or not one observer registered with the given mask is handeled
  73492. **/
  73493. hasSpecificMask(mask?: number): boolean;
  73494. }
  73495. }
  73496. declare module BABYLON {
  73497. /**
  73498. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  73499. * Babylon.js
  73500. */
  73501. export class DomManagement {
  73502. /**
  73503. * Checks if the window object exists
  73504. * @returns true if the window object exists
  73505. */
  73506. static IsWindowObjectExist(): boolean;
  73507. /**
  73508. * Checks if the navigator object exists
  73509. * @returns true if the navigator object exists
  73510. */
  73511. static IsNavigatorAvailable(): boolean;
  73512. /**
  73513. * Extracts text content from a DOM element hierarchy
  73514. * @param element defines the root element
  73515. * @returns a string
  73516. */
  73517. static GetDOMTextContent(element: HTMLElement): string;
  73518. }
  73519. }
  73520. declare module BABYLON {
  73521. /**
  73522. * Logger used througouht the application to allow configuration of
  73523. * the log level required for the messages.
  73524. */
  73525. export class Logger {
  73526. /**
  73527. * No log
  73528. */
  73529. static readonly NoneLogLevel: number;
  73530. /**
  73531. * Only message logs
  73532. */
  73533. static readonly MessageLogLevel: number;
  73534. /**
  73535. * Only warning logs
  73536. */
  73537. static readonly WarningLogLevel: number;
  73538. /**
  73539. * Only error logs
  73540. */
  73541. static readonly ErrorLogLevel: number;
  73542. /**
  73543. * All logs
  73544. */
  73545. static readonly AllLogLevel: number;
  73546. private static _LogCache;
  73547. /**
  73548. * Gets a value indicating the number of loading errors
  73549. * @ignorenaming
  73550. */
  73551. static errorsCount: number;
  73552. /**
  73553. * Callback called when a new log is added
  73554. */
  73555. static OnNewCacheEntry: (entry: string) => void;
  73556. private static _AddLogEntry;
  73557. private static _FormatMessage;
  73558. private static _LogDisabled;
  73559. private static _LogEnabled;
  73560. private static _WarnDisabled;
  73561. private static _WarnEnabled;
  73562. private static _ErrorDisabled;
  73563. private static _ErrorEnabled;
  73564. /**
  73565. * Log a message to the console
  73566. */
  73567. static Log: (message: string) => void;
  73568. /**
  73569. * Write a warning message to the console
  73570. */
  73571. static Warn: (message: string) => void;
  73572. /**
  73573. * Write an error message to the console
  73574. */
  73575. static Error: (message: string) => void;
  73576. /**
  73577. * Gets current log cache (list of logs)
  73578. */
  73579. static get LogCache(): string;
  73580. /**
  73581. * Clears the log cache
  73582. */
  73583. static ClearLogCache(): void;
  73584. /**
  73585. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  73586. */
  73587. static set LogLevels(level: number);
  73588. }
  73589. }
  73590. declare module BABYLON {
  73591. /** @hidden */
  73592. export class _TypeStore {
  73593. /** @hidden */
  73594. static RegisteredTypes: {
  73595. [key: string]: Object;
  73596. };
  73597. /** @hidden */
  73598. static GetClass(fqdn: string): any;
  73599. }
  73600. }
  73601. declare module BABYLON {
  73602. /**
  73603. * Helper to manipulate strings
  73604. */
  73605. export class StringTools {
  73606. /**
  73607. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  73608. * @param str Source string
  73609. * @param suffix Suffix to search for in the source string
  73610. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73611. */
  73612. static EndsWith(str: string, suffix: string): boolean;
  73613. /**
  73614. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  73615. * @param str Source string
  73616. * @param suffix Suffix to search for in the source string
  73617. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73618. */
  73619. static StartsWith(str: string, suffix: string): boolean;
  73620. /**
  73621. * Decodes a buffer into a string
  73622. * @param buffer The buffer to decode
  73623. * @returns The decoded string
  73624. */
  73625. static Decode(buffer: Uint8Array | Uint16Array): string;
  73626. /**
  73627. * Encode a buffer to a base64 string
  73628. * @param buffer defines the buffer to encode
  73629. * @returns the encoded string
  73630. */
  73631. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  73632. }
  73633. }
  73634. declare module BABYLON {
  73635. /**
  73636. * Class containing a set of static utilities functions for deep copy.
  73637. */
  73638. export class DeepCopier {
  73639. /**
  73640. * Tries to copy an object by duplicating every property
  73641. * @param source defines the source object
  73642. * @param destination defines the target object
  73643. * @param doNotCopyList defines a list of properties to avoid
  73644. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  73645. */
  73646. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  73647. }
  73648. }
  73649. declare module BABYLON {
  73650. /**
  73651. * Class containing a set of static utilities functions for precision date
  73652. */
  73653. export class PrecisionDate {
  73654. /**
  73655. * Gets either window.performance.now() if supported or Date.now() else
  73656. */
  73657. static get Now(): number;
  73658. }
  73659. }
  73660. declare module BABYLON {
  73661. /** @hidden */
  73662. export class _DevTools {
  73663. static WarnImport(name: string): string;
  73664. }
  73665. }
  73666. declare module BABYLON {
  73667. /**
  73668. * Interface used to define the mechanism to get data from the network
  73669. */
  73670. export interface IWebRequest {
  73671. /**
  73672. * Returns client's response url
  73673. */
  73674. responseURL: string;
  73675. /**
  73676. * Returns client's status
  73677. */
  73678. status: number;
  73679. /**
  73680. * Returns client's status as a text
  73681. */
  73682. statusText: string;
  73683. }
  73684. }
  73685. declare module BABYLON {
  73686. /**
  73687. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  73688. */
  73689. export class WebRequest implements IWebRequest {
  73690. private _xhr;
  73691. /**
  73692. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  73693. * i.e. when loading files, where the server/service expects an Authorization header
  73694. */
  73695. static CustomRequestHeaders: {
  73696. [key: string]: string;
  73697. };
  73698. /**
  73699. * Add callback functions in this array to update all the requests before they get sent to the network
  73700. */
  73701. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  73702. private _injectCustomRequestHeaders;
  73703. /**
  73704. * Gets or sets a function to be called when loading progress changes
  73705. */
  73706. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  73707. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  73708. /**
  73709. * Returns client's state
  73710. */
  73711. get readyState(): number;
  73712. /**
  73713. * Returns client's status
  73714. */
  73715. get status(): number;
  73716. /**
  73717. * Returns client's status as a text
  73718. */
  73719. get statusText(): string;
  73720. /**
  73721. * Returns client's response
  73722. */
  73723. get response(): any;
  73724. /**
  73725. * Returns client's response url
  73726. */
  73727. get responseURL(): string;
  73728. /**
  73729. * Returns client's response as text
  73730. */
  73731. get responseText(): string;
  73732. /**
  73733. * Gets or sets the expected response type
  73734. */
  73735. get responseType(): XMLHttpRequestResponseType;
  73736. set responseType(value: XMLHttpRequestResponseType);
  73737. /** @hidden */
  73738. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  73739. /** @hidden */
  73740. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  73741. /**
  73742. * Cancels any network activity
  73743. */
  73744. abort(): void;
  73745. /**
  73746. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  73747. * @param body defines an optional request body
  73748. */
  73749. send(body?: Document | BodyInit | null): void;
  73750. /**
  73751. * Sets the request method, request URL
  73752. * @param method defines the method to use (GET, POST, etc..)
  73753. * @param url defines the url to connect with
  73754. */
  73755. open(method: string, url: string): void;
  73756. /**
  73757. * Sets the value of a request header.
  73758. * @param name The name of the header whose value is to be set
  73759. * @param value The value to set as the body of the header
  73760. */
  73761. setRequestHeader(name: string, value: string): void;
  73762. /**
  73763. * Get the string containing the text of a particular header's value.
  73764. * @param name The name of the header
  73765. * @returns The string containing the text of the given header name
  73766. */
  73767. getResponseHeader(name: string): Nullable<string>;
  73768. }
  73769. }
  73770. declare module BABYLON {
  73771. /**
  73772. * File request interface
  73773. */
  73774. export interface IFileRequest {
  73775. /**
  73776. * Raised when the request is complete (success or error).
  73777. */
  73778. onCompleteObservable: Observable<IFileRequest>;
  73779. /**
  73780. * Aborts the request for a file.
  73781. */
  73782. abort: () => void;
  73783. }
  73784. }
  73785. declare module BABYLON {
  73786. /**
  73787. * Define options used to create a render target texture
  73788. */
  73789. export class RenderTargetCreationOptions {
  73790. /**
  73791. * Specifies is mipmaps must be generated
  73792. */
  73793. generateMipMaps?: boolean;
  73794. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  73795. generateDepthBuffer?: boolean;
  73796. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  73797. generateStencilBuffer?: boolean;
  73798. /** Defines texture type (int by default) */
  73799. type?: number;
  73800. /** Defines sampling mode (trilinear by default) */
  73801. samplingMode?: number;
  73802. /** Defines format (RGBA by default) */
  73803. format?: number;
  73804. }
  73805. }
  73806. declare module BABYLON {
  73807. /** Defines the cross module used constants to avoid circular dependncies */
  73808. export class Constants {
  73809. /** Defines that alpha blending is disabled */
  73810. static readonly ALPHA_DISABLE: number;
  73811. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  73812. static readonly ALPHA_ADD: number;
  73813. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  73814. static readonly ALPHA_COMBINE: number;
  73815. /** Defines that alpha blending is DEST - SRC * DEST */
  73816. static readonly ALPHA_SUBTRACT: number;
  73817. /** Defines that alpha blending is SRC * DEST */
  73818. static readonly ALPHA_MULTIPLY: number;
  73819. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  73820. static readonly ALPHA_MAXIMIZED: number;
  73821. /** Defines that alpha blending is SRC + DEST */
  73822. static readonly ALPHA_ONEONE: number;
  73823. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  73824. static readonly ALPHA_PREMULTIPLIED: number;
  73825. /**
  73826. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  73827. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  73828. */
  73829. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  73830. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  73831. static readonly ALPHA_INTERPOLATE: number;
  73832. /**
  73833. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  73834. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  73835. */
  73836. static readonly ALPHA_SCREENMODE: number;
  73837. /**
  73838. * Defines that alpha blending is SRC + DST
  73839. * Alpha will be set to SRC ALPHA + DST ALPHA
  73840. */
  73841. static readonly ALPHA_ONEONE_ONEONE: number;
  73842. /**
  73843. * Defines that alpha blending is SRC * DST ALPHA + DST
  73844. * Alpha will be set to 0
  73845. */
  73846. static readonly ALPHA_ALPHATOCOLOR: number;
  73847. /**
  73848. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73849. */
  73850. static readonly ALPHA_REVERSEONEMINUS: number;
  73851. /**
  73852. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  73853. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  73854. */
  73855. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  73856. /**
  73857. * Defines that alpha blending is SRC + DST
  73858. * Alpha will be set to SRC ALPHA
  73859. */
  73860. static readonly ALPHA_ONEONE_ONEZERO: number;
  73861. /**
  73862. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73863. * Alpha will be set to DST ALPHA
  73864. */
  73865. static readonly ALPHA_EXCLUSION: number;
  73866. /** Defines that alpha blending equation a SUM */
  73867. static readonly ALPHA_EQUATION_ADD: number;
  73868. /** Defines that alpha blending equation a SUBSTRACTION */
  73869. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  73870. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  73871. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  73872. /** Defines that alpha blending equation a MAX operation */
  73873. static readonly ALPHA_EQUATION_MAX: number;
  73874. /** Defines that alpha blending equation a MIN operation */
  73875. static readonly ALPHA_EQUATION_MIN: number;
  73876. /**
  73877. * Defines that alpha blending equation a DARKEN operation:
  73878. * It takes the min of the src and sums the alpha channels.
  73879. */
  73880. static readonly ALPHA_EQUATION_DARKEN: number;
  73881. /** Defines that the ressource is not delayed*/
  73882. static readonly DELAYLOADSTATE_NONE: number;
  73883. /** Defines that the ressource was successfully delay loaded */
  73884. static readonly DELAYLOADSTATE_LOADED: number;
  73885. /** Defines that the ressource is currently delay loading */
  73886. static readonly DELAYLOADSTATE_LOADING: number;
  73887. /** Defines that the ressource is delayed and has not started loading */
  73888. static readonly DELAYLOADSTATE_NOTLOADED: number;
  73889. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  73890. static readonly NEVER: number;
  73891. /** 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 */
  73892. static readonly ALWAYS: number;
  73893. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  73894. static readonly LESS: number;
  73895. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  73896. static readonly EQUAL: number;
  73897. /** 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 */
  73898. static readonly LEQUAL: number;
  73899. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  73900. static readonly GREATER: number;
  73901. /** 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 */
  73902. static readonly GEQUAL: number;
  73903. /** 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 */
  73904. static readonly NOTEQUAL: number;
  73905. /** Passed to stencilOperation to specify that stencil value must be kept */
  73906. static readonly KEEP: number;
  73907. /** Passed to stencilOperation to specify that stencil value must be replaced */
  73908. static readonly REPLACE: number;
  73909. /** Passed to stencilOperation to specify that stencil value must be incremented */
  73910. static readonly INCR: number;
  73911. /** Passed to stencilOperation to specify that stencil value must be decremented */
  73912. static readonly DECR: number;
  73913. /** Passed to stencilOperation to specify that stencil value must be inverted */
  73914. static readonly INVERT: number;
  73915. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  73916. static readonly INCR_WRAP: number;
  73917. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  73918. static readonly DECR_WRAP: number;
  73919. /** Texture is not repeating outside of 0..1 UVs */
  73920. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  73921. /** Texture is repeating outside of 0..1 UVs */
  73922. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  73923. /** Texture is repeating and mirrored */
  73924. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  73925. /** ALPHA */
  73926. static readonly TEXTUREFORMAT_ALPHA: number;
  73927. /** LUMINANCE */
  73928. static readonly TEXTUREFORMAT_LUMINANCE: number;
  73929. /** LUMINANCE_ALPHA */
  73930. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  73931. /** RGB */
  73932. static readonly TEXTUREFORMAT_RGB: number;
  73933. /** RGBA */
  73934. static readonly TEXTUREFORMAT_RGBA: number;
  73935. /** RED */
  73936. static readonly TEXTUREFORMAT_RED: number;
  73937. /** RED (2nd reference) */
  73938. static readonly TEXTUREFORMAT_R: number;
  73939. /** RG */
  73940. static readonly TEXTUREFORMAT_RG: number;
  73941. /** RED_INTEGER */
  73942. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  73943. /** RED_INTEGER (2nd reference) */
  73944. static readonly TEXTUREFORMAT_R_INTEGER: number;
  73945. /** RG_INTEGER */
  73946. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  73947. /** RGB_INTEGER */
  73948. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  73949. /** RGBA_INTEGER */
  73950. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  73951. /** UNSIGNED_BYTE */
  73952. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  73953. /** UNSIGNED_BYTE (2nd reference) */
  73954. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  73955. /** FLOAT */
  73956. static readonly TEXTURETYPE_FLOAT: number;
  73957. /** HALF_FLOAT */
  73958. static readonly TEXTURETYPE_HALF_FLOAT: number;
  73959. /** BYTE */
  73960. static readonly TEXTURETYPE_BYTE: number;
  73961. /** SHORT */
  73962. static readonly TEXTURETYPE_SHORT: number;
  73963. /** UNSIGNED_SHORT */
  73964. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  73965. /** INT */
  73966. static readonly TEXTURETYPE_INT: number;
  73967. /** UNSIGNED_INT */
  73968. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  73969. /** UNSIGNED_SHORT_4_4_4_4 */
  73970. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  73971. /** UNSIGNED_SHORT_5_5_5_1 */
  73972. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  73973. /** UNSIGNED_SHORT_5_6_5 */
  73974. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  73975. /** UNSIGNED_INT_2_10_10_10_REV */
  73976. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  73977. /** UNSIGNED_INT_24_8 */
  73978. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  73979. /** UNSIGNED_INT_10F_11F_11F_REV */
  73980. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  73981. /** UNSIGNED_INT_5_9_9_9_REV */
  73982. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  73983. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  73984. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  73985. /** nearest is mag = nearest and min = nearest and no mip */
  73986. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  73987. /** mag = nearest and min = nearest and mip = none */
  73988. static readonly TEXTURE_NEAREST_NEAREST: number;
  73989. /** Bilinear is mag = linear and min = linear and no mip */
  73990. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  73991. /** mag = linear and min = linear and mip = none */
  73992. static readonly TEXTURE_LINEAR_LINEAR: number;
  73993. /** Trilinear is mag = linear and min = linear and mip = linear */
  73994. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  73995. /** Trilinear is mag = linear and min = linear and mip = linear */
  73996. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  73997. /** mag = nearest and min = nearest and mip = nearest */
  73998. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  73999. /** mag = nearest and min = linear and mip = nearest */
  74000. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  74001. /** mag = nearest and min = linear and mip = linear */
  74002. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  74003. /** mag = nearest and min = linear and mip = none */
  74004. static readonly TEXTURE_NEAREST_LINEAR: number;
  74005. /** nearest is mag = nearest and min = nearest and mip = linear */
  74006. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  74007. /** mag = linear and min = nearest and mip = nearest */
  74008. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  74009. /** mag = linear and min = nearest and mip = linear */
  74010. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  74011. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74012. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  74013. /** mag = linear and min = nearest and mip = none */
  74014. static readonly TEXTURE_LINEAR_NEAREST: number;
  74015. /** Explicit coordinates mode */
  74016. static readonly TEXTURE_EXPLICIT_MODE: number;
  74017. /** Spherical coordinates mode */
  74018. static readonly TEXTURE_SPHERICAL_MODE: number;
  74019. /** Planar coordinates mode */
  74020. static readonly TEXTURE_PLANAR_MODE: number;
  74021. /** Cubic coordinates mode */
  74022. static readonly TEXTURE_CUBIC_MODE: number;
  74023. /** Projection coordinates mode */
  74024. static readonly TEXTURE_PROJECTION_MODE: number;
  74025. /** Skybox coordinates mode */
  74026. static readonly TEXTURE_SKYBOX_MODE: number;
  74027. /** Inverse Cubic coordinates mode */
  74028. static readonly TEXTURE_INVCUBIC_MODE: number;
  74029. /** Equirectangular coordinates mode */
  74030. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  74031. /** Equirectangular Fixed coordinates mode */
  74032. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  74033. /** Equirectangular Fixed Mirrored coordinates mode */
  74034. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74035. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  74036. static readonly SCALEMODE_FLOOR: number;
  74037. /** Defines that texture rescaling will look for the nearest power of 2 size */
  74038. static readonly SCALEMODE_NEAREST: number;
  74039. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  74040. static readonly SCALEMODE_CEILING: number;
  74041. /**
  74042. * The dirty texture flag value
  74043. */
  74044. static readonly MATERIAL_TextureDirtyFlag: number;
  74045. /**
  74046. * The dirty light flag value
  74047. */
  74048. static readonly MATERIAL_LightDirtyFlag: number;
  74049. /**
  74050. * The dirty fresnel flag value
  74051. */
  74052. static readonly MATERIAL_FresnelDirtyFlag: number;
  74053. /**
  74054. * The dirty attribute flag value
  74055. */
  74056. static readonly MATERIAL_AttributesDirtyFlag: number;
  74057. /**
  74058. * The dirty misc flag value
  74059. */
  74060. static readonly MATERIAL_MiscDirtyFlag: number;
  74061. /**
  74062. * The all dirty flag value
  74063. */
  74064. static readonly MATERIAL_AllDirtyFlag: number;
  74065. /**
  74066. * Returns the triangle fill mode
  74067. */
  74068. static readonly MATERIAL_TriangleFillMode: number;
  74069. /**
  74070. * Returns the wireframe mode
  74071. */
  74072. static readonly MATERIAL_WireFrameFillMode: number;
  74073. /**
  74074. * Returns the point fill mode
  74075. */
  74076. static readonly MATERIAL_PointFillMode: number;
  74077. /**
  74078. * Returns the point list draw mode
  74079. */
  74080. static readonly MATERIAL_PointListDrawMode: number;
  74081. /**
  74082. * Returns the line list draw mode
  74083. */
  74084. static readonly MATERIAL_LineListDrawMode: number;
  74085. /**
  74086. * Returns the line loop draw mode
  74087. */
  74088. static readonly MATERIAL_LineLoopDrawMode: number;
  74089. /**
  74090. * Returns the line strip draw mode
  74091. */
  74092. static readonly MATERIAL_LineStripDrawMode: number;
  74093. /**
  74094. * Returns the triangle strip draw mode
  74095. */
  74096. static readonly MATERIAL_TriangleStripDrawMode: number;
  74097. /**
  74098. * Returns the triangle fan draw mode
  74099. */
  74100. static readonly MATERIAL_TriangleFanDrawMode: number;
  74101. /**
  74102. * Stores the clock-wise side orientation
  74103. */
  74104. static readonly MATERIAL_ClockWiseSideOrientation: number;
  74105. /**
  74106. * Stores the counter clock-wise side orientation
  74107. */
  74108. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  74109. /**
  74110. * Nothing
  74111. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74112. */
  74113. static readonly ACTION_NothingTrigger: number;
  74114. /**
  74115. * On pick
  74116. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74117. */
  74118. static readonly ACTION_OnPickTrigger: number;
  74119. /**
  74120. * On left pick
  74121. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74122. */
  74123. static readonly ACTION_OnLeftPickTrigger: number;
  74124. /**
  74125. * On right pick
  74126. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74127. */
  74128. static readonly ACTION_OnRightPickTrigger: number;
  74129. /**
  74130. * On center pick
  74131. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74132. */
  74133. static readonly ACTION_OnCenterPickTrigger: number;
  74134. /**
  74135. * On pick down
  74136. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74137. */
  74138. static readonly ACTION_OnPickDownTrigger: number;
  74139. /**
  74140. * On double pick
  74141. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74142. */
  74143. static readonly ACTION_OnDoublePickTrigger: number;
  74144. /**
  74145. * On pick up
  74146. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74147. */
  74148. static readonly ACTION_OnPickUpTrigger: number;
  74149. /**
  74150. * On pick out.
  74151. * This trigger will only be raised if you also declared a OnPickDown
  74152. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74153. */
  74154. static readonly ACTION_OnPickOutTrigger: number;
  74155. /**
  74156. * On long press
  74157. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74158. */
  74159. static readonly ACTION_OnLongPressTrigger: number;
  74160. /**
  74161. * On pointer over
  74162. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74163. */
  74164. static readonly ACTION_OnPointerOverTrigger: number;
  74165. /**
  74166. * On pointer out
  74167. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74168. */
  74169. static readonly ACTION_OnPointerOutTrigger: number;
  74170. /**
  74171. * On every frame
  74172. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74173. */
  74174. static readonly ACTION_OnEveryFrameTrigger: number;
  74175. /**
  74176. * On intersection enter
  74177. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74178. */
  74179. static readonly ACTION_OnIntersectionEnterTrigger: number;
  74180. /**
  74181. * On intersection exit
  74182. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74183. */
  74184. static readonly ACTION_OnIntersectionExitTrigger: number;
  74185. /**
  74186. * On key down
  74187. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74188. */
  74189. static readonly ACTION_OnKeyDownTrigger: number;
  74190. /**
  74191. * On key up
  74192. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74193. */
  74194. static readonly ACTION_OnKeyUpTrigger: number;
  74195. /**
  74196. * Billboard mode will only apply to Y axis
  74197. */
  74198. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  74199. /**
  74200. * Billboard mode will apply to all axes
  74201. */
  74202. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  74203. /**
  74204. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74205. */
  74206. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  74207. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  74208. * Test order :
  74209. * Is the bounding sphere outside the frustum ?
  74210. * If not, are the bounding box vertices outside the frustum ?
  74211. * It not, then the cullable object is in the frustum.
  74212. */
  74213. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  74214. /** Culling strategy : Bounding Sphere Only.
  74215. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  74216. * It's also less accurate than the standard because some not visible objects can still be selected.
  74217. * Test : is the bounding sphere outside the frustum ?
  74218. * If not, then the cullable object is in the frustum.
  74219. */
  74220. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  74221. /** Culling strategy : Optimistic Inclusion.
  74222. * This in an inclusion test first, then the standard exclusion test.
  74223. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  74224. * 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.
  74225. * Anyway, it's as accurate as the standard strategy.
  74226. * Test :
  74227. * Is the cullable object bounding sphere center in the frustum ?
  74228. * If not, apply the default culling strategy.
  74229. */
  74230. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  74231. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  74232. * This in an inclusion test first, then the bounding sphere only exclusion test.
  74233. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  74234. * 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.
  74235. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  74236. * Test :
  74237. * Is the cullable object bounding sphere center in the frustum ?
  74238. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  74239. */
  74240. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  74241. /**
  74242. * No logging while loading
  74243. */
  74244. static readonly SCENELOADER_NO_LOGGING: number;
  74245. /**
  74246. * Minimal logging while loading
  74247. */
  74248. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  74249. /**
  74250. * Summary logging while loading
  74251. */
  74252. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  74253. /**
  74254. * Detailled logging while loading
  74255. */
  74256. static readonly SCENELOADER_DETAILED_LOGGING: number;
  74257. }
  74258. }
  74259. declare module BABYLON {
  74260. /**
  74261. * This represents the required contract to create a new type of texture loader.
  74262. */
  74263. export interface IInternalTextureLoader {
  74264. /**
  74265. * Defines wether the loader supports cascade loading the different faces.
  74266. */
  74267. supportCascades: boolean;
  74268. /**
  74269. * This returns if the loader support the current file information.
  74270. * @param extension defines the file extension of the file being loaded
  74271. * @returns true if the loader can load the specified file
  74272. */
  74273. canLoad(extension: string): boolean;
  74274. /**
  74275. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  74276. * @param data contains the texture data
  74277. * @param texture defines the BabylonJS internal texture
  74278. * @param createPolynomials will be true if polynomials have been requested
  74279. * @param onLoad defines the callback to trigger once the texture is ready
  74280. * @param onError defines the callback to trigger in case of error
  74281. */
  74282. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  74283. /**
  74284. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  74285. * @param data contains the texture data
  74286. * @param texture defines the BabylonJS internal texture
  74287. * @param callback defines the method to call once ready to upload
  74288. */
  74289. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  74290. }
  74291. }
  74292. declare module BABYLON {
  74293. /**
  74294. * Class used to store and describe the pipeline context associated with an effect
  74295. */
  74296. export interface IPipelineContext {
  74297. /**
  74298. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  74299. */
  74300. isAsync: boolean;
  74301. /**
  74302. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  74303. */
  74304. isReady: boolean;
  74305. /** @hidden */
  74306. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  74307. }
  74308. }
  74309. declare module BABYLON {
  74310. /**
  74311. * Class used to store gfx data (like WebGLBuffer)
  74312. */
  74313. export class DataBuffer {
  74314. /**
  74315. * Gets or sets the number of objects referencing this buffer
  74316. */
  74317. references: number;
  74318. /** Gets or sets the size of the underlying buffer */
  74319. capacity: number;
  74320. /**
  74321. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  74322. */
  74323. is32Bits: boolean;
  74324. /**
  74325. * Gets the underlying buffer
  74326. */
  74327. get underlyingResource(): any;
  74328. }
  74329. }
  74330. declare module BABYLON {
  74331. /** @hidden */
  74332. export interface IShaderProcessor {
  74333. attributeProcessor?: (attribute: string) => string;
  74334. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  74335. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  74336. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  74337. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  74338. lineProcessor?: (line: string, isFragment: boolean) => string;
  74339. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74340. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74341. }
  74342. }
  74343. declare module BABYLON {
  74344. /** @hidden */
  74345. export interface ProcessingOptions {
  74346. defines: string[];
  74347. indexParameters: any;
  74348. isFragment: boolean;
  74349. shouldUseHighPrecisionShader: boolean;
  74350. supportsUniformBuffers: boolean;
  74351. shadersRepository: string;
  74352. includesShadersStore: {
  74353. [key: string]: string;
  74354. };
  74355. processor?: IShaderProcessor;
  74356. version: string;
  74357. platformName: string;
  74358. lookForClosingBracketForUniformBuffer?: boolean;
  74359. }
  74360. }
  74361. declare module BABYLON {
  74362. /** @hidden */
  74363. export class ShaderCodeNode {
  74364. line: string;
  74365. children: ShaderCodeNode[];
  74366. additionalDefineKey?: string;
  74367. additionalDefineValue?: string;
  74368. isValid(preprocessors: {
  74369. [key: string]: string;
  74370. }): boolean;
  74371. process(preprocessors: {
  74372. [key: string]: string;
  74373. }, options: ProcessingOptions): string;
  74374. }
  74375. }
  74376. declare module BABYLON {
  74377. /** @hidden */
  74378. export class ShaderCodeCursor {
  74379. private _lines;
  74380. lineIndex: number;
  74381. get currentLine(): string;
  74382. get canRead(): boolean;
  74383. set lines(value: string[]);
  74384. }
  74385. }
  74386. declare module BABYLON {
  74387. /** @hidden */
  74388. export class ShaderCodeConditionNode extends ShaderCodeNode {
  74389. process(preprocessors: {
  74390. [key: string]: string;
  74391. }, options: ProcessingOptions): string;
  74392. }
  74393. }
  74394. declare module BABYLON {
  74395. /** @hidden */
  74396. export class ShaderDefineExpression {
  74397. isTrue(preprocessors: {
  74398. [key: string]: string;
  74399. }): boolean;
  74400. }
  74401. }
  74402. declare module BABYLON {
  74403. /** @hidden */
  74404. export class ShaderCodeTestNode extends ShaderCodeNode {
  74405. testExpression: ShaderDefineExpression;
  74406. isValid(preprocessors: {
  74407. [key: string]: string;
  74408. }): boolean;
  74409. }
  74410. }
  74411. declare module BABYLON {
  74412. /** @hidden */
  74413. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  74414. define: string;
  74415. not: boolean;
  74416. constructor(define: string, not?: boolean);
  74417. isTrue(preprocessors: {
  74418. [key: string]: string;
  74419. }): boolean;
  74420. }
  74421. }
  74422. declare module BABYLON {
  74423. /** @hidden */
  74424. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  74425. leftOperand: ShaderDefineExpression;
  74426. rightOperand: ShaderDefineExpression;
  74427. isTrue(preprocessors: {
  74428. [key: string]: string;
  74429. }): boolean;
  74430. }
  74431. }
  74432. declare module BABYLON {
  74433. /** @hidden */
  74434. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  74435. leftOperand: ShaderDefineExpression;
  74436. rightOperand: ShaderDefineExpression;
  74437. isTrue(preprocessors: {
  74438. [key: string]: string;
  74439. }): boolean;
  74440. }
  74441. }
  74442. declare module BABYLON {
  74443. /** @hidden */
  74444. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  74445. define: string;
  74446. operand: string;
  74447. testValue: string;
  74448. constructor(define: string, operand: string, testValue: string);
  74449. isTrue(preprocessors: {
  74450. [key: string]: string;
  74451. }): boolean;
  74452. }
  74453. }
  74454. declare module BABYLON {
  74455. /**
  74456. * Class used to enable access to offline support
  74457. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  74458. */
  74459. export interface IOfflineProvider {
  74460. /**
  74461. * Gets a boolean indicating if scene must be saved in the database
  74462. */
  74463. enableSceneOffline: boolean;
  74464. /**
  74465. * Gets a boolean indicating if textures must be saved in the database
  74466. */
  74467. enableTexturesOffline: boolean;
  74468. /**
  74469. * Open the offline support and make it available
  74470. * @param successCallback defines the callback to call on success
  74471. * @param errorCallback defines the callback to call on error
  74472. */
  74473. open(successCallback: () => void, errorCallback: () => void): void;
  74474. /**
  74475. * Loads an image from the offline support
  74476. * @param url defines the url to load from
  74477. * @param image defines the target DOM image
  74478. */
  74479. loadImage(url: string, image: HTMLImageElement): void;
  74480. /**
  74481. * Loads a file from offline support
  74482. * @param url defines the URL to load from
  74483. * @param sceneLoaded defines a callback to call on success
  74484. * @param progressCallBack defines a callback to call when progress changed
  74485. * @param errorCallback defines a callback to call on error
  74486. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  74487. */
  74488. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  74489. }
  74490. }
  74491. declare module BABYLON {
  74492. /**
  74493. * Class used to help managing file picking and drag'n'drop
  74494. * File Storage
  74495. */
  74496. export class FilesInputStore {
  74497. /**
  74498. * List of files ready to be loaded
  74499. */
  74500. static FilesToLoad: {
  74501. [key: string]: File;
  74502. };
  74503. }
  74504. }
  74505. declare module BABYLON {
  74506. /**
  74507. * Class used to define a retry strategy when error happens while loading assets
  74508. */
  74509. export class RetryStrategy {
  74510. /**
  74511. * Function used to defines an exponential back off strategy
  74512. * @param maxRetries defines the maximum number of retries (3 by default)
  74513. * @param baseInterval defines the interval between retries
  74514. * @returns the strategy function to use
  74515. */
  74516. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  74517. }
  74518. }
  74519. declare module BABYLON {
  74520. /**
  74521. * @ignore
  74522. * Application error to support additional information when loading a file
  74523. */
  74524. export abstract class BaseError extends Error {
  74525. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  74526. }
  74527. }
  74528. declare module BABYLON {
  74529. /** @ignore */
  74530. export class LoadFileError extends BaseError {
  74531. request?: WebRequest;
  74532. file?: File;
  74533. /**
  74534. * Creates a new LoadFileError
  74535. * @param message defines the message of the error
  74536. * @param request defines the optional web request
  74537. * @param file defines the optional file
  74538. */
  74539. constructor(message: string, object?: WebRequest | File);
  74540. }
  74541. /** @ignore */
  74542. export class RequestFileError extends BaseError {
  74543. request: WebRequest;
  74544. /**
  74545. * Creates a new LoadFileError
  74546. * @param message defines the message of the error
  74547. * @param request defines the optional web request
  74548. */
  74549. constructor(message: string, request: WebRequest);
  74550. }
  74551. /** @ignore */
  74552. export class ReadFileError extends BaseError {
  74553. file: File;
  74554. /**
  74555. * Creates a new ReadFileError
  74556. * @param message defines the message of the error
  74557. * @param file defines the optional file
  74558. */
  74559. constructor(message: string, file: File);
  74560. }
  74561. /**
  74562. * @hidden
  74563. */
  74564. export class FileTools {
  74565. /**
  74566. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  74567. */
  74568. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  74569. /**
  74570. * Gets or sets the base URL to use to load assets
  74571. */
  74572. static BaseUrl: string;
  74573. /**
  74574. * Default behaviour for cors in the application.
  74575. * It can be a string if the expected behavior is identical in the entire app.
  74576. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  74577. */
  74578. static CorsBehavior: string | ((url: string | string[]) => string);
  74579. /**
  74580. * Gets or sets a function used to pre-process url before using them to load assets
  74581. */
  74582. static PreprocessUrl: (url: string) => string;
  74583. /**
  74584. * Removes unwanted characters from an url
  74585. * @param url defines the url to clean
  74586. * @returns the cleaned url
  74587. */
  74588. private static _CleanUrl;
  74589. /**
  74590. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  74591. * @param url define the url we are trying
  74592. * @param element define the dom element where to configure the cors policy
  74593. */
  74594. static SetCorsBehavior(url: string | string[], element: {
  74595. crossOrigin: string | null;
  74596. }): void;
  74597. /**
  74598. * Loads an image as an HTMLImageElement.
  74599. * @param input url string, ArrayBuffer, or Blob to load
  74600. * @param onLoad callback called when the image successfully loads
  74601. * @param onError callback called when the image fails to load
  74602. * @param offlineProvider offline provider for caching
  74603. * @param mimeType optional mime type
  74604. * @returns the HTMLImageElement of the loaded image
  74605. */
  74606. 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>;
  74607. /**
  74608. * Reads a file from a File object
  74609. * @param file defines the file to load
  74610. * @param onSuccess defines the callback to call when data is loaded
  74611. * @param onProgress defines the callback to call during loading process
  74612. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  74613. * @param onError defines the callback to call when an error occurs
  74614. * @returns a file request object
  74615. */
  74616. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  74617. /**
  74618. * Loads a file from a url
  74619. * @param url url to load
  74620. * @param onSuccess callback called when the file successfully loads
  74621. * @param onProgress callback called while file is loading (if the server supports this mode)
  74622. * @param offlineProvider defines the offline provider for caching
  74623. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74624. * @param onError callback called when the file fails to load
  74625. * @returns a file request object
  74626. */
  74627. 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;
  74628. /**
  74629. * Loads a file
  74630. * @param url url to load
  74631. * @param onSuccess callback called when the file successfully loads
  74632. * @param onProgress callback called while file is loading (if the server supports this mode)
  74633. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74634. * @param onError callback called when the file fails to load
  74635. * @param onOpened callback called when the web request is opened
  74636. * @returns a file request object
  74637. */
  74638. 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;
  74639. /**
  74640. * Checks if the loaded document was accessed via `file:`-Protocol.
  74641. * @returns boolean
  74642. */
  74643. static IsFileURL(): boolean;
  74644. }
  74645. }
  74646. declare module BABYLON {
  74647. /** @hidden */
  74648. export class ShaderProcessor {
  74649. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  74650. private static _ProcessPrecision;
  74651. private static _ExtractOperation;
  74652. private static _BuildSubExpression;
  74653. private static _BuildExpression;
  74654. private static _MoveCursorWithinIf;
  74655. private static _MoveCursor;
  74656. private static _EvaluatePreProcessors;
  74657. private static _PreparePreProcessors;
  74658. private static _ProcessShaderConversion;
  74659. private static _ProcessIncludes;
  74660. /**
  74661. * Loads a file from a url
  74662. * @param url url to load
  74663. * @param onSuccess callback called when the file successfully loads
  74664. * @param onProgress callback called while file is loading (if the server supports this mode)
  74665. * @param offlineProvider defines the offline provider for caching
  74666. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74667. * @param onError callback called when the file fails to load
  74668. * @returns a file request object
  74669. * @hidden
  74670. */
  74671. 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;
  74672. }
  74673. }
  74674. declare module BABYLON {
  74675. /**
  74676. * @hidden
  74677. */
  74678. export interface IColor4Like {
  74679. r: float;
  74680. g: float;
  74681. b: float;
  74682. a: float;
  74683. }
  74684. /**
  74685. * @hidden
  74686. */
  74687. export interface IColor3Like {
  74688. r: float;
  74689. g: float;
  74690. b: float;
  74691. }
  74692. /**
  74693. * @hidden
  74694. */
  74695. export interface IVector4Like {
  74696. x: float;
  74697. y: float;
  74698. z: float;
  74699. w: float;
  74700. }
  74701. /**
  74702. * @hidden
  74703. */
  74704. export interface IVector3Like {
  74705. x: float;
  74706. y: float;
  74707. z: float;
  74708. }
  74709. /**
  74710. * @hidden
  74711. */
  74712. export interface IVector2Like {
  74713. x: float;
  74714. y: float;
  74715. }
  74716. /**
  74717. * @hidden
  74718. */
  74719. export interface IMatrixLike {
  74720. toArray(): DeepImmutable<Float32Array>;
  74721. updateFlag: int;
  74722. }
  74723. /**
  74724. * @hidden
  74725. */
  74726. export interface IViewportLike {
  74727. x: float;
  74728. y: float;
  74729. width: float;
  74730. height: float;
  74731. }
  74732. /**
  74733. * @hidden
  74734. */
  74735. export interface IPlaneLike {
  74736. normal: IVector3Like;
  74737. d: float;
  74738. normalize(): void;
  74739. }
  74740. }
  74741. declare module BABYLON {
  74742. /**
  74743. * Interface used to define common properties for effect fallbacks
  74744. */
  74745. export interface IEffectFallbacks {
  74746. /**
  74747. * Removes the defines that should be removed when falling back.
  74748. * @param currentDefines defines the current define statements for the shader.
  74749. * @param effect defines the current effect we try to compile
  74750. * @returns The resulting defines with defines of the current rank removed.
  74751. */
  74752. reduce(currentDefines: string, effect: Effect): string;
  74753. /**
  74754. * Removes the fallback from the bound mesh.
  74755. */
  74756. unBindMesh(): void;
  74757. /**
  74758. * Checks to see if more fallbacks are still availible.
  74759. */
  74760. hasMoreFallbacks: boolean;
  74761. }
  74762. }
  74763. declare module BABYLON {
  74764. /**
  74765. * Class used to evalaute queries containing `and` and `or` operators
  74766. */
  74767. export class AndOrNotEvaluator {
  74768. /**
  74769. * Evaluate a query
  74770. * @param query defines the query to evaluate
  74771. * @param evaluateCallback defines the callback used to filter result
  74772. * @returns true if the query matches
  74773. */
  74774. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  74775. private static _HandleParenthesisContent;
  74776. private static _SimplifyNegation;
  74777. }
  74778. }
  74779. declare module BABYLON {
  74780. /**
  74781. * Class used to store custom tags
  74782. */
  74783. export class Tags {
  74784. /**
  74785. * Adds support for tags on the given object
  74786. * @param obj defines the object to use
  74787. */
  74788. static EnableFor(obj: any): void;
  74789. /**
  74790. * Removes tags support
  74791. * @param obj defines the object to use
  74792. */
  74793. static DisableFor(obj: any): void;
  74794. /**
  74795. * Gets a boolean indicating if the given object has tags
  74796. * @param obj defines the object to use
  74797. * @returns a boolean
  74798. */
  74799. static HasTags(obj: any): boolean;
  74800. /**
  74801. * Gets the tags available on a given object
  74802. * @param obj defines the object to use
  74803. * @param asString defines if the tags must be returned as a string instead of an array of strings
  74804. * @returns the tags
  74805. */
  74806. static GetTags(obj: any, asString?: boolean): any;
  74807. /**
  74808. * Adds tags to an object
  74809. * @param obj defines the object to use
  74810. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  74811. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  74812. */
  74813. static AddTagsTo(obj: any, tagsString: string): void;
  74814. /**
  74815. * @hidden
  74816. */
  74817. static _AddTagTo(obj: any, tag: string): void;
  74818. /**
  74819. * Removes specific tags from a specific object
  74820. * @param obj defines the object to use
  74821. * @param tagsString defines the tags to remove
  74822. */
  74823. static RemoveTagsFrom(obj: any, tagsString: string): void;
  74824. /**
  74825. * @hidden
  74826. */
  74827. static _RemoveTagFrom(obj: any, tag: string): void;
  74828. /**
  74829. * Defines if tags hosted on an object match a given query
  74830. * @param obj defines the object to use
  74831. * @param tagsQuery defines the tag query
  74832. * @returns a boolean
  74833. */
  74834. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  74835. }
  74836. }
  74837. declare module BABYLON {
  74838. /**
  74839. * Scalar computation library
  74840. */
  74841. export class Scalar {
  74842. /**
  74843. * Two pi constants convenient for computation.
  74844. */
  74845. static TwoPi: number;
  74846. /**
  74847. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74848. * @param a number
  74849. * @param b number
  74850. * @param epsilon (default = 1.401298E-45)
  74851. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74852. */
  74853. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  74854. /**
  74855. * Returns a string : the upper case translation of the number i to hexadecimal.
  74856. * @param i number
  74857. * @returns the upper case translation of the number i to hexadecimal.
  74858. */
  74859. static ToHex(i: number): string;
  74860. /**
  74861. * Returns -1 if value is negative and +1 is value is positive.
  74862. * @param value the value
  74863. * @returns the value itself if it's equal to zero.
  74864. */
  74865. static Sign(value: number): number;
  74866. /**
  74867. * Returns the value itself if it's between min and max.
  74868. * Returns min if the value is lower than min.
  74869. * Returns max if the value is greater than max.
  74870. * @param value the value to clmap
  74871. * @param min the min value to clamp to (default: 0)
  74872. * @param max the max value to clamp to (default: 1)
  74873. * @returns the clamped value
  74874. */
  74875. static Clamp(value: number, min?: number, max?: number): number;
  74876. /**
  74877. * the log2 of value.
  74878. * @param value the value to compute log2 of
  74879. * @returns the log2 of value.
  74880. */
  74881. static Log2(value: number): number;
  74882. /**
  74883. * Loops the value, so that it is never larger than length and never smaller than 0.
  74884. *
  74885. * This is similar to the modulo operator but it works with floating point numbers.
  74886. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  74887. * With t = 5 and length = 2.5, the result would be 0.0.
  74888. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  74889. * @param value the value
  74890. * @param length the length
  74891. * @returns the looped value
  74892. */
  74893. static Repeat(value: number, length: number): number;
  74894. /**
  74895. * Normalize the value between 0.0 and 1.0 using min and max values
  74896. * @param value value to normalize
  74897. * @param min max to normalize between
  74898. * @param max min to normalize between
  74899. * @returns the normalized value
  74900. */
  74901. static Normalize(value: number, min: number, max: number): number;
  74902. /**
  74903. * Denormalize the value from 0.0 and 1.0 using min and max values
  74904. * @param normalized value to denormalize
  74905. * @param min max to denormalize between
  74906. * @param max min to denormalize between
  74907. * @returns the denormalized value
  74908. */
  74909. static Denormalize(normalized: number, min: number, max: number): number;
  74910. /**
  74911. * Calculates the shortest difference between two given angles given in degrees.
  74912. * @param current current angle in degrees
  74913. * @param target target angle in degrees
  74914. * @returns the delta
  74915. */
  74916. static DeltaAngle(current: number, target: number): number;
  74917. /**
  74918. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  74919. * @param tx value
  74920. * @param length length
  74921. * @returns The returned value will move back and forth between 0 and length
  74922. */
  74923. static PingPong(tx: number, length: number): number;
  74924. /**
  74925. * Interpolates between min and max with smoothing at the limits.
  74926. *
  74927. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  74928. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  74929. * @param from from
  74930. * @param to to
  74931. * @param tx value
  74932. * @returns the smooth stepped value
  74933. */
  74934. static SmoothStep(from: number, to: number, tx: number): number;
  74935. /**
  74936. * Moves a value current towards target.
  74937. *
  74938. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  74939. * Negative values of maxDelta pushes the value away from target.
  74940. * @param current current value
  74941. * @param target target value
  74942. * @param maxDelta max distance to move
  74943. * @returns resulting value
  74944. */
  74945. static MoveTowards(current: number, target: number, maxDelta: number): number;
  74946. /**
  74947. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  74948. *
  74949. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  74950. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  74951. * @param current current value
  74952. * @param target target value
  74953. * @param maxDelta max distance to move
  74954. * @returns resulting angle
  74955. */
  74956. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  74957. /**
  74958. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  74959. * @param start start value
  74960. * @param end target value
  74961. * @param amount amount to lerp between
  74962. * @returns the lerped value
  74963. */
  74964. static Lerp(start: number, end: number, amount: number): number;
  74965. /**
  74966. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  74967. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  74968. * @param start start value
  74969. * @param end target value
  74970. * @param amount amount to lerp between
  74971. * @returns the lerped value
  74972. */
  74973. static LerpAngle(start: number, end: number, amount: number): number;
  74974. /**
  74975. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  74976. * @param a start value
  74977. * @param b target value
  74978. * @param value value between a and b
  74979. * @returns the inverseLerp value
  74980. */
  74981. static InverseLerp(a: number, b: number, value: number): number;
  74982. /**
  74983. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  74984. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  74985. * @param value1 spline value
  74986. * @param tangent1 spline value
  74987. * @param value2 spline value
  74988. * @param tangent2 spline value
  74989. * @param amount input value
  74990. * @returns hermite result
  74991. */
  74992. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  74993. /**
  74994. * Returns a random float number between and min and max values
  74995. * @param min min value of random
  74996. * @param max max value of random
  74997. * @returns random value
  74998. */
  74999. static RandomRange(min: number, max: number): number;
  75000. /**
  75001. * This function returns percentage of a number in a given range.
  75002. *
  75003. * RangeToPercent(40,20,60) will return 0.5 (50%)
  75004. * RangeToPercent(34,0,100) will return 0.34 (34%)
  75005. * @param number to convert to percentage
  75006. * @param min min range
  75007. * @param max max range
  75008. * @returns the percentage
  75009. */
  75010. static RangeToPercent(number: number, min: number, max: number): number;
  75011. /**
  75012. * This function returns number that corresponds to the percentage in a given range.
  75013. *
  75014. * PercentToRange(0.34,0,100) will return 34.
  75015. * @param percent to convert to number
  75016. * @param min min range
  75017. * @param max max range
  75018. * @returns the number
  75019. */
  75020. static PercentToRange(percent: number, min: number, max: number): number;
  75021. /**
  75022. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  75023. * @param angle The angle to normalize in radian.
  75024. * @return The converted angle.
  75025. */
  75026. static NormalizeRadians(angle: number): number;
  75027. }
  75028. }
  75029. declare module BABYLON {
  75030. /**
  75031. * Constant used to convert a value to gamma space
  75032. * @ignorenaming
  75033. */
  75034. export const ToGammaSpace: number;
  75035. /**
  75036. * Constant used to convert a value to linear space
  75037. * @ignorenaming
  75038. */
  75039. export const ToLinearSpace = 2.2;
  75040. /**
  75041. * Constant used to define the minimal number value in Babylon.js
  75042. * @ignorenaming
  75043. */
  75044. let Epsilon: number;
  75045. }
  75046. declare module BABYLON {
  75047. /**
  75048. * Class used to represent a viewport on screen
  75049. */
  75050. export class Viewport {
  75051. /** viewport left coordinate */
  75052. x: number;
  75053. /** viewport top coordinate */
  75054. y: number;
  75055. /**viewport width */
  75056. width: number;
  75057. /** viewport height */
  75058. height: number;
  75059. /**
  75060. * Creates a Viewport object located at (x, y) and sized (width, height)
  75061. * @param x defines viewport left coordinate
  75062. * @param y defines viewport top coordinate
  75063. * @param width defines the viewport width
  75064. * @param height defines the viewport height
  75065. */
  75066. constructor(
  75067. /** viewport left coordinate */
  75068. x: number,
  75069. /** viewport top coordinate */
  75070. y: number,
  75071. /**viewport width */
  75072. width: number,
  75073. /** viewport height */
  75074. height: number);
  75075. /**
  75076. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  75077. * @param renderWidth defines the rendering width
  75078. * @param renderHeight defines the rendering height
  75079. * @returns a new Viewport
  75080. */
  75081. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  75082. /**
  75083. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  75084. * @param renderWidth defines the rendering width
  75085. * @param renderHeight defines the rendering height
  75086. * @param ref defines the target viewport
  75087. * @returns the current viewport
  75088. */
  75089. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  75090. /**
  75091. * Returns a new Viewport copied from the current one
  75092. * @returns a new Viewport
  75093. */
  75094. clone(): Viewport;
  75095. }
  75096. }
  75097. declare module BABYLON {
  75098. /**
  75099. * Class containing a set of static utilities functions for arrays.
  75100. */
  75101. export class ArrayTools {
  75102. /**
  75103. * Returns an array of the given size filled with element built from the given constructor and the paramters
  75104. * @param size the number of element to construct and put in the array
  75105. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  75106. * @returns a new array filled with new objects
  75107. */
  75108. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  75109. }
  75110. }
  75111. declare module BABYLON {
  75112. /**
  75113. * Class representing a vector containing 2 coordinates
  75114. */
  75115. export class Vector2 {
  75116. /** defines the first coordinate */
  75117. x: number;
  75118. /** defines the second coordinate */
  75119. y: number;
  75120. /**
  75121. * Creates a new Vector2 from the given x and y coordinates
  75122. * @param x defines the first coordinate
  75123. * @param y defines the second coordinate
  75124. */
  75125. constructor(
  75126. /** defines the first coordinate */
  75127. x?: number,
  75128. /** defines the second coordinate */
  75129. y?: number);
  75130. /**
  75131. * Gets a string with the Vector2 coordinates
  75132. * @returns a string with the Vector2 coordinates
  75133. */
  75134. toString(): string;
  75135. /**
  75136. * Gets class name
  75137. * @returns the string "Vector2"
  75138. */
  75139. getClassName(): string;
  75140. /**
  75141. * Gets current vector hash code
  75142. * @returns the Vector2 hash code as a number
  75143. */
  75144. getHashCode(): number;
  75145. /**
  75146. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  75147. * @param array defines the source array
  75148. * @param index defines the offset in source array
  75149. * @returns the current Vector2
  75150. */
  75151. toArray(array: FloatArray, index?: number): Vector2;
  75152. /**
  75153. * Copy the current vector to an array
  75154. * @returns a new array with 2 elements: the Vector2 coordinates.
  75155. */
  75156. asArray(): number[];
  75157. /**
  75158. * Sets the Vector2 coordinates with the given Vector2 coordinates
  75159. * @param source defines the source Vector2
  75160. * @returns the current updated Vector2
  75161. */
  75162. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  75163. /**
  75164. * Sets the Vector2 coordinates with the given floats
  75165. * @param x defines the first coordinate
  75166. * @param y defines the second coordinate
  75167. * @returns the current updated Vector2
  75168. */
  75169. copyFromFloats(x: number, y: number): Vector2;
  75170. /**
  75171. * Sets the Vector2 coordinates with the given floats
  75172. * @param x defines the first coordinate
  75173. * @param y defines the second coordinate
  75174. * @returns the current updated Vector2
  75175. */
  75176. set(x: number, y: number): Vector2;
  75177. /**
  75178. * Add another vector with the current one
  75179. * @param otherVector defines the other vector
  75180. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  75181. */
  75182. add(otherVector: DeepImmutable<Vector2>): Vector2;
  75183. /**
  75184. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  75185. * @param otherVector defines the other vector
  75186. * @param result defines the target vector
  75187. * @returns the unmodified current Vector2
  75188. */
  75189. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75190. /**
  75191. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  75192. * @param otherVector defines the other vector
  75193. * @returns the current updated Vector2
  75194. */
  75195. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75196. /**
  75197. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  75198. * @param otherVector defines the other vector
  75199. * @returns a new Vector2
  75200. */
  75201. addVector3(otherVector: Vector3): Vector2;
  75202. /**
  75203. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  75204. * @param otherVector defines the other vector
  75205. * @returns a new Vector2
  75206. */
  75207. subtract(otherVector: Vector2): Vector2;
  75208. /**
  75209. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  75210. * @param otherVector defines the other vector
  75211. * @param result defines the target vector
  75212. * @returns the unmodified current Vector2
  75213. */
  75214. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75215. /**
  75216. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  75217. * @param otherVector defines the other vector
  75218. * @returns the current updated Vector2
  75219. */
  75220. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75221. /**
  75222. * Multiplies in place the current Vector2 coordinates by the given ones
  75223. * @param otherVector defines the other vector
  75224. * @returns the current updated Vector2
  75225. */
  75226. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75227. /**
  75228. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  75229. * @param otherVector defines the other vector
  75230. * @returns a new Vector2
  75231. */
  75232. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  75233. /**
  75234. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  75235. * @param otherVector defines the other vector
  75236. * @param result defines the target vector
  75237. * @returns the unmodified current Vector2
  75238. */
  75239. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75240. /**
  75241. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  75242. * @param x defines the first coordinate
  75243. * @param y defines the second coordinate
  75244. * @returns a new Vector2
  75245. */
  75246. multiplyByFloats(x: number, y: number): Vector2;
  75247. /**
  75248. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  75249. * @param otherVector defines the other vector
  75250. * @returns a new Vector2
  75251. */
  75252. divide(otherVector: Vector2): Vector2;
  75253. /**
  75254. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  75255. * @param otherVector defines the other vector
  75256. * @param result defines the target vector
  75257. * @returns the unmodified current Vector2
  75258. */
  75259. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75260. /**
  75261. * Divides the current Vector2 coordinates by the given ones
  75262. * @param otherVector defines the other vector
  75263. * @returns the current updated Vector2
  75264. */
  75265. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75266. /**
  75267. * Gets a new Vector2 with current Vector2 negated coordinates
  75268. * @returns a new Vector2
  75269. */
  75270. negate(): Vector2;
  75271. /**
  75272. * Negate this vector in place
  75273. * @returns this
  75274. */
  75275. negateInPlace(): Vector2;
  75276. /**
  75277. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  75278. * @param result defines the Vector3 object where to store the result
  75279. * @returns the current Vector2
  75280. */
  75281. negateToRef(result: Vector2): Vector2;
  75282. /**
  75283. * Multiply the Vector2 coordinates by scale
  75284. * @param scale defines the scaling factor
  75285. * @returns the current updated Vector2
  75286. */
  75287. scaleInPlace(scale: number): Vector2;
  75288. /**
  75289. * Returns a new Vector2 scaled by "scale" from the current Vector2
  75290. * @param scale defines the scaling factor
  75291. * @returns a new Vector2
  75292. */
  75293. scale(scale: number): Vector2;
  75294. /**
  75295. * Scale the current Vector2 values by a factor to a given Vector2
  75296. * @param scale defines the scale factor
  75297. * @param result defines the Vector2 object where to store the result
  75298. * @returns the unmodified current Vector2
  75299. */
  75300. scaleToRef(scale: number, result: Vector2): Vector2;
  75301. /**
  75302. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  75303. * @param scale defines the scale factor
  75304. * @param result defines the Vector2 object where to store the result
  75305. * @returns the unmodified current Vector2
  75306. */
  75307. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  75308. /**
  75309. * Gets a boolean if two vectors are equals
  75310. * @param otherVector defines the other vector
  75311. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  75312. */
  75313. equals(otherVector: DeepImmutable<Vector2>): boolean;
  75314. /**
  75315. * Gets a boolean if two vectors are equals (using an epsilon value)
  75316. * @param otherVector defines the other vector
  75317. * @param epsilon defines the minimal distance to consider equality
  75318. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  75319. */
  75320. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  75321. /**
  75322. * Gets a new Vector2 from current Vector2 floored values
  75323. * @returns a new Vector2
  75324. */
  75325. floor(): Vector2;
  75326. /**
  75327. * Gets a new Vector2 from current Vector2 floored values
  75328. * @returns a new Vector2
  75329. */
  75330. fract(): Vector2;
  75331. /**
  75332. * Gets the length of the vector
  75333. * @returns the vector length (float)
  75334. */
  75335. length(): number;
  75336. /**
  75337. * Gets the vector squared length
  75338. * @returns the vector squared length (float)
  75339. */
  75340. lengthSquared(): number;
  75341. /**
  75342. * Normalize the vector
  75343. * @returns the current updated Vector2
  75344. */
  75345. normalize(): Vector2;
  75346. /**
  75347. * Gets a new Vector2 copied from the Vector2
  75348. * @returns a new Vector2
  75349. */
  75350. clone(): Vector2;
  75351. /**
  75352. * Gets a new Vector2(0, 0)
  75353. * @returns a new Vector2
  75354. */
  75355. static Zero(): Vector2;
  75356. /**
  75357. * Gets a new Vector2(1, 1)
  75358. * @returns a new Vector2
  75359. */
  75360. static One(): Vector2;
  75361. /**
  75362. * Gets a new Vector2 set from the given index element of the given array
  75363. * @param array defines the data source
  75364. * @param offset defines the offset in the data source
  75365. * @returns a new Vector2
  75366. */
  75367. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  75368. /**
  75369. * Sets "result" from the given index element of the given array
  75370. * @param array defines the data source
  75371. * @param offset defines the offset in the data source
  75372. * @param result defines the target vector
  75373. */
  75374. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  75375. /**
  75376. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  75377. * @param value1 defines 1st point of control
  75378. * @param value2 defines 2nd point of control
  75379. * @param value3 defines 3rd point of control
  75380. * @param value4 defines 4th point of control
  75381. * @param amount defines the interpolation factor
  75382. * @returns a new Vector2
  75383. */
  75384. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  75385. /**
  75386. * 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".
  75387. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  75388. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  75389. * @param value defines the value to clamp
  75390. * @param min defines the lower limit
  75391. * @param max defines the upper limit
  75392. * @returns a new Vector2
  75393. */
  75394. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  75395. /**
  75396. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  75397. * @param value1 defines the 1st control point
  75398. * @param tangent1 defines the outgoing tangent
  75399. * @param value2 defines the 2nd control point
  75400. * @param tangent2 defines the incoming tangent
  75401. * @param amount defines the interpolation factor
  75402. * @returns a new Vector2
  75403. */
  75404. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  75405. /**
  75406. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  75407. * @param start defines the start vector
  75408. * @param end defines the end vector
  75409. * @param amount defines the interpolation factor
  75410. * @returns a new Vector2
  75411. */
  75412. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  75413. /**
  75414. * Gets the dot product of the vector "left" and the vector "right"
  75415. * @param left defines first vector
  75416. * @param right defines second vector
  75417. * @returns the dot product (float)
  75418. */
  75419. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  75420. /**
  75421. * Returns a new Vector2 equal to the normalized given vector
  75422. * @param vector defines the vector to normalize
  75423. * @returns a new Vector2
  75424. */
  75425. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  75426. /**
  75427. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  75428. * @param left defines 1st vector
  75429. * @param right defines 2nd vector
  75430. * @returns a new Vector2
  75431. */
  75432. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75433. /**
  75434. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  75435. * @param left defines 1st vector
  75436. * @param right defines 2nd vector
  75437. * @returns a new Vector2
  75438. */
  75439. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75440. /**
  75441. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  75442. * @param vector defines the vector to transform
  75443. * @param transformation defines the matrix to apply
  75444. * @returns a new Vector2
  75445. */
  75446. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  75447. /**
  75448. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  75449. * @param vector defines the vector to transform
  75450. * @param transformation defines the matrix to apply
  75451. * @param result defines the target vector
  75452. */
  75453. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  75454. /**
  75455. * Determines if a given vector is included in a triangle
  75456. * @param p defines the vector to test
  75457. * @param p0 defines 1st triangle point
  75458. * @param p1 defines 2nd triangle point
  75459. * @param p2 defines 3rd triangle point
  75460. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  75461. */
  75462. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  75463. /**
  75464. * Gets the distance between the vectors "value1" and "value2"
  75465. * @param value1 defines first vector
  75466. * @param value2 defines second vector
  75467. * @returns the distance between vectors
  75468. */
  75469. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75470. /**
  75471. * Returns the squared distance between the vectors "value1" and "value2"
  75472. * @param value1 defines first vector
  75473. * @param value2 defines second vector
  75474. * @returns the squared distance between vectors
  75475. */
  75476. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75477. /**
  75478. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  75479. * @param value1 defines first vector
  75480. * @param value2 defines second vector
  75481. * @returns a new Vector2
  75482. */
  75483. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  75484. /**
  75485. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  75486. * @param p defines the middle point
  75487. * @param segA defines one point of the segment
  75488. * @param segB defines the other point of the segment
  75489. * @returns the shortest distance
  75490. */
  75491. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  75492. }
  75493. /**
  75494. * Class used to store (x,y,z) vector representation
  75495. * A Vector3 is the main object used in 3D geometry
  75496. * It can represent etiher the coordinates of a point the space, either a direction
  75497. * Reminder: js uses a left handed forward facing system
  75498. */
  75499. export class Vector3 {
  75500. /**
  75501. * Defines the first coordinates (on X axis)
  75502. */
  75503. x: number;
  75504. /**
  75505. * Defines the second coordinates (on Y axis)
  75506. */
  75507. y: number;
  75508. /**
  75509. * Defines the third coordinates (on Z axis)
  75510. */
  75511. z: number;
  75512. private static _UpReadOnly;
  75513. private static _ZeroReadOnly;
  75514. /**
  75515. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  75516. * @param x defines the first coordinates (on X axis)
  75517. * @param y defines the second coordinates (on Y axis)
  75518. * @param z defines the third coordinates (on Z axis)
  75519. */
  75520. constructor(
  75521. /**
  75522. * Defines the first coordinates (on X axis)
  75523. */
  75524. x?: number,
  75525. /**
  75526. * Defines the second coordinates (on Y axis)
  75527. */
  75528. y?: number,
  75529. /**
  75530. * Defines the third coordinates (on Z axis)
  75531. */
  75532. z?: number);
  75533. /**
  75534. * Creates a string representation of the Vector3
  75535. * @returns a string with the Vector3 coordinates.
  75536. */
  75537. toString(): string;
  75538. /**
  75539. * Gets the class name
  75540. * @returns the string "Vector3"
  75541. */
  75542. getClassName(): string;
  75543. /**
  75544. * Creates the Vector3 hash code
  75545. * @returns a number which tends to be unique between Vector3 instances
  75546. */
  75547. getHashCode(): number;
  75548. /**
  75549. * Creates an array containing three elements : the coordinates of the Vector3
  75550. * @returns a new array of numbers
  75551. */
  75552. asArray(): number[];
  75553. /**
  75554. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  75555. * @param array defines the destination array
  75556. * @param index defines the offset in the destination array
  75557. * @returns the current Vector3
  75558. */
  75559. toArray(array: FloatArray, index?: number): Vector3;
  75560. /**
  75561. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  75562. * @returns a new Quaternion object, computed from the Vector3 coordinates
  75563. */
  75564. toQuaternion(): Quaternion;
  75565. /**
  75566. * Adds the given vector to the current Vector3
  75567. * @param otherVector defines the second operand
  75568. * @returns the current updated Vector3
  75569. */
  75570. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75571. /**
  75572. * Adds the given coordinates to the current Vector3
  75573. * @param x defines the x coordinate of the operand
  75574. * @param y defines the y coordinate of the operand
  75575. * @param z defines the z coordinate of the operand
  75576. * @returns the current updated Vector3
  75577. */
  75578. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75579. /**
  75580. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  75581. * @param otherVector defines the second operand
  75582. * @returns the resulting Vector3
  75583. */
  75584. add(otherVector: DeepImmutable<Vector3>): Vector3;
  75585. /**
  75586. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  75587. * @param otherVector defines the second operand
  75588. * @param result defines the Vector3 object where to store the result
  75589. * @returns the current Vector3
  75590. */
  75591. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75592. /**
  75593. * Subtract the given vector from the current Vector3
  75594. * @param otherVector defines the second operand
  75595. * @returns the current updated Vector3
  75596. */
  75597. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75598. /**
  75599. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  75600. * @param otherVector defines the second operand
  75601. * @returns the resulting Vector3
  75602. */
  75603. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  75604. /**
  75605. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  75606. * @param otherVector defines the second operand
  75607. * @param result defines the Vector3 object where to store the result
  75608. * @returns the current Vector3
  75609. */
  75610. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75611. /**
  75612. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  75613. * @param x defines the x coordinate of the operand
  75614. * @param y defines the y coordinate of the operand
  75615. * @param z defines the z coordinate of the operand
  75616. * @returns the resulting Vector3
  75617. */
  75618. subtractFromFloats(x: number, y: number, z: number): Vector3;
  75619. /**
  75620. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  75621. * @param x defines the x coordinate of the operand
  75622. * @param y defines the y coordinate of the operand
  75623. * @param z defines the z coordinate of the operand
  75624. * @param result defines the Vector3 object where to store the result
  75625. * @returns the current Vector3
  75626. */
  75627. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  75628. /**
  75629. * Gets a new Vector3 set with the current Vector3 negated coordinates
  75630. * @returns a new Vector3
  75631. */
  75632. negate(): Vector3;
  75633. /**
  75634. * Negate this vector in place
  75635. * @returns this
  75636. */
  75637. negateInPlace(): Vector3;
  75638. /**
  75639. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  75640. * @param result defines the Vector3 object where to store the result
  75641. * @returns the current Vector3
  75642. */
  75643. negateToRef(result: Vector3): Vector3;
  75644. /**
  75645. * Multiplies the Vector3 coordinates by the float "scale"
  75646. * @param scale defines the multiplier factor
  75647. * @returns the current updated Vector3
  75648. */
  75649. scaleInPlace(scale: number): Vector3;
  75650. /**
  75651. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  75652. * @param scale defines the multiplier factor
  75653. * @returns a new Vector3
  75654. */
  75655. scale(scale: number): Vector3;
  75656. /**
  75657. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  75658. * @param scale defines the multiplier factor
  75659. * @param result defines the Vector3 object where to store the result
  75660. * @returns the current Vector3
  75661. */
  75662. scaleToRef(scale: number, result: Vector3): Vector3;
  75663. /**
  75664. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  75665. * @param scale defines the scale factor
  75666. * @param result defines the Vector3 object where to store the result
  75667. * @returns the unmodified current Vector3
  75668. */
  75669. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  75670. /**
  75671. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  75672. * @param otherVector defines the second operand
  75673. * @returns true if both vectors are equals
  75674. */
  75675. equals(otherVector: DeepImmutable<Vector3>): boolean;
  75676. /**
  75677. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  75678. * @param otherVector defines the second operand
  75679. * @param epsilon defines the minimal distance to define values as equals
  75680. * @returns true if both vectors are distant less than epsilon
  75681. */
  75682. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  75683. /**
  75684. * Returns true if the current Vector3 coordinates equals the given floats
  75685. * @param x defines the x coordinate of the operand
  75686. * @param y defines the y coordinate of the operand
  75687. * @param z defines the z coordinate of the operand
  75688. * @returns true if both vectors are equals
  75689. */
  75690. equalsToFloats(x: number, y: number, z: number): boolean;
  75691. /**
  75692. * Multiplies the current Vector3 coordinates by the given ones
  75693. * @param otherVector defines the second operand
  75694. * @returns the current updated Vector3
  75695. */
  75696. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75697. /**
  75698. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  75699. * @param otherVector defines the second operand
  75700. * @returns the new Vector3
  75701. */
  75702. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  75703. /**
  75704. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  75705. * @param otherVector defines the second operand
  75706. * @param result defines the Vector3 object where to store the result
  75707. * @returns the current Vector3
  75708. */
  75709. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75710. /**
  75711. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  75712. * @param x defines the x coordinate of the operand
  75713. * @param y defines the y coordinate of the operand
  75714. * @param z defines the z coordinate of the operand
  75715. * @returns the new Vector3
  75716. */
  75717. multiplyByFloats(x: number, y: number, z: number): Vector3;
  75718. /**
  75719. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  75720. * @param otherVector defines the second operand
  75721. * @returns the new Vector3
  75722. */
  75723. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  75724. /**
  75725. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  75726. * @param otherVector defines the second operand
  75727. * @param result defines the Vector3 object where to store the result
  75728. * @returns the current Vector3
  75729. */
  75730. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75731. /**
  75732. * Divides the current Vector3 coordinates by the given ones.
  75733. * @param otherVector defines the second operand
  75734. * @returns the current updated Vector3
  75735. */
  75736. divideInPlace(otherVector: Vector3): Vector3;
  75737. /**
  75738. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  75739. * @param other defines the second operand
  75740. * @returns the current updated Vector3
  75741. */
  75742. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75743. /**
  75744. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  75745. * @param other defines the second operand
  75746. * @returns the current updated Vector3
  75747. */
  75748. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75749. /**
  75750. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  75751. * @param x defines the x coordinate of the operand
  75752. * @param y defines the y coordinate of the operand
  75753. * @param z defines the z coordinate of the operand
  75754. * @returns the current updated Vector3
  75755. */
  75756. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75757. /**
  75758. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  75759. * @param x defines the x coordinate of the operand
  75760. * @param y defines the y coordinate of the operand
  75761. * @param z defines the z coordinate of the operand
  75762. * @returns the current updated Vector3
  75763. */
  75764. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75765. /**
  75766. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  75767. * Check if is non uniform within a certain amount of decimal places to account for this
  75768. * @param epsilon the amount the values can differ
  75769. * @returns if the the vector is non uniform to a certain number of decimal places
  75770. */
  75771. isNonUniformWithinEpsilon(epsilon: number): boolean;
  75772. /**
  75773. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  75774. */
  75775. get isNonUniform(): boolean;
  75776. /**
  75777. * Gets a new Vector3 from current Vector3 floored values
  75778. * @returns a new Vector3
  75779. */
  75780. floor(): Vector3;
  75781. /**
  75782. * Gets a new Vector3 from current Vector3 floored values
  75783. * @returns a new Vector3
  75784. */
  75785. fract(): Vector3;
  75786. /**
  75787. * Gets the length of the Vector3
  75788. * @returns the length of the Vector3
  75789. */
  75790. length(): number;
  75791. /**
  75792. * Gets the squared length of the Vector3
  75793. * @returns squared length of the Vector3
  75794. */
  75795. lengthSquared(): number;
  75796. /**
  75797. * Normalize the current Vector3.
  75798. * Please note that this is an in place operation.
  75799. * @returns the current updated Vector3
  75800. */
  75801. normalize(): Vector3;
  75802. /**
  75803. * Reorders the x y z properties of the vector in place
  75804. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  75805. * @returns the current updated vector
  75806. */
  75807. reorderInPlace(order: string): this;
  75808. /**
  75809. * Rotates the vector around 0,0,0 by a quaternion
  75810. * @param quaternion the rotation quaternion
  75811. * @param result vector to store the result
  75812. * @returns the resulting vector
  75813. */
  75814. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  75815. /**
  75816. * Rotates a vector around a given point
  75817. * @param quaternion the rotation quaternion
  75818. * @param point the point to rotate around
  75819. * @param result vector to store the result
  75820. * @returns the resulting vector
  75821. */
  75822. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  75823. /**
  75824. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  75825. * The cross product is then orthogonal to both current and "other"
  75826. * @param other defines the right operand
  75827. * @returns the cross product
  75828. */
  75829. cross(other: Vector3): Vector3;
  75830. /**
  75831. * Normalize the current Vector3 with the given input length.
  75832. * Please note that this is an in place operation.
  75833. * @param len the length of the vector
  75834. * @returns the current updated Vector3
  75835. */
  75836. normalizeFromLength(len: number): Vector3;
  75837. /**
  75838. * Normalize the current Vector3 to a new vector
  75839. * @returns the new Vector3
  75840. */
  75841. normalizeToNew(): Vector3;
  75842. /**
  75843. * Normalize the current Vector3 to the reference
  75844. * @param reference define the Vector3 to update
  75845. * @returns the updated Vector3
  75846. */
  75847. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  75848. /**
  75849. * Creates a new Vector3 copied from the current Vector3
  75850. * @returns the new Vector3
  75851. */
  75852. clone(): Vector3;
  75853. /**
  75854. * Copies the given vector coordinates to the current Vector3 ones
  75855. * @param source defines the source Vector3
  75856. * @returns the current updated Vector3
  75857. */
  75858. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  75859. /**
  75860. * Copies the given floats to the current Vector3 coordinates
  75861. * @param x defines the x coordinate of the operand
  75862. * @param y defines the y coordinate of the operand
  75863. * @param z defines the z coordinate of the operand
  75864. * @returns the current updated Vector3
  75865. */
  75866. copyFromFloats(x: number, y: number, z: number): Vector3;
  75867. /**
  75868. * Copies the given floats to the current Vector3 coordinates
  75869. * @param x defines the x coordinate of the operand
  75870. * @param y defines the y coordinate of the operand
  75871. * @param z defines the z coordinate of the operand
  75872. * @returns the current updated Vector3
  75873. */
  75874. set(x: number, y: number, z: number): Vector3;
  75875. /**
  75876. * Copies the given float to the current Vector3 coordinates
  75877. * @param v defines the x, y and z coordinates of the operand
  75878. * @returns the current updated Vector3
  75879. */
  75880. setAll(v: number): Vector3;
  75881. /**
  75882. * Get the clip factor between two vectors
  75883. * @param vector0 defines the first operand
  75884. * @param vector1 defines the second operand
  75885. * @param axis defines the axis to use
  75886. * @param size defines the size along the axis
  75887. * @returns the clip factor
  75888. */
  75889. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  75890. /**
  75891. * Get angle between two vectors
  75892. * @param vector0 angle between vector0 and vector1
  75893. * @param vector1 angle between vector0 and vector1
  75894. * @param normal direction of the normal
  75895. * @return the angle between vector0 and vector1
  75896. */
  75897. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  75898. /**
  75899. * Returns a new Vector3 set from the index "offset" of the given array
  75900. * @param array defines the source array
  75901. * @param offset defines the offset in the source array
  75902. * @returns the new Vector3
  75903. */
  75904. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  75905. /**
  75906. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  75907. * @param array defines the source array
  75908. * @param offset defines the offset in the source array
  75909. * @returns the new Vector3
  75910. * @deprecated Please use FromArray instead.
  75911. */
  75912. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  75913. /**
  75914. * Sets the given vector "result" with the element values from the index "offset" of the given array
  75915. * @param array defines the source array
  75916. * @param offset defines the offset in the source array
  75917. * @param result defines the Vector3 where to store the result
  75918. */
  75919. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  75920. /**
  75921. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  75922. * @param array defines the source array
  75923. * @param offset defines the offset in the source array
  75924. * @param result defines the Vector3 where to store the result
  75925. * @deprecated Please use FromArrayToRef instead.
  75926. */
  75927. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  75928. /**
  75929. * Sets the given vector "result" with the given floats.
  75930. * @param x defines the x coordinate of the source
  75931. * @param y defines the y coordinate of the source
  75932. * @param z defines the z coordinate of the source
  75933. * @param result defines the Vector3 where to store the result
  75934. */
  75935. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  75936. /**
  75937. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  75938. * @returns a new empty Vector3
  75939. */
  75940. static Zero(): Vector3;
  75941. /**
  75942. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  75943. * @returns a new unit Vector3
  75944. */
  75945. static One(): Vector3;
  75946. /**
  75947. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  75948. * @returns a new up Vector3
  75949. */
  75950. static Up(): Vector3;
  75951. /**
  75952. * Gets a up Vector3 that must not be updated
  75953. */
  75954. static get UpReadOnly(): DeepImmutable<Vector3>;
  75955. /**
  75956. * Gets a zero Vector3 that must not be updated
  75957. */
  75958. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  75959. /**
  75960. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  75961. * @returns a new down Vector3
  75962. */
  75963. static Down(): Vector3;
  75964. /**
  75965. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  75966. * @returns a new forward Vector3
  75967. */
  75968. static Forward(): Vector3;
  75969. /**
  75970. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  75971. * @returns a new forward Vector3
  75972. */
  75973. static Backward(): Vector3;
  75974. /**
  75975. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  75976. * @returns a new right Vector3
  75977. */
  75978. static Right(): Vector3;
  75979. /**
  75980. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  75981. * @returns a new left Vector3
  75982. */
  75983. static Left(): Vector3;
  75984. /**
  75985. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  75986. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  75987. * @param vector defines the Vector3 to transform
  75988. * @param transformation defines the transformation matrix
  75989. * @returns the transformed Vector3
  75990. */
  75991. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  75992. /**
  75993. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  75994. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  75995. * @param vector defines the Vector3 to transform
  75996. * @param transformation defines the transformation matrix
  75997. * @param result defines the Vector3 where to store the result
  75998. */
  75999. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76000. /**
  76001. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  76002. * This method computes tranformed coordinates only, not transformed direction vectors
  76003. * @param x define the x coordinate of the source vector
  76004. * @param y define the y coordinate of the source vector
  76005. * @param z define the z coordinate of the source vector
  76006. * @param transformation defines the transformation matrix
  76007. * @param result defines the Vector3 where to store the result
  76008. */
  76009. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76010. /**
  76011. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  76012. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76013. * @param vector defines the Vector3 to transform
  76014. * @param transformation defines the transformation matrix
  76015. * @returns the new Vector3
  76016. */
  76017. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76018. /**
  76019. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  76020. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76021. * @param vector defines the Vector3 to transform
  76022. * @param transformation defines the transformation matrix
  76023. * @param result defines the Vector3 where to store the result
  76024. */
  76025. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76026. /**
  76027. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  76028. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76029. * @param x define the x coordinate of the source vector
  76030. * @param y define the y coordinate of the source vector
  76031. * @param z define the z coordinate of the source vector
  76032. * @param transformation defines the transformation matrix
  76033. * @param result defines the Vector3 where to store the result
  76034. */
  76035. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76036. /**
  76037. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  76038. * @param value1 defines the first control point
  76039. * @param value2 defines the second control point
  76040. * @param value3 defines the third control point
  76041. * @param value4 defines the fourth control point
  76042. * @param amount defines the amount on the spline to use
  76043. * @returns the new Vector3
  76044. */
  76045. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  76046. /**
  76047. * 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"
  76048. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76049. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76050. * @param value defines the current value
  76051. * @param min defines the lower range value
  76052. * @param max defines the upper range value
  76053. * @returns the new Vector3
  76054. */
  76055. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  76056. /**
  76057. * 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"
  76058. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76059. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76060. * @param value defines the current value
  76061. * @param min defines the lower range value
  76062. * @param max defines the upper range value
  76063. * @param result defines the Vector3 where to store the result
  76064. */
  76065. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  76066. /**
  76067. * Checks if a given vector is inside a specific range
  76068. * @param v defines the vector to test
  76069. * @param min defines the minimum range
  76070. * @param max defines the maximum range
  76071. */
  76072. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  76073. /**
  76074. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  76075. * @param value1 defines the first control point
  76076. * @param tangent1 defines the first tangent vector
  76077. * @param value2 defines the second control point
  76078. * @param tangent2 defines the second tangent vector
  76079. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  76080. * @returns the new Vector3
  76081. */
  76082. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  76083. /**
  76084. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  76085. * @param start defines the start value
  76086. * @param end defines the end value
  76087. * @param amount max defines amount between both (between 0 and 1)
  76088. * @returns the new Vector3
  76089. */
  76090. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  76091. /**
  76092. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  76093. * @param start defines the start value
  76094. * @param end defines the end value
  76095. * @param amount max defines amount between both (between 0 and 1)
  76096. * @param result defines the Vector3 where to store the result
  76097. */
  76098. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  76099. /**
  76100. * Returns the dot product (float) between the vectors "left" and "right"
  76101. * @param left defines the left operand
  76102. * @param right defines the right operand
  76103. * @returns the dot product
  76104. */
  76105. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  76106. /**
  76107. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  76108. * The cross product is then orthogonal to both "left" and "right"
  76109. * @param left defines the left operand
  76110. * @param right defines the right operand
  76111. * @returns the cross product
  76112. */
  76113. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76114. /**
  76115. * Sets the given vector "result" with the cross product of "left" and "right"
  76116. * The cross product is then orthogonal to both "left" and "right"
  76117. * @param left defines the left operand
  76118. * @param right defines the right operand
  76119. * @param result defines the Vector3 where to store the result
  76120. */
  76121. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  76122. /**
  76123. * Returns a new Vector3 as the normalization of the given vector
  76124. * @param vector defines the Vector3 to normalize
  76125. * @returns the new Vector3
  76126. */
  76127. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  76128. /**
  76129. * Sets the given vector "result" with the normalization of the given first vector
  76130. * @param vector defines the Vector3 to normalize
  76131. * @param result defines the Vector3 where to store the result
  76132. */
  76133. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  76134. /**
  76135. * Project a Vector3 onto screen space
  76136. * @param vector defines the Vector3 to project
  76137. * @param world defines the world matrix to use
  76138. * @param transform defines the transform (view x projection) matrix to use
  76139. * @param viewport defines the screen viewport to use
  76140. * @returns the new Vector3
  76141. */
  76142. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  76143. /** @hidden */
  76144. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  76145. /**
  76146. * Unproject from screen space to object space
  76147. * @param source defines the screen space Vector3 to use
  76148. * @param viewportWidth defines the current width of the viewport
  76149. * @param viewportHeight defines the current height of the viewport
  76150. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76151. * @param transform defines the transform (view x projection) matrix to use
  76152. * @returns the new Vector3
  76153. */
  76154. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  76155. /**
  76156. * Unproject from screen space to object space
  76157. * @param source defines the screen space Vector3 to use
  76158. * @param viewportWidth defines the current width of the viewport
  76159. * @param viewportHeight defines the current height of the viewport
  76160. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76161. * @param view defines the view matrix to use
  76162. * @param projection defines the projection matrix to use
  76163. * @returns the new Vector3
  76164. */
  76165. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  76166. /**
  76167. * Unproject from screen space to object space
  76168. * @param source defines the screen space Vector3 to use
  76169. * @param viewportWidth defines the current width of the viewport
  76170. * @param viewportHeight defines the current height of the viewport
  76171. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76172. * @param view defines the view matrix to use
  76173. * @param projection defines the projection matrix to use
  76174. * @param result defines the Vector3 where to store the result
  76175. */
  76176. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76177. /**
  76178. * Unproject from screen space to object space
  76179. * @param sourceX defines the screen space x coordinate to use
  76180. * @param sourceY defines the screen space y coordinate to use
  76181. * @param sourceZ defines the screen space z coordinate to use
  76182. * @param viewportWidth defines the current width of the viewport
  76183. * @param viewportHeight defines the current height of the viewport
  76184. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76185. * @param view defines the view matrix to use
  76186. * @param projection defines the projection matrix to use
  76187. * @param result defines the Vector3 where to store the result
  76188. */
  76189. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76190. /**
  76191. * Gets the minimal coordinate values between two Vector3
  76192. * @param left defines the first operand
  76193. * @param right defines the second operand
  76194. * @returns the new Vector3
  76195. */
  76196. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76197. /**
  76198. * Gets the maximal coordinate values between two Vector3
  76199. * @param left defines the first operand
  76200. * @param right defines the second operand
  76201. * @returns the new Vector3
  76202. */
  76203. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76204. /**
  76205. * Returns the distance between the vectors "value1" and "value2"
  76206. * @param value1 defines the first operand
  76207. * @param value2 defines the second operand
  76208. * @returns the distance
  76209. */
  76210. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76211. /**
  76212. * Returns the squared distance between the vectors "value1" and "value2"
  76213. * @param value1 defines the first operand
  76214. * @param value2 defines the second operand
  76215. * @returns the squared distance
  76216. */
  76217. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76218. /**
  76219. * Returns a new Vector3 located at the center between "value1" and "value2"
  76220. * @param value1 defines the first operand
  76221. * @param value2 defines the second operand
  76222. * @returns the new Vector3
  76223. */
  76224. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  76225. /**
  76226. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  76227. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  76228. * to something in order to rotate it from its local system to the given target system
  76229. * Note: axis1, axis2 and axis3 are normalized during this operation
  76230. * @param axis1 defines the first axis
  76231. * @param axis2 defines the second axis
  76232. * @param axis3 defines the third axis
  76233. * @returns a new Vector3
  76234. */
  76235. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  76236. /**
  76237. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  76238. * @param axis1 defines the first axis
  76239. * @param axis2 defines the second axis
  76240. * @param axis3 defines the third axis
  76241. * @param ref defines the Vector3 where to store the result
  76242. */
  76243. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  76244. }
  76245. /**
  76246. * Vector4 class created for EulerAngle class conversion to Quaternion
  76247. */
  76248. export class Vector4 {
  76249. /** x value of the vector */
  76250. x: number;
  76251. /** y value of the vector */
  76252. y: number;
  76253. /** z value of the vector */
  76254. z: number;
  76255. /** w value of the vector */
  76256. w: number;
  76257. /**
  76258. * Creates a Vector4 object from the given floats.
  76259. * @param x x value of the vector
  76260. * @param y y value of the vector
  76261. * @param z z value of the vector
  76262. * @param w w value of the vector
  76263. */
  76264. constructor(
  76265. /** x value of the vector */
  76266. x: number,
  76267. /** y value of the vector */
  76268. y: number,
  76269. /** z value of the vector */
  76270. z: number,
  76271. /** w value of the vector */
  76272. w: number);
  76273. /**
  76274. * Returns the string with the Vector4 coordinates.
  76275. * @returns a string containing all the vector values
  76276. */
  76277. toString(): string;
  76278. /**
  76279. * Returns the string "Vector4".
  76280. * @returns "Vector4"
  76281. */
  76282. getClassName(): string;
  76283. /**
  76284. * Returns the Vector4 hash code.
  76285. * @returns a unique hash code
  76286. */
  76287. getHashCode(): number;
  76288. /**
  76289. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  76290. * @returns the resulting array
  76291. */
  76292. asArray(): number[];
  76293. /**
  76294. * Populates the given array from the given index with the Vector4 coordinates.
  76295. * @param array array to populate
  76296. * @param index index of the array to start at (default: 0)
  76297. * @returns the Vector4.
  76298. */
  76299. toArray(array: FloatArray, index?: number): Vector4;
  76300. /**
  76301. * Adds the given vector to the current Vector4.
  76302. * @param otherVector the vector to add
  76303. * @returns the updated Vector4.
  76304. */
  76305. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76306. /**
  76307. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  76308. * @param otherVector the vector to add
  76309. * @returns the resulting vector
  76310. */
  76311. add(otherVector: DeepImmutable<Vector4>): Vector4;
  76312. /**
  76313. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  76314. * @param otherVector the vector to add
  76315. * @param result the vector to store the result
  76316. * @returns the current Vector4.
  76317. */
  76318. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76319. /**
  76320. * Subtract in place the given vector from the current Vector4.
  76321. * @param otherVector the vector to subtract
  76322. * @returns the updated Vector4.
  76323. */
  76324. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76325. /**
  76326. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  76327. * @param otherVector the vector to add
  76328. * @returns the new vector with the result
  76329. */
  76330. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  76331. /**
  76332. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  76333. * @param otherVector the vector to subtract
  76334. * @param result the vector to store the result
  76335. * @returns the current Vector4.
  76336. */
  76337. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76338. /**
  76339. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76340. */
  76341. /**
  76342. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76343. * @param x value to subtract
  76344. * @param y value to subtract
  76345. * @param z value to subtract
  76346. * @param w value to subtract
  76347. * @returns new vector containing the result
  76348. */
  76349. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76350. /**
  76351. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76352. * @param x value to subtract
  76353. * @param y value to subtract
  76354. * @param z value to subtract
  76355. * @param w value to subtract
  76356. * @param result the vector to store the result in
  76357. * @returns the current Vector4.
  76358. */
  76359. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  76360. /**
  76361. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  76362. * @returns a new vector with the negated values
  76363. */
  76364. negate(): Vector4;
  76365. /**
  76366. * Negate this vector in place
  76367. * @returns this
  76368. */
  76369. negateInPlace(): Vector4;
  76370. /**
  76371. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  76372. * @param result defines the Vector3 object where to store the result
  76373. * @returns the current Vector4
  76374. */
  76375. negateToRef(result: Vector4): Vector4;
  76376. /**
  76377. * Multiplies the current Vector4 coordinates by scale (float).
  76378. * @param scale the number to scale with
  76379. * @returns the updated Vector4.
  76380. */
  76381. scaleInPlace(scale: number): Vector4;
  76382. /**
  76383. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  76384. * @param scale the number to scale with
  76385. * @returns a new vector with the result
  76386. */
  76387. scale(scale: number): Vector4;
  76388. /**
  76389. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  76390. * @param scale the number to scale with
  76391. * @param result a vector to store the result in
  76392. * @returns the current Vector4.
  76393. */
  76394. scaleToRef(scale: number, result: Vector4): Vector4;
  76395. /**
  76396. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  76397. * @param scale defines the scale factor
  76398. * @param result defines the Vector4 object where to store the result
  76399. * @returns the unmodified current Vector4
  76400. */
  76401. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  76402. /**
  76403. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  76404. * @param otherVector the vector to compare against
  76405. * @returns true if they are equal
  76406. */
  76407. equals(otherVector: DeepImmutable<Vector4>): boolean;
  76408. /**
  76409. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  76410. * @param otherVector vector to compare against
  76411. * @param epsilon (Default: very small number)
  76412. * @returns true if they are equal
  76413. */
  76414. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  76415. /**
  76416. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  76417. * @param x x value to compare against
  76418. * @param y y value to compare against
  76419. * @param z z value to compare against
  76420. * @param w w value to compare against
  76421. * @returns true if equal
  76422. */
  76423. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  76424. /**
  76425. * Multiplies in place the current Vector4 by the given one.
  76426. * @param otherVector vector to multiple with
  76427. * @returns the updated Vector4.
  76428. */
  76429. multiplyInPlace(otherVector: Vector4): Vector4;
  76430. /**
  76431. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  76432. * @param otherVector vector to multiple with
  76433. * @returns resulting new vector
  76434. */
  76435. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  76436. /**
  76437. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  76438. * @param otherVector vector to multiple with
  76439. * @param result vector to store the result
  76440. * @returns the current Vector4.
  76441. */
  76442. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76443. /**
  76444. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  76445. * @param x x value multiply with
  76446. * @param y y value multiply with
  76447. * @param z z value multiply with
  76448. * @param w w value multiply with
  76449. * @returns resulting new vector
  76450. */
  76451. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  76452. /**
  76453. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  76454. * @param otherVector vector to devide with
  76455. * @returns resulting new vector
  76456. */
  76457. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  76458. /**
  76459. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  76460. * @param otherVector vector to devide with
  76461. * @param result vector to store the result
  76462. * @returns the current Vector4.
  76463. */
  76464. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76465. /**
  76466. * Divides the current Vector3 coordinates by the given ones.
  76467. * @param otherVector vector to devide with
  76468. * @returns the updated Vector3.
  76469. */
  76470. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76471. /**
  76472. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  76473. * @param other defines the second operand
  76474. * @returns the current updated Vector4
  76475. */
  76476. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76477. /**
  76478. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  76479. * @param other defines the second operand
  76480. * @returns the current updated Vector4
  76481. */
  76482. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76483. /**
  76484. * Gets a new Vector4 from current Vector4 floored values
  76485. * @returns a new Vector4
  76486. */
  76487. floor(): Vector4;
  76488. /**
  76489. * Gets a new Vector4 from current Vector3 floored values
  76490. * @returns a new Vector4
  76491. */
  76492. fract(): Vector4;
  76493. /**
  76494. * Returns the Vector4 length (float).
  76495. * @returns the length
  76496. */
  76497. length(): number;
  76498. /**
  76499. * Returns the Vector4 squared length (float).
  76500. * @returns the length squared
  76501. */
  76502. lengthSquared(): number;
  76503. /**
  76504. * Normalizes in place the Vector4.
  76505. * @returns the updated Vector4.
  76506. */
  76507. normalize(): Vector4;
  76508. /**
  76509. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  76510. * @returns this converted to a new vector3
  76511. */
  76512. toVector3(): Vector3;
  76513. /**
  76514. * Returns a new Vector4 copied from the current one.
  76515. * @returns the new cloned vector
  76516. */
  76517. clone(): Vector4;
  76518. /**
  76519. * Updates the current Vector4 with the given one coordinates.
  76520. * @param source the source vector to copy from
  76521. * @returns the updated Vector4.
  76522. */
  76523. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  76524. /**
  76525. * Updates the current Vector4 coordinates with the given floats.
  76526. * @param x float to copy from
  76527. * @param y float to copy from
  76528. * @param z float to copy from
  76529. * @param w float to copy from
  76530. * @returns the updated Vector4.
  76531. */
  76532. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76533. /**
  76534. * Updates the current Vector4 coordinates with the given floats.
  76535. * @param x float to set from
  76536. * @param y float to set from
  76537. * @param z float to set from
  76538. * @param w float to set from
  76539. * @returns the updated Vector4.
  76540. */
  76541. set(x: number, y: number, z: number, w: number): Vector4;
  76542. /**
  76543. * Copies the given float to the current Vector3 coordinates
  76544. * @param v defines the x, y, z and w coordinates of the operand
  76545. * @returns the current updated Vector3
  76546. */
  76547. setAll(v: number): Vector4;
  76548. /**
  76549. * Returns a new Vector4 set from the starting index of the given array.
  76550. * @param array the array to pull values from
  76551. * @param offset the offset into the array to start at
  76552. * @returns the new vector
  76553. */
  76554. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  76555. /**
  76556. * Updates the given vector "result" from the starting index of the given array.
  76557. * @param array the array to pull values from
  76558. * @param offset the offset into the array to start at
  76559. * @param result the vector to store the result in
  76560. */
  76561. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  76562. /**
  76563. * Updates the given vector "result" from the starting index of the given Float32Array.
  76564. * @param array the array to pull values from
  76565. * @param offset the offset into the array to start at
  76566. * @param result the vector to store the result in
  76567. */
  76568. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  76569. /**
  76570. * Updates the given vector "result" coordinates from the given floats.
  76571. * @param x float to set from
  76572. * @param y float to set from
  76573. * @param z float to set from
  76574. * @param w float to set from
  76575. * @param result the vector to the floats in
  76576. */
  76577. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  76578. /**
  76579. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  76580. * @returns the new vector
  76581. */
  76582. static Zero(): Vector4;
  76583. /**
  76584. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  76585. * @returns the new vector
  76586. */
  76587. static One(): Vector4;
  76588. /**
  76589. * Returns a new normalized Vector4 from the given one.
  76590. * @param vector the vector to normalize
  76591. * @returns the vector
  76592. */
  76593. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  76594. /**
  76595. * Updates the given vector "result" from the normalization of the given one.
  76596. * @param vector the vector to normalize
  76597. * @param result the vector to store the result in
  76598. */
  76599. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  76600. /**
  76601. * Returns a vector with the minimum values from the left and right vectors
  76602. * @param left left vector to minimize
  76603. * @param right right vector to minimize
  76604. * @returns a new vector with the minimum of the left and right vector values
  76605. */
  76606. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76607. /**
  76608. * Returns a vector with the maximum values from the left and right vectors
  76609. * @param left left vector to maximize
  76610. * @param right right vector to maximize
  76611. * @returns a new vector with the maximum of the left and right vector values
  76612. */
  76613. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76614. /**
  76615. * Returns the distance (float) between the vectors "value1" and "value2".
  76616. * @param value1 value to calulate the distance between
  76617. * @param value2 value to calulate the distance between
  76618. * @return the distance between the two vectors
  76619. */
  76620. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76621. /**
  76622. * Returns the squared distance (float) between the vectors "value1" and "value2".
  76623. * @param value1 value to calulate the distance between
  76624. * @param value2 value to calulate the distance between
  76625. * @return the distance between the two vectors squared
  76626. */
  76627. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76628. /**
  76629. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  76630. * @param value1 value to calulate the center between
  76631. * @param value2 value to calulate the center between
  76632. * @return the center between the two vectors
  76633. */
  76634. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  76635. /**
  76636. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  76637. * This methods computes transformed normalized direction vectors only.
  76638. * @param vector the vector to transform
  76639. * @param transformation the transformation matrix to apply
  76640. * @returns the new vector
  76641. */
  76642. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  76643. /**
  76644. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  76645. * This methods computes transformed normalized direction vectors only.
  76646. * @param vector the vector to transform
  76647. * @param transformation the transformation matrix to apply
  76648. * @param result the vector to store the result in
  76649. */
  76650. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76651. /**
  76652. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  76653. * This methods computes transformed normalized direction vectors only.
  76654. * @param x value to transform
  76655. * @param y value to transform
  76656. * @param z value to transform
  76657. * @param w value to transform
  76658. * @param transformation the transformation matrix to apply
  76659. * @param result the vector to store the results in
  76660. */
  76661. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76662. /**
  76663. * Creates a new Vector4 from a Vector3
  76664. * @param source defines the source data
  76665. * @param w defines the 4th component (default is 0)
  76666. * @returns a new Vector4
  76667. */
  76668. static FromVector3(source: Vector3, w?: number): Vector4;
  76669. }
  76670. /**
  76671. * Class used to store quaternion data
  76672. * @see https://en.wikipedia.org/wiki/Quaternion
  76673. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  76674. */
  76675. export class Quaternion {
  76676. /** defines the first component (0 by default) */
  76677. x: number;
  76678. /** defines the second component (0 by default) */
  76679. y: number;
  76680. /** defines the third component (0 by default) */
  76681. z: number;
  76682. /** defines the fourth component (1.0 by default) */
  76683. w: number;
  76684. /**
  76685. * Creates a new Quaternion from the given floats
  76686. * @param x defines the first component (0 by default)
  76687. * @param y defines the second component (0 by default)
  76688. * @param z defines the third component (0 by default)
  76689. * @param w defines the fourth component (1.0 by default)
  76690. */
  76691. constructor(
  76692. /** defines the first component (0 by default) */
  76693. x?: number,
  76694. /** defines the second component (0 by default) */
  76695. y?: number,
  76696. /** defines the third component (0 by default) */
  76697. z?: number,
  76698. /** defines the fourth component (1.0 by default) */
  76699. w?: number);
  76700. /**
  76701. * Gets a string representation for the current quaternion
  76702. * @returns a string with the Quaternion coordinates
  76703. */
  76704. toString(): string;
  76705. /**
  76706. * Gets the class name of the quaternion
  76707. * @returns the string "Quaternion"
  76708. */
  76709. getClassName(): string;
  76710. /**
  76711. * Gets a hash code for this quaternion
  76712. * @returns the quaternion hash code
  76713. */
  76714. getHashCode(): number;
  76715. /**
  76716. * Copy the quaternion to an array
  76717. * @returns a new array populated with 4 elements from the quaternion coordinates
  76718. */
  76719. asArray(): number[];
  76720. /**
  76721. * Check if two quaternions are equals
  76722. * @param otherQuaternion defines the second operand
  76723. * @return true if the current quaternion and the given one coordinates are strictly equals
  76724. */
  76725. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  76726. /**
  76727. * Gets a boolean if two quaternions are equals (using an epsilon value)
  76728. * @param otherQuaternion defines the other quaternion
  76729. * @param epsilon defines the minimal distance to consider equality
  76730. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  76731. */
  76732. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  76733. /**
  76734. * Clone the current quaternion
  76735. * @returns a new quaternion copied from the current one
  76736. */
  76737. clone(): Quaternion;
  76738. /**
  76739. * Copy a quaternion to the current one
  76740. * @param other defines the other quaternion
  76741. * @returns the updated current quaternion
  76742. */
  76743. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  76744. /**
  76745. * Updates the current quaternion with the given float coordinates
  76746. * @param x defines the x coordinate
  76747. * @param y defines the y coordinate
  76748. * @param z defines the z coordinate
  76749. * @param w defines the w coordinate
  76750. * @returns the updated current quaternion
  76751. */
  76752. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  76753. /**
  76754. * Updates the current quaternion from the given float coordinates
  76755. * @param x defines the x coordinate
  76756. * @param y defines the y coordinate
  76757. * @param z defines the z coordinate
  76758. * @param w defines the w coordinate
  76759. * @returns the updated current quaternion
  76760. */
  76761. set(x: number, y: number, z: number, w: number): Quaternion;
  76762. /**
  76763. * Adds two quaternions
  76764. * @param other defines the second operand
  76765. * @returns a new quaternion as the addition result of the given one and the current quaternion
  76766. */
  76767. add(other: DeepImmutable<Quaternion>): Quaternion;
  76768. /**
  76769. * Add a quaternion to the current one
  76770. * @param other defines the quaternion to add
  76771. * @returns the current quaternion
  76772. */
  76773. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  76774. /**
  76775. * Subtract two quaternions
  76776. * @param other defines the second operand
  76777. * @returns a new quaternion as the subtraction result of the given one from the current one
  76778. */
  76779. subtract(other: Quaternion): Quaternion;
  76780. /**
  76781. * Multiplies the current quaternion by a scale factor
  76782. * @param value defines the scale factor
  76783. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  76784. */
  76785. scale(value: number): Quaternion;
  76786. /**
  76787. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  76788. * @param scale defines the scale factor
  76789. * @param result defines the Quaternion object where to store the result
  76790. * @returns the unmodified current quaternion
  76791. */
  76792. scaleToRef(scale: number, result: Quaternion): Quaternion;
  76793. /**
  76794. * Multiplies in place the current quaternion by a scale factor
  76795. * @param value defines the scale factor
  76796. * @returns the current modified quaternion
  76797. */
  76798. scaleInPlace(value: number): Quaternion;
  76799. /**
  76800. * Scale the current quaternion values by a factor and add the result to a given quaternion
  76801. * @param scale defines the scale factor
  76802. * @param result defines the Quaternion object where to store the result
  76803. * @returns the unmodified current quaternion
  76804. */
  76805. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  76806. /**
  76807. * Multiplies two quaternions
  76808. * @param q1 defines the second operand
  76809. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  76810. */
  76811. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  76812. /**
  76813. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  76814. * @param q1 defines the second operand
  76815. * @param result defines the target quaternion
  76816. * @returns the current quaternion
  76817. */
  76818. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  76819. /**
  76820. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  76821. * @param q1 defines the second operand
  76822. * @returns the currentupdated quaternion
  76823. */
  76824. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  76825. /**
  76826. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  76827. * @param ref defines the target quaternion
  76828. * @returns the current quaternion
  76829. */
  76830. conjugateToRef(ref: Quaternion): Quaternion;
  76831. /**
  76832. * Conjugates in place (1-q) the current quaternion
  76833. * @returns the current updated quaternion
  76834. */
  76835. conjugateInPlace(): Quaternion;
  76836. /**
  76837. * Conjugates in place (1-q) the current quaternion
  76838. * @returns a new quaternion
  76839. */
  76840. conjugate(): Quaternion;
  76841. /**
  76842. * Gets length of current quaternion
  76843. * @returns the quaternion length (float)
  76844. */
  76845. length(): number;
  76846. /**
  76847. * Normalize in place the current quaternion
  76848. * @returns the current updated quaternion
  76849. */
  76850. normalize(): Quaternion;
  76851. /**
  76852. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  76853. * @param order is a reserved parameter and is ignore for now
  76854. * @returns a new Vector3 containing the Euler angles
  76855. */
  76856. toEulerAngles(order?: string): Vector3;
  76857. /**
  76858. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  76859. * @param result defines the vector which will be filled with the Euler angles
  76860. * @param order is a reserved parameter and is ignore for now
  76861. * @returns the current unchanged quaternion
  76862. */
  76863. toEulerAnglesToRef(result: Vector3): Quaternion;
  76864. /**
  76865. * Updates the given rotation matrix with the current quaternion values
  76866. * @param result defines the target matrix
  76867. * @returns the current unchanged quaternion
  76868. */
  76869. toRotationMatrix(result: Matrix): Quaternion;
  76870. /**
  76871. * Updates the current quaternion from the given rotation matrix values
  76872. * @param matrix defines the source matrix
  76873. * @returns the current updated quaternion
  76874. */
  76875. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76876. /**
  76877. * Creates a new quaternion from a rotation matrix
  76878. * @param matrix defines the source matrix
  76879. * @returns a new quaternion created from the given rotation matrix values
  76880. */
  76881. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76882. /**
  76883. * Updates the given quaternion with the given rotation matrix values
  76884. * @param matrix defines the source matrix
  76885. * @param result defines the target quaternion
  76886. */
  76887. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  76888. /**
  76889. * Returns the dot product (float) between the quaternions "left" and "right"
  76890. * @param left defines the left operand
  76891. * @param right defines the right operand
  76892. * @returns the dot product
  76893. */
  76894. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  76895. /**
  76896. * Checks if the two quaternions are close to each other
  76897. * @param quat0 defines the first quaternion to check
  76898. * @param quat1 defines the second quaternion to check
  76899. * @returns true if the two quaternions are close to each other
  76900. */
  76901. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  76902. /**
  76903. * Creates an empty quaternion
  76904. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  76905. */
  76906. static Zero(): Quaternion;
  76907. /**
  76908. * Inverse a given quaternion
  76909. * @param q defines the source quaternion
  76910. * @returns a new quaternion as the inverted current quaternion
  76911. */
  76912. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  76913. /**
  76914. * Inverse a given quaternion
  76915. * @param q defines the source quaternion
  76916. * @param result the quaternion the result will be stored in
  76917. * @returns the result quaternion
  76918. */
  76919. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  76920. /**
  76921. * Creates an identity quaternion
  76922. * @returns the identity quaternion
  76923. */
  76924. static Identity(): Quaternion;
  76925. /**
  76926. * Gets a boolean indicating if the given quaternion is identity
  76927. * @param quaternion defines the quaternion to check
  76928. * @returns true if the quaternion is identity
  76929. */
  76930. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  76931. /**
  76932. * Creates a quaternion from a rotation around an axis
  76933. * @param axis defines the axis to use
  76934. * @param angle defines the angle to use
  76935. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  76936. */
  76937. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  76938. /**
  76939. * Creates a rotation around an axis and stores it into the given quaternion
  76940. * @param axis defines the axis to use
  76941. * @param angle defines the angle to use
  76942. * @param result defines the target quaternion
  76943. * @returns the target quaternion
  76944. */
  76945. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  76946. /**
  76947. * Creates a new quaternion from data stored into an array
  76948. * @param array defines the data source
  76949. * @param offset defines the offset in the source array where the data starts
  76950. * @returns a new quaternion
  76951. */
  76952. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  76953. /**
  76954. * Create a quaternion from Euler rotation angles
  76955. * @param x Pitch
  76956. * @param y Yaw
  76957. * @param z Roll
  76958. * @returns the new Quaternion
  76959. */
  76960. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  76961. /**
  76962. * Updates a quaternion from Euler rotation angles
  76963. * @param x Pitch
  76964. * @param y Yaw
  76965. * @param z Roll
  76966. * @param result the quaternion to store the result
  76967. * @returns the updated quaternion
  76968. */
  76969. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  76970. /**
  76971. * Create a quaternion from Euler rotation vector
  76972. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  76973. * @returns the new Quaternion
  76974. */
  76975. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  76976. /**
  76977. * Updates a quaternion from Euler rotation vector
  76978. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  76979. * @param result the quaternion to store the result
  76980. * @returns the updated quaternion
  76981. */
  76982. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  76983. /**
  76984. * Creates a new quaternion from the given Euler float angles (y, x, z)
  76985. * @param yaw defines the rotation around Y axis
  76986. * @param pitch defines the rotation around X axis
  76987. * @param roll defines the rotation around Z axis
  76988. * @returns the new quaternion
  76989. */
  76990. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  76991. /**
  76992. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  76993. * @param yaw defines the rotation around Y axis
  76994. * @param pitch defines the rotation around X axis
  76995. * @param roll defines the rotation around Z axis
  76996. * @param result defines the target quaternion
  76997. */
  76998. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  76999. /**
  77000. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  77001. * @param alpha defines the rotation around first axis
  77002. * @param beta defines the rotation around second axis
  77003. * @param gamma defines the rotation around third axis
  77004. * @returns the new quaternion
  77005. */
  77006. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  77007. /**
  77008. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  77009. * @param alpha defines the rotation around first axis
  77010. * @param beta defines the rotation around second axis
  77011. * @param gamma defines the rotation around third axis
  77012. * @param result defines the target quaternion
  77013. */
  77014. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  77015. /**
  77016. * 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)
  77017. * @param axis1 defines the first axis
  77018. * @param axis2 defines the second axis
  77019. * @param axis3 defines the third axis
  77020. * @returns the new quaternion
  77021. */
  77022. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  77023. /**
  77024. * 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
  77025. * @param axis1 defines the first axis
  77026. * @param axis2 defines the second axis
  77027. * @param axis3 defines the third axis
  77028. * @param ref defines the target quaternion
  77029. */
  77030. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  77031. /**
  77032. * Interpolates between two quaternions
  77033. * @param left defines first quaternion
  77034. * @param right defines second quaternion
  77035. * @param amount defines the gradient to use
  77036. * @returns the new interpolated quaternion
  77037. */
  77038. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77039. /**
  77040. * Interpolates between two quaternions and stores it into a target quaternion
  77041. * @param left defines first quaternion
  77042. * @param right defines second quaternion
  77043. * @param amount defines the gradient to use
  77044. * @param result defines the target quaternion
  77045. */
  77046. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  77047. /**
  77048. * Interpolate between two quaternions using Hermite interpolation
  77049. * @param value1 defines first quaternion
  77050. * @param tangent1 defines the incoming tangent
  77051. * @param value2 defines second quaternion
  77052. * @param tangent2 defines the outgoing tangent
  77053. * @param amount defines the target quaternion
  77054. * @returns the new interpolated quaternion
  77055. */
  77056. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77057. }
  77058. /**
  77059. * Class used to store matrix data (4x4)
  77060. */
  77061. export class Matrix {
  77062. private static _updateFlagSeed;
  77063. private static _identityReadOnly;
  77064. private _isIdentity;
  77065. private _isIdentityDirty;
  77066. private _isIdentity3x2;
  77067. private _isIdentity3x2Dirty;
  77068. /**
  77069. * Gets the update flag of the matrix which is an unique number for the matrix.
  77070. * It will be incremented every time the matrix data change.
  77071. * You can use it to speed the comparison between two versions of the same matrix.
  77072. */
  77073. updateFlag: number;
  77074. private readonly _m;
  77075. /**
  77076. * Gets the internal data of the matrix
  77077. */
  77078. get m(): DeepImmutable<Float32Array>;
  77079. /** @hidden */
  77080. _markAsUpdated(): void;
  77081. /** @hidden */
  77082. private _updateIdentityStatus;
  77083. /**
  77084. * Creates an empty matrix (filled with zeros)
  77085. */
  77086. constructor();
  77087. /**
  77088. * Check if the current matrix is identity
  77089. * @returns true is the matrix is the identity matrix
  77090. */
  77091. isIdentity(): boolean;
  77092. /**
  77093. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  77094. * @returns true is the matrix is the identity matrix
  77095. */
  77096. isIdentityAs3x2(): boolean;
  77097. /**
  77098. * Gets the determinant of the matrix
  77099. * @returns the matrix determinant
  77100. */
  77101. determinant(): number;
  77102. /**
  77103. * Returns the matrix as a Float32Array
  77104. * @returns the matrix underlying array
  77105. */
  77106. toArray(): DeepImmutable<Float32Array>;
  77107. /**
  77108. * Returns the matrix as a Float32Array
  77109. * @returns the matrix underlying array.
  77110. */
  77111. asArray(): DeepImmutable<Float32Array>;
  77112. /**
  77113. * Inverts the current matrix in place
  77114. * @returns the current inverted matrix
  77115. */
  77116. invert(): Matrix;
  77117. /**
  77118. * Sets all the matrix elements to zero
  77119. * @returns the current matrix
  77120. */
  77121. reset(): Matrix;
  77122. /**
  77123. * Adds the current matrix with a second one
  77124. * @param other defines the matrix to add
  77125. * @returns a new matrix as the addition of the current matrix and the given one
  77126. */
  77127. add(other: DeepImmutable<Matrix>): Matrix;
  77128. /**
  77129. * Sets the given matrix "result" to the addition of the current matrix and the given one
  77130. * @param other defines the matrix to add
  77131. * @param result defines the target matrix
  77132. * @returns the current matrix
  77133. */
  77134. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77135. /**
  77136. * Adds in place the given matrix to the current matrix
  77137. * @param other defines the second operand
  77138. * @returns the current updated matrix
  77139. */
  77140. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  77141. /**
  77142. * Sets the given matrix to the current inverted Matrix
  77143. * @param other defines the target matrix
  77144. * @returns the unmodified current matrix
  77145. */
  77146. invertToRef(other: Matrix): Matrix;
  77147. /**
  77148. * add a value at the specified position in the current Matrix
  77149. * @param index the index of the value within the matrix. between 0 and 15.
  77150. * @param value the value to be added
  77151. * @returns the current updated matrix
  77152. */
  77153. addAtIndex(index: number, value: number): Matrix;
  77154. /**
  77155. * mutiply the specified position in the current Matrix by a value
  77156. * @param index the index of the value within the matrix. between 0 and 15.
  77157. * @param value the value to be added
  77158. * @returns the current updated matrix
  77159. */
  77160. multiplyAtIndex(index: number, value: number): Matrix;
  77161. /**
  77162. * Inserts the translation vector (using 3 floats) in the current matrix
  77163. * @param x defines the 1st component of the translation
  77164. * @param y defines the 2nd component of the translation
  77165. * @param z defines the 3rd component of the translation
  77166. * @returns the current updated matrix
  77167. */
  77168. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77169. /**
  77170. * Adds the translation vector (using 3 floats) in the current matrix
  77171. * @param x defines the 1st component of the translation
  77172. * @param y defines the 2nd component of the translation
  77173. * @param z defines the 3rd component of the translation
  77174. * @returns the current updated matrix
  77175. */
  77176. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77177. /**
  77178. * Inserts the translation vector in the current matrix
  77179. * @param vector3 defines the translation to insert
  77180. * @returns the current updated matrix
  77181. */
  77182. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  77183. /**
  77184. * Gets the translation value of the current matrix
  77185. * @returns a new Vector3 as the extracted translation from the matrix
  77186. */
  77187. getTranslation(): Vector3;
  77188. /**
  77189. * Fill a Vector3 with the extracted translation from the matrix
  77190. * @param result defines the Vector3 where to store the translation
  77191. * @returns the current matrix
  77192. */
  77193. getTranslationToRef(result: Vector3): Matrix;
  77194. /**
  77195. * Remove rotation and scaling part from the matrix
  77196. * @returns the updated matrix
  77197. */
  77198. removeRotationAndScaling(): Matrix;
  77199. /**
  77200. * Multiply two matrices
  77201. * @param other defines the second operand
  77202. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  77203. */
  77204. multiply(other: DeepImmutable<Matrix>): Matrix;
  77205. /**
  77206. * Copy the current matrix from the given one
  77207. * @param other defines the source matrix
  77208. * @returns the current updated matrix
  77209. */
  77210. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  77211. /**
  77212. * Populates the given array from the starting index with the current matrix values
  77213. * @param array defines the target array
  77214. * @param offset defines the offset in the target array where to start storing values
  77215. * @returns the current matrix
  77216. */
  77217. copyToArray(array: Float32Array, offset?: number): Matrix;
  77218. /**
  77219. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  77220. * @param other defines the second operand
  77221. * @param result defines the matrix where to store the multiplication
  77222. * @returns the current matrix
  77223. */
  77224. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77225. /**
  77226. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  77227. * @param other defines the second operand
  77228. * @param result defines the array where to store the multiplication
  77229. * @param offset defines the offset in the target array where to start storing values
  77230. * @returns the current matrix
  77231. */
  77232. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  77233. /**
  77234. * Check equality between this matrix and a second one
  77235. * @param value defines the second matrix to compare
  77236. * @returns true is the current matrix and the given one values are strictly equal
  77237. */
  77238. equals(value: DeepImmutable<Matrix>): boolean;
  77239. /**
  77240. * Clone the current matrix
  77241. * @returns a new matrix from the current matrix
  77242. */
  77243. clone(): Matrix;
  77244. /**
  77245. * Returns the name of the current matrix class
  77246. * @returns the string "Matrix"
  77247. */
  77248. getClassName(): string;
  77249. /**
  77250. * Gets the hash code of the current matrix
  77251. * @returns the hash code
  77252. */
  77253. getHashCode(): number;
  77254. /**
  77255. * Decomposes the current Matrix into a translation, rotation and scaling components
  77256. * @param scale defines the scale vector3 given as a reference to update
  77257. * @param rotation defines the rotation quaternion given as a reference to update
  77258. * @param translation defines the translation vector3 given as a reference to update
  77259. * @returns true if operation was successful
  77260. */
  77261. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  77262. /**
  77263. * Gets specific row of the matrix
  77264. * @param index defines the number of the row to get
  77265. * @returns the index-th row of the current matrix as a new Vector4
  77266. */
  77267. getRow(index: number): Nullable<Vector4>;
  77268. /**
  77269. * Sets the index-th row of the current matrix to the vector4 values
  77270. * @param index defines the number of the row to set
  77271. * @param row defines the target vector4
  77272. * @returns the updated current matrix
  77273. */
  77274. setRow(index: number, row: Vector4): Matrix;
  77275. /**
  77276. * Compute the transpose of the matrix
  77277. * @returns the new transposed matrix
  77278. */
  77279. transpose(): Matrix;
  77280. /**
  77281. * Compute the transpose of the matrix and store it in a given matrix
  77282. * @param result defines the target matrix
  77283. * @returns the current matrix
  77284. */
  77285. transposeToRef(result: Matrix): Matrix;
  77286. /**
  77287. * Sets the index-th row of the current matrix with the given 4 x float values
  77288. * @param index defines the row index
  77289. * @param x defines the x component to set
  77290. * @param y defines the y component to set
  77291. * @param z defines the z component to set
  77292. * @param w defines the w component to set
  77293. * @returns the updated current matrix
  77294. */
  77295. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  77296. /**
  77297. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  77298. * @param scale defines the scale factor
  77299. * @returns a new matrix
  77300. */
  77301. scale(scale: number): Matrix;
  77302. /**
  77303. * Scale the current matrix values by a factor to a given result matrix
  77304. * @param scale defines the scale factor
  77305. * @param result defines the matrix to store the result
  77306. * @returns the current matrix
  77307. */
  77308. scaleToRef(scale: number, result: Matrix): Matrix;
  77309. /**
  77310. * Scale the current matrix values by a factor and add the result to a given matrix
  77311. * @param scale defines the scale factor
  77312. * @param result defines the Matrix to store the result
  77313. * @returns the current matrix
  77314. */
  77315. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  77316. /**
  77317. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  77318. * @param ref matrix to store the result
  77319. */
  77320. toNormalMatrix(ref: Matrix): void;
  77321. /**
  77322. * Gets only rotation part of the current matrix
  77323. * @returns a new matrix sets to the extracted rotation matrix from the current one
  77324. */
  77325. getRotationMatrix(): Matrix;
  77326. /**
  77327. * Extracts the rotation matrix from the current one and sets it as the given "result"
  77328. * @param result defines the target matrix to store data to
  77329. * @returns the current matrix
  77330. */
  77331. getRotationMatrixToRef(result: Matrix): Matrix;
  77332. /**
  77333. * Toggles model matrix from being right handed to left handed in place and vice versa
  77334. */
  77335. toggleModelMatrixHandInPlace(): void;
  77336. /**
  77337. * Toggles projection matrix from being right handed to left handed in place and vice versa
  77338. */
  77339. toggleProjectionMatrixHandInPlace(): void;
  77340. /**
  77341. * Creates a matrix from an array
  77342. * @param array defines the source array
  77343. * @param offset defines an offset in the source array
  77344. * @returns a new Matrix set from the starting index of the given array
  77345. */
  77346. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  77347. /**
  77348. * Copy the content of an array into a given matrix
  77349. * @param array defines the source array
  77350. * @param offset defines an offset in the source array
  77351. * @param result defines the target matrix
  77352. */
  77353. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  77354. /**
  77355. * Stores an array into a matrix after having multiplied each component by a given factor
  77356. * @param array defines the source array
  77357. * @param offset defines the offset in the source array
  77358. * @param scale defines the scaling factor
  77359. * @param result defines the target matrix
  77360. */
  77361. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  77362. /**
  77363. * Gets an identity matrix that must not be updated
  77364. */
  77365. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  77366. /**
  77367. * Stores a list of values (16) inside a given matrix
  77368. * @param initialM11 defines 1st value of 1st row
  77369. * @param initialM12 defines 2nd value of 1st row
  77370. * @param initialM13 defines 3rd value of 1st row
  77371. * @param initialM14 defines 4th value of 1st row
  77372. * @param initialM21 defines 1st value of 2nd row
  77373. * @param initialM22 defines 2nd value of 2nd row
  77374. * @param initialM23 defines 3rd value of 2nd row
  77375. * @param initialM24 defines 4th value of 2nd row
  77376. * @param initialM31 defines 1st value of 3rd row
  77377. * @param initialM32 defines 2nd value of 3rd row
  77378. * @param initialM33 defines 3rd value of 3rd row
  77379. * @param initialM34 defines 4th value of 3rd row
  77380. * @param initialM41 defines 1st value of 4th row
  77381. * @param initialM42 defines 2nd value of 4th row
  77382. * @param initialM43 defines 3rd value of 4th row
  77383. * @param initialM44 defines 4th value of 4th row
  77384. * @param result defines the target matrix
  77385. */
  77386. 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;
  77387. /**
  77388. * Creates new matrix from a list of values (16)
  77389. * @param initialM11 defines 1st value of 1st row
  77390. * @param initialM12 defines 2nd value of 1st row
  77391. * @param initialM13 defines 3rd value of 1st row
  77392. * @param initialM14 defines 4th value of 1st row
  77393. * @param initialM21 defines 1st value of 2nd row
  77394. * @param initialM22 defines 2nd value of 2nd row
  77395. * @param initialM23 defines 3rd value of 2nd row
  77396. * @param initialM24 defines 4th value of 2nd row
  77397. * @param initialM31 defines 1st value of 3rd row
  77398. * @param initialM32 defines 2nd value of 3rd row
  77399. * @param initialM33 defines 3rd value of 3rd row
  77400. * @param initialM34 defines 4th value of 3rd row
  77401. * @param initialM41 defines 1st value of 4th row
  77402. * @param initialM42 defines 2nd value of 4th row
  77403. * @param initialM43 defines 3rd value of 4th row
  77404. * @param initialM44 defines 4th value of 4th row
  77405. * @returns the new matrix
  77406. */
  77407. 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;
  77408. /**
  77409. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77410. * @param scale defines the scale vector3
  77411. * @param rotation defines the rotation quaternion
  77412. * @param translation defines the translation vector3
  77413. * @returns a new matrix
  77414. */
  77415. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  77416. /**
  77417. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77418. * @param scale defines the scale vector3
  77419. * @param rotation defines the rotation quaternion
  77420. * @param translation defines the translation vector3
  77421. * @param result defines the target matrix
  77422. */
  77423. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  77424. /**
  77425. * Creates a new identity matrix
  77426. * @returns a new identity matrix
  77427. */
  77428. static Identity(): Matrix;
  77429. /**
  77430. * Creates a new identity matrix and stores the result in a given matrix
  77431. * @param result defines the target matrix
  77432. */
  77433. static IdentityToRef(result: Matrix): void;
  77434. /**
  77435. * Creates a new zero matrix
  77436. * @returns a new zero matrix
  77437. */
  77438. static Zero(): Matrix;
  77439. /**
  77440. * Creates a new rotation matrix for "angle" radians around the X axis
  77441. * @param angle defines the angle (in radians) to use
  77442. * @return the new matrix
  77443. */
  77444. static RotationX(angle: number): Matrix;
  77445. /**
  77446. * Creates a new matrix as the invert of a given matrix
  77447. * @param source defines the source matrix
  77448. * @returns the new matrix
  77449. */
  77450. static Invert(source: DeepImmutable<Matrix>): Matrix;
  77451. /**
  77452. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  77453. * @param angle defines the angle (in radians) to use
  77454. * @param result defines the target matrix
  77455. */
  77456. static RotationXToRef(angle: number, result: Matrix): void;
  77457. /**
  77458. * Creates a new rotation matrix for "angle" radians around the Y axis
  77459. * @param angle defines the angle (in radians) to use
  77460. * @return the new matrix
  77461. */
  77462. static RotationY(angle: number): Matrix;
  77463. /**
  77464. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  77465. * @param angle defines the angle (in radians) to use
  77466. * @param result defines the target matrix
  77467. */
  77468. static RotationYToRef(angle: number, result: Matrix): void;
  77469. /**
  77470. * Creates a new rotation matrix for "angle" radians around the Z axis
  77471. * @param angle defines the angle (in radians) to use
  77472. * @return the new matrix
  77473. */
  77474. static RotationZ(angle: number): Matrix;
  77475. /**
  77476. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  77477. * @param angle defines the angle (in radians) to use
  77478. * @param result defines the target matrix
  77479. */
  77480. static RotationZToRef(angle: number, result: Matrix): void;
  77481. /**
  77482. * Creates a new rotation matrix for "angle" radians around the given axis
  77483. * @param axis defines the axis to use
  77484. * @param angle defines the angle (in radians) to use
  77485. * @return the new matrix
  77486. */
  77487. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  77488. /**
  77489. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  77490. * @param axis defines the axis to use
  77491. * @param angle defines the angle (in radians) to use
  77492. * @param result defines the target matrix
  77493. */
  77494. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  77495. /**
  77496. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  77497. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  77498. * @param from defines the vector to align
  77499. * @param to defines the vector to align to
  77500. * @param result defines the target matrix
  77501. */
  77502. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  77503. /**
  77504. * Creates a rotation matrix
  77505. * @param yaw defines the yaw angle in radians (Y axis)
  77506. * @param pitch defines the pitch angle in radians (X axis)
  77507. * @param roll defines the roll angle in radians (X axis)
  77508. * @returns the new rotation matrix
  77509. */
  77510. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  77511. /**
  77512. * Creates a rotation matrix and stores it in a given matrix
  77513. * @param yaw defines the yaw angle in radians (Y axis)
  77514. * @param pitch defines the pitch angle in radians (X axis)
  77515. * @param roll defines the roll angle in radians (X axis)
  77516. * @param result defines the target matrix
  77517. */
  77518. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  77519. /**
  77520. * Creates a scaling matrix
  77521. * @param x defines the scale factor on X axis
  77522. * @param y defines the scale factor on Y axis
  77523. * @param z defines the scale factor on Z axis
  77524. * @returns the new matrix
  77525. */
  77526. static Scaling(x: number, y: number, z: number): Matrix;
  77527. /**
  77528. * Creates a scaling matrix and stores it in a given matrix
  77529. * @param x defines the scale factor on X axis
  77530. * @param y defines the scale factor on Y axis
  77531. * @param z defines the scale factor on Z axis
  77532. * @param result defines the target matrix
  77533. */
  77534. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  77535. /**
  77536. * Creates a translation matrix
  77537. * @param x defines the translation on X axis
  77538. * @param y defines the translation on Y axis
  77539. * @param z defines the translationon Z axis
  77540. * @returns the new matrix
  77541. */
  77542. static Translation(x: number, y: number, z: number): Matrix;
  77543. /**
  77544. * Creates a translation matrix and stores it in a given matrix
  77545. * @param x defines the translation on X axis
  77546. * @param y defines the translation on Y axis
  77547. * @param z defines the translationon Z axis
  77548. * @param result defines the target matrix
  77549. */
  77550. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  77551. /**
  77552. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77553. * @param startValue defines the start value
  77554. * @param endValue defines the end value
  77555. * @param gradient defines the gradient factor
  77556. * @returns the new matrix
  77557. */
  77558. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77559. /**
  77560. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77561. * @param startValue defines the start value
  77562. * @param endValue defines the end value
  77563. * @param gradient defines the gradient factor
  77564. * @param result defines the Matrix object where to store data
  77565. */
  77566. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77567. /**
  77568. * Builds a new matrix whose values are computed by:
  77569. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77570. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77571. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77572. * @param startValue defines the first matrix
  77573. * @param endValue defines the second matrix
  77574. * @param gradient defines the gradient between the two matrices
  77575. * @returns the new matrix
  77576. */
  77577. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77578. /**
  77579. * Update a matrix to values which are computed by:
  77580. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77581. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77582. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77583. * @param startValue defines the first matrix
  77584. * @param endValue defines the second matrix
  77585. * @param gradient defines the gradient between the two matrices
  77586. * @param result defines the target matrix
  77587. */
  77588. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77589. /**
  77590. * 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"
  77591. * This function works in left handed mode
  77592. * @param eye defines the final position of the entity
  77593. * @param target defines where the entity should look at
  77594. * @param up defines the up vector for the entity
  77595. * @returns the new matrix
  77596. */
  77597. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77598. /**
  77599. * 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".
  77600. * This function works in left handed mode
  77601. * @param eye defines the final position of the entity
  77602. * @param target defines where the entity should look at
  77603. * @param up defines the up vector for the entity
  77604. * @param result defines the target matrix
  77605. */
  77606. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77607. /**
  77608. * 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"
  77609. * This function works in right handed mode
  77610. * @param eye defines the final position of the entity
  77611. * @param target defines where the entity should look at
  77612. * @param up defines the up vector for the entity
  77613. * @returns the new matrix
  77614. */
  77615. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77616. /**
  77617. * 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".
  77618. * This function works in right handed mode
  77619. * @param eye defines the final position of the entity
  77620. * @param target defines where the entity should look at
  77621. * @param up defines the up vector for the entity
  77622. * @param result defines the target matrix
  77623. */
  77624. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77625. /**
  77626. * Create a left-handed orthographic projection matrix
  77627. * @param width defines the viewport width
  77628. * @param height defines the viewport height
  77629. * @param znear defines the near clip plane
  77630. * @param zfar defines the far clip plane
  77631. * @returns a new matrix as a left-handed orthographic projection matrix
  77632. */
  77633. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77634. /**
  77635. * Store a left-handed orthographic projection to a given matrix
  77636. * @param width defines the viewport width
  77637. * @param height defines the viewport height
  77638. * @param znear defines the near clip plane
  77639. * @param zfar defines the far clip plane
  77640. * @param result defines the target matrix
  77641. */
  77642. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  77643. /**
  77644. * Create a left-handed orthographic projection matrix
  77645. * @param left defines the viewport left coordinate
  77646. * @param right defines the viewport right coordinate
  77647. * @param bottom defines the viewport bottom coordinate
  77648. * @param top defines the viewport top coordinate
  77649. * @param znear defines the near clip plane
  77650. * @param zfar defines the far clip plane
  77651. * @returns a new matrix as a left-handed orthographic projection matrix
  77652. */
  77653. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77654. /**
  77655. * Stores a left-handed orthographic projection into a given matrix
  77656. * @param left defines the viewport left coordinate
  77657. * @param right defines the viewport right coordinate
  77658. * @param bottom defines the viewport bottom coordinate
  77659. * @param top defines the viewport top coordinate
  77660. * @param znear defines the near clip plane
  77661. * @param zfar defines the far clip plane
  77662. * @param result defines the target matrix
  77663. */
  77664. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77665. /**
  77666. * Creates a right-handed orthographic projection matrix
  77667. * @param left defines the viewport left coordinate
  77668. * @param right defines the viewport right coordinate
  77669. * @param bottom defines the viewport bottom coordinate
  77670. * @param top defines the viewport top coordinate
  77671. * @param znear defines the near clip plane
  77672. * @param zfar defines the far clip plane
  77673. * @returns a new matrix as a right-handed orthographic projection matrix
  77674. */
  77675. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77676. /**
  77677. * Stores a right-handed orthographic projection into a given matrix
  77678. * @param left defines the viewport left coordinate
  77679. * @param right defines the viewport right coordinate
  77680. * @param bottom defines the viewport bottom coordinate
  77681. * @param top defines the viewport top coordinate
  77682. * @param znear defines the near clip plane
  77683. * @param zfar defines the far clip plane
  77684. * @param result defines the target matrix
  77685. */
  77686. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77687. /**
  77688. * Creates a left-handed perspective projection matrix
  77689. * @param width defines the viewport width
  77690. * @param height defines the viewport height
  77691. * @param znear defines the near clip plane
  77692. * @param zfar defines the far clip plane
  77693. * @returns a new matrix as a left-handed perspective projection matrix
  77694. */
  77695. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77696. /**
  77697. * Creates a left-handed perspective projection matrix
  77698. * @param fov defines the horizontal field of view
  77699. * @param aspect defines the aspect ratio
  77700. * @param znear defines the near clip plane
  77701. * @param zfar defines the far clip plane
  77702. * @returns a new matrix as a left-handed perspective projection matrix
  77703. */
  77704. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77705. /**
  77706. * Stores a left-handed perspective projection into a given matrix
  77707. * @param fov defines the horizontal field of view
  77708. * @param aspect defines the aspect ratio
  77709. * @param znear defines the near clip plane
  77710. * @param zfar defines the far clip plane
  77711. * @param result defines the target matrix
  77712. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77713. */
  77714. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77715. /**
  77716. * Stores a left-handed perspective projection into a given matrix with depth reversed
  77717. * @param fov defines the horizontal field of view
  77718. * @param aspect defines the aspect ratio
  77719. * @param znear defines the near clip plane
  77720. * @param zfar not used as infinity is used as far clip
  77721. * @param result defines the target matrix
  77722. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77723. */
  77724. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77725. /**
  77726. * Creates a right-handed perspective projection matrix
  77727. * @param fov defines the horizontal field of view
  77728. * @param aspect defines the aspect ratio
  77729. * @param znear defines the near clip plane
  77730. * @param zfar defines the far clip plane
  77731. * @returns a new matrix as a right-handed perspective projection matrix
  77732. */
  77733. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77734. /**
  77735. * Stores a right-handed perspective projection into a given matrix
  77736. * @param fov defines the horizontal field of view
  77737. * @param aspect defines the aspect ratio
  77738. * @param znear defines the near clip plane
  77739. * @param zfar defines the far clip plane
  77740. * @param result defines the target matrix
  77741. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77742. */
  77743. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77744. /**
  77745. * Stores a right-handed perspective projection into a given matrix
  77746. * @param fov defines the horizontal field of view
  77747. * @param aspect defines the aspect ratio
  77748. * @param znear defines the near clip plane
  77749. * @param zfar not used as infinity is used as far clip
  77750. * @param result defines the target matrix
  77751. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77752. */
  77753. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77754. /**
  77755. * Stores a perspective projection for WebVR info a given matrix
  77756. * @param fov defines the field of view
  77757. * @param znear defines the near clip plane
  77758. * @param zfar defines the far clip plane
  77759. * @param result defines the target matrix
  77760. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  77761. */
  77762. static PerspectiveFovWebVRToRef(fov: {
  77763. upDegrees: number;
  77764. downDegrees: number;
  77765. leftDegrees: number;
  77766. rightDegrees: number;
  77767. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  77768. /**
  77769. * Computes a complete transformation matrix
  77770. * @param viewport defines the viewport to use
  77771. * @param world defines the world matrix
  77772. * @param view defines the view matrix
  77773. * @param projection defines the projection matrix
  77774. * @param zmin defines the near clip plane
  77775. * @param zmax defines the far clip plane
  77776. * @returns the transformation matrix
  77777. */
  77778. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  77779. /**
  77780. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  77781. * @param matrix defines the matrix to use
  77782. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  77783. */
  77784. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  77785. /**
  77786. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  77787. * @param matrix defines the matrix to use
  77788. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  77789. */
  77790. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  77791. /**
  77792. * Compute the transpose of a given matrix
  77793. * @param matrix defines the matrix to transpose
  77794. * @returns the new matrix
  77795. */
  77796. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  77797. /**
  77798. * Compute the transpose of a matrix and store it in a target matrix
  77799. * @param matrix defines the matrix to transpose
  77800. * @param result defines the target matrix
  77801. */
  77802. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  77803. /**
  77804. * Computes a reflection matrix from a plane
  77805. * @param plane defines the reflection plane
  77806. * @returns a new matrix
  77807. */
  77808. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  77809. /**
  77810. * Computes a reflection matrix from a plane
  77811. * @param plane defines the reflection plane
  77812. * @param result defines the target matrix
  77813. */
  77814. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  77815. /**
  77816. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  77817. * @param xaxis defines the value of the 1st axis
  77818. * @param yaxis defines the value of the 2nd axis
  77819. * @param zaxis defines the value of the 3rd axis
  77820. * @param result defines the target matrix
  77821. */
  77822. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  77823. /**
  77824. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  77825. * @param quat defines the quaternion to use
  77826. * @param result defines the target matrix
  77827. */
  77828. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  77829. }
  77830. /**
  77831. * @hidden
  77832. */
  77833. export class TmpVectors {
  77834. static Vector2: Vector2[];
  77835. static Vector3: Vector3[];
  77836. static Vector4: Vector4[];
  77837. static Quaternion: Quaternion[];
  77838. static Matrix: Matrix[];
  77839. }
  77840. }
  77841. declare module BABYLON {
  77842. /**
  77843. * Defines potential orientation for back face culling
  77844. */
  77845. export enum Orientation {
  77846. /**
  77847. * Clockwise
  77848. */
  77849. CW = 0,
  77850. /** Counter clockwise */
  77851. CCW = 1
  77852. }
  77853. /** Class used to represent a Bezier curve */
  77854. export class BezierCurve {
  77855. /**
  77856. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  77857. * @param t defines the time
  77858. * @param x1 defines the left coordinate on X axis
  77859. * @param y1 defines the left coordinate on Y axis
  77860. * @param x2 defines the right coordinate on X axis
  77861. * @param y2 defines the right coordinate on Y axis
  77862. * @returns the interpolated value
  77863. */
  77864. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  77865. }
  77866. /**
  77867. * Defines angle representation
  77868. */
  77869. export class Angle {
  77870. private _radians;
  77871. /**
  77872. * Creates an Angle object of "radians" radians (float).
  77873. * @param radians the angle in radians
  77874. */
  77875. constructor(radians: number);
  77876. /**
  77877. * Get value in degrees
  77878. * @returns the Angle value in degrees (float)
  77879. */
  77880. degrees(): number;
  77881. /**
  77882. * Get value in radians
  77883. * @returns the Angle value in radians (float)
  77884. */
  77885. radians(): number;
  77886. /**
  77887. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  77888. * @param a defines first vector
  77889. * @param b defines second vector
  77890. * @returns a new Angle
  77891. */
  77892. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  77893. /**
  77894. * Gets a new Angle object from the given float in radians
  77895. * @param radians defines the angle value in radians
  77896. * @returns a new Angle
  77897. */
  77898. static FromRadians(radians: number): Angle;
  77899. /**
  77900. * Gets a new Angle object from the given float in degrees
  77901. * @param degrees defines the angle value in degrees
  77902. * @returns a new Angle
  77903. */
  77904. static FromDegrees(degrees: number): Angle;
  77905. }
  77906. /**
  77907. * This represents an arc in a 2d space.
  77908. */
  77909. export class Arc2 {
  77910. /** Defines the start point of the arc */
  77911. startPoint: Vector2;
  77912. /** Defines the mid point of the arc */
  77913. midPoint: Vector2;
  77914. /** Defines the end point of the arc */
  77915. endPoint: Vector2;
  77916. /**
  77917. * Defines the center point of the arc.
  77918. */
  77919. centerPoint: Vector2;
  77920. /**
  77921. * Defines the radius of the arc.
  77922. */
  77923. radius: number;
  77924. /**
  77925. * Defines the angle of the arc (from mid point to end point).
  77926. */
  77927. angle: Angle;
  77928. /**
  77929. * Defines the start angle of the arc (from start point to middle point).
  77930. */
  77931. startAngle: Angle;
  77932. /**
  77933. * Defines the orientation of the arc (clock wise/counter clock wise).
  77934. */
  77935. orientation: Orientation;
  77936. /**
  77937. * Creates an Arc object from the three given points : start, middle and end.
  77938. * @param startPoint Defines the start point of the arc
  77939. * @param midPoint Defines the midlle point of the arc
  77940. * @param endPoint Defines the end point of the arc
  77941. */
  77942. constructor(
  77943. /** Defines the start point of the arc */
  77944. startPoint: Vector2,
  77945. /** Defines the mid point of the arc */
  77946. midPoint: Vector2,
  77947. /** Defines the end point of the arc */
  77948. endPoint: Vector2);
  77949. }
  77950. /**
  77951. * Represents a 2D path made up of multiple 2D points
  77952. */
  77953. export class Path2 {
  77954. private _points;
  77955. private _length;
  77956. /**
  77957. * If the path start and end point are the same
  77958. */
  77959. closed: boolean;
  77960. /**
  77961. * Creates a Path2 object from the starting 2D coordinates x and y.
  77962. * @param x the starting points x value
  77963. * @param y the starting points y value
  77964. */
  77965. constructor(x: number, y: number);
  77966. /**
  77967. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  77968. * @param x the added points x value
  77969. * @param y the added points y value
  77970. * @returns the updated Path2.
  77971. */
  77972. addLineTo(x: number, y: number): Path2;
  77973. /**
  77974. * 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.
  77975. * @param midX middle point x value
  77976. * @param midY middle point y value
  77977. * @param endX end point x value
  77978. * @param endY end point y value
  77979. * @param numberOfSegments (default: 36)
  77980. * @returns the updated Path2.
  77981. */
  77982. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  77983. /**
  77984. * Closes the Path2.
  77985. * @returns the Path2.
  77986. */
  77987. close(): Path2;
  77988. /**
  77989. * Gets the sum of the distance between each sequential point in the path
  77990. * @returns the Path2 total length (float).
  77991. */
  77992. length(): number;
  77993. /**
  77994. * Gets the points which construct the path
  77995. * @returns the Path2 internal array of points.
  77996. */
  77997. getPoints(): Vector2[];
  77998. /**
  77999. * Retreives the point at the distance aways from the starting point
  78000. * @param normalizedLengthPosition the length along the path to retreive the point from
  78001. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  78002. */
  78003. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  78004. /**
  78005. * Creates a new path starting from an x and y position
  78006. * @param x starting x value
  78007. * @param y starting y value
  78008. * @returns a new Path2 starting at the coordinates (x, y).
  78009. */
  78010. static StartingAt(x: number, y: number): Path2;
  78011. }
  78012. /**
  78013. * Represents a 3D path made up of multiple 3D points
  78014. */
  78015. export class Path3D {
  78016. /**
  78017. * an array of Vector3, the curve axis of the Path3D
  78018. */
  78019. path: Vector3[];
  78020. private _curve;
  78021. private _distances;
  78022. private _tangents;
  78023. private _normals;
  78024. private _binormals;
  78025. private _raw;
  78026. private _alignTangentsWithPath;
  78027. private readonly _pointAtData;
  78028. /**
  78029. * new Path3D(path, normal, raw)
  78030. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  78031. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  78032. * @param path an array of Vector3, the curve axis of the Path3D
  78033. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  78034. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  78035. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  78036. */
  78037. constructor(
  78038. /**
  78039. * an array of Vector3, the curve axis of the Path3D
  78040. */
  78041. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  78042. /**
  78043. * Returns the Path3D array of successive Vector3 designing its curve.
  78044. * @returns the Path3D array of successive Vector3 designing its curve.
  78045. */
  78046. getCurve(): Vector3[];
  78047. /**
  78048. * Returns the Path3D array of successive Vector3 designing its curve.
  78049. * @returns the Path3D array of successive Vector3 designing its curve.
  78050. */
  78051. getPoints(): Vector3[];
  78052. /**
  78053. * @returns the computed length (float) of the path.
  78054. */
  78055. length(): number;
  78056. /**
  78057. * Returns an array populated with tangent vectors on each Path3D curve point.
  78058. * @returns an array populated with tangent vectors on each Path3D curve point.
  78059. */
  78060. getTangents(): Vector3[];
  78061. /**
  78062. * Returns an array populated with normal vectors on each Path3D curve point.
  78063. * @returns an array populated with normal vectors on each Path3D curve point.
  78064. */
  78065. getNormals(): Vector3[];
  78066. /**
  78067. * Returns an array populated with binormal vectors on each Path3D curve point.
  78068. * @returns an array populated with binormal vectors on each Path3D curve point.
  78069. */
  78070. getBinormals(): Vector3[];
  78071. /**
  78072. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  78073. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  78074. */
  78075. getDistances(): number[];
  78076. /**
  78077. * Returns an interpolated point along this path
  78078. * @param position the position of the point along this path, from 0.0 to 1.0
  78079. * @returns a new Vector3 as the point
  78080. */
  78081. getPointAt(position: number): Vector3;
  78082. /**
  78083. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78084. * @param position the position of the point along this path, from 0.0 to 1.0
  78085. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  78086. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  78087. */
  78088. getTangentAt(position: number, interpolated?: boolean): Vector3;
  78089. /**
  78090. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78091. * @param position the position of the point along this path, from 0.0 to 1.0
  78092. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  78093. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  78094. */
  78095. getNormalAt(position: number, interpolated?: boolean): Vector3;
  78096. /**
  78097. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  78098. * @param position the position of the point along this path, from 0.0 to 1.0
  78099. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  78100. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  78101. */
  78102. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  78103. /**
  78104. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  78105. * @param position the position of the point along this path, from 0.0 to 1.0
  78106. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  78107. */
  78108. getDistanceAt(position: number): number;
  78109. /**
  78110. * Returns the array index of the previous point of an interpolated point along this path
  78111. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78112. * @returns the array index
  78113. */
  78114. getPreviousPointIndexAt(position: number): number;
  78115. /**
  78116. * 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)
  78117. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78118. * @returns the sub position
  78119. */
  78120. getSubPositionAt(position: number): number;
  78121. /**
  78122. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  78123. * @param target the vector of which to get the closest position to
  78124. * @returns the position of the closest virtual point on this path to the target vector
  78125. */
  78126. getClosestPositionTo(target: Vector3): number;
  78127. /**
  78128. * Returns a sub path (slice) of this path
  78129. * @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
  78130. * @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
  78131. * @returns a sub path (slice) of this path
  78132. */
  78133. slice(start?: number, end?: number): Path3D;
  78134. /**
  78135. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  78136. * @param path path which all values are copied into the curves points
  78137. * @param firstNormal which should be projected onto the curve
  78138. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  78139. * @returns the same object updated.
  78140. */
  78141. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  78142. private _compute;
  78143. private _getFirstNonNullVector;
  78144. private _getLastNonNullVector;
  78145. private _normalVector;
  78146. /**
  78147. * Updates the point at data for an interpolated point along this curve
  78148. * @param position the position of the point along this curve, from 0.0 to 1.0
  78149. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  78150. * @returns the (updated) point at data
  78151. */
  78152. private _updatePointAtData;
  78153. /**
  78154. * Updates the point at data from the specified parameters
  78155. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  78156. * @param point the interpolated point
  78157. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  78158. */
  78159. private _setPointAtData;
  78160. /**
  78161. * Updates the point at interpolation matrix for the tangents, normals and binormals
  78162. */
  78163. private _updateInterpolationMatrix;
  78164. }
  78165. /**
  78166. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78167. * A Curve3 is designed from a series of successive Vector3.
  78168. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  78169. */
  78170. export class Curve3 {
  78171. private _points;
  78172. private _length;
  78173. /**
  78174. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  78175. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  78176. * @param v1 (Vector3) the control point
  78177. * @param v2 (Vector3) the end point of the Quadratic Bezier
  78178. * @param nbPoints (integer) the wanted number of points in the curve
  78179. * @returns the created Curve3
  78180. */
  78181. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78182. /**
  78183. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  78184. * @param v0 (Vector3) the origin point of the Cubic Bezier
  78185. * @param v1 (Vector3) the first control point
  78186. * @param v2 (Vector3) the second control point
  78187. * @param v3 (Vector3) the end point of the Cubic Bezier
  78188. * @param nbPoints (integer) the wanted number of points in the curve
  78189. * @returns the created Curve3
  78190. */
  78191. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78192. /**
  78193. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  78194. * @param p1 (Vector3) the origin point of the Hermite Spline
  78195. * @param t1 (Vector3) the tangent vector at the origin point
  78196. * @param p2 (Vector3) the end point of the Hermite Spline
  78197. * @param t2 (Vector3) the tangent vector at the end point
  78198. * @param nbPoints (integer) the wanted number of points in the curve
  78199. * @returns the created Curve3
  78200. */
  78201. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78202. /**
  78203. * Returns a Curve3 object along a CatmullRom Spline curve :
  78204. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  78205. * @param nbPoints (integer) the wanted number of points between each curve control points
  78206. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  78207. * @returns the created Curve3
  78208. */
  78209. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  78210. /**
  78211. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78212. * A Curve3 is designed from a series of successive Vector3.
  78213. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  78214. * @param points points which make up the curve
  78215. */
  78216. constructor(points: Vector3[]);
  78217. /**
  78218. * @returns the Curve3 stored array of successive Vector3
  78219. */
  78220. getPoints(): Vector3[];
  78221. /**
  78222. * @returns the computed length (float) of the curve.
  78223. */
  78224. length(): number;
  78225. /**
  78226. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  78227. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  78228. * curveA and curveB keep unchanged.
  78229. * @param curve the curve to continue from this curve
  78230. * @returns the newly constructed curve
  78231. */
  78232. continue(curve: DeepImmutable<Curve3>): Curve3;
  78233. private _computeLength;
  78234. }
  78235. }
  78236. declare module BABYLON {
  78237. /**
  78238. * This represents the main contract an easing function should follow.
  78239. * Easing functions are used throughout the animation system.
  78240. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78241. */
  78242. export interface IEasingFunction {
  78243. /**
  78244. * Given an input gradient between 0 and 1, this returns the corrseponding value
  78245. * of the easing function.
  78246. * The link below provides some of the most common examples of easing functions.
  78247. * @see https://easings.net/
  78248. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78249. * @returns the corresponding value on the curve defined by the easing function
  78250. */
  78251. ease(gradient: number): number;
  78252. }
  78253. /**
  78254. * Base class used for every default easing function.
  78255. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78256. */
  78257. export class EasingFunction implements IEasingFunction {
  78258. /**
  78259. * Interpolation follows the mathematical formula associated with the easing function.
  78260. */
  78261. static readonly EASINGMODE_EASEIN: number;
  78262. /**
  78263. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  78264. */
  78265. static readonly EASINGMODE_EASEOUT: number;
  78266. /**
  78267. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  78268. */
  78269. static readonly EASINGMODE_EASEINOUT: number;
  78270. private _easingMode;
  78271. /**
  78272. * Sets the easing mode of the current function.
  78273. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  78274. */
  78275. setEasingMode(easingMode: number): void;
  78276. /**
  78277. * Gets the current easing mode.
  78278. * @returns the easing mode
  78279. */
  78280. getEasingMode(): number;
  78281. /**
  78282. * @hidden
  78283. */
  78284. easeInCore(gradient: number): number;
  78285. /**
  78286. * Given an input gradient between 0 and 1, this returns the corresponding value
  78287. * of the easing function.
  78288. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78289. * @returns the corresponding value on the curve defined by the easing function
  78290. */
  78291. ease(gradient: number): number;
  78292. }
  78293. /**
  78294. * Easing function with a circle shape (see link below).
  78295. * @see https://easings.net/#easeInCirc
  78296. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78297. */
  78298. export class CircleEase extends EasingFunction implements IEasingFunction {
  78299. /** @hidden */
  78300. easeInCore(gradient: number): number;
  78301. }
  78302. /**
  78303. * Easing function with a ease back shape (see link below).
  78304. * @see https://easings.net/#easeInBack
  78305. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78306. */
  78307. export class BackEase extends EasingFunction implements IEasingFunction {
  78308. /** Defines the amplitude of the function */
  78309. amplitude: number;
  78310. /**
  78311. * Instantiates a back ease easing
  78312. * @see https://easings.net/#easeInBack
  78313. * @param amplitude Defines the amplitude of the function
  78314. */
  78315. constructor(
  78316. /** Defines the amplitude of the function */
  78317. amplitude?: number);
  78318. /** @hidden */
  78319. easeInCore(gradient: number): number;
  78320. }
  78321. /**
  78322. * Easing function with a bouncing shape (see link below).
  78323. * @see https://easings.net/#easeInBounce
  78324. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78325. */
  78326. export class BounceEase extends EasingFunction implements IEasingFunction {
  78327. /** Defines the number of bounces */
  78328. bounces: number;
  78329. /** Defines the amplitude of the bounce */
  78330. bounciness: number;
  78331. /**
  78332. * Instantiates a bounce easing
  78333. * @see https://easings.net/#easeInBounce
  78334. * @param bounces Defines the number of bounces
  78335. * @param bounciness Defines the amplitude of the bounce
  78336. */
  78337. constructor(
  78338. /** Defines the number of bounces */
  78339. bounces?: number,
  78340. /** Defines the amplitude of the bounce */
  78341. bounciness?: number);
  78342. /** @hidden */
  78343. easeInCore(gradient: number): number;
  78344. }
  78345. /**
  78346. * Easing function with a power of 3 shape (see link below).
  78347. * @see https://easings.net/#easeInCubic
  78348. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78349. */
  78350. export class CubicEase extends EasingFunction implements IEasingFunction {
  78351. /** @hidden */
  78352. easeInCore(gradient: number): number;
  78353. }
  78354. /**
  78355. * Easing function with an elastic shape (see link below).
  78356. * @see https://easings.net/#easeInElastic
  78357. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78358. */
  78359. export class ElasticEase extends EasingFunction implements IEasingFunction {
  78360. /** Defines the number of oscillations*/
  78361. oscillations: number;
  78362. /** Defines the amplitude of the oscillations*/
  78363. springiness: number;
  78364. /**
  78365. * Instantiates an elastic easing function
  78366. * @see https://easings.net/#easeInElastic
  78367. * @param oscillations Defines the number of oscillations
  78368. * @param springiness Defines the amplitude of the oscillations
  78369. */
  78370. constructor(
  78371. /** Defines the number of oscillations*/
  78372. oscillations?: number,
  78373. /** Defines the amplitude of the oscillations*/
  78374. springiness?: number);
  78375. /** @hidden */
  78376. easeInCore(gradient: number): number;
  78377. }
  78378. /**
  78379. * Easing function with an exponential shape (see link below).
  78380. * @see https://easings.net/#easeInExpo
  78381. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78382. */
  78383. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  78384. /** Defines the exponent of the function */
  78385. exponent: number;
  78386. /**
  78387. * Instantiates an exponential easing function
  78388. * @see https://easings.net/#easeInExpo
  78389. * @param exponent Defines the exponent of the function
  78390. */
  78391. constructor(
  78392. /** Defines the exponent of the function */
  78393. exponent?: number);
  78394. /** @hidden */
  78395. easeInCore(gradient: number): number;
  78396. }
  78397. /**
  78398. * Easing function with a power shape (see link below).
  78399. * @see https://easings.net/#easeInQuad
  78400. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78401. */
  78402. export class PowerEase extends EasingFunction implements IEasingFunction {
  78403. /** Defines the power of the function */
  78404. power: number;
  78405. /**
  78406. * Instantiates an power base easing function
  78407. * @see https://easings.net/#easeInQuad
  78408. * @param power Defines the power of the function
  78409. */
  78410. constructor(
  78411. /** Defines the power of the function */
  78412. power?: number);
  78413. /** @hidden */
  78414. easeInCore(gradient: number): number;
  78415. }
  78416. /**
  78417. * Easing function with a power of 2 shape (see link below).
  78418. * @see https://easings.net/#easeInQuad
  78419. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78420. */
  78421. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  78422. /** @hidden */
  78423. easeInCore(gradient: number): number;
  78424. }
  78425. /**
  78426. * Easing function with a power of 4 shape (see link below).
  78427. * @see https://easings.net/#easeInQuart
  78428. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78429. */
  78430. export class QuarticEase extends EasingFunction implements IEasingFunction {
  78431. /** @hidden */
  78432. easeInCore(gradient: number): number;
  78433. }
  78434. /**
  78435. * Easing function with a power of 5 shape (see link below).
  78436. * @see https://easings.net/#easeInQuint
  78437. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78438. */
  78439. export class QuinticEase extends EasingFunction implements IEasingFunction {
  78440. /** @hidden */
  78441. easeInCore(gradient: number): number;
  78442. }
  78443. /**
  78444. * Easing function with a sin shape (see link below).
  78445. * @see https://easings.net/#easeInSine
  78446. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78447. */
  78448. export class SineEase extends EasingFunction implements IEasingFunction {
  78449. /** @hidden */
  78450. easeInCore(gradient: number): number;
  78451. }
  78452. /**
  78453. * Easing function with a bezier shape (see link below).
  78454. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78455. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78456. */
  78457. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  78458. /** Defines the x component of the start tangent in the bezier curve */
  78459. x1: number;
  78460. /** Defines the y component of the start tangent in the bezier curve */
  78461. y1: number;
  78462. /** Defines the x component of the end tangent in the bezier curve */
  78463. x2: number;
  78464. /** Defines the y component of the end tangent in the bezier curve */
  78465. y2: number;
  78466. /**
  78467. * Instantiates a bezier function
  78468. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78469. * @param x1 Defines the x component of the start tangent in the bezier curve
  78470. * @param y1 Defines the y component of the start tangent in the bezier curve
  78471. * @param x2 Defines the x component of the end tangent in the bezier curve
  78472. * @param y2 Defines the y component of the end tangent in the bezier curve
  78473. */
  78474. constructor(
  78475. /** Defines the x component of the start tangent in the bezier curve */
  78476. x1?: number,
  78477. /** Defines the y component of the start tangent in the bezier curve */
  78478. y1?: number,
  78479. /** Defines the x component of the end tangent in the bezier curve */
  78480. x2?: number,
  78481. /** Defines the y component of the end tangent in the bezier curve */
  78482. y2?: number);
  78483. /** @hidden */
  78484. easeInCore(gradient: number): number;
  78485. }
  78486. }
  78487. declare module BABYLON {
  78488. /**
  78489. * Class used to hold a RBG color
  78490. */
  78491. export class Color3 {
  78492. /**
  78493. * Defines the red component (between 0 and 1, default is 0)
  78494. */
  78495. r: number;
  78496. /**
  78497. * Defines the green component (between 0 and 1, default is 0)
  78498. */
  78499. g: number;
  78500. /**
  78501. * Defines the blue component (between 0 and 1, default is 0)
  78502. */
  78503. b: number;
  78504. /**
  78505. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  78506. * @param r defines the red component (between 0 and 1, default is 0)
  78507. * @param g defines the green component (between 0 and 1, default is 0)
  78508. * @param b defines the blue component (between 0 and 1, default is 0)
  78509. */
  78510. constructor(
  78511. /**
  78512. * Defines the red component (between 0 and 1, default is 0)
  78513. */
  78514. r?: number,
  78515. /**
  78516. * Defines the green component (between 0 and 1, default is 0)
  78517. */
  78518. g?: number,
  78519. /**
  78520. * Defines the blue component (between 0 and 1, default is 0)
  78521. */
  78522. b?: number);
  78523. /**
  78524. * Creates a string with the Color3 current values
  78525. * @returns the string representation of the Color3 object
  78526. */
  78527. toString(): string;
  78528. /**
  78529. * Returns the string "Color3"
  78530. * @returns "Color3"
  78531. */
  78532. getClassName(): string;
  78533. /**
  78534. * Compute the Color3 hash code
  78535. * @returns an unique number that can be used to hash Color3 objects
  78536. */
  78537. getHashCode(): number;
  78538. /**
  78539. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  78540. * @param array defines the array where to store the r,g,b components
  78541. * @param index defines an optional index in the target array to define where to start storing values
  78542. * @returns the current Color3 object
  78543. */
  78544. toArray(array: FloatArray, index?: number): Color3;
  78545. /**
  78546. * Returns a new Color4 object from the current Color3 and the given alpha
  78547. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  78548. * @returns a new Color4 object
  78549. */
  78550. toColor4(alpha?: number): Color4;
  78551. /**
  78552. * Returns a new array populated with 3 numeric elements : red, green and blue values
  78553. * @returns the new array
  78554. */
  78555. asArray(): number[];
  78556. /**
  78557. * Returns the luminance value
  78558. * @returns a float value
  78559. */
  78560. toLuminance(): number;
  78561. /**
  78562. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  78563. * @param otherColor defines the second operand
  78564. * @returns the new Color3 object
  78565. */
  78566. multiply(otherColor: DeepImmutable<Color3>): Color3;
  78567. /**
  78568. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  78569. * @param otherColor defines the second operand
  78570. * @param result defines the Color3 object where to store the result
  78571. * @returns the current Color3
  78572. */
  78573. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78574. /**
  78575. * Determines equality between Color3 objects
  78576. * @param otherColor defines the second operand
  78577. * @returns true if the rgb values are equal to the given ones
  78578. */
  78579. equals(otherColor: DeepImmutable<Color3>): boolean;
  78580. /**
  78581. * Determines equality between the current Color3 object and a set of r,b,g values
  78582. * @param r defines the red component to check
  78583. * @param g defines the green component to check
  78584. * @param b defines the blue component to check
  78585. * @returns true if the rgb values are equal to the given ones
  78586. */
  78587. equalsFloats(r: number, g: number, b: number): boolean;
  78588. /**
  78589. * Multiplies in place each rgb value by scale
  78590. * @param scale defines the scaling factor
  78591. * @returns the updated Color3
  78592. */
  78593. scale(scale: number): Color3;
  78594. /**
  78595. * Multiplies the rgb values by scale and stores the result into "result"
  78596. * @param scale defines the scaling factor
  78597. * @param result defines the Color3 object where to store the result
  78598. * @returns the unmodified current Color3
  78599. */
  78600. scaleToRef(scale: number, result: Color3): Color3;
  78601. /**
  78602. * Scale the current Color3 values by a factor and add the result to a given Color3
  78603. * @param scale defines the scale factor
  78604. * @param result defines color to store the result into
  78605. * @returns the unmodified current Color3
  78606. */
  78607. scaleAndAddToRef(scale: number, result: Color3): Color3;
  78608. /**
  78609. * Clamps the rgb values by the min and max values and stores the result into "result"
  78610. * @param min defines minimum clamping value (default is 0)
  78611. * @param max defines maximum clamping value (default is 1)
  78612. * @param result defines color to store the result into
  78613. * @returns the original Color3
  78614. */
  78615. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  78616. /**
  78617. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  78618. * @param otherColor defines the second operand
  78619. * @returns the new Color3
  78620. */
  78621. add(otherColor: DeepImmutable<Color3>): Color3;
  78622. /**
  78623. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  78624. * @param otherColor defines the second operand
  78625. * @param result defines Color3 object to store the result into
  78626. * @returns the unmodified current Color3
  78627. */
  78628. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78629. /**
  78630. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  78631. * @param otherColor defines the second operand
  78632. * @returns the new Color3
  78633. */
  78634. subtract(otherColor: DeepImmutable<Color3>): Color3;
  78635. /**
  78636. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  78637. * @param otherColor defines the second operand
  78638. * @param result defines Color3 object to store the result into
  78639. * @returns the unmodified current Color3
  78640. */
  78641. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78642. /**
  78643. * Copy the current object
  78644. * @returns a new Color3 copied the current one
  78645. */
  78646. clone(): Color3;
  78647. /**
  78648. * Copies the rgb values from the source in the current Color3
  78649. * @param source defines the source Color3 object
  78650. * @returns the updated Color3 object
  78651. */
  78652. copyFrom(source: DeepImmutable<Color3>): Color3;
  78653. /**
  78654. * Updates the Color3 rgb values from the given floats
  78655. * @param r defines the red component to read from
  78656. * @param g defines the green component to read from
  78657. * @param b defines the blue component to read from
  78658. * @returns the current Color3 object
  78659. */
  78660. copyFromFloats(r: number, g: number, b: number): Color3;
  78661. /**
  78662. * Updates the Color3 rgb values from the given floats
  78663. * @param r defines the red component to read from
  78664. * @param g defines the green component to read from
  78665. * @param b defines the blue component to read from
  78666. * @returns the current Color3 object
  78667. */
  78668. set(r: number, g: number, b: number): Color3;
  78669. /**
  78670. * Compute the Color3 hexadecimal code as a string
  78671. * @returns a string containing the hexadecimal representation of the Color3 object
  78672. */
  78673. toHexString(): string;
  78674. /**
  78675. * Computes a new Color3 converted from the current one to linear space
  78676. * @returns a new Color3 object
  78677. */
  78678. toLinearSpace(): Color3;
  78679. /**
  78680. * Converts current color in rgb space to HSV values
  78681. * @returns a new color3 representing the HSV values
  78682. */
  78683. toHSV(): Color3;
  78684. /**
  78685. * Converts current color in rgb space to HSV values
  78686. * @param result defines the Color3 where to store the HSV values
  78687. */
  78688. toHSVToRef(result: Color3): void;
  78689. /**
  78690. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  78691. * @param convertedColor defines the Color3 object where to store the linear space version
  78692. * @returns the unmodified Color3
  78693. */
  78694. toLinearSpaceToRef(convertedColor: Color3): Color3;
  78695. /**
  78696. * Computes a new Color3 converted from the current one to gamma space
  78697. * @returns a new Color3 object
  78698. */
  78699. toGammaSpace(): Color3;
  78700. /**
  78701. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  78702. * @param convertedColor defines the Color3 object where to store the gamma space version
  78703. * @returns the unmodified Color3
  78704. */
  78705. toGammaSpaceToRef(convertedColor: Color3): Color3;
  78706. private static _BlackReadOnly;
  78707. /**
  78708. * Convert Hue, saturation and value to a Color3 (RGB)
  78709. * @param hue defines the hue
  78710. * @param saturation defines the saturation
  78711. * @param value defines the value
  78712. * @param result defines the Color3 where to store the RGB values
  78713. */
  78714. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  78715. /**
  78716. * Creates a new Color3 from the string containing valid hexadecimal values
  78717. * @param hex defines a string containing valid hexadecimal values
  78718. * @returns a new Color3 object
  78719. */
  78720. static FromHexString(hex: string): Color3;
  78721. /**
  78722. * Creates a new Color3 from the starting index of the given array
  78723. * @param array defines the source array
  78724. * @param offset defines an offset in the source array
  78725. * @returns a new Color3 object
  78726. */
  78727. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  78728. /**
  78729. * Creates a new Color3 from integer values (< 256)
  78730. * @param r defines the red component to read from (value between 0 and 255)
  78731. * @param g defines the green component to read from (value between 0 and 255)
  78732. * @param b defines the blue component to read from (value between 0 and 255)
  78733. * @returns a new Color3 object
  78734. */
  78735. static FromInts(r: number, g: number, b: number): Color3;
  78736. /**
  78737. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78738. * @param start defines the start Color3 value
  78739. * @param end defines the end Color3 value
  78740. * @param amount defines the gradient value between start and end
  78741. * @returns a new Color3 object
  78742. */
  78743. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  78744. /**
  78745. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78746. * @param left defines the start value
  78747. * @param right defines the end value
  78748. * @param amount defines the gradient factor
  78749. * @param result defines the Color3 object where to store the result
  78750. */
  78751. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  78752. /**
  78753. * Returns a Color3 value containing a red color
  78754. * @returns a new Color3 object
  78755. */
  78756. static Red(): Color3;
  78757. /**
  78758. * Returns a Color3 value containing a green color
  78759. * @returns a new Color3 object
  78760. */
  78761. static Green(): Color3;
  78762. /**
  78763. * Returns a Color3 value containing a blue color
  78764. * @returns a new Color3 object
  78765. */
  78766. static Blue(): Color3;
  78767. /**
  78768. * Returns a Color3 value containing a black color
  78769. * @returns a new Color3 object
  78770. */
  78771. static Black(): Color3;
  78772. /**
  78773. * Gets a Color3 value containing a black color that must not be updated
  78774. */
  78775. static get BlackReadOnly(): DeepImmutable<Color3>;
  78776. /**
  78777. * Returns a Color3 value containing a white color
  78778. * @returns a new Color3 object
  78779. */
  78780. static White(): Color3;
  78781. /**
  78782. * Returns a Color3 value containing a purple color
  78783. * @returns a new Color3 object
  78784. */
  78785. static Purple(): Color3;
  78786. /**
  78787. * Returns a Color3 value containing a magenta color
  78788. * @returns a new Color3 object
  78789. */
  78790. static Magenta(): Color3;
  78791. /**
  78792. * Returns a Color3 value containing a yellow color
  78793. * @returns a new Color3 object
  78794. */
  78795. static Yellow(): Color3;
  78796. /**
  78797. * Returns a Color3 value containing a gray color
  78798. * @returns a new Color3 object
  78799. */
  78800. static Gray(): Color3;
  78801. /**
  78802. * Returns a Color3 value containing a teal color
  78803. * @returns a new Color3 object
  78804. */
  78805. static Teal(): Color3;
  78806. /**
  78807. * Returns a Color3 value containing a random color
  78808. * @returns a new Color3 object
  78809. */
  78810. static Random(): Color3;
  78811. }
  78812. /**
  78813. * Class used to hold a RBGA color
  78814. */
  78815. export class Color4 {
  78816. /**
  78817. * Defines the red component (between 0 and 1, default is 0)
  78818. */
  78819. r: number;
  78820. /**
  78821. * Defines the green component (between 0 and 1, default is 0)
  78822. */
  78823. g: number;
  78824. /**
  78825. * Defines the blue component (between 0 and 1, default is 0)
  78826. */
  78827. b: number;
  78828. /**
  78829. * Defines the alpha component (between 0 and 1, default is 1)
  78830. */
  78831. a: number;
  78832. /**
  78833. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  78834. * @param r defines the red component (between 0 and 1, default is 0)
  78835. * @param g defines the green component (between 0 and 1, default is 0)
  78836. * @param b defines the blue component (between 0 and 1, default is 0)
  78837. * @param a defines the alpha component (between 0 and 1, default is 1)
  78838. */
  78839. constructor(
  78840. /**
  78841. * Defines the red component (between 0 and 1, default is 0)
  78842. */
  78843. r?: number,
  78844. /**
  78845. * Defines the green component (between 0 and 1, default is 0)
  78846. */
  78847. g?: number,
  78848. /**
  78849. * Defines the blue component (between 0 and 1, default is 0)
  78850. */
  78851. b?: number,
  78852. /**
  78853. * Defines the alpha component (between 0 and 1, default is 1)
  78854. */
  78855. a?: number);
  78856. /**
  78857. * Adds in place the given Color4 values to the current Color4 object
  78858. * @param right defines the second operand
  78859. * @returns the current updated Color4 object
  78860. */
  78861. addInPlace(right: DeepImmutable<Color4>): Color4;
  78862. /**
  78863. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  78864. * @returns the new array
  78865. */
  78866. asArray(): number[];
  78867. /**
  78868. * Stores from the starting index in the given array the Color4 successive values
  78869. * @param array defines the array where to store the r,g,b components
  78870. * @param index defines an optional index in the target array to define where to start storing values
  78871. * @returns the current Color4 object
  78872. */
  78873. toArray(array: number[], index?: number): Color4;
  78874. /**
  78875. * Determines equality between Color4 objects
  78876. * @param otherColor defines the second operand
  78877. * @returns true if the rgba values are equal to the given ones
  78878. */
  78879. equals(otherColor: DeepImmutable<Color4>): boolean;
  78880. /**
  78881. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  78882. * @param right defines the second operand
  78883. * @returns a new Color4 object
  78884. */
  78885. add(right: DeepImmutable<Color4>): Color4;
  78886. /**
  78887. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  78888. * @param right defines the second operand
  78889. * @returns a new Color4 object
  78890. */
  78891. subtract(right: DeepImmutable<Color4>): Color4;
  78892. /**
  78893. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  78894. * @param right defines the second operand
  78895. * @param result defines the Color4 object where to store the result
  78896. * @returns the current Color4 object
  78897. */
  78898. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  78899. /**
  78900. * Creates a new Color4 with the current Color4 values multiplied by scale
  78901. * @param scale defines the scaling factor to apply
  78902. * @returns a new Color4 object
  78903. */
  78904. scale(scale: number): Color4;
  78905. /**
  78906. * Multiplies the current Color4 values by scale and stores the result in "result"
  78907. * @param scale defines the scaling factor to apply
  78908. * @param result defines the Color4 object where to store the result
  78909. * @returns the current unmodified Color4
  78910. */
  78911. scaleToRef(scale: number, result: Color4): Color4;
  78912. /**
  78913. * Scale the current Color4 values by a factor and add the result to a given Color4
  78914. * @param scale defines the scale factor
  78915. * @param result defines the Color4 object where to store the result
  78916. * @returns the unmodified current Color4
  78917. */
  78918. scaleAndAddToRef(scale: number, result: Color4): Color4;
  78919. /**
  78920. * Clamps the rgb values by the min and max values and stores the result into "result"
  78921. * @param min defines minimum clamping value (default is 0)
  78922. * @param max defines maximum clamping value (default is 1)
  78923. * @param result defines color to store the result into.
  78924. * @returns the cuurent Color4
  78925. */
  78926. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  78927. /**
  78928. * Multipy an Color4 value by another and return a new Color4 object
  78929. * @param color defines the Color4 value to multiply by
  78930. * @returns a new Color4 object
  78931. */
  78932. multiply(color: Color4): Color4;
  78933. /**
  78934. * Multipy a Color4 value by another and push the result in a reference value
  78935. * @param color defines the Color4 value to multiply by
  78936. * @param result defines the Color4 to fill the result in
  78937. * @returns the result Color4
  78938. */
  78939. multiplyToRef(color: Color4, result: Color4): Color4;
  78940. /**
  78941. * Creates a string with the Color4 current values
  78942. * @returns the string representation of the Color4 object
  78943. */
  78944. toString(): string;
  78945. /**
  78946. * Returns the string "Color4"
  78947. * @returns "Color4"
  78948. */
  78949. getClassName(): string;
  78950. /**
  78951. * Compute the Color4 hash code
  78952. * @returns an unique number that can be used to hash Color4 objects
  78953. */
  78954. getHashCode(): number;
  78955. /**
  78956. * Creates a new Color4 copied from the current one
  78957. * @returns a new Color4 object
  78958. */
  78959. clone(): Color4;
  78960. /**
  78961. * Copies the given Color4 values into the current one
  78962. * @param source defines the source Color4 object
  78963. * @returns the current updated Color4 object
  78964. */
  78965. copyFrom(source: Color4): Color4;
  78966. /**
  78967. * Copies the given float values into the current one
  78968. * @param r defines the red component to read from
  78969. * @param g defines the green component to read from
  78970. * @param b defines the blue component to read from
  78971. * @param a defines the alpha component to read from
  78972. * @returns the current updated Color4 object
  78973. */
  78974. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  78975. /**
  78976. * Copies the given float values into the current one
  78977. * @param r defines the red component to read from
  78978. * @param g defines the green component to read from
  78979. * @param b defines the blue component to read from
  78980. * @param a defines the alpha component to read from
  78981. * @returns the current updated Color4 object
  78982. */
  78983. set(r: number, g: number, b: number, a: number): Color4;
  78984. /**
  78985. * Compute the Color4 hexadecimal code as a string
  78986. * @returns a string containing the hexadecimal representation of the Color4 object
  78987. */
  78988. toHexString(): string;
  78989. /**
  78990. * Computes a new Color4 converted from the current one to linear space
  78991. * @returns a new Color4 object
  78992. */
  78993. toLinearSpace(): Color4;
  78994. /**
  78995. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  78996. * @param convertedColor defines the Color4 object where to store the linear space version
  78997. * @returns the unmodified Color4
  78998. */
  78999. toLinearSpaceToRef(convertedColor: Color4): Color4;
  79000. /**
  79001. * Computes a new Color4 converted from the current one to gamma space
  79002. * @returns a new Color4 object
  79003. */
  79004. toGammaSpace(): Color4;
  79005. /**
  79006. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  79007. * @param convertedColor defines the Color4 object where to store the gamma space version
  79008. * @returns the unmodified Color4
  79009. */
  79010. toGammaSpaceToRef(convertedColor: Color4): Color4;
  79011. /**
  79012. * Creates a new Color4 from the string containing valid hexadecimal values
  79013. * @param hex defines a string containing valid hexadecimal values
  79014. * @returns a new Color4 object
  79015. */
  79016. static FromHexString(hex: string): Color4;
  79017. /**
  79018. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79019. * @param left defines the start value
  79020. * @param right defines the end value
  79021. * @param amount defines the gradient factor
  79022. * @returns a new Color4 object
  79023. */
  79024. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  79025. /**
  79026. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79027. * @param left defines the start value
  79028. * @param right defines the end value
  79029. * @param amount defines the gradient factor
  79030. * @param result defines the Color4 object where to store data
  79031. */
  79032. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  79033. /**
  79034. * Creates a new Color4 from a Color3 and an alpha value
  79035. * @param color3 defines the source Color3 to read from
  79036. * @param alpha defines the alpha component (1.0 by default)
  79037. * @returns a new Color4 object
  79038. */
  79039. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  79040. /**
  79041. * Creates a new Color4 from the starting index element of the given array
  79042. * @param array defines the source array to read from
  79043. * @param offset defines the offset in the source array
  79044. * @returns a new Color4 object
  79045. */
  79046. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  79047. /**
  79048. * Creates a new Color3 from integer values (< 256)
  79049. * @param r defines the red component to read from (value between 0 and 255)
  79050. * @param g defines the green component to read from (value between 0 and 255)
  79051. * @param b defines the blue component to read from (value between 0 and 255)
  79052. * @param a defines the alpha component to read from (value between 0 and 255)
  79053. * @returns a new Color3 object
  79054. */
  79055. static FromInts(r: number, g: number, b: number, a: number): Color4;
  79056. /**
  79057. * Check the content of a given array and convert it to an array containing RGBA data
  79058. * If the original array was already containing count * 4 values then it is returned directly
  79059. * @param colors defines the array to check
  79060. * @param count defines the number of RGBA data to expect
  79061. * @returns an array containing count * 4 values (RGBA)
  79062. */
  79063. static CheckColors4(colors: number[], count: number): number[];
  79064. }
  79065. /**
  79066. * @hidden
  79067. */
  79068. export class TmpColors {
  79069. static Color3: Color3[];
  79070. static Color4: Color4[];
  79071. }
  79072. }
  79073. declare module BABYLON {
  79074. /**
  79075. * Defines an interface which represents an animation key frame
  79076. */
  79077. export interface IAnimationKey {
  79078. /**
  79079. * Frame of the key frame
  79080. */
  79081. frame: number;
  79082. /**
  79083. * Value at the specifies key frame
  79084. */
  79085. value: any;
  79086. /**
  79087. * The input tangent for the cubic hermite spline
  79088. */
  79089. inTangent?: any;
  79090. /**
  79091. * The output tangent for the cubic hermite spline
  79092. */
  79093. outTangent?: any;
  79094. /**
  79095. * The animation interpolation type
  79096. */
  79097. interpolation?: AnimationKeyInterpolation;
  79098. }
  79099. /**
  79100. * Enum for the animation key frame interpolation type
  79101. */
  79102. export enum AnimationKeyInterpolation {
  79103. /**
  79104. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  79105. */
  79106. STEP = 1
  79107. }
  79108. }
  79109. declare module BABYLON {
  79110. /**
  79111. * Represents the range of an animation
  79112. */
  79113. export class AnimationRange {
  79114. /**The name of the animation range**/
  79115. name: string;
  79116. /**The starting frame of the animation */
  79117. from: number;
  79118. /**The ending frame of the animation*/
  79119. to: number;
  79120. /**
  79121. * Initializes the range of an animation
  79122. * @param name The name of the animation range
  79123. * @param from The starting frame of the animation
  79124. * @param to The ending frame of the animation
  79125. */
  79126. constructor(
  79127. /**The name of the animation range**/
  79128. name: string,
  79129. /**The starting frame of the animation */
  79130. from: number,
  79131. /**The ending frame of the animation*/
  79132. to: number);
  79133. /**
  79134. * Makes a copy of the animation range
  79135. * @returns A copy of the animation range
  79136. */
  79137. clone(): AnimationRange;
  79138. }
  79139. }
  79140. declare module BABYLON {
  79141. /**
  79142. * Composed of a frame, and an action function
  79143. */
  79144. export class AnimationEvent {
  79145. /** The frame for which the event is triggered **/
  79146. frame: number;
  79147. /** The event to perform when triggered **/
  79148. action: (currentFrame: number) => void;
  79149. /** Specifies if the event should be triggered only once**/
  79150. onlyOnce?: boolean | undefined;
  79151. /**
  79152. * Specifies if the animation event is done
  79153. */
  79154. isDone: boolean;
  79155. /**
  79156. * Initializes the animation event
  79157. * @param frame The frame for which the event is triggered
  79158. * @param action The event to perform when triggered
  79159. * @param onlyOnce Specifies if the event should be triggered only once
  79160. */
  79161. constructor(
  79162. /** The frame for which the event is triggered **/
  79163. frame: number,
  79164. /** The event to perform when triggered **/
  79165. action: (currentFrame: number) => void,
  79166. /** Specifies if the event should be triggered only once**/
  79167. onlyOnce?: boolean | undefined);
  79168. /** @hidden */
  79169. _clone(): AnimationEvent;
  79170. }
  79171. }
  79172. declare module BABYLON {
  79173. /**
  79174. * Interface used to define a behavior
  79175. */
  79176. export interface Behavior<T> {
  79177. /** gets or sets behavior's name */
  79178. name: string;
  79179. /**
  79180. * Function called when the behavior needs to be initialized (after attaching it to a target)
  79181. */
  79182. init(): void;
  79183. /**
  79184. * Called when the behavior is attached to a target
  79185. * @param target defines the target where the behavior is attached to
  79186. */
  79187. attach(target: T): void;
  79188. /**
  79189. * Called when the behavior is detached from its target
  79190. */
  79191. detach(): void;
  79192. }
  79193. /**
  79194. * Interface implemented by classes supporting behaviors
  79195. */
  79196. export interface IBehaviorAware<T> {
  79197. /**
  79198. * Attach a behavior
  79199. * @param behavior defines the behavior to attach
  79200. * @returns the current host
  79201. */
  79202. addBehavior(behavior: Behavior<T>): T;
  79203. /**
  79204. * Remove a behavior from the current object
  79205. * @param behavior defines the behavior to detach
  79206. * @returns the current host
  79207. */
  79208. removeBehavior(behavior: Behavior<T>): T;
  79209. /**
  79210. * Gets a behavior using its name to search
  79211. * @param name defines the name to search
  79212. * @returns the behavior or null if not found
  79213. */
  79214. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  79215. }
  79216. }
  79217. declare module BABYLON {
  79218. /**
  79219. * Defines an array and its length.
  79220. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  79221. */
  79222. export interface ISmartArrayLike<T> {
  79223. /**
  79224. * The data of the array.
  79225. */
  79226. data: Array<T>;
  79227. /**
  79228. * The active length of the array.
  79229. */
  79230. length: number;
  79231. }
  79232. /**
  79233. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79234. */
  79235. export class SmartArray<T> implements ISmartArrayLike<T> {
  79236. /**
  79237. * The full set of data from the array.
  79238. */
  79239. data: Array<T>;
  79240. /**
  79241. * The active length of the array.
  79242. */
  79243. length: number;
  79244. protected _id: number;
  79245. /**
  79246. * Instantiates a Smart Array.
  79247. * @param capacity defines the default capacity of the array.
  79248. */
  79249. constructor(capacity: number);
  79250. /**
  79251. * Pushes a value at the end of the active data.
  79252. * @param value defines the object to push in the array.
  79253. */
  79254. push(value: T): void;
  79255. /**
  79256. * Iterates over the active data and apply the lambda to them.
  79257. * @param func defines the action to apply on each value.
  79258. */
  79259. forEach(func: (content: T) => void): void;
  79260. /**
  79261. * Sorts the full sets of data.
  79262. * @param compareFn defines the comparison function to apply.
  79263. */
  79264. sort(compareFn: (a: T, b: T) => number): void;
  79265. /**
  79266. * Resets the active data to an empty array.
  79267. */
  79268. reset(): void;
  79269. /**
  79270. * Releases all the data from the array as well as the array.
  79271. */
  79272. dispose(): void;
  79273. /**
  79274. * Concats the active data with a given array.
  79275. * @param array defines the data to concatenate with.
  79276. */
  79277. concat(array: any): void;
  79278. /**
  79279. * Returns the position of a value in the active data.
  79280. * @param value defines the value to find the index for
  79281. * @returns the index if found in the active data otherwise -1
  79282. */
  79283. indexOf(value: T): number;
  79284. /**
  79285. * Returns whether an element is part of the active data.
  79286. * @param value defines the value to look for
  79287. * @returns true if found in the active data otherwise false
  79288. */
  79289. contains(value: T): boolean;
  79290. private static _GlobalId;
  79291. }
  79292. /**
  79293. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79294. * The data in this array can only be present once
  79295. */
  79296. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  79297. private _duplicateId;
  79298. /**
  79299. * Pushes a value at the end of the active data.
  79300. * THIS DOES NOT PREVENT DUPPLICATE DATA
  79301. * @param value defines the object to push in the array.
  79302. */
  79303. push(value: T): void;
  79304. /**
  79305. * Pushes a value at the end of the active data.
  79306. * If the data is already present, it won t be added again
  79307. * @param value defines the object to push in the array.
  79308. * @returns true if added false if it was already present
  79309. */
  79310. pushNoDuplicate(value: T): boolean;
  79311. /**
  79312. * Resets the active data to an empty array.
  79313. */
  79314. reset(): void;
  79315. /**
  79316. * Concats the active data with a given array.
  79317. * This ensures no dupplicate will be present in the result.
  79318. * @param array defines the data to concatenate with.
  79319. */
  79320. concatWithNoDuplicate(array: any): void;
  79321. }
  79322. }
  79323. declare module BABYLON {
  79324. /**
  79325. * @ignore
  79326. * This is a list of all the different input types that are available in the application.
  79327. * Fo instance: ArcRotateCameraGamepadInput...
  79328. */
  79329. export var CameraInputTypes: {};
  79330. /**
  79331. * This is the contract to implement in order to create a new input class.
  79332. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  79333. */
  79334. export interface ICameraInput<TCamera extends Camera> {
  79335. /**
  79336. * Defines the camera the input is attached to.
  79337. */
  79338. camera: Nullable<TCamera>;
  79339. /**
  79340. * Gets the class name of the current intput.
  79341. * @returns the class name
  79342. */
  79343. getClassName(): string;
  79344. /**
  79345. * Get the friendly name associated with the input class.
  79346. * @returns the input friendly name
  79347. */
  79348. getSimpleName(): string;
  79349. /**
  79350. * Attach the input controls to a specific dom element to get the input from.
  79351. * @param element Defines the element the controls should be listened from
  79352. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79353. */
  79354. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79355. /**
  79356. * Detach the current controls from the specified dom element.
  79357. * @param element Defines the element to stop listening the inputs from
  79358. */
  79359. detachControl(element: Nullable<HTMLElement>): void;
  79360. /**
  79361. * Update the current camera state depending on the inputs that have been used this frame.
  79362. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79363. */
  79364. checkInputs?: () => void;
  79365. }
  79366. /**
  79367. * Represents a map of input types to input instance or input index to input instance.
  79368. */
  79369. export interface CameraInputsMap<TCamera extends Camera> {
  79370. /**
  79371. * Accessor to the input by input type.
  79372. */
  79373. [name: string]: ICameraInput<TCamera>;
  79374. /**
  79375. * Accessor to the input by input index.
  79376. */
  79377. [idx: number]: ICameraInput<TCamera>;
  79378. }
  79379. /**
  79380. * This represents the input manager used within a camera.
  79381. * It helps dealing with all the different kind of input attached to a camera.
  79382. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79383. */
  79384. export class CameraInputsManager<TCamera extends Camera> {
  79385. /**
  79386. * Defines the list of inputs attahed to the camera.
  79387. */
  79388. attached: CameraInputsMap<TCamera>;
  79389. /**
  79390. * Defines the dom element the camera is collecting inputs from.
  79391. * This is null if the controls have not been attached.
  79392. */
  79393. attachedElement: Nullable<HTMLElement>;
  79394. /**
  79395. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79396. */
  79397. noPreventDefault: boolean;
  79398. /**
  79399. * Defined the camera the input manager belongs to.
  79400. */
  79401. camera: TCamera;
  79402. /**
  79403. * Update the current camera state depending on the inputs that have been used this frame.
  79404. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79405. */
  79406. checkInputs: () => void;
  79407. /**
  79408. * Instantiate a new Camera Input Manager.
  79409. * @param camera Defines the camera the input manager blongs to
  79410. */
  79411. constructor(camera: TCamera);
  79412. /**
  79413. * Add an input method to a camera
  79414. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79415. * @param input camera input method
  79416. */
  79417. add(input: ICameraInput<TCamera>): void;
  79418. /**
  79419. * Remove a specific input method from a camera
  79420. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  79421. * @param inputToRemove camera input method
  79422. */
  79423. remove(inputToRemove: ICameraInput<TCamera>): void;
  79424. /**
  79425. * Remove a specific input type from a camera
  79426. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  79427. * @param inputType the type of the input to remove
  79428. */
  79429. removeByType(inputType: string): void;
  79430. private _addCheckInputs;
  79431. /**
  79432. * Attach the input controls to the currently attached dom element to listen the events from.
  79433. * @param input Defines the input to attach
  79434. */
  79435. attachInput(input: ICameraInput<TCamera>): void;
  79436. /**
  79437. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  79438. * @param element Defines the dom element to collect the events from
  79439. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79440. */
  79441. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  79442. /**
  79443. * Detach the current manager inputs controls from a specific dom element.
  79444. * @param element Defines the dom element to collect the events from
  79445. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  79446. */
  79447. detachElement(element: HTMLElement, disconnect?: boolean): void;
  79448. /**
  79449. * Rebuild the dynamic inputCheck function from the current list of
  79450. * defined inputs in the manager.
  79451. */
  79452. rebuildInputCheck(): void;
  79453. /**
  79454. * Remove all attached input methods from a camera
  79455. */
  79456. clear(): void;
  79457. /**
  79458. * Serialize the current input manager attached to a camera.
  79459. * This ensures than once parsed,
  79460. * the input associated to the camera will be identical to the current ones
  79461. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  79462. */
  79463. serialize(serializedCamera: any): void;
  79464. /**
  79465. * Parses an input manager serialized JSON to restore the previous list of inputs
  79466. * and states associated to a camera.
  79467. * @param parsedCamera Defines the JSON to parse
  79468. */
  79469. parse(parsedCamera: any): void;
  79470. }
  79471. }
  79472. declare module BABYLON {
  79473. /**
  79474. * Class used to store data that will be store in GPU memory
  79475. */
  79476. export class Buffer {
  79477. private _engine;
  79478. private _buffer;
  79479. /** @hidden */
  79480. _data: Nullable<DataArray>;
  79481. private _updatable;
  79482. private _instanced;
  79483. private _divisor;
  79484. /**
  79485. * Gets the byte stride.
  79486. */
  79487. readonly byteStride: number;
  79488. /**
  79489. * Constructor
  79490. * @param engine the engine
  79491. * @param data the data to use for this buffer
  79492. * @param updatable whether the data is updatable
  79493. * @param stride the stride (optional)
  79494. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79495. * @param instanced whether the buffer is instanced (optional)
  79496. * @param useBytes set to true if the stride in in bytes (optional)
  79497. * @param divisor sets an optional divisor for instances (1 by default)
  79498. */
  79499. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  79500. /**
  79501. * Create a new VertexBuffer based on the current buffer
  79502. * @param kind defines the vertex buffer kind (position, normal, etc.)
  79503. * @param offset defines offset in the buffer (0 by default)
  79504. * @param size defines the size in floats of attributes (position is 3 for instance)
  79505. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  79506. * @param instanced defines if the vertex buffer contains indexed data
  79507. * @param useBytes defines if the offset and stride are in bytes *
  79508. * @param divisor sets an optional divisor for instances (1 by default)
  79509. * @returns the new vertex buffer
  79510. */
  79511. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  79512. /**
  79513. * Gets a boolean indicating if the Buffer is updatable?
  79514. * @returns true if the buffer is updatable
  79515. */
  79516. isUpdatable(): boolean;
  79517. /**
  79518. * Gets current buffer's data
  79519. * @returns a DataArray or null
  79520. */
  79521. getData(): Nullable<DataArray>;
  79522. /**
  79523. * Gets underlying native buffer
  79524. * @returns underlying native buffer
  79525. */
  79526. getBuffer(): Nullable<DataBuffer>;
  79527. /**
  79528. * Gets the stride in float32 units (i.e. byte stride / 4).
  79529. * May not be an integer if the byte stride is not divisible by 4.
  79530. * @returns the stride in float32 units
  79531. * @deprecated Please use byteStride instead.
  79532. */
  79533. getStrideSize(): number;
  79534. /**
  79535. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79536. * @param data defines the data to store
  79537. */
  79538. create(data?: Nullable<DataArray>): void;
  79539. /** @hidden */
  79540. _rebuild(): void;
  79541. /**
  79542. * Update current buffer data
  79543. * @param data defines the data to store
  79544. */
  79545. update(data: DataArray): void;
  79546. /**
  79547. * Updates the data directly.
  79548. * @param data the new data
  79549. * @param offset the new offset
  79550. * @param vertexCount the vertex count (optional)
  79551. * @param useBytes set to true if the offset is in bytes
  79552. */
  79553. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  79554. /**
  79555. * Release all resources
  79556. */
  79557. dispose(): void;
  79558. }
  79559. /**
  79560. * Specialized buffer used to store vertex data
  79561. */
  79562. export class VertexBuffer {
  79563. /** @hidden */
  79564. _buffer: Buffer;
  79565. private _kind;
  79566. private _size;
  79567. private _ownsBuffer;
  79568. private _instanced;
  79569. private _instanceDivisor;
  79570. /**
  79571. * The byte type.
  79572. */
  79573. static readonly BYTE: number;
  79574. /**
  79575. * The unsigned byte type.
  79576. */
  79577. static readonly UNSIGNED_BYTE: number;
  79578. /**
  79579. * The short type.
  79580. */
  79581. static readonly SHORT: number;
  79582. /**
  79583. * The unsigned short type.
  79584. */
  79585. static readonly UNSIGNED_SHORT: number;
  79586. /**
  79587. * The integer type.
  79588. */
  79589. static readonly INT: number;
  79590. /**
  79591. * The unsigned integer type.
  79592. */
  79593. static readonly UNSIGNED_INT: number;
  79594. /**
  79595. * The float type.
  79596. */
  79597. static readonly FLOAT: number;
  79598. /**
  79599. * Gets or sets the instance divisor when in instanced mode
  79600. */
  79601. get instanceDivisor(): number;
  79602. set instanceDivisor(value: number);
  79603. /**
  79604. * Gets the byte stride.
  79605. */
  79606. readonly byteStride: number;
  79607. /**
  79608. * Gets the byte offset.
  79609. */
  79610. readonly byteOffset: number;
  79611. /**
  79612. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  79613. */
  79614. readonly normalized: boolean;
  79615. /**
  79616. * Gets the data type of each component in the array.
  79617. */
  79618. readonly type: number;
  79619. /**
  79620. * Constructor
  79621. * @param engine the engine
  79622. * @param data the data to use for this vertex buffer
  79623. * @param kind the vertex buffer kind
  79624. * @param updatable whether the data is updatable
  79625. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79626. * @param stride the stride (optional)
  79627. * @param instanced whether the buffer is instanced (optional)
  79628. * @param offset the offset of the data (optional)
  79629. * @param size the number of components (optional)
  79630. * @param type the type of the component (optional)
  79631. * @param normalized whether the data contains normalized data (optional)
  79632. * @param useBytes set to true if stride and offset are in bytes (optional)
  79633. * @param divisor defines the instance divisor to use (1 by default)
  79634. */
  79635. 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);
  79636. /** @hidden */
  79637. _rebuild(): void;
  79638. /**
  79639. * Returns the kind of the VertexBuffer (string)
  79640. * @returns a string
  79641. */
  79642. getKind(): string;
  79643. /**
  79644. * Gets a boolean indicating if the VertexBuffer is updatable?
  79645. * @returns true if the buffer is updatable
  79646. */
  79647. isUpdatable(): boolean;
  79648. /**
  79649. * Gets current buffer's data
  79650. * @returns a DataArray or null
  79651. */
  79652. getData(): Nullable<DataArray>;
  79653. /**
  79654. * Gets underlying native buffer
  79655. * @returns underlying native buffer
  79656. */
  79657. getBuffer(): Nullable<DataBuffer>;
  79658. /**
  79659. * Gets the stride in float32 units (i.e. byte stride / 4).
  79660. * May not be an integer if the byte stride is not divisible by 4.
  79661. * @returns the stride in float32 units
  79662. * @deprecated Please use byteStride instead.
  79663. */
  79664. getStrideSize(): number;
  79665. /**
  79666. * Returns the offset as a multiple of the type byte length.
  79667. * @returns the offset in bytes
  79668. * @deprecated Please use byteOffset instead.
  79669. */
  79670. getOffset(): number;
  79671. /**
  79672. * Returns the number of components per vertex attribute (integer)
  79673. * @returns the size in float
  79674. */
  79675. getSize(): number;
  79676. /**
  79677. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  79678. * @returns true if this buffer is instanced
  79679. */
  79680. getIsInstanced(): boolean;
  79681. /**
  79682. * Returns the instancing divisor, zero for non-instanced (integer).
  79683. * @returns a number
  79684. */
  79685. getInstanceDivisor(): number;
  79686. /**
  79687. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79688. * @param data defines the data to store
  79689. */
  79690. create(data?: DataArray): void;
  79691. /**
  79692. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  79693. * This function will create a new buffer if the current one is not updatable
  79694. * @param data defines the data to store
  79695. */
  79696. update(data: DataArray): void;
  79697. /**
  79698. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  79699. * Returns the directly updated WebGLBuffer.
  79700. * @param data the new data
  79701. * @param offset the new offset
  79702. * @param useBytes set to true if the offset is in bytes
  79703. */
  79704. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  79705. /**
  79706. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  79707. */
  79708. dispose(): void;
  79709. /**
  79710. * Enumerates each value of this vertex buffer as numbers.
  79711. * @param count the number of values to enumerate
  79712. * @param callback the callback function called for each value
  79713. */
  79714. forEach(count: number, callback: (value: number, index: number) => void): void;
  79715. /**
  79716. * Positions
  79717. */
  79718. static readonly PositionKind: string;
  79719. /**
  79720. * Normals
  79721. */
  79722. static readonly NormalKind: string;
  79723. /**
  79724. * Tangents
  79725. */
  79726. static readonly TangentKind: string;
  79727. /**
  79728. * Texture coordinates
  79729. */
  79730. static readonly UVKind: string;
  79731. /**
  79732. * Texture coordinates 2
  79733. */
  79734. static readonly UV2Kind: string;
  79735. /**
  79736. * Texture coordinates 3
  79737. */
  79738. static readonly UV3Kind: string;
  79739. /**
  79740. * Texture coordinates 4
  79741. */
  79742. static readonly UV4Kind: string;
  79743. /**
  79744. * Texture coordinates 5
  79745. */
  79746. static readonly UV5Kind: string;
  79747. /**
  79748. * Texture coordinates 6
  79749. */
  79750. static readonly UV6Kind: string;
  79751. /**
  79752. * Colors
  79753. */
  79754. static readonly ColorKind: string;
  79755. /**
  79756. * Matrix indices (for bones)
  79757. */
  79758. static readonly MatricesIndicesKind: string;
  79759. /**
  79760. * Matrix weights (for bones)
  79761. */
  79762. static readonly MatricesWeightsKind: string;
  79763. /**
  79764. * Additional matrix indices (for bones)
  79765. */
  79766. static readonly MatricesIndicesExtraKind: string;
  79767. /**
  79768. * Additional matrix weights (for bones)
  79769. */
  79770. static readonly MatricesWeightsExtraKind: string;
  79771. /**
  79772. * Deduces the stride given a kind.
  79773. * @param kind The kind string to deduce
  79774. * @returns The deduced stride
  79775. */
  79776. static DeduceStride(kind: string): number;
  79777. /**
  79778. * Gets the byte length of the given type.
  79779. * @param type the type
  79780. * @returns the number of bytes
  79781. */
  79782. static GetTypeByteLength(type: number): number;
  79783. /**
  79784. * Enumerates each value of the given parameters as numbers.
  79785. * @param data the data to enumerate
  79786. * @param byteOffset the byte offset of the data
  79787. * @param byteStride the byte stride of the data
  79788. * @param componentCount the number of components per element
  79789. * @param componentType the type of the component
  79790. * @param count the number of values to enumerate
  79791. * @param normalized whether the data is normalized
  79792. * @param callback the callback function called for each value
  79793. */
  79794. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  79795. private static _GetFloatValue;
  79796. }
  79797. }
  79798. declare module BABYLON {
  79799. /**
  79800. * @hidden
  79801. */
  79802. export class IntersectionInfo {
  79803. bu: Nullable<number>;
  79804. bv: Nullable<number>;
  79805. distance: number;
  79806. faceId: number;
  79807. subMeshId: number;
  79808. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  79809. }
  79810. }
  79811. declare module BABYLON {
  79812. /**
  79813. * Represens a plane by the equation ax + by + cz + d = 0
  79814. */
  79815. export class Plane {
  79816. private static _TmpMatrix;
  79817. /**
  79818. * Normal of the plane (a,b,c)
  79819. */
  79820. normal: Vector3;
  79821. /**
  79822. * d component of the plane
  79823. */
  79824. d: number;
  79825. /**
  79826. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79827. * @param a a component of the plane
  79828. * @param b b component of the plane
  79829. * @param c c component of the plane
  79830. * @param d d component of the plane
  79831. */
  79832. constructor(a: number, b: number, c: number, d: number);
  79833. /**
  79834. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79835. */
  79836. asArray(): number[];
  79837. /**
  79838. * @returns a new plane copied from the current Plane.
  79839. */
  79840. clone(): Plane;
  79841. /**
  79842. * @returns the string "Plane".
  79843. */
  79844. getClassName(): string;
  79845. /**
  79846. * @returns the Plane hash code.
  79847. */
  79848. getHashCode(): number;
  79849. /**
  79850. * Normalize the current Plane in place.
  79851. * @returns the updated Plane.
  79852. */
  79853. normalize(): Plane;
  79854. /**
  79855. * Applies a transformation the plane and returns the result
  79856. * @param transformation the transformation matrix to be applied to the plane
  79857. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79858. */
  79859. transform(transformation: DeepImmutable<Matrix>): Plane;
  79860. /**
  79861. * Calcualtte the dot product between the point and the plane normal
  79862. * @param point point to calculate the dot product with
  79863. * @returns the dot product (float) of the point coordinates and the plane normal.
  79864. */
  79865. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79866. /**
  79867. * Updates the current Plane from the plane defined by the three given points.
  79868. * @param point1 one of the points used to contruct the plane
  79869. * @param point2 one of the points used to contruct the plane
  79870. * @param point3 one of the points used to contruct the plane
  79871. * @returns the updated Plane.
  79872. */
  79873. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79874. /**
  79875. * Checks if the plane is facing a given direction
  79876. * @param direction the direction to check if the plane is facing
  79877. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79878. * @returns True is the vector "direction" is the same side than the plane normal.
  79879. */
  79880. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79881. /**
  79882. * Calculates the distance to a point
  79883. * @param point point to calculate distance to
  79884. * @returns the signed distance (float) from the given point to the Plane.
  79885. */
  79886. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  79887. /**
  79888. * Creates a plane from an array
  79889. * @param array the array to create a plane from
  79890. * @returns a new Plane from the given array.
  79891. */
  79892. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  79893. /**
  79894. * Creates a plane from three points
  79895. * @param point1 point used to create the plane
  79896. * @param point2 point used to create the plane
  79897. * @param point3 point used to create the plane
  79898. * @returns a new Plane defined by the three given points.
  79899. */
  79900. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79901. /**
  79902. * Creates a plane from an origin point and a normal
  79903. * @param origin origin of the plane to be constructed
  79904. * @param normal normal of the plane to be constructed
  79905. * @returns a new Plane the normal vector to this plane at the given origin point.
  79906. * Note : the vector "normal" is updated because normalized.
  79907. */
  79908. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  79909. /**
  79910. * Calculates the distance from a plane and a point
  79911. * @param origin origin of the plane to be constructed
  79912. * @param normal normal of the plane to be constructed
  79913. * @param point point to calculate distance to
  79914. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  79915. */
  79916. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  79917. }
  79918. }
  79919. declare module BABYLON {
  79920. /**
  79921. * Class used to store bounding sphere information
  79922. */
  79923. export class BoundingSphere {
  79924. /**
  79925. * Gets the center of the bounding sphere in local space
  79926. */
  79927. readonly center: Vector3;
  79928. /**
  79929. * Radius of the bounding sphere in local space
  79930. */
  79931. radius: number;
  79932. /**
  79933. * Gets the center of the bounding sphere in world space
  79934. */
  79935. readonly centerWorld: Vector3;
  79936. /**
  79937. * Radius of the bounding sphere in world space
  79938. */
  79939. radiusWorld: number;
  79940. /**
  79941. * Gets the minimum vector in local space
  79942. */
  79943. readonly minimum: Vector3;
  79944. /**
  79945. * Gets the maximum vector in local space
  79946. */
  79947. readonly maximum: Vector3;
  79948. private _worldMatrix;
  79949. private static readonly TmpVector3;
  79950. /**
  79951. * Creates a new bounding sphere
  79952. * @param min defines the minimum vector (in local space)
  79953. * @param max defines the maximum vector (in local space)
  79954. * @param worldMatrix defines the new world matrix
  79955. */
  79956. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  79957. /**
  79958. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  79959. * @param min defines the new minimum vector (in local space)
  79960. * @param max defines the new maximum vector (in local space)
  79961. * @param worldMatrix defines the new world matrix
  79962. */
  79963. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  79964. /**
  79965. * Scale the current bounding sphere by applying a scale factor
  79966. * @param factor defines the scale factor to apply
  79967. * @returns the current bounding box
  79968. */
  79969. scale(factor: number): BoundingSphere;
  79970. /**
  79971. * Gets the world matrix of the bounding box
  79972. * @returns a matrix
  79973. */
  79974. getWorldMatrix(): DeepImmutable<Matrix>;
  79975. /** @hidden */
  79976. _update(worldMatrix: DeepImmutable<Matrix>): void;
  79977. /**
  79978. * Tests if the bounding sphere is intersecting the frustum planes
  79979. * @param frustumPlanes defines the frustum planes to test
  79980. * @returns true if there is an intersection
  79981. */
  79982. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79983. /**
  79984. * Tests if the bounding sphere center is in between the frustum planes.
  79985. * Used for optimistic fast inclusion.
  79986. * @param frustumPlanes defines the frustum planes to test
  79987. * @returns true if the sphere center is in between the frustum planes
  79988. */
  79989. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  79990. /**
  79991. * Tests if a point is inside the bounding sphere
  79992. * @param point defines the point to test
  79993. * @returns true if the point is inside the bounding sphere
  79994. */
  79995. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  79996. /**
  79997. * Checks if two sphere intersct
  79998. * @param sphere0 sphere 0
  79999. * @param sphere1 sphere 1
  80000. * @returns true if the speres intersect
  80001. */
  80002. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  80003. }
  80004. }
  80005. declare module BABYLON {
  80006. /**
  80007. * Class used to store bounding box information
  80008. */
  80009. export class BoundingBox implements ICullable {
  80010. /**
  80011. * Gets the 8 vectors representing the bounding box in local space
  80012. */
  80013. readonly vectors: Vector3[];
  80014. /**
  80015. * Gets the center of the bounding box in local space
  80016. */
  80017. readonly center: Vector3;
  80018. /**
  80019. * Gets the center of the bounding box in world space
  80020. */
  80021. readonly centerWorld: Vector3;
  80022. /**
  80023. * Gets the extend size in local space
  80024. */
  80025. readonly extendSize: Vector3;
  80026. /**
  80027. * Gets the extend size in world space
  80028. */
  80029. readonly extendSizeWorld: Vector3;
  80030. /**
  80031. * Gets the OBB (object bounding box) directions
  80032. */
  80033. readonly directions: Vector3[];
  80034. /**
  80035. * Gets the 8 vectors representing the bounding box in world space
  80036. */
  80037. readonly vectorsWorld: Vector3[];
  80038. /**
  80039. * Gets the minimum vector in world space
  80040. */
  80041. readonly minimumWorld: Vector3;
  80042. /**
  80043. * Gets the maximum vector in world space
  80044. */
  80045. readonly maximumWorld: Vector3;
  80046. /**
  80047. * Gets the minimum vector in local space
  80048. */
  80049. readonly minimum: Vector3;
  80050. /**
  80051. * Gets the maximum vector in local space
  80052. */
  80053. readonly maximum: Vector3;
  80054. private _worldMatrix;
  80055. private static readonly TmpVector3;
  80056. /**
  80057. * @hidden
  80058. */
  80059. _tag: number;
  80060. /**
  80061. * Creates a new bounding box
  80062. * @param min defines the minimum vector (in local space)
  80063. * @param max defines the maximum vector (in local space)
  80064. * @param worldMatrix defines the new world matrix
  80065. */
  80066. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80067. /**
  80068. * Recreates the entire bounding box from scratch as if we call the constructor in place
  80069. * @param min defines the new minimum vector (in local space)
  80070. * @param max defines the new maximum vector (in local space)
  80071. * @param worldMatrix defines the new world matrix
  80072. */
  80073. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80074. /**
  80075. * Scale the current bounding box by applying a scale factor
  80076. * @param factor defines the scale factor to apply
  80077. * @returns the current bounding box
  80078. */
  80079. scale(factor: number): BoundingBox;
  80080. /**
  80081. * Gets the world matrix of the bounding box
  80082. * @returns a matrix
  80083. */
  80084. getWorldMatrix(): DeepImmutable<Matrix>;
  80085. /** @hidden */
  80086. _update(world: DeepImmutable<Matrix>): void;
  80087. /**
  80088. * Tests if the bounding box is intersecting the frustum planes
  80089. * @param frustumPlanes defines the frustum planes to test
  80090. * @returns true if there is an intersection
  80091. */
  80092. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80093. /**
  80094. * Tests if the bounding box is entirely inside the frustum planes
  80095. * @param frustumPlanes defines the frustum planes to test
  80096. * @returns true if there is an inclusion
  80097. */
  80098. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80099. /**
  80100. * Tests if a point is inside the bounding box
  80101. * @param point defines the point to test
  80102. * @returns true if the point is inside the bounding box
  80103. */
  80104. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80105. /**
  80106. * Tests if the bounding box intersects with a bounding sphere
  80107. * @param sphere defines the sphere to test
  80108. * @returns true if there is an intersection
  80109. */
  80110. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  80111. /**
  80112. * Tests if the bounding box intersects with a box defined by a min and max vectors
  80113. * @param min defines the min vector to use
  80114. * @param max defines the max vector to use
  80115. * @returns true if there is an intersection
  80116. */
  80117. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  80118. /**
  80119. * Tests if two bounding boxes are intersections
  80120. * @param box0 defines the first box to test
  80121. * @param box1 defines the second box to test
  80122. * @returns true if there is an intersection
  80123. */
  80124. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  80125. /**
  80126. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  80127. * @param minPoint defines the minimum vector of the bounding box
  80128. * @param maxPoint defines the maximum vector of the bounding box
  80129. * @param sphereCenter defines the sphere center
  80130. * @param sphereRadius defines the sphere radius
  80131. * @returns true if there is an intersection
  80132. */
  80133. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  80134. /**
  80135. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  80136. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80137. * @param frustumPlanes defines the frustum planes to test
  80138. * @return true if there is an inclusion
  80139. */
  80140. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80141. /**
  80142. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  80143. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80144. * @param frustumPlanes defines the frustum planes to test
  80145. * @return true if there is an intersection
  80146. */
  80147. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80148. }
  80149. }
  80150. declare module BABYLON {
  80151. /** @hidden */
  80152. export class Collider {
  80153. /** Define if a collision was found */
  80154. collisionFound: boolean;
  80155. /**
  80156. * Define last intersection point in local space
  80157. */
  80158. intersectionPoint: Vector3;
  80159. /**
  80160. * Define last collided mesh
  80161. */
  80162. collidedMesh: Nullable<AbstractMesh>;
  80163. private _collisionPoint;
  80164. private _planeIntersectionPoint;
  80165. private _tempVector;
  80166. private _tempVector2;
  80167. private _tempVector3;
  80168. private _tempVector4;
  80169. private _edge;
  80170. private _baseToVertex;
  80171. private _destinationPoint;
  80172. private _slidePlaneNormal;
  80173. private _displacementVector;
  80174. /** @hidden */
  80175. _radius: Vector3;
  80176. /** @hidden */
  80177. _retry: number;
  80178. private _velocity;
  80179. private _basePoint;
  80180. private _epsilon;
  80181. /** @hidden */
  80182. _velocityWorldLength: number;
  80183. /** @hidden */
  80184. _basePointWorld: Vector3;
  80185. private _velocityWorld;
  80186. private _normalizedVelocity;
  80187. /** @hidden */
  80188. _initialVelocity: Vector3;
  80189. /** @hidden */
  80190. _initialPosition: Vector3;
  80191. private _nearestDistance;
  80192. private _collisionMask;
  80193. get collisionMask(): number;
  80194. set collisionMask(mask: number);
  80195. /**
  80196. * Gets the plane normal used to compute the sliding response (in local space)
  80197. */
  80198. get slidePlaneNormal(): Vector3;
  80199. /** @hidden */
  80200. _initialize(source: Vector3, dir: Vector3, e: number): void;
  80201. /** @hidden */
  80202. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  80203. /** @hidden */
  80204. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  80205. /** @hidden */
  80206. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80207. /** @hidden */
  80208. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80209. /** @hidden */
  80210. _getResponse(pos: Vector3, vel: Vector3): void;
  80211. }
  80212. }
  80213. declare module BABYLON {
  80214. /**
  80215. * Interface for cullable objects
  80216. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  80217. */
  80218. export interface ICullable {
  80219. /**
  80220. * Checks if the object or part of the object is in the frustum
  80221. * @param frustumPlanes Camera near/planes
  80222. * @returns true if the object is in frustum otherwise false
  80223. */
  80224. isInFrustum(frustumPlanes: Plane[]): boolean;
  80225. /**
  80226. * Checks if a cullable object (mesh...) is in the camera frustum
  80227. * Unlike isInFrustum this cheks the full bounding box
  80228. * @param frustumPlanes Camera near/planes
  80229. * @returns true if the object is in frustum otherwise false
  80230. */
  80231. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80232. }
  80233. /**
  80234. * Info for a bounding data of a mesh
  80235. */
  80236. export class BoundingInfo implements ICullable {
  80237. /**
  80238. * Bounding box for the mesh
  80239. */
  80240. readonly boundingBox: BoundingBox;
  80241. /**
  80242. * Bounding sphere for the mesh
  80243. */
  80244. readonly boundingSphere: BoundingSphere;
  80245. private _isLocked;
  80246. private static readonly TmpVector3;
  80247. /**
  80248. * Constructs bounding info
  80249. * @param minimum min vector of the bounding box/sphere
  80250. * @param maximum max vector of the bounding box/sphere
  80251. * @param worldMatrix defines the new world matrix
  80252. */
  80253. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80254. /**
  80255. * Recreates the entire bounding info from scratch as if we call the constructor in place
  80256. * @param min defines the new minimum vector (in local space)
  80257. * @param max defines the new maximum vector (in local space)
  80258. * @param worldMatrix defines the new world matrix
  80259. */
  80260. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80261. /**
  80262. * min vector of the bounding box/sphere
  80263. */
  80264. get minimum(): Vector3;
  80265. /**
  80266. * max vector of the bounding box/sphere
  80267. */
  80268. get maximum(): Vector3;
  80269. /**
  80270. * If the info is locked and won't be updated to avoid perf overhead
  80271. */
  80272. get isLocked(): boolean;
  80273. set isLocked(value: boolean);
  80274. /**
  80275. * Updates the bounding sphere and box
  80276. * @param world world matrix to be used to update
  80277. */
  80278. update(world: DeepImmutable<Matrix>): void;
  80279. /**
  80280. * Recreate the bounding info to be centered around a specific point given a specific extend.
  80281. * @param center New center of the bounding info
  80282. * @param extend New extend of the bounding info
  80283. * @returns the current bounding info
  80284. */
  80285. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  80286. /**
  80287. * Scale the current bounding info by applying a scale factor
  80288. * @param factor defines the scale factor to apply
  80289. * @returns the current bounding info
  80290. */
  80291. scale(factor: number): BoundingInfo;
  80292. /**
  80293. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  80294. * @param frustumPlanes defines the frustum to test
  80295. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  80296. * @returns true if the bounding info is in the frustum planes
  80297. */
  80298. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  80299. /**
  80300. * Gets the world distance between the min and max points of the bounding box
  80301. */
  80302. get diagonalLength(): number;
  80303. /**
  80304. * Checks if a cullable object (mesh...) is in the camera frustum
  80305. * Unlike isInFrustum this cheks the full bounding box
  80306. * @param frustumPlanes Camera near/planes
  80307. * @returns true if the object is in frustum otherwise false
  80308. */
  80309. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80310. /** @hidden */
  80311. _checkCollision(collider: Collider): boolean;
  80312. /**
  80313. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  80314. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80315. * @param point the point to check intersection with
  80316. * @returns if the point intersects
  80317. */
  80318. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80319. /**
  80320. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  80321. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80322. * @param boundingInfo the bounding info to check intersection with
  80323. * @param precise if the intersection should be done using OBB
  80324. * @returns if the bounding info intersects
  80325. */
  80326. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  80327. }
  80328. }
  80329. declare module BABYLON {
  80330. /**
  80331. * Extracts minimum and maximum values from a list of indexed positions
  80332. * @param positions defines the positions to use
  80333. * @param indices defines the indices to the positions
  80334. * @param indexStart defines the start index
  80335. * @param indexCount defines the end index
  80336. * @param bias defines bias value to add to the result
  80337. * @return minimum and maximum values
  80338. */
  80339. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  80340. minimum: Vector3;
  80341. maximum: Vector3;
  80342. };
  80343. /**
  80344. * Extracts minimum and maximum values from a list of positions
  80345. * @param positions defines the positions to use
  80346. * @param start defines the start index in the positions array
  80347. * @param count defines the number of positions to handle
  80348. * @param bias defines bias value to add to the result
  80349. * @param stride defines the stride size to use (distance between two positions in the positions array)
  80350. * @return minimum and maximum values
  80351. */
  80352. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  80353. minimum: Vector3;
  80354. maximum: Vector3;
  80355. };
  80356. }
  80357. declare module BABYLON {
  80358. /** @hidden */
  80359. export class WebGLDataBuffer extends DataBuffer {
  80360. private _buffer;
  80361. constructor(resource: WebGLBuffer);
  80362. get underlyingResource(): any;
  80363. }
  80364. }
  80365. declare module BABYLON {
  80366. /** @hidden */
  80367. export class WebGLPipelineContext implements IPipelineContext {
  80368. engine: ThinEngine;
  80369. program: Nullable<WebGLProgram>;
  80370. context?: WebGLRenderingContext;
  80371. vertexShader?: WebGLShader;
  80372. fragmentShader?: WebGLShader;
  80373. isParallelCompiled: boolean;
  80374. onCompiled?: () => void;
  80375. transformFeedback?: WebGLTransformFeedback | null;
  80376. vertexCompilationError: Nullable<string>;
  80377. fragmentCompilationError: Nullable<string>;
  80378. programLinkError: Nullable<string>;
  80379. programValidationError: Nullable<string>;
  80380. get isAsync(): boolean;
  80381. get isReady(): boolean;
  80382. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  80383. }
  80384. }
  80385. declare module BABYLON {
  80386. interface ThinEngine {
  80387. /**
  80388. * Create an uniform buffer
  80389. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80390. * @param elements defines the content of the uniform buffer
  80391. * @returns the webGL uniform buffer
  80392. */
  80393. createUniformBuffer(elements: FloatArray): DataBuffer;
  80394. /**
  80395. * Create a dynamic uniform buffer
  80396. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80397. * @param elements defines the content of the uniform buffer
  80398. * @returns the webGL uniform buffer
  80399. */
  80400. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  80401. /**
  80402. * Update an existing uniform buffer
  80403. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80404. * @param uniformBuffer defines the target uniform buffer
  80405. * @param elements defines the content to update
  80406. * @param offset defines the offset in the uniform buffer where update should start
  80407. * @param count defines the size of the data to update
  80408. */
  80409. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  80410. /**
  80411. * Bind an uniform buffer to the current webGL context
  80412. * @param buffer defines the buffer to bind
  80413. */
  80414. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  80415. /**
  80416. * Bind a buffer to the current webGL context at a given location
  80417. * @param buffer defines the buffer to bind
  80418. * @param location defines the index where to bind the buffer
  80419. */
  80420. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  80421. /**
  80422. * Bind a specific block at a given index in a specific shader program
  80423. * @param pipelineContext defines the pipeline context to use
  80424. * @param blockName defines the block name
  80425. * @param index defines the index where to bind the block
  80426. */
  80427. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  80428. }
  80429. }
  80430. declare module BABYLON {
  80431. /**
  80432. * Uniform buffer objects.
  80433. *
  80434. * Handles blocks of uniform on the GPU.
  80435. *
  80436. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80437. *
  80438. * For more information, please refer to :
  80439. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80440. */
  80441. export class UniformBuffer {
  80442. private _engine;
  80443. private _buffer;
  80444. private _data;
  80445. private _bufferData;
  80446. private _dynamic?;
  80447. private _uniformLocations;
  80448. private _uniformSizes;
  80449. private _uniformLocationPointer;
  80450. private _needSync;
  80451. private _noUBO;
  80452. private _currentEffect;
  80453. /** @hidden */
  80454. _alreadyBound: boolean;
  80455. private static _MAX_UNIFORM_SIZE;
  80456. private static _tempBuffer;
  80457. /**
  80458. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  80459. * This is dynamic to allow compat with webgl 1 and 2.
  80460. * You will need to pass the name of the uniform as well as the value.
  80461. */
  80462. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  80463. /**
  80464. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  80465. * This is dynamic to allow compat with webgl 1 and 2.
  80466. * You will need to pass the name of the uniform as well as the value.
  80467. */
  80468. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  80469. /**
  80470. * Lambda to Update a single float in a uniform buffer.
  80471. * This is dynamic to allow compat with webgl 1 and 2.
  80472. * You will need to pass the name of the uniform as well as the value.
  80473. */
  80474. updateFloat: (name: string, x: number) => void;
  80475. /**
  80476. * Lambda to Update a vec2 of float in a uniform buffer.
  80477. * This is dynamic to allow compat with webgl 1 and 2.
  80478. * You will need to pass the name of the uniform as well as the value.
  80479. */
  80480. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  80481. /**
  80482. * Lambda to Update a vec3 of float in a uniform buffer.
  80483. * This is dynamic to allow compat with webgl 1 and 2.
  80484. * You will need to pass the name of the uniform as well as the value.
  80485. */
  80486. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  80487. /**
  80488. * Lambda to Update a vec4 of float in a uniform buffer.
  80489. * This is dynamic to allow compat with webgl 1 and 2.
  80490. * You will need to pass the name of the uniform as well as the value.
  80491. */
  80492. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  80493. /**
  80494. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  80495. * This is dynamic to allow compat with webgl 1 and 2.
  80496. * You will need to pass the name of the uniform as well as the value.
  80497. */
  80498. updateMatrix: (name: string, mat: Matrix) => void;
  80499. /**
  80500. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  80501. * This is dynamic to allow compat with webgl 1 and 2.
  80502. * You will need to pass the name of the uniform as well as the value.
  80503. */
  80504. updateVector3: (name: string, vector: Vector3) => void;
  80505. /**
  80506. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  80507. * This is dynamic to allow compat with webgl 1 and 2.
  80508. * You will need to pass the name of the uniform as well as the value.
  80509. */
  80510. updateVector4: (name: string, vector: Vector4) => void;
  80511. /**
  80512. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  80513. * This is dynamic to allow compat with webgl 1 and 2.
  80514. * You will need to pass the name of the uniform as well as the value.
  80515. */
  80516. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  80517. /**
  80518. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  80519. * This is dynamic to allow compat with webgl 1 and 2.
  80520. * You will need to pass the name of the uniform as well as the value.
  80521. */
  80522. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  80523. /**
  80524. * Instantiates a new Uniform buffer objects.
  80525. *
  80526. * Handles blocks of uniform on the GPU.
  80527. *
  80528. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80529. *
  80530. * For more information, please refer to :
  80531. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80532. * @param engine Define the engine the buffer is associated with
  80533. * @param data Define the data contained in the buffer
  80534. * @param dynamic Define if the buffer is updatable
  80535. */
  80536. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  80537. /**
  80538. * Indicates if the buffer is using the WebGL2 UBO implementation,
  80539. * or just falling back on setUniformXXX calls.
  80540. */
  80541. get useUbo(): boolean;
  80542. /**
  80543. * Indicates if the WebGL underlying uniform buffer is in sync
  80544. * with the javascript cache data.
  80545. */
  80546. get isSync(): boolean;
  80547. /**
  80548. * Indicates if the WebGL underlying uniform buffer is dynamic.
  80549. * Also, a dynamic UniformBuffer will disable cache verification and always
  80550. * update the underlying WebGL uniform buffer to the GPU.
  80551. * @returns if Dynamic, otherwise false
  80552. */
  80553. isDynamic(): boolean;
  80554. /**
  80555. * The data cache on JS side.
  80556. * @returns the underlying data as a float array
  80557. */
  80558. getData(): Float32Array;
  80559. /**
  80560. * The underlying WebGL Uniform buffer.
  80561. * @returns the webgl buffer
  80562. */
  80563. getBuffer(): Nullable<DataBuffer>;
  80564. /**
  80565. * std140 layout specifies how to align data within an UBO structure.
  80566. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  80567. * for specs.
  80568. */
  80569. private _fillAlignment;
  80570. /**
  80571. * Adds an uniform in the buffer.
  80572. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  80573. * for the layout to be correct !
  80574. * @param name Name of the uniform, as used in the uniform block in the shader.
  80575. * @param size Data size, or data directly.
  80576. */
  80577. addUniform(name: string, size: number | number[]): void;
  80578. /**
  80579. * Adds a Matrix 4x4 to the uniform buffer.
  80580. * @param name Name of the uniform, as used in the uniform block in the shader.
  80581. * @param mat A 4x4 matrix.
  80582. */
  80583. addMatrix(name: string, mat: Matrix): void;
  80584. /**
  80585. * Adds a vec2 to the uniform buffer.
  80586. * @param name Name of the uniform, as used in the uniform block in the shader.
  80587. * @param x Define the x component value of the vec2
  80588. * @param y Define the y component value of the vec2
  80589. */
  80590. addFloat2(name: string, x: number, y: number): void;
  80591. /**
  80592. * Adds a vec3 to the uniform buffer.
  80593. * @param name Name of the uniform, as used in the uniform block in the shader.
  80594. * @param x Define the x component value of the vec3
  80595. * @param y Define the y component value of the vec3
  80596. * @param z Define the z component value of the vec3
  80597. */
  80598. addFloat3(name: string, x: number, y: number, z: number): void;
  80599. /**
  80600. * Adds a vec3 to the uniform buffer.
  80601. * @param name Name of the uniform, as used in the uniform block in the shader.
  80602. * @param color Define the vec3 from a Color
  80603. */
  80604. addColor3(name: string, color: Color3): void;
  80605. /**
  80606. * Adds a vec4 to the uniform buffer.
  80607. * @param name Name of the uniform, as used in the uniform block in the shader.
  80608. * @param color Define the rgb components from a Color
  80609. * @param alpha Define the a component of the vec4
  80610. */
  80611. addColor4(name: string, color: Color3, alpha: number): void;
  80612. /**
  80613. * Adds a vec3 to the uniform buffer.
  80614. * @param name Name of the uniform, as used in the uniform block in the shader.
  80615. * @param vector Define the vec3 components from a Vector
  80616. */
  80617. addVector3(name: string, vector: Vector3): void;
  80618. /**
  80619. * Adds a Matrix 3x3 to the uniform buffer.
  80620. * @param name Name of the uniform, as used in the uniform block in the shader.
  80621. */
  80622. addMatrix3x3(name: string): void;
  80623. /**
  80624. * Adds a Matrix 2x2 to the uniform buffer.
  80625. * @param name Name of the uniform, as used in the uniform block in the shader.
  80626. */
  80627. addMatrix2x2(name: string): void;
  80628. /**
  80629. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  80630. */
  80631. create(): void;
  80632. /** @hidden */
  80633. _rebuild(): void;
  80634. /**
  80635. * Updates the WebGL Uniform Buffer on the GPU.
  80636. * If the `dynamic` flag is set to true, no cache comparison is done.
  80637. * Otherwise, the buffer will be updated only if the cache differs.
  80638. */
  80639. update(): void;
  80640. /**
  80641. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  80642. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80643. * @param data Define the flattened data
  80644. * @param size Define the size of the data.
  80645. */
  80646. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  80647. private _valueCache;
  80648. private _cacheMatrix;
  80649. private _updateMatrix3x3ForUniform;
  80650. private _updateMatrix3x3ForEffect;
  80651. private _updateMatrix2x2ForEffect;
  80652. private _updateMatrix2x2ForUniform;
  80653. private _updateFloatForEffect;
  80654. private _updateFloatForUniform;
  80655. private _updateFloat2ForEffect;
  80656. private _updateFloat2ForUniform;
  80657. private _updateFloat3ForEffect;
  80658. private _updateFloat3ForUniform;
  80659. private _updateFloat4ForEffect;
  80660. private _updateFloat4ForUniform;
  80661. private _updateMatrixForEffect;
  80662. private _updateMatrixForUniform;
  80663. private _updateVector3ForEffect;
  80664. private _updateVector3ForUniform;
  80665. private _updateVector4ForEffect;
  80666. private _updateVector4ForUniform;
  80667. private _updateColor3ForEffect;
  80668. private _updateColor3ForUniform;
  80669. private _updateColor4ForEffect;
  80670. private _updateColor4ForUniform;
  80671. /**
  80672. * Sets a sampler uniform on the effect.
  80673. * @param name Define the name of the sampler.
  80674. * @param texture Define the texture to set in the sampler
  80675. */
  80676. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  80677. /**
  80678. * Directly updates the value of the uniform in the cache AND on the GPU.
  80679. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80680. * @param data Define the flattened data
  80681. */
  80682. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  80683. /**
  80684. * Binds this uniform buffer to an effect.
  80685. * @param effect Define the effect to bind the buffer to
  80686. * @param name Name of the uniform block in the shader.
  80687. */
  80688. bindToEffect(effect: Effect, name: string): void;
  80689. /**
  80690. * Disposes the uniform buffer.
  80691. */
  80692. dispose(): void;
  80693. }
  80694. }
  80695. declare module BABYLON {
  80696. /**
  80697. * Enum that determines the text-wrapping mode to use.
  80698. */
  80699. export enum InspectableType {
  80700. /**
  80701. * Checkbox for booleans
  80702. */
  80703. Checkbox = 0,
  80704. /**
  80705. * Sliders for numbers
  80706. */
  80707. Slider = 1,
  80708. /**
  80709. * Vector3
  80710. */
  80711. Vector3 = 2,
  80712. /**
  80713. * Quaternions
  80714. */
  80715. Quaternion = 3,
  80716. /**
  80717. * Color3
  80718. */
  80719. Color3 = 4,
  80720. /**
  80721. * String
  80722. */
  80723. String = 5
  80724. }
  80725. /**
  80726. * Interface used to define custom inspectable properties.
  80727. * This interface is used by the inspector to display custom property grids
  80728. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80729. */
  80730. export interface IInspectable {
  80731. /**
  80732. * Gets the label to display
  80733. */
  80734. label: string;
  80735. /**
  80736. * Gets the name of the property to edit
  80737. */
  80738. propertyName: string;
  80739. /**
  80740. * Gets the type of the editor to use
  80741. */
  80742. type: InspectableType;
  80743. /**
  80744. * Gets the minimum value of the property when using in "slider" mode
  80745. */
  80746. min?: number;
  80747. /**
  80748. * Gets the maximum value of the property when using in "slider" mode
  80749. */
  80750. max?: number;
  80751. /**
  80752. * Gets the setp to use when using in "slider" mode
  80753. */
  80754. step?: number;
  80755. }
  80756. }
  80757. declare module BABYLON {
  80758. /**
  80759. * Class used to provide helper for timing
  80760. */
  80761. export class TimingTools {
  80762. /**
  80763. * Polyfill for setImmediate
  80764. * @param action defines the action to execute after the current execution block
  80765. */
  80766. static SetImmediate(action: () => void): void;
  80767. }
  80768. }
  80769. declare module BABYLON {
  80770. /**
  80771. * Class used to enable instatition of objects by class name
  80772. */
  80773. export class InstantiationTools {
  80774. /**
  80775. * Use this object to register external classes like custom textures or material
  80776. * to allow the laoders to instantiate them
  80777. */
  80778. static RegisteredExternalClasses: {
  80779. [key: string]: Object;
  80780. };
  80781. /**
  80782. * Tries to instantiate a new object from a given class name
  80783. * @param className defines the class name to instantiate
  80784. * @returns the new object or null if the system was not able to do the instantiation
  80785. */
  80786. static Instantiate(className: string): any;
  80787. }
  80788. }
  80789. declare module BABYLON {
  80790. /**
  80791. * Define options used to create a depth texture
  80792. */
  80793. export class DepthTextureCreationOptions {
  80794. /** Specifies whether or not a stencil should be allocated in the texture */
  80795. generateStencil?: boolean;
  80796. /** Specifies whether or not bilinear filtering is enable on the texture */
  80797. bilinearFiltering?: boolean;
  80798. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  80799. comparisonFunction?: number;
  80800. /** Specifies if the created texture is a cube texture */
  80801. isCube?: boolean;
  80802. }
  80803. }
  80804. declare module BABYLON {
  80805. interface ThinEngine {
  80806. /**
  80807. * Creates a depth stencil cube texture.
  80808. * This is only available in WebGL 2.
  80809. * @param size The size of face edge in the cube texture.
  80810. * @param options The options defining the cube texture.
  80811. * @returns The cube texture
  80812. */
  80813. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  80814. /**
  80815. * Creates a cube texture
  80816. * @param rootUrl defines the url where the files to load is located
  80817. * @param scene defines the current scene
  80818. * @param files defines the list of files to load (1 per face)
  80819. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80820. * @param onLoad defines an optional callback raised when the texture is loaded
  80821. * @param onError defines an optional callback raised if there is an issue to load the texture
  80822. * @param format defines the format of the data
  80823. * @param forcedExtension defines the extension to use to pick the right loader
  80824. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80825. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80826. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80827. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  80828. * @returns the cube texture as an InternalTexture
  80829. */
  80830. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>): InternalTexture;
  80831. /**
  80832. * Creates a cube texture
  80833. * @param rootUrl defines the url where the files to load is located
  80834. * @param scene defines the current scene
  80835. * @param files defines the list of files to load (1 per face)
  80836. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80837. * @param onLoad defines an optional callback raised when the texture is loaded
  80838. * @param onError defines an optional callback raised if there is an issue to load the texture
  80839. * @param format defines the format of the data
  80840. * @param forcedExtension defines the extension to use to pick the right loader
  80841. * @returns the cube texture as an InternalTexture
  80842. */
  80843. 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;
  80844. /**
  80845. * Creates a cube texture
  80846. * @param rootUrl defines the url where the files to load is located
  80847. * @param scene defines the current scene
  80848. * @param files defines the list of files to load (1 per face)
  80849. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80850. * @param onLoad defines an optional callback raised when the texture is loaded
  80851. * @param onError defines an optional callback raised if there is an issue to load the texture
  80852. * @param format defines the format of the data
  80853. * @param forcedExtension defines the extension to use to pick the right loader
  80854. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80855. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80856. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80857. * @returns the cube texture as an InternalTexture
  80858. */
  80859. 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;
  80860. /** @hidden */
  80861. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  80862. /** @hidden */
  80863. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  80864. /** @hidden */
  80865. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80866. /** @hidden */
  80867. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80868. /**
  80869. * @hidden
  80870. */
  80871. _setCubeMapTextureParams(loadMipmap: boolean): void;
  80872. }
  80873. }
  80874. declare module BABYLON {
  80875. /**
  80876. * Class for creating a cube texture
  80877. */
  80878. export class CubeTexture extends BaseTexture {
  80879. private _delayedOnLoad;
  80880. /**
  80881. * Observable triggered once the texture has been loaded.
  80882. */
  80883. onLoadObservable: Observable<CubeTexture>;
  80884. /**
  80885. * The url of the texture
  80886. */
  80887. url: string;
  80888. /**
  80889. * Gets or sets the center of the bounding box associated with the cube texture.
  80890. * It must define where the camera used to render the texture was set
  80891. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80892. */
  80893. boundingBoxPosition: Vector3;
  80894. private _boundingBoxSize;
  80895. /**
  80896. * Gets or sets the size of the bounding box associated with the cube texture
  80897. * When defined, the cubemap will switch to local mode
  80898. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  80899. * @example https://www.babylonjs-playground.com/#RNASML
  80900. */
  80901. set boundingBoxSize(value: Vector3);
  80902. /**
  80903. * Returns the bounding box size
  80904. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  80905. */
  80906. get boundingBoxSize(): Vector3;
  80907. protected _rotationY: number;
  80908. /**
  80909. * Sets texture matrix rotation angle around Y axis in radians.
  80910. */
  80911. set rotationY(value: number);
  80912. /**
  80913. * Gets texture matrix rotation angle around Y axis radians.
  80914. */
  80915. get rotationY(): number;
  80916. /**
  80917. * Are mip maps generated for this texture or not.
  80918. */
  80919. get noMipmap(): boolean;
  80920. private _noMipmap;
  80921. private _files;
  80922. protected _forcedExtension: Nullable<string>;
  80923. private _extensions;
  80924. private _textureMatrix;
  80925. private _format;
  80926. private _createPolynomials;
  80927. /** @hidden */
  80928. _prefiltered: boolean;
  80929. /**
  80930. * Creates a cube texture from an array of image urls
  80931. * @param files defines an array of image urls
  80932. * @param scene defines the hosting scene
  80933. * @param noMipmap specifies if mip maps are not used
  80934. * @returns a cube texture
  80935. */
  80936. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  80937. /**
  80938. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  80939. * @param url defines the url of the prefiltered texture
  80940. * @param scene defines the scene the texture is attached to
  80941. * @param forcedExtension defines the extension of the file if different from the url
  80942. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80943. * @return the prefiltered texture
  80944. */
  80945. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  80946. /**
  80947. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  80948. * as prefiltered data.
  80949. * @param rootUrl defines the url of the texture or the root name of the six images
  80950. * @param scene defines the scene the texture is attached to
  80951. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  80952. * @param noMipmap defines if mipmaps should be created or not
  80953. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  80954. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  80955. * @param onError defines a callback triggered in case of error during load
  80956. * @param format defines the internal format to use for the texture once loaded
  80957. * @param prefiltered defines whether or not the texture is created from prefiltered data
  80958. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  80959. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  80960. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80961. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80962. * @return the cube texture
  80963. */
  80964. 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);
  80965. /**
  80966. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  80967. */
  80968. get isPrefiltered(): boolean;
  80969. /**
  80970. * Get the current class name of the texture useful for serialization or dynamic coding.
  80971. * @returns "CubeTexture"
  80972. */
  80973. getClassName(): string;
  80974. /**
  80975. * Update the url (and optional buffer) of this texture if url was null during construction.
  80976. * @param url the url of the texture
  80977. * @param forcedExtension defines the extension to use
  80978. * @param onLoad callback called when the texture is loaded (defaults to null)
  80979. * @param prefiltered Defines whether the updated texture is prefiltered or not
  80980. */
  80981. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  80982. /**
  80983. * Delays loading of the cube texture
  80984. * @param forcedExtension defines the extension to use
  80985. */
  80986. delayLoad(forcedExtension?: string): void;
  80987. /**
  80988. * Returns the reflection texture matrix
  80989. * @returns the reflection texture matrix
  80990. */
  80991. getReflectionTextureMatrix(): Matrix;
  80992. /**
  80993. * Sets the reflection texture matrix
  80994. * @param value Reflection texture matrix
  80995. */
  80996. setReflectionTextureMatrix(value: Matrix): void;
  80997. /**
  80998. * Parses text to create a cube texture
  80999. * @param parsedTexture define the serialized text to read from
  81000. * @param scene defines the hosting scene
  81001. * @param rootUrl defines the root url of the cube texture
  81002. * @returns a cube texture
  81003. */
  81004. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  81005. /**
  81006. * Makes a clone, or deep copy, of the cube texture
  81007. * @returns a new cube texture
  81008. */
  81009. clone(): CubeTexture;
  81010. }
  81011. }
  81012. declare module BABYLON {
  81013. /**
  81014. * Manages the defines for the Material
  81015. */
  81016. export class MaterialDefines {
  81017. /** @hidden */
  81018. protected _keys: string[];
  81019. private _isDirty;
  81020. /** @hidden */
  81021. _renderId: number;
  81022. /** @hidden */
  81023. _areLightsDirty: boolean;
  81024. /** @hidden */
  81025. _areLightsDisposed: boolean;
  81026. /** @hidden */
  81027. _areAttributesDirty: boolean;
  81028. /** @hidden */
  81029. _areTexturesDirty: boolean;
  81030. /** @hidden */
  81031. _areFresnelDirty: boolean;
  81032. /** @hidden */
  81033. _areMiscDirty: boolean;
  81034. /** @hidden */
  81035. _areImageProcessingDirty: boolean;
  81036. /** @hidden */
  81037. _normals: boolean;
  81038. /** @hidden */
  81039. _uvs: boolean;
  81040. /** @hidden */
  81041. _needNormals: boolean;
  81042. /** @hidden */
  81043. _needUVs: boolean;
  81044. [id: string]: any;
  81045. /**
  81046. * Specifies if the material needs to be re-calculated
  81047. */
  81048. get isDirty(): boolean;
  81049. /**
  81050. * Marks the material to indicate that it has been re-calculated
  81051. */
  81052. markAsProcessed(): void;
  81053. /**
  81054. * Marks the material to indicate that it needs to be re-calculated
  81055. */
  81056. markAsUnprocessed(): void;
  81057. /**
  81058. * Marks the material to indicate all of its defines need to be re-calculated
  81059. */
  81060. markAllAsDirty(): void;
  81061. /**
  81062. * Marks the material to indicate that image processing needs to be re-calculated
  81063. */
  81064. markAsImageProcessingDirty(): void;
  81065. /**
  81066. * Marks the material to indicate the lights need to be re-calculated
  81067. * @param disposed Defines whether the light is dirty due to dispose or not
  81068. */
  81069. markAsLightDirty(disposed?: boolean): void;
  81070. /**
  81071. * Marks the attribute state as changed
  81072. */
  81073. markAsAttributesDirty(): void;
  81074. /**
  81075. * Marks the texture state as changed
  81076. */
  81077. markAsTexturesDirty(): void;
  81078. /**
  81079. * Marks the fresnel state as changed
  81080. */
  81081. markAsFresnelDirty(): void;
  81082. /**
  81083. * Marks the misc state as changed
  81084. */
  81085. markAsMiscDirty(): void;
  81086. /**
  81087. * Rebuilds the material defines
  81088. */
  81089. rebuild(): void;
  81090. /**
  81091. * Specifies if two material defines are equal
  81092. * @param other - A material define instance to compare to
  81093. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  81094. */
  81095. isEqual(other: MaterialDefines): boolean;
  81096. /**
  81097. * Clones this instance's defines to another instance
  81098. * @param other - material defines to clone values to
  81099. */
  81100. cloneTo(other: MaterialDefines): void;
  81101. /**
  81102. * Resets the material define values
  81103. */
  81104. reset(): void;
  81105. /**
  81106. * Converts the material define values to a string
  81107. * @returns - String of material define information
  81108. */
  81109. toString(): string;
  81110. }
  81111. }
  81112. declare module BABYLON {
  81113. /**
  81114. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  81115. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  81116. * 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;
  81117. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  81118. */
  81119. export class ColorCurves {
  81120. private _dirty;
  81121. private _tempColor;
  81122. private _globalCurve;
  81123. private _highlightsCurve;
  81124. private _midtonesCurve;
  81125. private _shadowsCurve;
  81126. private _positiveCurve;
  81127. private _negativeCurve;
  81128. private _globalHue;
  81129. private _globalDensity;
  81130. private _globalSaturation;
  81131. private _globalExposure;
  81132. /**
  81133. * Gets the global Hue value.
  81134. * 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).
  81135. */
  81136. get globalHue(): number;
  81137. /**
  81138. * Sets the global Hue value.
  81139. * 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).
  81140. */
  81141. set globalHue(value: number);
  81142. /**
  81143. * Gets the global Density value.
  81144. * 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.
  81145. * Values less than zero provide a filter of opposite hue.
  81146. */
  81147. get globalDensity(): number;
  81148. /**
  81149. * Sets the global Density value.
  81150. * 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.
  81151. * Values less than zero provide a filter of opposite hue.
  81152. */
  81153. set globalDensity(value: number);
  81154. /**
  81155. * Gets the global Saturation value.
  81156. * 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.
  81157. */
  81158. get globalSaturation(): number;
  81159. /**
  81160. * Sets the global Saturation value.
  81161. * 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.
  81162. */
  81163. set globalSaturation(value: number);
  81164. /**
  81165. * Gets the global Exposure value.
  81166. * 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.
  81167. */
  81168. get globalExposure(): number;
  81169. /**
  81170. * Sets the global Exposure value.
  81171. * 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.
  81172. */
  81173. set globalExposure(value: number);
  81174. private _highlightsHue;
  81175. private _highlightsDensity;
  81176. private _highlightsSaturation;
  81177. private _highlightsExposure;
  81178. /**
  81179. * Gets the highlights Hue value.
  81180. * 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).
  81181. */
  81182. get highlightsHue(): number;
  81183. /**
  81184. * Sets the highlights Hue value.
  81185. * 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).
  81186. */
  81187. set highlightsHue(value: number);
  81188. /**
  81189. * Gets the highlights Density value.
  81190. * 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.
  81191. * Values less than zero provide a filter of opposite hue.
  81192. */
  81193. get highlightsDensity(): number;
  81194. /**
  81195. * Sets the highlights Density value.
  81196. * 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.
  81197. * Values less than zero provide a filter of opposite hue.
  81198. */
  81199. set highlightsDensity(value: number);
  81200. /**
  81201. * Gets the highlights Saturation value.
  81202. * 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.
  81203. */
  81204. get highlightsSaturation(): number;
  81205. /**
  81206. * Sets the highlights Saturation value.
  81207. * 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.
  81208. */
  81209. set highlightsSaturation(value: number);
  81210. /**
  81211. * Gets the highlights Exposure value.
  81212. * 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.
  81213. */
  81214. get highlightsExposure(): number;
  81215. /**
  81216. * Sets the highlights Exposure value.
  81217. * 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.
  81218. */
  81219. set highlightsExposure(value: number);
  81220. private _midtonesHue;
  81221. private _midtonesDensity;
  81222. private _midtonesSaturation;
  81223. private _midtonesExposure;
  81224. /**
  81225. * Gets the midtones Hue value.
  81226. * 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).
  81227. */
  81228. get midtonesHue(): number;
  81229. /**
  81230. * Sets the midtones Hue value.
  81231. * 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).
  81232. */
  81233. set midtonesHue(value: number);
  81234. /**
  81235. * Gets the midtones Density value.
  81236. * 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.
  81237. * Values less than zero provide a filter of opposite hue.
  81238. */
  81239. get midtonesDensity(): number;
  81240. /**
  81241. * Sets the midtones Density value.
  81242. * 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.
  81243. * Values less than zero provide a filter of opposite hue.
  81244. */
  81245. set midtonesDensity(value: number);
  81246. /**
  81247. * Gets the midtones Saturation value.
  81248. * 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.
  81249. */
  81250. get midtonesSaturation(): number;
  81251. /**
  81252. * Sets the midtones Saturation value.
  81253. * 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.
  81254. */
  81255. set midtonesSaturation(value: number);
  81256. /**
  81257. * Gets the midtones Exposure value.
  81258. * 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.
  81259. */
  81260. get midtonesExposure(): number;
  81261. /**
  81262. * Sets the midtones Exposure value.
  81263. * 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.
  81264. */
  81265. set midtonesExposure(value: number);
  81266. private _shadowsHue;
  81267. private _shadowsDensity;
  81268. private _shadowsSaturation;
  81269. private _shadowsExposure;
  81270. /**
  81271. * Gets the shadows Hue value.
  81272. * 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).
  81273. */
  81274. get shadowsHue(): number;
  81275. /**
  81276. * Sets the shadows Hue value.
  81277. * 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).
  81278. */
  81279. set shadowsHue(value: number);
  81280. /**
  81281. * Gets the shadows Density value.
  81282. * 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.
  81283. * Values less than zero provide a filter of opposite hue.
  81284. */
  81285. get shadowsDensity(): number;
  81286. /**
  81287. * Sets the shadows Density value.
  81288. * 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.
  81289. * Values less than zero provide a filter of opposite hue.
  81290. */
  81291. set shadowsDensity(value: number);
  81292. /**
  81293. * Gets the shadows Saturation value.
  81294. * 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.
  81295. */
  81296. get shadowsSaturation(): number;
  81297. /**
  81298. * Sets the shadows Saturation value.
  81299. * 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.
  81300. */
  81301. set shadowsSaturation(value: number);
  81302. /**
  81303. * Gets the shadows Exposure value.
  81304. * 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.
  81305. */
  81306. get shadowsExposure(): number;
  81307. /**
  81308. * Sets the shadows Exposure value.
  81309. * 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.
  81310. */
  81311. set shadowsExposure(value: number);
  81312. /**
  81313. * Returns the class name
  81314. * @returns The class name
  81315. */
  81316. getClassName(): string;
  81317. /**
  81318. * Binds the color curves to the shader.
  81319. * @param colorCurves The color curve to bind
  81320. * @param effect The effect to bind to
  81321. * @param positiveUniform The positive uniform shader parameter
  81322. * @param neutralUniform The neutral uniform shader parameter
  81323. * @param negativeUniform The negative uniform shader parameter
  81324. */
  81325. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  81326. /**
  81327. * Prepare the list of uniforms associated with the ColorCurves effects.
  81328. * @param uniformsList The list of uniforms used in the effect
  81329. */
  81330. static PrepareUniforms(uniformsList: string[]): void;
  81331. /**
  81332. * Returns color grading data based on a hue, density, saturation and exposure value.
  81333. * @param filterHue The hue of the color filter.
  81334. * @param filterDensity The density of the color filter.
  81335. * @param saturation The saturation.
  81336. * @param exposure The exposure.
  81337. * @param result The result data container.
  81338. */
  81339. private getColorGradingDataToRef;
  81340. /**
  81341. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  81342. * @param value The input slider value in range [-100,100].
  81343. * @returns Adjusted value.
  81344. */
  81345. private static applyColorGradingSliderNonlinear;
  81346. /**
  81347. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  81348. * @param hue The hue (H) input.
  81349. * @param saturation The saturation (S) input.
  81350. * @param brightness The brightness (B) input.
  81351. * @result An RGBA color represented as Vector4.
  81352. */
  81353. private static fromHSBToRef;
  81354. /**
  81355. * Returns a value clamped between min and max
  81356. * @param value The value to clamp
  81357. * @param min The minimum of value
  81358. * @param max The maximum of value
  81359. * @returns The clamped value.
  81360. */
  81361. private static clamp;
  81362. /**
  81363. * Clones the current color curve instance.
  81364. * @return The cloned curves
  81365. */
  81366. clone(): ColorCurves;
  81367. /**
  81368. * Serializes the current color curve instance to a json representation.
  81369. * @return a JSON representation
  81370. */
  81371. serialize(): any;
  81372. /**
  81373. * Parses the color curve from a json representation.
  81374. * @param source the JSON source to parse
  81375. * @return The parsed curves
  81376. */
  81377. static Parse(source: any): ColorCurves;
  81378. }
  81379. }
  81380. declare module BABYLON {
  81381. /**
  81382. * Interface to follow in your material defines to integrate easily the
  81383. * Image proccessing functions.
  81384. * @hidden
  81385. */
  81386. export interface IImageProcessingConfigurationDefines {
  81387. IMAGEPROCESSING: boolean;
  81388. VIGNETTE: boolean;
  81389. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81390. VIGNETTEBLENDMODEOPAQUE: boolean;
  81391. TONEMAPPING: boolean;
  81392. TONEMAPPING_ACES: boolean;
  81393. CONTRAST: boolean;
  81394. EXPOSURE: boolean;
  81395. COLORCURVES: boolean;
  81396. COLORGRADING: boolean;
  81397. COLORGRADING3D: boolean;
  81398. SAMPLER3DGREENDEPTH: boolean;
  81399. SAMPLER3DBGRMAP: boolean;
  81400. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81401. }
  81402. /**
  81403. * @hidden
  81404. */
  81405. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  81406. IMAGEPROCESSING: boolean;
  81407. VIGNETTE: boolean;
  81408. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81409. VIGNETTEBLENDMODEOPAQUE: boolean;
  81410. TONEMAPPING: boolean;
  81411. TONEMAPPING_ACES: boolean;
  81412. CONTRAST: boolean;
  81413. COLORCURVES: boolean;
  81414. COLORGRADING: boolean;
  81415. COLORGRADING3D: boolean;
  81416. SAMPLER3DGREENDEPTH: boolean;
  81417. SAMPLER3DBGRMAP: boolean;
  81418. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81419. EXPOSURE: boolean;
  81420. constructor();
  81421. }
  81422. /**
  81423. * This groups together the common properties used for image processing either in direct forward pass
  81424. * or through post processing effect depending on the use of the image processing pipeline in your scene
  81425. * or not.
  81426. */
  81427. export class ImageProcessingConfiguration {
  81428. /**
  81429. * Default tone mapping applied in BabylonJS.
  81430. */
  81431. static readonly TONEMAPPING_STANDARD: number;
  81432. /**
  81433. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  81434. * to other engines rendering to increase portability.
  81435. */
  81436. static readonly TONEMAPPING_ACES: number;
  81437. /**
  81438. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  81439. */
  81440. colorCurves: Nullable<ColorCurves>;
  81441. private _colorCurvesEnabled;
  81442. /**
  81443. * Gets wether the color curves effect is enabled.
  81444. */
  81445. get colorCurvesEnabled(): boolean;
  81446. /**
  81447. * Sets wether the color curves effect is enabled.
  81448. */
  81449. set colorCurvesEnabled(value: boolean);
  81450. private _colorGradingTexture;
  81451. /**
  81452. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81453. */
  81454. get colorGradingTexture(): Nullable<BaseTexture>;
  81455. /**
  81456. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81457. */
  81458. set colorGradingTexture(value: Nullable<BaseTexture>);
  81459. private _colorGradingEnabled;
  81460. /**
  81461. * Gets wether the color grading effect is enabled.
  81462. */
  81463. get colorGradingEnabled(): boolean;
  81464. /**
  81465. * Sets wether the color grading effect is enabled.
  81466. */
  81467. set colorGradingEnabled(value: boolean);
  81468. private _colorGradingWithGreenDepth;
  81469. /**
  81470. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  81471. */
  81472. get colorGradingWithGreenDepth(): boolean;
  81473. /**
  81474. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  81475. */
  81476. set colorGradingWithGreenDepth(value: boolean);
  81477. private _colorGradingBGR;
  81478. /**
  81479. * Gets wether the color grading texture contains BGR values.
  81480. */
  81481. get colorGradingBGR(): boolean;
  81482. /**
  81483. * Sets wether the color grading texture contains BGR values.
  81484. */
  81485. set colorGradingBGR(value: boolean);
  81486. /** @hidden */
  81487. _exposure: number;
  81488. /**
  81489. * Gets the Exposure used in the effect.
  81490. */
  81491. get exposure(): number;
  81492. /**
  81493. * Sets the Exposure used in the effect.
  81494. */
  81495. set exposure(value: number);
  81496. private _toneMappingEnabled;
  81497. /**
  81498. * Gets wether the tone mapping effect is enabled.
  81499. */
  81500. get toneMappingEnabled(): boolean;
  81501. /**
  81502. * Sets wether the tone mapping effect is enabled.
  81503. */
  81504. set toneMappingEnabled(value: boolean);
  81505. private _toneMappingType;
  81506. /**
  81507. * Gets the type of tone mapping effect.
  81508. */
  81509. get toneMappingType(): number;
  81510. /**
  81511. * Sets the type of tone mapping effect used in BabylonJS.
  81512. */
  81513. set toneMappingType(value: number);
  81514. protected _contrast: number;
  81515. /**
  81516. * Gets the contrast used in the effect.
  81517. */
  81518. get contrast(): number;
  81519. /**
  81520. * Sets the contrast used in the effect.
  81521. */
  81522. set contrast(value: number);
  81523. /**
  81524. * Vignette stretch size.
  81525. */
  81526. vignetteStretch: number;
  81527. /**
  81528. * Vignette centre X Offset.
  81529. */
  81530. vignetteCentreX: number;
  81531. /**
  81532. * Vignette centre Y Offset.
  81533. */
  81534. vignetteCentreY: number;
  81535. /**
  81536. * Vignette weight or intensity of the vignette effect.
  81537. */
  81538. vignetteWeight: number;
  81539. /**
  81540. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  81541. * if vignetteEnabled is set to true.
  81542. */
  81543. vignetteColor: Color4;
  81544. /**
  81545. * Camera field of view used by the Vignette effect.
  81546. */
  81547. vignetteCameraFov: number;
  81548. private _vignetteBlendMode;
  81549. /**
  81550. * Gets the vignette blend mode allowing different kind of effect.
  81551. */
  81552. get vignetteBlendMode(): number;
  81553. /**
  81554. * Sets the vignette blend mode allowing different kind of effect.
  81555. */
  81556. set vignetteBlendMode(value: number);
  81557. private _vignetteEnabled;
  81558. /**
  81559. * Gets wether the vignette effect is enabled.
  81560. */
  81561. get vignetteEnabled(): boolean;
  81562. /**
  81563. * Sets wether the vignette effect is enabled.
  81564. */
  81565. set vignetteEnabled(value: boolean);
  81566. private _applyByPostProcess;
  81567. /**
  81568. * Gets wether the image processing is applied through a post process or not.
  81569. */
  81570. get applyByPostProcess(): boolean;
  81571. /**
  81572. * Sets wether the image processing is applied through a post process or not.
  81573. */
  81574. set applyByPostProcess(value: boolean);
  81575. private _isEnabled;
  81576. /**
  81577. * Gets wether the image processing is enabled or not.
  81578. */
  81579. get isEnabled(): boolean;
  81580. /**
  81581. * Sets wether the image processing is enabled or not.
  81582. */
  81583. set isEnabled(value: boolean);
  81584. /**
  81585. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  81586. */
  81587. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  81588. /**
  81589. * Method called each time the image processing information changes requires to recompile the effect.
  81590. */
  81591. protected _updateParameters(): void;
  81592. /**
  81593. * Gets the current class name.
  81594. * @return "ImageProcessingConfiguration"
  81595. */
  81596. getClassName(): string;
  81597. /**
  81598. * Prepare the list of uniforms associated with the Image Processing effects.
  81599. * @param uniforms The list of uniforms used in the effect
  81600. * @param defines the list of defines currently in use
  81601. */
  81602. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  81603. /**
  81604. * Prepare the list of samplers associated with the Image Processing effects.
  81605. * @param samplersList The list of uniforms used in the effect
  81606. * @param defines the list of defines currently in use
  81607. */
  81608. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  81609. /**
  81610. * Prepare the list of defines associated to the shader.
  81611. * @param defines the list of defines to complete
  81612. * @param forPostProcess Define if we are currently in post process mode or not
  81613. */
  81614. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  81615. /**
  81616. * Returns true if all the image processing information are ready.
  81617. * @returns True if ready, otherwise, false
  81618. */
  81619. isReady(): boolean;
  81620. /**
  81621. * Binds the image processing to the shader.
  81622. * @param effect The effect to bind to
  81623. * @param overrideAspectRatio Override the aspect ratio of the effect
  81624. */
  81625. bind(effect: Effect, overrideAspectRatio?: number): void;
  81626. /**
  81627. * Clones the current image processing instance.
  81628. * @return The cloned image processing
  81629. */
  81630. clone(): ImageProcessingConfiguration;
  81631. /**
  81632. * Serializes the current image processing instance to a json representation.
  81633. * @return a JSON representation
  81634. */
  81635. serialize(): any;
  81636. /**
  81637. * Parses the image processing from a json representation.
  81638. * @param source the JSON source to parse
  81639. * @return The parsed image processing
  81640. */
  81641. static Parse(source: any): ImageProcessingConfiguration;
  81642. private static _VIGNETTEMODE_MULTIPLY;
  81643. private static _VIGNETTEMODE_OPAQUE;
  81644. /**
  81645. * Used to apply the vignette as a mix with the pixel color.
  81646. */
  81647. static get VIGNETTEMODE_MULTIPLY(): number;
  81648. /**
  81649. * Used to apply the vignette as a replacement of the pixel color.
  81650. */
  81651. static get VIGNETTEMODE_OPAQUE(): number;
  81652. }
  81653. }
  81654. declare module BABYLON {
  81655. /** @hidden */
  81656. export var postprocessVertexShader: {
  81657. name: string;
  81658. shader: string;
  81659. };
  81660. }
  81661. declare module BABYLON {
  81662. interface ThinEngine {
  81663. /**
  81664. * Creates a new render target texture
  81665. * @param size defines the size of the texture
  81666. * @param options defines the options used to create the texture
  81667. * @returns a new render target texture stored in an InternalTexture
  81668. */
  81669. createRenderTargetTexture(size: number | {
  81670. width: number;
  81671. height: number;
  81672. layers?: number;
  81673. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  81674. /**
  81675. * Creates a depth stencil texture.
  81676. * This is only available in WebGL 2 or with the depth texture extension available.
  81677. * @param size The size of face edge in the texture.
  81678. * @param options The options defining the texture.
  81679. * @returns The texture
  81680. */
  81681. createDepthStencilTexture(size: number | {
  81682. width: number;
  81683. height: number;
  81684. layers?: number;
  81685. }, options: DepthTextureCreationOptions): InternalTexture;
  81686. /** @hidden */
  81687. _createDepthStencilTexture(size: number | {
  81688. width: number;
  81689. height: number;
  81690. layers?: number;
  81691. }, options: DepthTextureCreationOptions): InternalTexture;
  81692. }
  81693. }
  81694. declare module BABYLON {
  81695. /** Defines supported spaces */
  81696. export enum Space {
  81697. /** Local (object) space */
  81698. LOCAL = 0,
  81699. /** World space */
  81700. WORLD = 1,
  81701. /** Bone space */
  81702. BONE = 2
  81703. }
  81704. /** Defines the 3 main axes */
  81705. export class Axis {
  81706. /** X axis */
  81707. static X: Vector3;
  81708. /** Y axis */
  81709. static Y: Vector3;
  81710. /** Z axis */
  81711. static Z: Vector3;
  81712. }
  81713. }
  81714. declare module BABYLON {
  81715. /**
  81716. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  81717. * This is the base of the follow, arc rotate cameras and Free camera
  81718. * @see http://doc.babylonjs.com/features/cameras
  81719. */
  81720. export class TargetCamera extends Camera {
  81721. private static _RigCamTransformMatrix;
  81722. private static _TargetTransformMatrix;
  81723. private static _TargetFocalPoint;
  81724. /**
  81725. * Define the current direction the camera is moving to
  81726. */
  81727. cameraDirection: Vector3;
  81728. /**
  81729. * Define the current rotation the camera is rotating to
  81730. */
  81731. cameraRotation: Vector2;
  81732. /**
  81733. * When set, the up vector of the camera will be updated by the rotation of the camera
  81734. */
  81735. updateUpVectorFromRotation: boolean;
  81736. private _tmpQuaternion;
  81737. /**
  81738. * Define the current rotation of the camera
  81739. */
  81740. rotation: Vector3;
  81741. /**
  81742. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  81743. */
  81744. rotationQuaternion: Quaternion;
  81745. /**
  81746. * Define the current speed of the camera
  81747. */
  81748. speed: number;
  81749. /**
  81750. * Add constraint to the camera to prevent it to move freely in all directions and
  81751. * around all axis.
  81752. */
  81753. noRotationConstraint: boolean;
  81754. /**
  81755. * Define the current target of the camera as an object or a position.
  81756. */
  81757. lockedTarget: any;
  81758. /** @hidden */
  81759. _currentTarget: Vector3;
  81760. /** @hidden */
  81761. _initialFocalDistance: number;
  81762. /** @hidden */
  81763. _viewMatrix: Matrix;
  81764. /** @hidden */
  81765. _camMatrix: Matrix;
  81766. /** @hidden */
  81767. _cameraTransformMatrix: Matrix;
  81768. /** @hidden */
  81769. _cameraRotationMatrix: Matrix;
  81770. /** @hidden */
  81771. _referencePoint: Vector3;
  81772. /** @hidden */
  81773. _transformedReferencePoint: Vector3;
  81774. protected _globalCurrentTarget: Vector3;
  81775. protected _globalCurrentUpVector: Vector3;
  81776. /** @hidden */
  81777. _reset: () => void;
  81778. private _defaultUp;
  81779. /**
  81780. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  81781. * This is the base of the follow, arc rotate cameras and Free camera
  81782. * @see http://doc.babylonjs.com/features/cameras
  81783. * @param name Defines the name of the camera in the scene
  81784. * @param position Defines the start position of the camera in the scene
  81785. * @param scene Defines the scene the camera belongs to
  81786. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81787. */
  81788. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81789. /**
  81790. * Gets the position in front of the camera at a given distance.
  81791. * @param distance The distance from the camera we want the position to be
  81792. * @returns the position
  81793. */
  81794. getFrontPosition(distance: number): Vector3;
  81795. /** @hidden */
  81796. _getLockedTargetPosition(): Nullable<Vector3>;
  81797. private _storedPosition;
  81798. private _storedRotation;
  81799. private _storedRotationQuaternion;
  81800. /**
  81801. * Store current camera state of the camera (fov, position, rotation, etc..)
  81802. * @returns the camera
  81803. */
  81804. storeState(): Camera;
  81805. /**
  81806. * Restored camera state. You must call storeState() first
  81807. * @returns whether it was successful or not
  81808. * @hidden
  81809. */
  81810. _restoreStateValues(): boolean;
  81811. /** @hidden */
  81812. _initCache(): void;
  81813. /** @hidden */
  81814. _updateCache(ignoreParentClass?: boolean): void;
  81815. /** @hidden */
  81816. _isSynchronizedViewMatrix(): boolean;
  81817. /** @hidden */
  81818. _computeLocalCameraSpeed(): number;
  81819. /**
  81820. * Defines the target the camera should look at.
  81821. * @param target Defines the new target as a Vector or a mesh
  81822. */
  81823. setTarget(target: Vector3): void;
  81824. /**
  81825. * Return the current target position of the camera. This value is expressed in local space.
  81826. * @returns the target position
  81827. */
  81828. getTarget(): Vector3;
  81829. /** @hidden */
  81830. _decideIfNeedsToMove(): boolean;
  81831. /** @hidden */
  81832. _updatePosition(): void;
  81833. /** @hidden */
  81834. _checkInputs(): void;
  81835. protected _updateCameraRotationMatrix(): void;
  81836. /**
  81837. * 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)
  81838. * @returns the current camera
  81839. */
  81840. private _rotateUpVectorWithCameraRotationMatrix;
  81841. private _cachedRotationZ;
  81842. private _cachedQuaternionRotationZ;
  81843. /** @hidden */
  81844. _getViewMatrix(): Matrix;
  81845. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  81846. /**
  81847. * @hidden
  81848. */
  81849. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  81850. /**
  81851. * @hidden
  81852. */
  81853. _updateRigCameras(): void;
  81854. private _getRigCamPositionAndTarget;
  81855. /**
  81856. * Gets the current object class name.
  81857. * @return the class name
  81858. */
  81859. getClassName(): string;
  81860. }
  81861. }
  81862. declare module BABYLON {
  81863. /**
  81864. * Gather the list of keyboard event types as constants.
  81865. */
  81866. export class KeyboardEventTypes {
  81867. /**
  81868. * The keydown event is fired when a key becomes active (pressed).
  81869. */
  81870. static readonly KEYDOWN: number;
  81871. /**
  81872. * The keyup event is fired when a key has been released.
  81873. */
  81874. static readonly KEYUP: number;
  81875. }
  81876. /**
  81877. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81878. */
  81879. export class KeyboardInfo {
  81880. /**
  81881. * Defines the type of event (KeyboardEventTypes)
  81882. */
  81883. type: number;
  81884. /**
  81885. * Defines the related dom event
  81886. */
  81887. event: KeyboardEvent;
  81888. /**
  81889. * Instantiates a new keyboard info.
  81890. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81891. * @param type Defines the type of event (KeyboardEventTypes)
  81892. * @param event Defines the related dom event
  81893. */
  81894. constructor(
  81895. /**
  81896. * Defines the type of event (KeyboardEventTypes)
  81897. */
  81898. type: number,
  81899. /**
  81900. * Defines the related dom event
  81901. */
  81902. event: KeyboardEvent);
  81903. }
  81904. /**
  81905. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81906. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  81907. */
  81908. export class KeyboardInfoPre extends KeyboardInfo {
  81909. /**
  81910. * Defines the type of event (KeyboardEventTypes)
  81911. */
  81912. type: number;
  81913. /**
  81914. * Defines the related dom event
  81915. */
  81916. event: KeyboardEvent;
  81917. /**
  81918. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  81919. */
  81920. skipOnPointerObservable: boolean;
  81921. /**
  81922. * Instantiates a new keyboard pre info.
  81923. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  81924. * @param type Defines the type of event (KeyboardEventTypes)
  81925. * @param event Defines the related dom event
  81926. */
  81927. constructor(
  81928. /**
  81929. * Defines the type of event (KeyboardEventTypes)
  81930. */
  81931. type: number,
  81932. /**
  81933. * Defines the related dom event
  81934. */
  81935. event: KeyboardEvent);
  81936. }
  81937. }
  81938. declare module BABYLON {
  81939. /**
  81940. * Manage the keyboard inputs to control the movement of a free camera.
  81941. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  81942. */
  81943. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  81944. /**
  81945. * Defines the camera the input is attached to.
  81946. */
  81947. camera: FreeCamera;
  81948. /**
  81949. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  81950. */
  81951. keysUp: number[];
  81952. /**
  81953. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  81954. */
  81955. keysDown: number[];
  81956. /**
  81957. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  81958. */
  81959. keysLeft: number[];
  81960. /**
  81961. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  81962. */
  81963. keysRight: number[];
  81964. private _keys;
  81965. private _onCanvasBlurObserver;
  81966. private _onKeyboardObserver;
  81967. private _engine;
  81968. private _scene;
  81969. /**
  81970. * Attach the input controls to a specific dom element to get the input from.
  81971. * @param element Defines the element the controls should be listened from
  81972. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  81973. */
  81974. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81975. /**
  81976. * Detach the current controls from the specified dom element.
  81977. * @param element Defines the element to stop listening the inputs from
  81978. */
  81979. detachControl(element: Nullable<HTMLElement>): void;
  81980. /**
  81981. * Update the current camera state depending on the inputs that have been used this frame.
  81982. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  81983. */
  81984. checkInputs(): void;
  81985. /**
  81986. * Gets the class name of the current intput.
  81987. * @returns the class name
  81988. */
  81989. getClassName(): string;
  81990. /** @hidden */
  81991. _onLostFocus(): void;
  81992. /**
  81993. * Get the friendly name associated with the input class.
  81994. * @returns the input friendly name
  81995. */
  81996. getSimpleName(): string;
  81997. }
  81998. }
  81999. declare module BABYLON {
  82000. /**
  82001. * Interface describing all the common properties and methods a shadow light needs to implement.
  82002. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  82003. * as well as binding the different shadow properties to the effects.
  82004. */
  82005. export interface IShadowLight extends Light {
  82006. /**
  82007. * The light id in the scene (used in scene.findLighById for instance)
  82008. */
  82009. id: string;
  82010. /**
  82011. * The position the shdow will be casted from.
  82012. */
  82013. position: Vector3;
  82014. /**
  82015. * In 2d mode (needCube being false), the direction used to cast the shadow.
  82016. */
  82017. direction: Vector3;
  82018. /**
  82019. * The transformed position. Position of the light in world space taking parenting in account.
  82020. */
  82021. transformedPosition: Vector3;
  82022. /**
  82023. * The transformed direction. Direction of the light in world space taking parenting in account.
  82024. */
  82025. transformedDirection: Vector3;
  82026. /**
  82027. * The friendly name of the light in the scene.
  82028. */
  82029. name: string;
  82030. /**
  82031. * Defines the shadow projection clipping minimum z value.
  82032. */
  82033. shadowMinZ: number;
  82034. /**
  82035. * Defines the shadow projection clipping maximum z value.
  82036. */
  82037. shadowMaxZ: number;
  82038. /**
  82039. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82040. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82041. */
  82042. computeTransformedInformation(): boolean;
  82043. /**
  82044. * Gets the scene the light belongs to.
  82045. * @returns The scene
  82046. */
  82047. getScene(): Scene;
  82048. /**
  82049. * Callback defining a custom Projection Matrix Builder.
  82050. * This can be used to override the default projection matrix computation.
  82051. */
  82052. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82053. /**
  82054. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82055. * @param matrix The materix to updated with the projection information
  82056. * @param viewMatrix The transform matrix of the light
  82057. * @param renderList The list of mesh to render in the map
  82058. * @returns The current light
  82059. */
  82060. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82061. /**
  82062. * Gets the current depth scale used in ESM.
  82063. * @returns The scale
  82064. */
  82065. getDepthScale(): number;
  82066. /**
  82067. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82068. * @returns true if a cube texture needs to be use
  82069. */
  82070. needCube(): boolean;
  82071. /**
  82072. * Detects if the projection matrix requires to be recomputed this frame.
  82073. * @returns true if it requires to be recomputed otherwise, false.
  82074. */
  82075. needProjectionMatrixCompute(): boolean;
  82076. /**
  82077. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82078. */
  82079. forceProjectionMatrixCompute(): void;
  82080. /**
  82081. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82082. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82083. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82084. */
  82085. getShadowDirection(faceIndex?: number): Vector3;
  82086. /**
  82087. * Gets the minZ used for shadow according to both the scene and the light.
  82088. * @param activeCamera The camera we are returning the min for
  82089. * @returns the depth min z
  82090. */
  82091. getDepthMinZ(activeCamera: Camera): number;
  82092. /**
  82093. * Gets the maxZ used for shadow according to both the scene and the light.
  82094. * @param activeCamera The camera we are returning the max for
  82095. * @returns the depth max z
  82096. */
  82097. getDepthMaxZ(activeCamera: Camera): number;
  82098. }
  82099. /**
  82100. * Base implementation IShadowLight
  82101. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  82102. */
  82103. export abstract class ShadowLight extends Light implements IShadowLight {
  82104. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  82105. protected _position: Vector3;
  82106. protected _setPosition(value: Vector3): void;
  82107. /**
  82108. * Sets the position the shadow will be casted from. Also use as the light position for both
  82109. * point and spot lights.
  82110. */
  82111. get position(): Vector3;
  82112. /**
  82113. * Sets the position the shadow will be casted from. Also use as the light position for both
  82114. * point and spot lights.
  82115. */
  82116. set position(value: Vector3);
  82117. protected _direction: Vector3;
  82118. protected _setDirection(value: Vector3): void;
  82119. /**
  82120. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  82121. * Also use as the light direction on spot and directional lights.
  82122. */
  82123. get direction(): Vector3;
  82124. /**
  82125. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  82126. * Also use as the light direction on spot and directional lights.
  82127. */
  82128. set direction(value: Vector3);
  82129. protected _shadowMinZ: number;
  82130. /**
  82131. * Gets the shadow projection clipping minimum z value.
  82132. */
  82133. get shadowMinZ(): number;
  82134. /**
  82135. * Sets the shadow projection clipping minimum z value.
  82136. */
  82137. set shadowMinZ(value: number);
  82138. protected _shadowMaxZ: number;
  82139. /**
  82140. * Sets the shadow projection clipping maximum z value.
  82141. */
  82142. get shadowMaxZ(): number;
  82143. /**
  82144. * Gets the shadow projection clipping maximum z value.
  82145. */
  82146. set shadowMaxZ(value: number);
  82147. /**
  82148. * Callback defining a custom Projection Matrix Builder.
  82149. * This can be used to override the default projection matrix computation.
  82150. */
  82151. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82152. /**
  82153. * The transformed position. Position of the light in world space taking parenting in account.
  82154. */
  82155. transformedPosition: Vector3;
  82156. /**
  82157. * The transformed direction. Direction of the light in world space taking parenting in account.
  82158. */
  82159. transformedDirection: Vector3;
  82160. private _needProjectionMatrixCompute;
  82161. /**
  82162. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82163. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82164. */
  82165. computeTransformedInformation(): boolean;
  82166. /**
  82167. * Return the depth scale used for the shadow map.
  82168. * @returns the depth scale.
  82169. */
  82170. getDepthScale(): number;
  82171. /**
  82172. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82173. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82174. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82175. */
  82176. getShadowDirection(faceIndex?: number): Vector3;
  82177. /**
  82178. * Returns the ShadowLight absolute position in the World.
  82179. * @returns the position vector in world space
  82180. */
  82181. getAbsolutePosition(): Vector3;
  82182. /**
  82183. * Sets the ShadowLight direction toward the passed target.
  82184. * @param target The point to target in local space
  82185. * @returns the updated ShadowLight direction
  82186. */
  82187. setDirectionToTarget(target: Vector3): Vector3;
  82188. /**
  82189. * Returns the light rotation in euler definition.
  82190. * @returns the x y z rotation in local space.
  82191. */
  82192. getRotation(): Vector3;
  82193. /**
  82194. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82195. * @returns true if a cube texture needs to be use
  82196. */
  82197. needCube(): boolean;
  82198. /**
  82199. * Detects if the projection matrix requires to be recomputed this frame.
  82200. * @returns true if it requires to be recomputed otherwise, false.
  82201. */
  82202. needProjectionMatrixCompute(): boolean;
  82203. /**
  82204. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82205. */
  82206. forceProjectionMatrixCompute(): void;
  82207. /** @hidden */
  82208. _initCache(): void;
  82209. /** @hidden */
  82210. _isSynchronized(): boolean;
  82211. /**
  82212. * Computes the world matrix of the node
  82213. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82214. * @returns the world matrix
  82215. */
  82216. computeWorldMatrix(force?: boolean): Matrix;
  82217. /**
  82218. * Gets the minZ used for shadow according to both the scene and the light.
  82219. * @param activeCamera The camera we are returning the min for
  82220. * @returns the depth min z
  82221. */
  82222. getDepthMinZ(activeCamera: Camera): number;
  82223. /**
  82224. * Gets the maxZ used for shadow according to both the scene and the light.
  82225. * @param activeCamera The camera we are returning the max for
  82226. * @returns the depth max z
  82227. */
  82228. getDepthMaxZ(activeCamera: Camera): number;
  82229. /**
  82230. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82231. * @param matrix The materix to updated with the projection information
  82232. * @param viewMatrix The transform matrix of the light
  82233. * @param renderList The list of mesh to render in the map
  82234. * @returns The current light
  82235. */
  82236. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82237. }
  82238. }
  82239. declare module BABYLON {
  82240. /**
  82241. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  82242. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  82243. */
  82244. export class EffectFallbacks implements IEffectFallbacks {
  82245. private _defines;
  82246. private _currentRank;
  82247. private _maxRank;
  82248. private _mesh;
  82249. /**
  82250. * Removes the fallback from the bound mesh.
  82251. */
  82252. unBindMesh(): void;
  82253. /**
  82254. * Adds a fallback on the specified property.
  82255. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82256. * @param define The name of the define in the shader
  82257. */
  82258. addFallback(rank: number, define: string): void;
  82259. /**
  82260. * Sets the mesh to use CPU skinning when needing to fallback.
  82261. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82262. * @param mesh The mesh to use the fallbacks.
  82263. */
  82264. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  82265. /**
  82266. * Checks to see if more fallbacks are still availible.
  82267. */
  82268. get hasMoreFallbacks(): boolean;
  82269. /**
  82270. * Removes the defines that should be removed when falling back.
  82271. * @param currentDefines defines the current define statements for the shader.
  82272. * @param effect defines the current effect we try to compile
  82273. * @returns The resulting defines with defines of the current rank removed.
  82274. */
  82275. reduce(currentDefines: string, effect: Effect): string;
  82276. }
  82277. }
  82278. declare module BABYLON {
  82279. /**
  82280. * "Static Class" containing the most commonly used helper while dealing with material for
  82281. * rendering purpose.
  82282. *
  82283. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  82284. *
  82285. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  82286. */
  82287. export class MaterialHelper {
  82288. /**
  82289. * Bind the current view position to an effect.
  82290. * @param effect The effect to be bound
  82291. * @param scene The scene the eyes position is used from
  82292. */
  82293. static BindEyePosition(effect: Effect, scene: Scene): void;
  82294. /**
  82295. * Helps preparing the defines values about the UVs in used in the effect.
  82296. * UVs are shared as much as we can accross channels in the shaders.
  82297. * @param texture The texture we are preparing the UVs for
  82298. * @param defines The defines to update
  82299. * @param key The channel key "diffuse", "specular"... used in the shader
  82300. */
  82301. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  82302. /**
  82303. * Binds a texture matrix value to its corrsponding uniform
  82304. * @param texture The texture to bind the matrix for
  82305. * @param uniformBuffer The uniform buffer receivin the data
  82306. * @param key The channel key "diffuse", "specular"... used in the shader
  82307. */
  82308. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  82309. /**
  82310. * Gets the current status of the fog (should it be enabled?)
  82311. * @param mesh defines the mesh to evaluate for fog support
  82312. * @param scene defines the hosting scene
  82313. * @returns true if fog must be enabled
  82314. */
  82315. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  82316. /**
  82317. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  82318. * @param mesh defines the current mesh
  82319. * @param scene defines the current scene
  82320. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  82321. * @param pointsCloud defines if point cloud rendering has to be turned on
  82322. * @param fogEnabled defines if fog has to be turned on
  82323. * @param alphaTest defines if alpha testing has to be turned on
  82324. * @param defines defines the current list of defines
  82325. */
  82326. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  82327. /**
  82328. * Helper used to prepare the list of defines associated with frame values for shader compilation
  82329. * @param scene defines the current scene
  82330. * @param engine defines the current engine
  82331. * @param defines specifies the list of active defines
  82332. * @param useInstances defines if instances have to be turned on
  82333. * @param useClipPlane defines if clip plane have to be turned on
  82334. */
  82335. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  82336. /**
  82337. * Prepares the defines for bones
  82338. * @param mesh The mesh containing the geometry data we will draw
  82339. * @param defines The defines to update
  82340. */
  82341. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  82342. /**
  82343. * Prepares the defines for morph targets
  82344. * @param mesh The mesh containing the geometry data we will draw
  82345. * @param defines The defines to update
  82346. */
  82347. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  82348. /**
  82349. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  82350. * @param mesh The mesh containing the geometry data we will draw
  82351. * @param defines The defines to update
  82352. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  82353. * @param useBones Precise whether bones should be used or not (override mesh info)
  82354. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  82355. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  82356. * @returns false if defines are considered not dirty and have not been checked
  82357. */
  82358. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  82359. /**
  82360. * Prepares the defines related to multiview
  82361. * @param scene The scene we are intending to draw
  82362. * @param defines The defines to update
  82363. */
  82364. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  82365. /**
  82366. * Prepares the defines related to the light information passed in parameter
  82367. * @param scene The scene we are intending to draw
  82368. * @param mesh The mesh the effect is compiling for
  82369. * @param light The light the effect is compiling for
  82370. * @param lightIndex The index of the light
  82371. * @param defines The defines to update
  82372. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82373. * @param state Defines the current state regarding what is needed (normals, etc...)
  82374. */
  82375. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  82376. needNormals: boolean;
  82377. needRebuild: boolean;
  82378. shadowEnabled: boolean;
  82379. specularEnabled: boolean;
  82380. lightmapMode: boolean;
  82381. }): void;
  82382. /**
  82383. * Prepares the defines related to the light information passed in parameter
  82384. * @param scene The scene we are intending to draw
  82385. * @param mesh The mesh the effect is compiling for
  82386. * @param defines The defines to update
  82387. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82388. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  82389. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  82390. * @returns true if normals will be required for the rest of the effect
  82391. */
  82392. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  82393. /**
  82394. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  82395. * @param lightIndex defines the light index
  82396. * @param uniformsList The uniform list
  82397. * @param samplersList The sampler list
  82398. * @param projectedLightTexture defines if projected texture must be used
  82399. * @param uniformBuffersList defines an optional list of uniform buffers
  82400. */
  82401. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  82402. /**
  82403. * Prepares the uniforms and samplers list to be used in the effect
  82404. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  82405. * @param samplersList The sampler list
  82406. * @param defines The defines helping in the list generation
  82407. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  82408. */
  82409. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  82410. /**
  82411. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  82412. * @param defines The defines to update while falling back
  82413. * @param fallbacks The authorized effect fallbacks
  82414. * @param maxSimultaneousLights The maximum number of lights allowed
  82415. * @param rank the current rank of the Effect
  82416. * @returns The newly affected rank
  82417. */
  82418. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  82419. private static _TmpMorphInfluencers;
  82420. /**
  82421. * Prepares the list of attributes required for morph targets according to the effect defines.
  82422. * @param attribs The current list of supported attribs
  82423. * @param mesh The mesh to prepare the morph targets attributes for
  82424. * @param influencers The number of influencers
  82425. */
  82426. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  82427. /**
  82428. * Prepares the list of attributes required for morph targets according to the effect defines.
  82429. * @param attribs The current list of supported attribs
  82430. * @param mesh The mesh to prepare the morph targets attributes for
  82431. * @param defines The current Defines of the effect
  82432. */
  82433. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  82434. /**
  82435. * Prepares the list of attributes required for bones according to the effect defines.
  82436. * @param attribs The current list of supported attribs
  82437. * @param mesh The mesh to prepare the bones attributes for
  82438. * @param defines The current Defines of the effect
  82439. * @param fallbacks The current efffect fallback strategy
  82440. */
  82441. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  82442. /**
  82443. * Check and prepare the list of attributes required for instances according to the effect defines.
  82444. * @param attribs The current list of supported attribs
  82445. * @param defines The current MaterialDefines of the effect
  82446. */
  82447. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  82448. /**
  82449. * Add the list of attributes required for instances to the attribs array.
  82450. * @param attribs The current list of supported attribs
  82451. */
  82452. static PushAttributesForInstances(attribs: string[]): void;
  82453. /**
  82454. * Binds the light information to the effect.
  82455. * @param light The light containing the generator
  82456. * @param effect The effect we are binding the data to
  82457. * @param lightIndex The light index in the effect used to render
  82458. */
  82459. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  82460. /**
  82461. * Binds the lights information from the scene to the effect for the given mesh.
  82462. * @param light Light to bind
  82463. * @param lightIndex Light index
  82464. * @param scene The scene where the light belongs to
  82465. * @param effect The effect we are binding the data to
  82466. * @param useSpecular Defines if specular is supported
  82467. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82468. */
  82469. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82470. /**
  82471. * Binds the lights information from the scene to the effect for the given mesh.
  82472. * @param scene The scene the lights belongs to
  82473. * @param mesh The mesh we are binding the information to render
  82474. * @param effect The effect we are binding the data to
  82475. * @param defines The generated defines for the effect
  82476. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  82477. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82478. */
  82479. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  82480. private static _tempFogColor;
  82481. /**
  82482. * Binds the fog information from the scene to the effect for the given mesh.
  82483. * @param scene The scene the lights belongs to
  82484. * @param mesh The mesh we are binding the information to render
  82485. * @param effect The effect we are binding the data to
  82486. * @param linearSpace Defines if the fog effect is applied in linear space
  82487. */
  82488. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  82489. /**
  82490. * Binds the bones information from the mesh to the effect.
  82491. * @param mesh The mesh we are binding the information to render
  82492. * @param effect The effect we are binding the data to
  82493. */
  82494. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  82495. /**
  82496. * Binds the morph targets information from the mesh to the effect.
  82497. * @param abstractMesh The mesh we are binding the information to render
  82498. * @param effect The effect we are binding the data to
  82499. */
  82500. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  82501. /**
  82502. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  82503. * @param defines The generated defines used in the effect
  82504. * @param effect The effect we are binding the data to
  82505. * @param scene The scene we are willing to render with logarithmic scale for
  82506. */
  82507. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  82508. /**
  82509. * Binds the clip plane information from the scene to the effect.
  82510. * @param scene The scene the clip plane information are extracted from
  82511. * @param effect The effect we are binding the data to
  82512. */
  82513. static BindClipPlane(effect: Effect, scene: Scene): void;
  82514. }
  82515. }
  82516. declare module BABYLON {
  82517. /** @hidden */
  82518. export var packingFunctions: {
  82519. name: string;
  82520. shader: string;
  82521. };
  82522. }
  82523. declare module BABYLON {
  82524. /** @hidden */
  82525. export var clipPlaneFragmentDeclaration: {
  82526. name: string;
  82527. shader: string;
  82528. };
  82529. }
  82530. declare module BABYLON {
  82531. /** @hidden */
  82532. export var clipPlaneFragment: {
  82533. name: string;
  82534. shader: string;
  82535. };
  82536. }
  82537. declare module BABYLON {
  82538. /** @hidden */
  82539. export var shadowMapPixelShader: {
  82540. name: string;
  82541. shader: string;
  82542. };
  82543. }
  82544. declare module BABYLON {
  82545. /** @hidden */
  82546. export var bonesDeclaration: {
  82547. name: string;
  82548. shader: string;
  82549. };
  82550. }
  82551. declare module BABYLON {
  82552. /** @hidden */
  82553. export var morphTargetsVertexGlobalDeclaration: {
  82554. name: string;
  82555. shader: string;
  82556. };
  82557. }
  82558. declare module BABYLON {
  82559. /** @hidden */
  82560. export var morphTargetsVertexDeclaration: {
  82561. name: string;
  82562. shader: string;
  82563. };
  82564. }
  82565. declare module BABYLON {
  82566. /** @hidden */
  82567. export var instancesDeclaration: {
  82568. name: string;
  82569. shader: string;
  82570. };
  82571. }
  82572. declare module BABYLON {
  82573. /** @hidden */
  82574. export var helperFunctions: {
  82575. name: string;
  82576. shader: string;
  82577. };
  82578. }
  82579. declare module BABYLON {
  82580. /** @hidden */
  82581. export var clipPlaneVertexDeclaration: {
  82582. name: string;
  82583. shader: string;
  82584. };
  82585. }
  82586. declare module BABYLON {
  82587. /** @hidden */
  82588. export var morphTargetsVertex: {
  82589. name: string;
  82590. shader: string;
  82591. };
  82592. }
  82593. declare module BABYLON {
  82594. /** @hidden */
  82595. export var instancesVertex: {
  82596. name: string;
  82597. shader: string;
  82598. };
  82599. }
  82600. declare module BABYLON {
  82601. /** @hidden */
  82602. export var bonesVertex: {
  82603. name: string;
  82604. shader: string;
  82605. };
  82606. }
  82607. declare module BABYLON {
  82608. /** @hidden */
  82609. export var clipPlaneVertex: {
  82610. name: string;
  82611. shader: string;
  82612. };
  82613. }
  82614. declare module BABYLON {
  82615. /** @hidden */
  82616. export var shadowMapVertexShader: {
  82617. name: string;
  82618. shader: string;
  82619. };
  82620. }
  82621. declare module BABYLON {
  82622. /** @hidden */
  82623. export var depthBoxBlurPixelShader: {
  82624. name: string;
  82625. shader: string;
  82626. };
  82627. }
  82628. declare module BABYLON {
  82629. /**
  82630. * Class representing a ray with position and direction
  82631. */
  82632. export class Ray {
  82633. /** origin point */
  82634. origin: Vector3;
  82635. /** direction */
  82636. direction: Vector3;
  82637. /** length of the ray */
  82638. length: number;
  82639. private static readonly TmpVector3;
  82640. private _tmpRay;
  82641. /**
  82642. * Creates a new ray
  82643. * @param origin origin point
  82644. * @param direction direction
  82645. * @param length length of the ray
  82646. */
  82647. constructor(
  82648. /** origin point */
  82649. origin: Vector3,
  82650. /** direction */
  82651. direction: Vector3,
  82652. /** length of the ray */
  82653. length?: number);
  82654. /**
  82655. * Checks if the ray intersects a box
  82656. * @param minimum bound of the box
  82657. * @param maximum bound of the box
  82658. * @param intersectionTreshold extra extend to be added to the box in all direction
  82659. * @returns if the box was hit
  82660. */
  82661. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  82662. /**
  82663. * Checks if the ray intersects a box
  82664. * @param box the bounding box to check
  82665. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  82666. * @returns if the box was hit
  82667. */
  82668. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  82669. /**
  82670. * If the ray hits a sphere
  82671. * @param sphere the bounding sphere to check
  82672. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  82673. * @returns true if it hits the sphere
  82674. */
  82675. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  82676. /**
  82677. * If the ray hits a triange
  82678. * @param vertex0 triangle vertex
  82679. * @param vertex1 triangle vertex
  82680. * @param vertex2 triangle vertex
  82681. * @returns intersection information if hit
  82682. */
  82683. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  82684. /**
  82685. * Checks if ray intersects a plane
  82686. * @param plane the plane to check
  82687. * @returns the distance away it was hit
  82688. */
  82689. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  82690. /**
  82691. * Calculate the intercept of a ray on a given axis
  82692. * @param axis to check 'x' | 'y' | 'z'
  82693. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  82694. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  82695. */
  82696. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  82697. /**
  82698. * Checks if ray intersects a mesh
  82699. * @param mesh the mesh to check
  82700. * @param fastCheck if only the bounding box should checked
  82701. * @returns picking info of the intersecton
  82702. */
  82703. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  82704. /**
  82705. * Checks if ray intersects a mesh
  82706. * @param meshes the meshes to check
  82707. * @param fastCheck if only the bounding box should checked
  82708. * @param results array to store result in
  82709. * @returns Array of picking infos
  82710. */
  82711. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  82712. private _comparePickingInfo;
  82713. private static smallnum;
  82714. private static rayl;
  82715. /**
  82716. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  82717. * @param sega the first point of the segment to test the intersection against
  82718. * @param segb the second point of the segment to test the intersection against
  82719. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  82720. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  82721. */
  82722. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  82723. /**
  82724. * Update the ray from viewport position
  82725. * @param x position
  82726. * @param y y position
  82727. * @param viewportWidth viewport width
  82728. * @param viewportHeight viewport height
  82729. * @param world world matrix
  82730. * @param view view matrix
  82731. * @param projection projection matrix
  82732. * @returns this ray updated
  82733. */
  82734. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82735. /**
  82736. * Creates a ray with origin and direction of 0,0,0
  82737. * @returns the new ray
  82738. */
  82739. static Zero(): Ray;
  82740. /**
  82741. * Creates a new ray from screen space and viewport
  82742. * @param x position
  82743. * @param y y position
  82744. * @param viewportWidth viewport width
  82745. * @param viewportHeight viewport height
  82746. * @param world world matrix
  82747. * @param view view matrix
  82748. * @param projection projection matrix
  82749. * @returns new ray
  82750. */
  82751. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82752. /**
  82753. * 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
  82754. * transformed to the given world matrix.
  82755. * @param origin The origin point
  82756. * @param end The end point
  82757. * @param world a matrix to transform the ray to. Default is the identity matrix.
  82758. * @returns the new ray
  82759. */
  82760. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  82761. /**
  82762. * Transforms a ray by a matrix
  82763. * @param ray ray to transform
  82764. * @param matrix matrix to apply
  82765. * @returns the resulting new ray
  82766. */
  82767. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  82768. /**
  82769. * Transforms a ray by a matrix
  82770. * @param ray ray to transform
  82771. * @param matrix matrix to apply
  82772. * @param result ray to store result in
  82773. */
  82774. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  82775. /**
  82776. * Unproject a ray from screen space to object space
  82777. * @param sourceX defines the screen space x coordinate to use
  82778. * @param sourceY defines the screen space y coordinate to use
  82779. * @param viewportWidth defines the current width of the viewport
  82780. * @param viewportHeight defines the current height of the viewport
  82781. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82782. * @param view defines the view matrix to use
  82783. * @param projection defines the projection matrix to use
  82784. */
  82785. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  82786. }
  82787. /**
  82788. * Type used to define predicate used to select faces when a mesh intersection is detected
  82789. */
  82790. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  82791. interface Scene {
  82792. /** @hidden */
  82793. _tempPickingRay: Nullable<Ray>;
  82794. /** @hidden */
  82795. _cachedRayForTransform: Ray;
  82796. /** @hidden */
  82797. _pickWithRayInverseMatrix: Matrix;
  82798. /** @hidden */
  82799. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  82800. /** @hidden */
  82801. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  82802. }
  82803. }
  82804. declare module BABYLON {
  82805. /**
  82806. * Groups all the scene component constants in one place to ease maintenance.
  82807. * @hidden
  82808. */
  82809. export class SceneComponentConstants {
  82810. static readonly NAME_EFFECTLAYER: string;
  82811. static readonly NAME_LAYER: string;
  82812. static readonly NAME_LENSFLARESYSTEM: string;
  82813. static readonly NAME_BOUNDINGBOXRENDERER: string;
  82814. static readonly NAME_PARTICLESYSTEM: string;
  82815. static readonly NAME_GAMEPAD: string;
  82816. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  82817. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  82818. static readonly NAME_DEPTHRENDERER: string;
  82819. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  82820. static readonly NAME_SPRITE: string;
  82821. static readonly NAME_OUTLINERENDERER: string;
  82822. static readonly NAME_PROCEDURALTEXTURE: string;
  82823. static readonly NAME_SHADOWGENERATOR: string;
  82824. static readonly NAME_OCTREE: string;
  82825. static readonly NAME_PHYSICSENGINE: string;
  82826. static readonly NAME_AUDIO: string;
  82827. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  82828. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82829. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  82830. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82831. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  82832. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  82833. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  82834. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  82835. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  82836. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  82837. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  82838. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  82839. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  82840. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  82841. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  82842. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  82843. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  82844. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  82845. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  82846. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  82847. static readonly STEP_AFTERRENDER_AUDIO: number;
  82848. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  82849. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  82850. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  82851. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  82852. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  82853. static readonly STEP_POINTERMOVE_SPRITE: number;
  82854. static readonly STEP_POINTERDOWN_SPRITE: number;
  82855. static readonly STEP_POINTERUP_SPRITE: number;
  82856. }
  82857. /**
  82858. * This represents a scene component.
  82859. *
  82860. * This is used to decouple the dependency the scene is having on the different workloads like
  82861. * layers, post processes...
  82862. */
  82863. export interface ISceneComponent {
  82864. /**
  82865. * The name of the component. Each component must have a unique name.
  82866. */
  82867. name: string;
  82868. /**
  82869. * The scene the component belongs to.
  82870. */
  82871. scene: Scene;
  82872. /**
  82873. * Register the component to one instance of a scene.
  82874. */
  82875. register(): void;
  82876. /**
  82877. * Rebuilds the elements related to this component in case of
  82878. * context lost for instance.
  82879. */
  82880. rebuild(): void;
  82881. /**
  82882. * Disposes the component and the associated ressources.
  82883. */
  82884. dispose(): void;
  82885. }
  82886. /**
  82887. * This represents a SERIALIZABLE scene component.
  82888. *
  82889. * This extends Scene Component to add Serialization methods on top.
  82890. */
  82891. export interface ISceneSerializableComponent extends ISceneComponent {
  82892. /**
  82893. * Adds all the elements from the container to the scene
  82894. * @param container the container holding the elements
  82895. */
  82896. addFromContainer(container: AbstractScene): void;
  82897. /**
  82898. * Removes all the elements in the container from the scene
  82899. * @param container contains the elements to remove
  82900. * @param dispose if the removed element should be disposed (default: false)
  82901. */
  82902. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  82903. /**
  82904. * Serializes the component data to the specified json object
  82905. * @param serializationObject The object to serialize to
  82906. */
  82907. serialize(serializationObject: any): void;
  82908. }
  82909. /**
  82910. * Strong typing of a Mesh related stage step action
  82911. */
  82912. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  82913. /**
  82914. * Strong typing of a Evaluate Sub Mesh related stage step action
  82915. */
  82916. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  82917. /**
  82918. * Strong typing of a Active Mesh related stage step action
  82919. */
  82920. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  82921. /**
  82922. * Strong typing of a Camera related stage step action
  82923. */
  82924. export type CameraStageAction = (camera: Camera) => void;
  82925. /**
  82926. * Strong typing of a Camera Frame buffer related stage step action
  82927. */
  82928. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  82929. /**
  82930. * Strong typing of a Render Target related stage step action
  82931. */
  82932. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  82933. /**
  82934. * Strong typing of a RenderingGroup related stage step action
  82935. */
  82936. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  82937. /**
  82938. * Strong typing of a Mesh Render related stage step action
  82939. */
  82940. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  82941. /**
  82942. * Strong typing of a simple stage step action
  82943. */
  82944. export type SimpleStageAction = () => void;
  82945. /**
  82946. * Strong typing of a render target action.
  82947. */
  82948. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  82949. /**
  82950. * Strong typing of a pointer move action.
  82951. */
  82952. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  82953. /**
  82954. * Strong typing of a pointer up/down action.
  82955. */
  82956. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  82957. /**
  82958. * Representation of a stage in the scene (Basically a list of ordered steps)
  82959. * @hidden
  82960. */
  82961. export class Stage<T extends Function> extends Array<{
  82962. index: number;
  82963. component: ISceneComponent;
  82964. action: T;
  82965. }> {
  82966. /**
  82967. * Hide ctor from the rest of the world.
  82968. * @param items The items to add.
  82969. */
  82970. private constructor();
  82971. /**
  82972. * Creates a new Stage.
  82973. * @returns A new instance of a Stage
  82974. */
  82975. static Create<T extends Function>(): Stage<T>;
  82976. /**
  82977. * Registers a step in an ordered way in the targeted stage.
  82978. * @param index Defines the position to register the step in
  82979. * @param component Defines the component attached to the step
  82980. * @param action Defines the action to launch during the step
  82981. */
  82982. registerStep(index: number, component: ISceneComponent, action: T): void;
  82983. /**
  82984. * Clears all the steps from the stage.
  82985. */
  82986. clear(): void;
  82987. }
  82988. }
  82989. declare module BABYLON {
  82990. interface Scene {
  82991. /** @hidden */
  82992. _pointerOverSprite: Nullable<Sprite>;
  82993. /** @hidden */
  82994. _pickedDownSprite: Nullable<Sprite>;
  82995. /** @hidden */
  82996. _tempSpritePickingRay: Nullable<Ray>;
  82997. /**
  82998. * All of the sprite managers added to this scene
  82999. * @see http://doc.babylonjs.com/babylon101/sprites
  83000. */
  83001. spriteManagers: Array<ISpriteManager>;
  83002. /**
  83003. * An event triggered when sprites rendering is about to start
  83004. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83005. */
  83006. onBeforeSpritesRenderingObservable: Observable<Scene>;
  83007. /**
  83008. * An event triggered when sprites rendering is done
  83009. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83010. */
  83011. onAfterSpritesRenderingObservable: Observable<Scene>;
  83012. /** @hidden */
  83013. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83014. /** Launch a ray to try to pick a sprite in the scene
  83015. * @param x position on screen
  83016. * @param y position on screen
  83017. * @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
  83018. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83019. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83020. * @returns a PickingInfo
  83021. */
  83022. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83023. /** Use the given ray to pick a sprite in the scene
  83024. * @param ray The ray (in world space) to use to pick meshes
  83025. * @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
  83026. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83027. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83028. * @returns a PickingInfo
  83029. */
  83030. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83031. /** @hidden */
  83032. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83033. /** Launch a ray to try to pick sprites in the scene
  83034. * @param x position on screen
  83035. * @param y position on screen
  83036. * @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
  83037. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83038. * @returns a PickingInfo array
  83039. */
  83040. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83041. /** Use the given ray to pick sprites in the scene
  83042. * @param ray The ray (in world space) to use to pick meshes
  83043. * @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
  83044. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83045. * @returns a PickingInfo array
  83046. */
  83047. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83048. /**
  83049. * Force the sprite under the pointer
  83050. * @param sprite defines the sprite to use
  83051. */
  83052. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  83053. /**
  83054. * Gets the sprite under the pointer
  83055. * @returns a Sprite or null if no sprite is under the pointer
  83056. */
  83057. getPointerOverSprite(): Nullable<Sprite>;
  83058. }
  83059. /**
  83060. * Defines the sprite scene component responsible to manage sprites
  83061. * in a given scene.
  83062. */
  83063. export class SpriteSceneComponent implements ISceneComponent {
  83064. /**
  83065. * The component name helpfull to identify the component in the list of scene components.
  83066. */
  83067. readonly name: string;
  83068. /**
  83069. * The scene the component belongs to.
  83070. */
  83071. scene: Scene;
  83072. /** @hidden */
  83073. private _spritePredicate;
  83074. /**
  83075. * Creates a new instance of the component for the given scene
  83076. * @param scene Defines the scene to register the component in
  83077. */
  83078. constructor(scene: Scene);
  83079. /**
  83080. * Registers the component in a given scene
  83081. */
  83082. register(): void;
  83083. /**
  83084. * Rebuilds the elements related to this component in case of
  83085. * context lost for instance.
  83086. */
  83087. rebuild(): void;
  83088. /**
  83089. * Disposes the component and the associated ressources.
  83090. */
  83091. dispose(): void;
  83092. private _pickSpriteButKeepRay;
  83093. private _pointerMove;
  83094. private _pointerDown;
  83095. private _pointerUp;
  83096. }
  83097. }
  83098. declare module BABYLON {
  83099. /** @hidden */
  83100. export var fogFragmentDeclaration: {
  83101. name: string;
  83102. shader: string;
  83103. };
  83104. }
  83105. declare module BABYLON {
  83106. /** @hidden */
  83107. export var fogFragment: {
  83108. name: string;
  83109. shader: string;
  83110. };
  83111. }
  83112. declare module BABYLON {
  83113. /** @hidden */
  83114. export var spritesPixelShader: {
  83115. name: string;
  83116. shader: string;
  83117. };
  83118. }
  83119. declare module BABYLON {
  83120. /** @hidden */
  83121. export var fogVertexDeclaration: {
  83122. name: string;
  83123. shader: string;
  83124. };
  83125. }
  83126. declare module BABYLON {
  83127. /** @hidden */
  83128. export var spritesVertexShader: {
  83129. name: string;
  83130. shader: string;
  83131. };
  83132. }
  83133. declare module BABYLON {
  83134. /**
  83135. * Defines the minimum interface to fullfil in order to be a sprite manager.
  83136. */
  83137. export interface ISpriteManager extends IDisposable {
  83138. /**
  83139. * Restricts the camera to viewing objects with the same layerMask.
  83140. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  83141. */
  83142. layerMask: number;
  83143. /**
  83144. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83145. */
  83146. isPickable: boolean;
  83147. /**
  83148. * Specifies the rendering group id for this mesh (0 by default)
  83149. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83150. */
  83151. renderingGroupId: number;
  83152. /**
  83153. * Defines the list of sprites managed by the manager.
  83154. */
  83155. sprites: Array<Sprite>;
  83156. /**
  83157. * Tests the intersection of a sprite with a specific ray.
  83158. * @param ray The ray we are sending to test the collision
  83159. * @param camera The camera space we are sending rays in
  83160. * @param predicate A predicate allowing excluding sprites from the list of object to test
  83161. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  83162. * @returns picking info or null.
  83163. */
  83164. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83165. /**
  83166. * Intersects the sprites with a ray
  83167. * @param ray defines the ray to intersect with
  83168. * @param camera defines the current active camera
  83169. * @param predicate defines a predicate used to select candidate sprites
  83170. * @returns null if no hit or a PickingInfo array
  83171. */
  83172. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83173. /**
  83174. * Renders the list of sprites on screen.
  83175. */
  83176. render(): void;
  83177. }
  83178. /**
  83179. * Class used to manage multiple sprites on the same spritesheet
  83180. * @see http://doc.babylonjs.com/babylon101/sprites
  83181. */
  83182. export class SpriteManager implements ISpriteManager {
  83183. /** defines the manager's name */
  83184. name: string;
  83185. /** Gets the list of sprites */
  83186. sprites: Sprite[];
  83187. /** Gets or sets the rendering group id (0 by default) */
  83188. renderingGroupId: number;
  83189. /** Gets or sets camera layer mask */
  83190. layerMask: number;
  83191. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  83192. fogEnabled: boolean;
  83193. /** Gets or sets a boolean indicating if the sprites are pickable */
  83194. isPickable: boolean;
  83195. /** Defines the default width of a cell in the spritesheet */
  83196. cellWidth: number;
  83197. /** Defines the default height of a cell in the spritesheet */
  83198. cellHeight: number;
  83199. /** Associative array from JSON sprite data file */
  83200. private _cellData;
  83201. /** Array of sprite names from JSON sprite data file */
  83202. private _spriteMap;
  83203. /** True when packed cell data from JSON file is ready*/
  83204. private _packedAndReady;
  83205. /**
  83206. * An event triggered when the manager is disposed.
  83207. */
  83208. onDisposeObservable: Observable<SpriteManager>;
  83209. private _onDisposeObserver;
  83210. /**
  83211. * Callback called when the manager is disposed
  83212. */
  83213. set onDispose(callback: () => void);
  83214. private _capacity;
  83215. private _fromPacked;
  83216. private _spriteTexture;
  83217. private _epsilon;
  83218. private _scene;
  83219. private _vertexData;
  83220. private _buffer;
  83221. private _vertexBuffers;
  83222. private _indexBuffer;
  83223. private _effectBase;
  83224. private _effectFog;
  83225. /**
  83226. * Gets or sets the spritesheet texture
  83227. */
  83228. get texture(): Texture;
  83229. set texture(value: Texture);
  83230. private _blendMode;
  83231. /**
  83232. * Blend mode use to render the particle, it can be any of
  83233. * the static Constants.ALPHA_x properties provided in this class.
  83234. * Default value is Constants.ALPHA_COMBINE
  83235. */
  83236. get blendMode(): number;
  83237. set blendMode(blendMode: number);
  83238. /** Disables writing to the depth buffer when rendering the sprites.
  83239. * It can be handy to disable depth writing when using textures without alpha channel
  83240. * and setting some specific blend modes.
  83241. */
  83242. disableDepthWrite: boolean;
  83243. /**
  83244. * Creates a new sprite manager
  83245. * @param name defines the manager's name
  83246. * @param imgUrl defines the sprite sheet url
  83247. * @param capacity defines the maximum allowed number of sprites
  83248. * @param cellSize defines the size of a sprite cell
  83249. * @param scene defines the hosting scene
  83250. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  83251. * @param samplingMode defines the smapling mode to use with spritesheet
  83252. * @param fromPacked set to false; do not alter
  83253. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  83254. */
  83255. constructor(
  83256. /** defines the manager's name */
  83257. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  83258. private _makePacked;
  83259. private _appendSpriteVertex;
  83260. /**
  83261. * Intersects the sprites with a ray
  83262. * @param ray defines the ray to intersect with
  83263. * @param camera defines the current active camera
  83264. * @param predicate defines a predicate used to select candidate sprites
  83265. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  83266. * @returns null if no hit or a PickingInfo
  83267. */
  83268. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83269. /**
  83270. * Intersects the sprites with a ray
  83271. * @param ray defines the ray to intersect with
  83272. * @param camera defines the current active camera
  83273. * @param predicate defines a predicate used to select candidate sprites
  83274. * @returns null if no hit or a PickingInfo array
  83275. */
  83276. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83277. /**
  83278. * Render all child sprites
  83279. */
  83280. render(): void;
  83281. /**
  83282. * Release associated resources
  83283. */
  83284. dispose(): void;
  83285. }
  83286. }
  83287. declare module BABYLON {
  83288. /** Interface used by value gradients (color, factor, ...) */
  83289. export interface IValueGradient {
  83290. /**
  83291. * Gets or sets the gradient value (between 0 and 1)
  83292. */
  83293. gradient: number;
  83294. }
  83295. /** Class used to store color4 gradient */
  83296. export class ColorGradient implements IValueGradient {
  83297. /**
  83298. * Gets or sets the gradient value (between 0 and 1)
  83299. */
  83300. gradient: number;
  83301. /**
  83302. * Gets or sets first associated color
  83303. */
  83304. color1: Color4;
  83305. /**
  83306. * Gets or sets second associated color
  83307. */
  83308. color2?: Color4;
  83309. /**
  83310. * Will get a color picked randomly between color1 and color2.
  83311. * If color2 is undefined then color1 will be used
  83312. * @param result defines the target Color4 to store the result in
  83313. */
  83314. getColorToRef(result: Color4): void;
  83315. }
  83316. /** Class used to store color 3 gradient */
  83317. export class Color3Gradient implements IValueGradient {
  83318. /**
  83319. * Gets or sets the gradient value (between 0 and 1)
  83320. */
  83321. gradient: number;
  83322. /**
  83323. * Gets or sets the associated color
  83324. */
  83325. color: Color3;
  83326. }
  83327. /** Class used to store factor gradient */
  83328. export class FactorGradient implements IValueGradient {
  83329. /**
  83330. * Gets or sets the gradient value (between 0 and 1)
  83331. */
  83332. gradient: number;
  83333. /**
  83334. * Gets or sets first associated factor
  83335. */
  83336. factor1: number;
  83337. /**
  83338. * Gets or sets second associated factor
  83339. */
  83340. factor2?: number;
  83341. /**
  83342. * Will get a number picked randomly between factor1 and factor2.
  83343. * If factor2 is undefined then factor1 will be used
  83344. * @returns the picked number
  83345. */
  83346. getFactor(): number;
  83347. }
  83348. /**
  83349. * Helper used to simplify some generic gradient tasks
  83350. */
  83351. export class GradientHelper {
  83352. /**
  83353. * Gets the current gradient from an array of IValueGradient
  83354. * @param ratio defines the current ratio to get
  83355. * @param gradients defines the array of IValueGradient
  83356. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83357. */
  83358. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83359. }
  83360. }
  83361. declare module BABYLON {
  83362. /**
  83363. * Interface for the size containing width and height
  83364. */
  83365. export interface ISize {
  83366. /**
  83367. * Width
  83368. */
  83369. width: number;
  83370. /**
  83371. * Heighht
  83372. */
  83373. height: number;
  83374. }
  83375. /**
  83376. * Size containing widht and height
  83377. */
  83378. export class Size implements ISize {
  83379. /**
  83380. * Width
  83381. */
  83382. width: number;
  83383. /**
  83384. * Height
  83385. */
  83386. height: number;
  83387. /**
  83388. * Creates a Size object from the given width and height (floats).
  83389. * @param width width of the new size
  83390. * @param height height of the new size
  83391. */
  83392. constructor(width: number, height: number);
  83393. /**
  83394. * Returns a string with the Size width and height
  83395. * @returns a string with the Size width and height
  83396. */
  83397. toString(): string;
  83398. /**
  83399. * "Size"
  83400. * @returns the string "Size"
  83401. */
  83402. getClassName(): string;
  83403. /**
  83404. * Returns the Size hash code.
  83405. * @returns a hash code for a unique width and height
  83406. */
  83407. getHashCode(): number;
  83408. /**
  83409. * Updates the current size from the given one.
  83410. * @param src the given size
  83411. */
  83412. copyFrom(src: Size): void;
  83413. /**
  83414. * Updates in place the current Size from the given floats.
  83415. * @param width width of the new size
  83416. * @param height height of the new size
  83417. * @returns the updated Size.
  83418. */
  83419. copyFromFloats(width: number, height: number): Size;
  83420. /**
  83421. * Updates in place the current Size from the given floats.
  83422. * @param width width to set
  83423. * @param height height to set
  83424. * @returns the updated Size.
  83425. */
  83426. set(width: number, height: number): Size;
  83427. /**
  83428. * Multiplies the width and height by numbers
  83429. * @param w factor to multiple the width by
  83430. * @param h factor to multiple the height by
  83431. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83432. */
  83433. multiplyByFloats(w: number, h: number): Size;
  83434. /**
  83435. * Clones the size
  83436. * @returns a new Size copied from the given one.
  83437. */
  83438. clone(): Size;
  83439. /**
  83440. * True if the current Size and the given one width and height are strictly equal.
  83441. * @param other the other size to compare against
  83442. * @returns True if the current Size and the given one width and height are strictly equal.
  83443. */
  83444. equals(other: Size): boolean;
  83445. /**
  83446. * The surface of the Size : width * height (float).
  83447. */
  83448. get surface(): number;
  83449. /**
  83450. * Create a new size of zero
  83451. * @returns a new Size set to (0.0, 0.0)
  83452. */
  83453. static Zero(): Size;
  83454. /**
  83455. * Sums the width and height of two sizes
  83456. * @param otherSize size to add to this size
  83457. * @returns a new Size set as the addition result of the current Size and the given one.
  83458. */
  83459. add(otherSize: Size): Size;
  83460. /**
  83461. * Subtracts the width and height of two
  83462. * @param otherSize size to subtract to this size
  83463. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83464. */
  83465. subtract(otherSize: Size): Size;
  83466. /**
  83467. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83468. * @param start starting size to lerp between
  83469. * @param end end size to lerp between
  83470. * @param amount amount to lerp between the start and end values
  83471. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83472. */
  83473. static Lerp(start: Size, end: Size, amount: number): Size;
  83474. }
  83475. }
  83476. declare module BABYLON {
  83477. interface ThinEngine {
  83478. /**
  83479. * Creates a dynamic texture
  83480. * @param width defines the width of the texture
  83481. * @param height defines the height of the texture
  83482. * @param generateMipMaps defines if the engine should generate the mip levels
  83483. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83484. * @returns the dynamic texture inside an InternalTexture
  83485. */
  83486. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83487. /**
  83488. * Update the content of a dynamic texture
  83489. * @param texture defines the texture to update
  83490. * @param canvas defines the canvas containing the source
  83491. * @param invertY defines if data must be stored with Y axis inverted
  83492. * @param premulAlpha defines if alpha is stored as premultiplied
  83493. * @param format defines the format of the data
  83494. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83495. */
  83496. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83497. }
  83498. }
  83499. declare module BABYLON {
  83500. /**
  83501. * Helper class used to generate a canvas to manipulate images
  83502. */
  83503. export class CanvasGenerator {
  83504. /**
  83505. * Create a new canvas (or offscreen canvas depending on the context)
  83506. * @param width defines the expected width
  83507. * @param height defines the expected height
  83508. * @return a new canvas or offscreen canvas
  83509. */
  83510. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83511. }
  83512. }
  83513. declare module BABYLON {
  83514. /**
  83515. * A class extending Texture allowing drawing on a texture
  83516. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83517. */
  83518. export class DynamicTexture extends Texture {
  83519. private _generateMipMaps;
  83520. private _canvas;
  83521. private _context;
  83522. private _engine;
  83523. /**
  83524. * Creates a DynamicTexture
  83525. * @param name defines the name of the texture
  83526. * @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
  83527. * @param scene defines the scene where you want the texture
  83528. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83529. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83530. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83531. */
  83532. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83533. /**
  83534. * Get the current class name of the texture useful for serialization or dynamic coding.
  83535. * @returns "DynamicTexture"
  83536. */
  83537. getClassName(): string;
  83538. /**
  83539. * Gets the current state of canRescale
  83540. */
  83541. get canRescale(): boolean;
  83542. private _recreate;
  83543. /**
  83544. * Scales the texture
  83545. * @param ratio the scale factor to apply to both width and height
  83546. */
  83547. scale(ratio: number): void;
  83548. /**
  83549. * Resizes the texture
  83550. * @param width the new width
  83551. * @param height the new height
  83552. */
  83553. scaleTo(width: number, height: number): void;
  83554. /**
  83555. * Gets the context of the canvas used by the texture
  83556. * @returns the canvas context of the dynamic texture
  83557. */
  83558. getContext(): CanvasRenderingContext2D;
  83559. /**
  83560. * Clears the texture
  83561. */
  83562. clear(): void;
  83563. /**
  83564. * Updates the texture
  83565. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83566. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83567. */
  83568. update(invertY?: boolean, premulAlpha?: boolean): void;
  83569. /**
  83570. * Draws text onto the texture
  83571. * @param text defines the text to be drawn
  83572. * @param x defines the placement of the text from the left
  83573. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83574. * @param font defines the font to be used with font-style, font-size, font-name
  83575. * @param color defines the color used for the text
  83576. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83577. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83578. * @param update defines whether texture is immediately update (default is true)
  83579. */
  83580. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83581. /**
  83582. * Clones the texture
  83583. * @returns the clone of the texture.
  83584. */
  83585. clone(): DynamicTexture;
  83586. /**
  83587. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83588. * @returns a serialized dynamic texture object
  83589. */
  83590. serialize(): any;
  83591. /** @hidden */
  83592. _rebuild(): void;
  83593. }
  83594. }
  83595. declare module BABYLON {
  83596. interface Engine {
  83597. /**
  83598. * Creates a raw texture
  83599. * @param data defines the data to store in the texture
  83600. * @param width defines the width of the texture
  83601. * @param height defines the height of the texture
  83602. * @param format defines the format of the data
  83603. * @param generateMipMaps defines if the engine should generate the mip levels
  83604. * @param invertY defines if data must be stored with Y axis inverted
  83605. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83606. * @param compression defines the compression used (null by default)
  83607. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83608. * @returns the raw texture inside an InternalTexture
  83609. */
  83610. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83611. /**
  83612. * Update a raw texture
  83613. * @param texture defines the texture to update
  83614. * @param data defines the data to store in the texture
  83615. * @param format defines the format of the data
  83616. * @param invertY defines if data must be stored with Y axis inverted
  83617. */
  83618. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83619. /**
  83620. * Update a raw texture
  83621. * @param texture defines the texture to update
  83622. * @param data defines the data to store in the texture
  83623. * @param format defines the format of the data
  83624. * @param invertY defines if data must be stored with Y axis inverted
  83625. * @param compression defines the compression used (null by default)
  83626. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83627. */
  83628. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83629. /**
  83630. * Creates a new raw cube texture
  83631. * @param data defines the array of data to use to create each face
  83632. * @param size defines the size of the textures
  83633. * @param format defines the format of the data
  83634. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83635. * @param generateMipMaps defines if the engine should generate the mip levels
  83636. * @param invertY defines if data must be stored with Y axis inverted
  83637. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83638. * @param compression defines the compression used (null by default)
  83639. * @returns the cube texture as an InternalTexture
  83640. */
  83641. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  83642. /**
  83643. * Update a raw cube texture
  83644. * @param texture defines the texture to udpdate
  83645. * @param data defines the data to store
  83646. * @param format defines the data format
  83647. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83648. * @param invertY defines if data must be stored with Y axis inverted
  83649. */
  83650. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  83651. /**
  83652. * Update a raw cube texture
  83653. * @param texture defines the texture to udpdate
  83654. * @param data defines the data to store
  83655. * @param format defines the data format
  83656. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83657. * @param invertY defines if data must be stored with Y axis inverted
  83658. * @param compression defines the compression used (null by default)
  83659. */
  83660. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  83661. /**
  83662. * Update a raw cube texture
  83663. * @param texture defines the texture to udpdate
  83664. * @param data defines the data to store
  83665. * @param format defines the data format
  83666. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83667. * @param invertY defines if data must be stored with Y axis inverted
  83668. * @param compression defines the compression used (null by default)
  83669. * @param level defines which level of the texture to update
  83670. */
  83671. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  83672. /**
  83673. * Creates a new raw cube texture from a specified url
  83674. * @param url defines the url where the data is located
  83675. * @param scene defines the current scene
  83676. * @param size defines the size of the textures
  83677. * @param format defines the format of the data
  83678. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83679. * @param noMipmap defines if the engine should avoid generating the mip levels
  83680. * @param callback defines a callback used to extract texture data from loaded data
  83681. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83682. * @param onLoad defines a callback called when texture is loaded
  83683. * @param onError defines a callback called if there is an error
  83684. * @returns the cube texture as an InternalTexture
  83685. */
  83686. 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;
  83687. /**
  83688. * Creates a new raw cube texture from a specified url
  83689. * @param url defines the url where the data is located
  83690. * @param scene defines the current scene
  83691. * @param size defines the size of the textures
  83692. * @param format defines the format of the data
  83693. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83694. * @param noMipmap defines if the engine should avoid generating the mip levels
  83695. * @param callback defines a callback used to extract texture data from loaded data
  83696. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83697. * @param onLoad defines a callback called when texture is loaded
  83698. * @param onError defines a callback called if there is an error
  83699. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83700. * @param invertY defines if data must be stored with Y axis inverted
  83701. * @returns the cube texture as an InternalTexture
  83702. */
  83703. 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;
  83704. /**
  83705. * Creates a new raw 3D texture
  83706. * @param data defines the data used to create the texture
  83707. * @param width defines the width of the texture
  83708. * @param height defines the height of the texture
  83709. * @param depth defines the depth of the texture
  83710. * @param format defines the format of the texture
  83711. * @param generateMipMaps defines if the engine must generate mip levels
  83712. * @param invertY defines if data must be stored with Y axis inverted
  83713. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83714. * @param compression defines the compressed used (can be null)
  83715. * @param textureType defines the compressed used (can be null)
  83716. * @returns a new raw 3D texture (stored in an InternalTexture)
  83717. */
  83718. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83719. /**
  83720. * Update a raw 3D texture
  83721. * @param texture defines the texture to update
  83722. * @param data defines the data to store
  83723. * @param format defines the data format
  83724. * @param invertY defines if data must be stored with Y axis inverted
  83725. */
  83726. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83727. /**
  83728. * Update a raw 3D texture
  83729. * @param texture defines the texture to update
  83730. * @param data defines the data to store
  83731. * @param format defines the data format
  83732. * @param invertY defines if data must be stored with Y axis inverted
  83733. * @param compression defines the used compression (can be null)
  83734. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83735. */
  83736. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83737. /**
  83738. * Creates a new raw 2D array texture
  83739. * @param data defines the data used to create the texture
  83740. * @param width defines the width of the texture
  83741. * @param height defines the height of the texture
  83742. * @param depth defines the number of layers of the texture
  83743. * @param format defines the format of the texture
  83744. * @param generateMipMaps defines if the engine must generate mip levels
  83745. * @param invertY defines if data must be stored with Y axis inverted
  83746. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83747. * @param compression defines the compressed used (can be null)
  83748. * @param textureType defines the compressed used (can be null)
  83749. * @returns a new raw 2D array texture (stored in an InternalTexture)
  83750. */
  83751. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83752. /**
  83753. * Update a raw 2D array texture
  83754. * @param texture defines the texture to update
  83755. * @param data defines the data to store
  83756. * @param format defines the data format
  83757. * @param invertY defines if data must be stored with Y axis inverted
  83758. */
  83759. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83760. /**
  83761. * Update a raw 2D array texture
  83762. * @param texture defines the texture to update
  83763. * @param data defines the data to store
  83764. * @param format defines the data format
  83765. * @param invertY defines if data must be stored with Y axis inverted
  83766. * @param compression defines the used compression (can be null)
  83767. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83768. */
  83769. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83770. }
  83771. }
  83772. declare module BABYLON {
  83773. /**
  83774. * Raw texture can help creating a texture directly from an array of data.
  83775. * This can be super useful if you either get the data from an uncompressed source or
  83776. * if you wish to create your texture pixel by pixel.
  83777. */
  83778. export class RawTexture extends Texture {
  83779. /**
  83780. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83781. */
  83782. format: number;
  83783. private _engine;
  83784. /**
  83785. * Instantiates a new RawTexture.
  83786. * Raw texture can help creating a texture directly from an array of data.
  83787. * This can be super useful if you either get the data from an uncompressed source or
  83788. * if you wish to create your texture pixel by pixel.
  83789. * @param data define the array of data to use to create the texture
  83790. * @param width define the width of the texture
  83791. * @param height define the height of the texture
  83792. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83793. * @param scene define the scene the texture belongs to
  83794. * @param generateMipMaps define whether mip maps should be generated or not
  83795. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83796. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83797. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83798. */
  83799. constructor(data: ArrayBufferView, width: number, height: number,
  83800. /**
  83801. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83802. */
  83803. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  83804. /**
  83805. * Updates the texture underlying data.
  83806. * @param data Define the new data of the texture
  83807. */
  83808. update(data: ArrayBufferView): void;
  83809. /**
  83810. * Creates a luminance texture from some data.
  83811. * @param data Define the texture data
  83812. * @param width Define the width of the texture
  83813. * @param height Define the height of the texture
  83814. * @param scene Define the scene the texture belongs to
  83815. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83816. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83817. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83818. * @returns the luminance texture
  83819. */
  83820. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83821. /**
  83822. * Creates a luminance alpha texture from some data.
  83823. * @param data Define the texture data
  83824. * @param width Define the width of the texture
  83825. * @param height Define the height of the texture
  83826. * @param scene Define the scene the texture belongs to
  83827. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83828. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83829. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83830. * @returns the luminance alpha texture
  83831. */
  83832. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83833. /**
  83834. * Creates an alpha texture from some data.
  83835. * @param data Define the texture data
  83836. * @param width Define the width of the texture
  83837. * @param height Define the height of the texture
  83838. * @param scene Define the scene the texture belongs to
  83839. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83840. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83841. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83842. * @returns the alpha texture
  83843. */
  83844. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83845. /**
  83846. * Creates a RGB texture from some data.
  83847. * @param data Define the texture data
  83848. * @param width Define the width of the texture
  83849. * @param height Define the height of the texture
  83850. * @param scene Define the scene the texture belongs to
  83851. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83852. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83853. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83854. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83855. * @returns the RGB alpha texture
  83856. */
  83857. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83858. /**
  83859. * Creates a RGBA texture from some data.
  83860. * @param data Define the texture data
  83861. * @param width Define the width of the texture
  83862. * @param height Define the height of the texture
  83863. * @param scene Define the scene the texture belongs to
  83864. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83865. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83866. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83867. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83868. * @returns the RGBA texture
  83869. */
  83870. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83871. /**
  83872. * Creates a R texture from some data.
  83873. * @param data Define the texture data
  83874. * @param width Define the width of the texture
  83875. * @param height Define the height of the texture
  83876. * @param scene Define the scene the texture belongs to
  83877. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83878. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83879. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83880. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83881. * @returns the R texture
  83882. */
  83883. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83884. }
  83885. }
  83886. declare module BABYLON {
  83887. interface AbstractScene {
  83888. /**
  83889. * The list of procedural textures added to the scene
  83890. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83891. */
  83892. proceduralTextures: Array<ProceduralTexture>;
  83893. }
  83894. /**
  83895. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  83896. * in a given scene.
  83897. */
  83898. export class ProceduralTextureSceneComponent implements ISceneComponent {
  83899. /**
  83900. * The component name helpfull to identify the component in the list of scene components.
  83901. */
  83902. readonly name: string;
  83903. /**
  83904. * The scene the component belongs to.
  83905. */
  83906. scene: Scene;
  83907. /**
  83908. * Creates a new instance of the component for the given scene
  83909. * @param scene Defines the scene to register the component in
  83910. */
  83911. constructor(scene: Scene);
  83912. /**
  83913. * Registers the component in a given scene
  83914. */
  83915. register(): void;
  83916. /**
  83917. * Rebuilds the elements related to this component in case of
  83918. * context lost for instance.
  83919. */
  83920. rebuild(): void;
  83921. /**
  83922. * Disposes the component and the associated ressources.
  83923. */
  83924. dispose(): void;
  83925. private _beforeClear;
  83926. }
  83927. }
  83928. declare module BABYLON {
  83929. interface ThinEngine {
  83930. /**
  83931. * Creates a new render target cube texture
  83932. * @param size defines the size of the texture
  83933. * @param options defines the options used to create the texture
  83934. * @returns a new render target cube texture stored in an InternalTexture
  83935. */
  83936. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  83937. }
  83938. }
  83939. declare module BABYLON {
  83940. /** @hidden */
  83941. export var proceduralVertexShader: {
  83942. name: string;
  83943. shader: string;
  83944. };
  83945. }
  83946. declare module BABYLON {
  83947. /**
  83948. * 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.
  83949. * This is the base class of any Procedural texture and contains most of the shareable code.
  83950. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83951. */
  83952. export class ProceduralTexture extends Texture {
  83953. isCube: boolean;
  83954. /**
  83955. * Define if the texture is enabled or not (disabled texture will not render)
  83956. */
  83957. isEnabled: boolean;
  83958. /**
  83959. * Define if the texture must be cleared before rendering (default is true)
  83960. */
  83961. autoClear: boolean;
  83962. /**
  83963. * Callback called when the texture is generated
  83964. */
  83965. onGenerated: () => void;
  83966. /**
  83967. * Event raised when the texture is generated
  83968. */
  83969. onGeneratedObservable: Observable<ProceduralTexture>;
  83970. /** @hidden */
  83971. _generateMipMaps: boolean;
  83972. /** @hidden **/
  83973. _effect: Effect;
  83974. /** @hidden */
  83975. _textures: {
  83976. [key: string]: Texture;
  83977. };
  83978. private _size;
  83979. private _currentRefreshId;
  83980. private _frameId;
  83981. private _refreshRate;
  83982. private _vertexBuffers;
  83983. private _indexBuffer;
  83984. private _uniforms;
  83985. private _samplers;
  83986. private _fragment;
  83987. private _floats;
  83988. private _ints;
  83989. private _floatsArrays;
  83990. private _colors3;
  83991. private _colors4;
  83992. private _vectors2;
  83993. private _vectors3;
  83994. private _matrices;
  83995. private _fallbackTexture;
  83996. private _fallbackTextureUsed;
  83997. private _engine;
  83998. private _cachedDefines;
  83999. private _contentUpdateId;
  84000. private _contentData;
  84001. /**
  84002. * Instantiates a new procedural texture.
  84003. * 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.
  84004. * This is the base class of any Procedural texture and contains most of the shareable code.
  84005. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84006. * @param name Define the name of the texture
  84007. * @param size Define the size of the texture to create
  84008. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84009. * @param scene Define the scene the texture belongs to
  84010. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84011. * @param generateMipMaps Define if the texture should creates mip maps or not
  84012. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84013. */
  84014. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84015. /**
  84016. * The effect that is created when initializing the post process.
  84017. * @returns The created effect corresponding the the postprocess.
  84018. */
  84019. getEffect(): Effect;
  84020. /**
  84021. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84022. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84023. */
  84024. getContent(): Nullable<ArrayBufferView>;
  84025. private _createIndexBuffer;
  84026. /** @hidden */
  84027. _rebuild(): void;
  84028. /**
  84029. * Resets the texture in order to recreate its associated resources.
  84030. * This can be called in case of context loss
  84031. */
  84032. reset(): void;
  84033. protected _getDefines(): string;
  84034. /**
  84035. * Is the texture ready to be used ? (rendered at least once)
  84036. * @returns true if ready, otherwise, false.
  84037. */
  84038. isReady(): boolean;
  84039. /**
  84040. * Resets the refresh counter of the texture and start bak from scratch.
  84041. * Could be useful to regenerate the texture if it is setup to render only once.
  84042. */
  84043. resetRefreshCounter(): void;
  84044. /**
  84045. * Set the fragment shader to use in order to render the texture.
  84046. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84047. */
  84048. setFragment(fragment: any): void;
  84049. /**
  84050. * Define the refresh rate of the texture or the rendering frequency.
  84051. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84052. */
  84053. get refreshRate(): number;
  84054. set refreshRate(value: number);
  84055. /** @hidden */
  84056. _shouldRender(): boolean;
  84057. /**
  84058. * Get the size the texture is rendering at.
  84059. * @returns the size (texture is always squared)
  84060. */
  84061. getRenderSize(): number;
  84062. /**
  84063. * Resize the texture to new value.
  84064. * @param size Define the new size the texture should have
  84065. * @param generateMipMaps Define whether the new texture should create mip maps
  84066. */
  84067. resize(size: number, generateMipMaps: boolean): void;
  84068. private _checkUniform;
  84069. /**
  84070. * Set a texture in the shader program used to render.
  84071. * @param name Define the name of the uniform samplers as defined in the shader
  84072. * @param texture Define the texture to bind to this sampler
  84073. * @return the texture itself allowing "fluent" like uniform updates
  84074. */
  84075. setTexture(name: string, texture: Texture): ProceduralTexture;
  84076. /**
  84077. * Set a float in the shader.
  84078. * @param name Define the name of the uniform as defined in the shader
  84079. * @param value Define the value to give to the uniform
  84080. * @return the texture itself allowing "fluent" like uniform updates
  84081. */
  84082. setFloat(name: string, value: number): ProceduralTexture;
  84083. /**
  84084. * Set a int in the shader.
  84085. * @param name Define the name of the uniform as defined in the shader
  84086. * @param value Define the value to give to the uniform
  84087. * @return the texture itself allowing "fluent" like uniform updates
  84088. */
  84089. setInt(name: string, value: number): ProceduralTexture;
  84090. /**
  84091. * Set an array of floats in the shader.
  84092. * @param name Define the name of the uniform as defined in the shader
  84093. * @param value Define the value to give to the uniform
  84094. * @return the texture itself allowing "fluent" like uniform updates
  84095. */
  84096. setFloats(name: string, value: number[]): ProceduralTexture;
  84097. /**
  84098. * Set a vec3 in the shader from a Color3.
  84099. * @param name Define the name of the uniform as defined in the shader
  84100. * @param value Define the value to give to the uniform
  84101. * @return the texture itself allowing "fluent" like uniform updates
  84102. */
  84103. setColor3(name: string, value: Color3): ProceduralTexture;
  84104. /**
  84105. * Set a vec4 in the shader from a Color4.
  84106. * @param name Define the name of the uniform as defined in the shader
  84107. * @param value Define the value to give to the uniform
  84108. * @return the texture itself allowing "fluent" like uniform updates
  84109. */
  84110. setColor4(name: string, value: Color4): ProceduralTexture;
  84111. /**
  84112. * Set a vec2 in the shader from a Vector2.
  84113. * @param name Define the name of the uniform as defined in the shader
  84114. * @param value Define the value to give to the uniform
  84115. * @return the texture itself allowing "fluent" like uniform updates
  84116. */
  84117. setVector2(name: string, value: Vector2): ProceduralTexture;
  84118. /**
  84119. * Set a vec3 in the shader from a Vector3.
  84120. * @param name Define the name of the uniform as defined in the shader
  84121. * @param value Define the value to give to the uniform
  84122. * @return the texture itself allowing "fluent" like uniform updates
  84123. */
  84124. setVector3(name: string, value: Vector3): ProceduralTexture;
  84125. /**
  84126. * Set a mat4 in the shader from a MAtrix.
  84127. * @param name Define the name of the uniform as defined in the shader
  84128. * @param value Define the value to give to the uniform
  84129. * @return the texture itself allowing "fluent" like uniform updates
  84130. */
  84131. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84132. /**
  84133. * Render the texture to its associated render target.
  84134. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84135. */
  84136. render(useCameraPostProcess?: boolean): void;
  84137. /**
  84138. * Clone the texture.
  84139. * @returns the cloned texture
  84140. */
  84141. clone(): ProceduralTexture;
  84142. /**
  84143. * Dispose the texture and release its asoociated resources.
  84144. */
  84145. dispose(): void;
  84146. }
  84147. }
  84148. declare module BABYLON {
  84149. /**
  84150. * This represents the base class for particle system in Babylon.
  84151. * 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.
  84152. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84153. * @example https://doc.babylonjs.com/babylon101/particles
  84154. */
  84155. export class BaseParticleSystem {
  84156. /**
  84157. * Source color is added to the destination color without alpha affecting the result
  84158. */
  84159. static BLENDMODE_ONEONE: number;
  84160. /**
  84161. * Blend current color and particle color using particle’s alpha
  84162. */
  84163. static BLENDMODE_STANDARD: number;
  84164. /**
  84165. * Add current color and particle color multiplied by particle’s alpha
  84166. */
  84167. static BLENDMODE_ADD: number;
  84168. /**
  84169. * Multiply current color with particle color
  84170. */
  84171. static BLENDMODE_MULTIPLY: number;
  84172. /**
  84173. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84174. */
  84175. static BLENDMODE_MULTIPLYADD: number;
  84176. /**
  84177. * List of animations used by the particle system.
  84178. */
  84179. animations: Animation[];
  84180. /**
  84181. * The id of the Particle system.
  84182. */
  84183. id: string;
  84184. /**
  84185. * The friendly name of the Particle system.
  84186. */
  84187. name: string;
  84188. /**
  84189. * The rendering group used by the Particle system to chose when to render.
  84190. */
  84191. renderingGroupId: number;
  84192. /**
  84193. * The emitter represents the Mesh or position we are attaching the particle system to.
  84194. */
  84195. emitter: Nullable<AbstractMesh | Vector3>;
  84196. /**
  84197. * The maximum number of particles to emit per frame
  84198. */
  84199. emitRate: number;
  84200. /**
  84201. * If you want to launch only a few particles at once, that can be done, as well.
  84202. */
  84203. manualEmitCount: number;
  84204. /**
  84205. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84206. */
  84207. updateSpeed: number;
  84208. /**
  84209. * The amount of time the particle system is running (depends of the overall update speed).
  84210. */
  84211. targetStopDuration: number;
  84212. /**
  84213. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84214. */
  84215. disposeOnStop: boolean;
  84216. /**
  84217. * Minimum power of emitting particles.
  84218. */
  84219. minEmitPower: number;
  84220. /**
  84221. * Maximum power of emitting particles.
  84222. */
  84223. maxEmitPower: number;
  84224. /**
  84225. * Minimum life time of emitting particles.
  84226. */
  84227. minLifeTime: number;
  84228. /**
  84229. * Maximum life time of emitting particles.
  84230. */
  84231. maxLifeTime: number;
  84232. /**
  84233. * Minimum Size of emitting particles.
  84234. */
  84235. minSize: number;
  84236. /**
  84237. * Maximum Size of emitting particles.
  84238. */
  84239. maxSize: number;
  84240. /**
  84241. * Minimum scale of emitting particles on X axis.
  84242. */
  84243. minScaleX: number;
  84244. /**
  84245. * Maximum scale of emitting particles on X axis.
  84246. */
  84247. maxScaleX: number;
  84248. /**
  84249. * Minimum scale of emitting particles on Y axis.
  84250. */
  84251. minScaleY: number;
  84252. /**
  84253. * Maximum scale of emitting particles on Y axis.
  84254. */
  84255. maxScaleY: number;
  84256. /**
  84257. * Gets or sets the minimal initial rotation in radians.
  84258. */
  84259. minInitialRotation: number;
  84260. /**
  84261. * Gets or sets the maximal initial rotation in radians.
  84262. */
  84263. maxInitialRotation: number;
  84264. /**
  84265. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84266. */
  84267. minAngularSpeed: number;
  84268. /**
  84269. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84270. */
  84271. maxAngularSpeed: number;
  84272. /**
  84273. * The texture used to render each particle. (this can be a spritesheet)
  84274. */
  84275. particleTexture: Nullable<Texture>;
  84276. /**
  84277. * The layer mask we are rendering the particles through.
  84278. */
  84279. layerMask: number;
  84280. /**
  84281. * This can help using your own shader to render the particle system.
  84282. * The according effect will be created
  84283. */
  84284. customShader: any;
  84285. /**
  84286. * By default particle system starts as soon as they are created. This prevents the
  84287. * automatic start to happen and let you decide when to start emitting particles.
  84288. */
  84289. preventAutoStart: boolean;
  84290. private _noiseTexture;
  84291. /**
  84292. * Gets or sets a texture used to add random noise to particle positions
  84293. */
  84294. get noiseTexture(): Nullable<ProceduralTexture>;
  84295. set noiseTexture(value: Nullable<ProceduralTexture>);
  84296. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84297. noiseStrength: Vector3;
  84298. /**
  84299. * Callback triggered when the particle animation is ending.
  84300. */
  84301. onAnimationEnd: Nullable<() => void>;
  84302. /**
  84303. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84304. */
  84305. blendMode: number;
  84306. /**
  84307. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84308. * to override the particles.
  84309. */
  84310. forceDepthWrite: boolean;
  84311. /** 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 */
  84312. preWarmCycles: number;
  84313. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84314. preWarmStepOffset: number;
  84315. /**
  84316. * 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)
  84317. */
  84318. spriteCellChangeSpeed: number;
  84319. /**
  84320. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84321. */
  84322. startSpriteCellID: number;
  84323. /**
  84324. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84325. */
  84326. endSpriteCellID: number;
  84327. /**
  84328. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84329. */
  84330. spriteCellWidth: number;
  84331. /**
  84332. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84333. */
  84334. spriteCellHeight: number;
  84335. /**
  84336. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84337. */
  84338. spriteRandomStartCell: boolean;
  84339. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84340. translationPivot: Vector2;
  84341. /** @hidden */
  84342. protected _isAnimationSheetEnabled: boolean;
  84343. /**
  84344. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84345. */
  84346. beginAnimationOnStart: boolean;
  84347. /**
  84348. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84349. */
  84350. beginAnimationFrom: number;
  84351. /**
  84352. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84353. */
  84354. beginAnimationTo: number;
  84355. /**
  84356. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84357. */
  84358. beginAnimationLoop: boolean;
  84359. /**
  84360. * Gets or sets a world offset applied to all particles
  84361. */
  84362. worldOffset: Vector3;
  84363. /**
  84364. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84365. */
  84366. get isAnimationSheetEnabled(): boolean;
  84367. set isAnimationSheetEnabled(value: boolean);
  84368. /**
  84369. * Get hosting scene
  84370. * @returns the scene
  84371. */
  84372. getScene(): Scene;
  84373. /**
  84374. * You can use gravity if you want to give an orientation to your particles.
  84375. */
  84376. gravity: Vector3;
  84377. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84378. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84379. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84380. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84381. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84382. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84383. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84384. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84385. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84386. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84387. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84388. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84389. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84390. /**
  84391. * Defines the delay in milliseconds before starting the system (0 by default)
  84392. */
  84393. startDelay: number;
  84394. /**
  84395. * Gets the current list of drag gradients.
  84396. * You must use addDragGradient and removeDragGradient to udpate this list
  84397. * @returns the list of drag gradients
  84398. */
  84399. getDragGradients(): Nullable<Array<FactorGradient>>;
  84400. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84401. limitVelocityDamping: number;
  84402. /**
  84403. * Gets the current list of limit velocity gradients.
  84404. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84405. * @returns the list of limit velocity gradients
  84406. */
  84407. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84408. /**
  84409. * Gets the current list of color gradients.
  84410. * You must use addColorGradient and removeColorGradient to udpate this list
  84411. * @returns the list of color gradients
  84412. */
  84413. getColorGradients(): Nullable<Array<ColorGradient>>;
  84414. /**
  84415. * Gets the current list of size gradients.
  84416. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84417. * @returns the list of size gradients
  84418. */
  84419. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84420. /**
  84421. * Gets the current list of color remap gradients.
  84422. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84423. * @returns the list of color remap gradients
  84424. */
  84425. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84426. /**
  84427. * Gets the current list of alpha remap gradients.
  84428. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84429. * @returns the list of alpha remap gradients
  84430. */
  84431. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84432. /**
  84433. * Gets the current list of life time gradients.
  84434. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84435. * @returns the list of life time gradients
  84436. */
  84437. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84438. /**
  84439. * Gets the current list of angular speed gradients.
  84440. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84441. * @returns the list of angular speed gradients
  84442. */
  84443. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84444. /**
  84445. * Gets the current list of velocity gradients.
  84446. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84447. * @returns the list of velocity gradients
  84448. */
  84449. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84450. /**
  84451. * Gets the current list of start size gradients.
  84452. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84453. * @returns the list of start size gradients
  84454. */
  84455. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84456. /**
  84457. * Gets the current list of emit rate gradients.
  84458. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84459. * @returns the list of emit rate gradients
  84460. */
  84461. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84462. /**
  84463. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84464. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84465. */
  84466. get direction1(): Vector3;
  84467. set direction1(value: Vector3);
  84468. /**
  84469. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84470. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84471. */
  84472. get direction2(): Vector3;
  84473. set direction2(value: Vector3);
  84474. /**
  84475. * 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.
  84476. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84477. */
  84478. get minEmitBox(): Vector3;
  84479. set minEmitBox(value: Vector3);
  84480. /**
  84481. * 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.
  84482. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84483. */
  84484. get maxEmitBox(): Vector3;
  84485. set maxEmitBox(value: Vector3);
  84486. /**
  84487. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84488. */
  84489. color1: Color4;
  84490. /**
  84491. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84492. */
  84493. color2: Color4;
  84494. /**
  84495. * Color the particle will have at the end of its lifetime
  84496. */
  84497. colorDead: Color4;
  84498. /**
  84499. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84500. */
  84501. textureMask: Color4;
  84502. /**
  84503. * The particle emitter type defines the emitter used by the particle system.
  84504. * It can be for example box, sphere, or cone...
  84505. */
  84506. particleEmitterType: IParticleEmitterType;
  84507. /** @hidden */
  84508. _isSubEmitter: boolean;
  84509. /**
  84510. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84511. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84512. */
  84513. billboardMode: number;
  84514. protected _isBillboardBased: boolean;
  84515. /**
  84516. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84517. */
  84518. get isBillboardBased(): boolean;
  84519. set isBillboardBased(value: boolean);
  84520. /**
  84521. * The scene the particle system belongs to.
  84522. */
  84523. protected _scene: Scene;
  84524. /**
  84525. * Local cache of defines for image processing.
  84526. */
  84527. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84528. /**
  84529. * Default configuration related to image processing available in the standard Material.
  84530. */
  84531. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84532. /**
  84533. * Gets the image processing configuration used either in this material.
  84534. */
  84535. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  84536. /**
  84537. * Sets the Default image processing configuration used either in the this material.
  84538. *
  84539. * If sets to null, the scene one is in use.
  84540. */
  84541. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  84542. /**
  84543. * Attaches a new image processing configuration to the Standard Material.
  84544. * @param configuration
  84545. */
  84546. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84547. /** @hidden */
  84548. protected _reset(): void;
  84549. /** @hidden */
  84550. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84551. /**
  84552. * Instantiates a particle system.
  84553. * 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.
  84554. * @param name The name of the particle system
  84555. */
  84556. constructor(name: string);
  84557. /**
  84558. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84559. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84560. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84561. * @returns the emitter
  84562. */
  84563. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84564. /**
  84565. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84566. * @param radius The radius of the hemisphere to emit from
  84567. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84568. * @returns the emitter
  84569. */
  84570. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84571. /**
  84572. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84573. * @param radius The radius of the sphere to emit from
  84574. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84575. * @returns the emitter
  84576. */
  84577. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84578. /**
  84579. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84580. * @param radius The radius of the sphere to emit from
  84581. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84582. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84583. * @returns the emitter
  84584. */
  84585. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84586. /**
  84587. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84588. * @param radius The radius of the emission cylinder
  84589. * @param height The height of the emission cylinder
  84590. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84591. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84592. * @returns the emitter
  84593. */
  84594. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84595. /**
  84596. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84597. * @param radius The radius of the cylinder to emit from
  84598. * @param height The height of the emission cylinder
  84599. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84600. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84601. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84602. * @returns the emitter
  84603. */
  84604. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84605. /**
  84606. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84607. * @param radius The radius of the cone to emit from
  84608. * @param angle The base angle of the cone
  84609. * @returns the emitter
  84610. */
  84611. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84612. /**
  84613. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84614. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84615. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84616. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84617. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84618. * @returns the emitter
  84619. */
  84620. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84621. }
  84622. }
  84623. declare module BABYLON {
  84624. /**
  84625. * Type of sub emitter
  84626. */
  84627. export enum SubEmitterType {
  84628. /**
  84629. * Attached to the particle over it's lifetime
  84630. */
  84631. ATTACHED = 0,
  84632. /**
  84633. * Created when the particle dies
  84634. */
  84635. END = 1
  84636. }
  84637. /**
  84638. * Sub emitter class used to emit particles from an existing particle
  84639. */
  84640. export class SubEmitter {
  84641. /**
  84642. * the particle system to be used by the sub emitter
  84643. */
  84644. particleSystem: ParticleSystem;
  84645. /**
  84646. * Type of the submitter (Default: END)
  84647. */
  84648. type: SubEmitterType;
  84649. /**
  84650. * 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)
  84651. * Note: This only is supported when using an emitter of type Mesh
  84652. */
  84653. inheritDirection: boolean;
  84654. /**
  84655. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84656. */
  84657. inheritedVelocityAmount: number;
  84658. /**
  84659. * Creates a sub emitter
  84660. * @param particleSystem the particle system to be used by the sub emitter
  84661. */
  84662. constructor(
  84663. /**
  84664. * the particle system to be used by the sub emitter
  84665. */
  84666. particleSystem: ParticleSystem);
  84667. /**
  84668. * Clones the sub emitter
  84669. * @returns the cloned sub emitter
  84670. */
  84671. clone(): SubEmitter;
  84672. /**
  84673. * Serialize current object to a JSON object
  84674. * @returns the serialized object
  84675. */
  84676. serialize(): any;
  84677. /** @hidden */
  84678. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84679. /**
  84680. * Creates a new SubEmitter from a serialized JSON version
  84681. * @param serializationObject defines the JSON object to read from
  84682. * @param scene defines the hosting scene
  84683. * @param rootUrl defines the rootUrl for data loading
  84684. * @returns a new SubEmitter
  84685. */
  84686. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84687. /** Release associated resources */
  84688. dispose(): void;
  84689. }
  84690. }
  84691. declare module BABYLON {
  84692. /** @hidden */
  84693. export var imageProcessingDeclaration: {
  84694. name: string;
  84695. shader: string;
  84696. };
  84697. }
  84698. declare module BABYLON {
  84699. /** @hidden */
  84700. export var imageProcessingFunctions: {
  84701. name: string;
  84702. shader: string;
  84703. };
  84704. }
  84705. declare module BABYLON {
  84706. /** @hidden */
  84707. export var particlesPixelShader: {
  84708. name: string;
  84709. shader: string;
  84710. };
  84711. }
  84712. declare module BABYLON {
  84713. /** @hidden */
  84714. export var particlesVertexShader: {
  84715. name: string;
  84716. shader: string;
  84717. };
  84718. }
  84719. declare module BABYLON {
  84720. /**
  84721. * This represents a particle system in Babylon.
  84722. * 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.
  84723. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84724. * @example https://doc.babylonjs.com/babylon101/particles
  84725. */
  84726. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84727. /**
  84728. * Billboard mode will only apply to Y axis
  84729. */
  84730. static readonly BILLBOARDMODE_Y: number;
  84731. /**
  84732. * Billboard mode will apply to all axes
  84733. */
  84734. static readonly BILLBOARDMODE_ALL: number;
  84735. /**
  84736. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84737. */
  84738. static readonly BILLBOARDMODE_STRETCHED: number;
  84739. /**
  84740. * This function can be defined to provide custom update for active particles.
  84741. * This function will be called instead of regular update (age, position, color, etc.).
  84742. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84743. */
  84744. updateFunction: (particles: Particle[]) => void;
  84745. private _emitterWorldMatrix;
  84746. /**
  84747. * This function can be defined to specify initial direction for every new particle.
  84748. * It by default use the emitterType defined function
  84749. */
  84750. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  84751. /**
  84752. * This function can be defined to specify initial position for every new particle.
  84753. * It by default use the emitterType defined function
  84754. */
  84755. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  84756. /**
  84757. * @hidden
  84758. */
  84759. _inheritedVelocityOffset: Vector3;
  84760. /**
  84761. * An event triggered when the system is disposed
  84762. */
  84763. onDisposeObservable: Observable<ParticleSystem>;
  84764. private _onDisposeObserver;
  84765. /**
  84766. * Sets a callback that will be triggered when the system is disposed
  84767. */
  84768. set onDispose(callback: () => void);
  84769. private _particles;
  84770. private _epsilon;
  84771. private _capacity;
  84772. private _stockParticles;
  84773. private _newPartsExcess;
  84774. private _vertexData;
  84775. private _vertexBuffer;
  84776. private _vertexBuffers;
  84777. private _spriteBuffer;
  84778. private _indexBuffer;
  84779. private _effect;
  84780. private _customEffect;
  84781. private _cachedDefines;
  84782. private _scaledColorStep;
  84783. private _colorDiff;
  84784. private _scaledDirection;
  84785. private _scaledGravity;
  84786. private _currentRenderId;
  84787. private _alive;
  84788. private _useInstancing;
  84789. private _started;
  84790. private _stopped;
  84791. private _actualFrame;
  84792. private _scaledUpdateSpeed;
  84793. private _vertexBufferSize;
  84794. /** @hidden */
  84795. _currentEmitRateGradient: Nullable<FactorGradient>;
  84796. /** @hidden */
  84797. _currentEmitRate1: number;
  84798. /** @hidden */
  84799. _currentEmitRate2: number;
  84800. /** @hidden */
  84801. _currentStartSizeGradient: Nullable<FactorGradient>;
  84802. /** @hidden */
  84803. _currentStartSize1: number;
  84804. /** @hidden */
  84805. _currentStartSize2: number;
  84806. private readonly _rawTextureWidth;
  84807. private _rampGradientsTexture;
  84808. private _useRampGradients;
  84809. /** Gets or sets a boolean indicating that ramp gradients must be used
  84810. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84811. */
  84812. get useRampGradients(): boolean;
  84813. set useRampGradients(value: boolean);
  84814. /**
  84815. * 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.
  84816. * 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: [])
  84817. */
  84818. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  84819. private _subEmitters;
  84820. /**
  84821. * @hidden
  84822. * If the particle systems emitter should be disposed when the particle system is disposed
  84823. */
  84824. _disposeEmitterOnDispose: boolean;
  84825. /**
  84826. * The current active Sub-systems, this property is used by the root particle system only.
  84827. */
  84828. activeSubSystems: Array<ParticleSystem>;
  84829. private _rootParticleSystem;
  84830. /**
  84831. * Gets the current list of active particles
  84832. */
  84833. get particles(): Particle[];
  84834. /**
  84835. * Returns the string "ParticleSystem"
  84836. * @returns a string containing the class name
  84837. */
  84838. getClassName(): string;
  84839. /**
  84840. * Instantiates a particle system.
  84841. * 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.
  84842. * @param name The name of the particle system
  84843. * @param capacity The max number of particles alive at the same time
  84844. * @param scene The scene the particle system belongs to
  84845. * @param customEffect a custom effect used to change the way particles are rendered by default
  84846. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  84847. * @param epsilon Offset used to render the particles
  84848. */
  84849. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  84850. private _addFactorGradient;
  84851. private _removeFactorGradient;
  84852. /**
  84853. * Adds a new life time gradient
  84854. * @param gradient defines the gradient to use (between 0 and 1)
  84855. * @param factor defines the life time factor to affect to the specified gradient
  84856. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84857. * @returns the current particle system
  84858. */
  84859. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84860. /**
  84861. * Remove a specific life time gradient
  84862. * @param gradient defines the gradient to remove
  84863. * @returns the current particle system
  84864. */
  84865. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84866. /**
  84867. * Adds a new size gradient
  84868. * @param gradient defines the gradient to use (between 0 and 1)
  84869. * @param factor defines the size factor to affect to the specified gradient
  84870. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84871. * @returns the current particle system
  84872. */
  84873. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84874. /**
  84875. * Remove a specific size gradient
  84876. * @param gradient defines the gradient to remove
  84877. * @returns the current particle system
  84878. */
  84879. removeSizeGradient(gradient: number): IParticleSystem;
  84880. /**
  84881. * Adds a new color remap gradient
  84882. * @param gradient defines the gradient to use (between 0 and 1)
  84883. * @param min defines the color remap minimal range
  84884. * @param max defines the color remap maximal range
  84885. * @returns the current particle system
  84886. */
  84887. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84888. /**
  84889. * Remove a specific color remap gradient
  84890. * @param gradient defines the gradient to remove
  84891. * @returns the current particle system
  84892. */
  84893. removeColorRemapGradient(gradient: number): IParticleSystem;
  84894. /**
  84895. * Adds a new alpha remap gradient
  84896. * @param gradient defines the gradient to use (between 0 and 1)
  84897. * @param min defines the alpha remap minimal range
  84898. * @param max defines the alpha remap maximal range
  84899. * @returns the current particle system
  84900. */
  84901. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84902. /**
  84903. * Remove a specific alpha remap gradient
  84904. * @param gradient defines the gradient to remove
  84905. * @returns the current particle system
  84906. */
  84907. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  84908. /**
  84909. * Adds a new angular speed gradient
  84910. * @param gradient defines the gradient to use (between 0 and 1)
  84911. * @param factor defines the angular speed to affect to the specified gradient
  84912. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84913. * @returns the current particle system
  84914. */
  84915. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84916. /**
  84917. * Remove a specific angular speed gradient
  84918. * @param gradient defines the gradient to remove
  84919. * @returns the current particle system
  84920. */
  84921. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84922. /**
  84923. * Adds a new velocity gradient
  84924. * @param gradient defines the gradient to use (between 0 and 1)
  84925. * @param factor defines the velocity to affect to the specified gradient
  84926. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84927. * @returns the current particle system
  84928. */
  84929. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84930. /**
  84931. * Remove a specific velocity gradient
  84932. * @param gradient defines the gradient to remove
  84933. * @returns the current particle system
  84934. */
  84935. removeVelocityGradient(gradient: number): IParticleSystem;
  84936. /**
  84937. * Adds a new limit velocity gradient
  84938. * @param gradient defines the gradient to use (between 0 and 1)
  84939. * @param factor defines the limit velocity value to affect to the specified gradient
  84940. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84941. * @returns the current particle system
  84942. */
  84943. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84944. /**
  84945. * Remove a specific limit velocity gradient
  84946. * @param gradient defines the gradient to remove
  84947. * @returns the current particle system
  84948. */
  84949. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84950. /**
  84951. * Adds a new drag gradient
  84952. * @param gradient defines the gradient to use (between 0 and 1)
  84953. * @param factor defines the drag value to affect to the specified gradient
  84954. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84955. * @returns the current particle system
  84956. */
  84957. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84958. /**
  84959. * Remove a specific drag gradient
  84960. * @param gradient defines the gradient to remove
  84961. * @returns the current particle system
  84962. */
  84963. removeDragGradient(gradient: number): IParticleSystem;
  84964. /**
  84965. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84966. * @param gradient defines the gradient to use (between 0 and 1)
  84967. * @param factor defines the emit rate value to affect to the specified gradient
  84968. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84969. * @returns the current particle system
  84970. */
  84971. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84972. /**
  84973. * Remove a specific emit rate gradient
  84974. * @param gradient defines the gradient to remove
  84975. * @returns the current particle system
  84976. */
  84977. removeEmitRateGradient(gradient: number): IParticleSystem;
  84978. /**
  84979. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84980. * @param gradient defines the gradient to use (between 0 and 1)
  84981. * @param factor defines the start size value to affect to the specified gradient
  84982. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84983. * @returns the current particle system
  84984. */
  84985. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84986. /**
  84987. * Remove a specific start size gradient
  84988. * @param gradient defines the gradient to remove
  84989. * @returns the current particle system
  84990. */
  84991. removeStartSizeGradient(gradient: number): IParticleSystem;
  84992. private _createRampGradientTexture;
  84993. /**
  84994. * Gets the current list of ramp gradients.
  84995. * You must use addRampGradient and removeRampGradient to udpate this list
  84996. * @returns the list of ramp gradients
  84997. */
  84998. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84999. /**
  85000. * Adds a new ramp gradient used to remap particle colors
  85001. * @param gradient defines the gradient to use (between 0 and 1)
  85002. * @param color defines the color to affect to the specified gradient
  85003. * @returns the current particle system
  85004. */
  85005. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85006. /**
  85007. * Remove a specific ramp gradient
  85008. * @param gradient defines the gradient to remove
  85009. * @returns the current particle system
  85010. */
  85011. removeRampGradient(gradient: number): ParticleSystem;
  85012. /**
  85013. * Adds a new color gradient
  85014. * @param gradient defines the gradient to use (between 0 and 1)
  85015. * @param color1 defines the color to affect to the specified gradient
  85016. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85017. * @returns this particle system
  85018. */
  85019. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85020. /**
  85021. * Remove a specific color gradient
  85022. * @param gradient defines the gradient to remove
  85023. * @returns this particle system
  85024. */
  85025. removeColorGradient(gradient: number): IParticleSystem;
  85026. private _fetchR;
  85027. protected _reset(): void;
  85028. private _resetEffect;
  85029. private _createVertexBuffers;
  85030. private _createIndexBuffer;
  85031. /**
  85032. * Gets the maximum number of particles active at the same time.
  85033. * @returns The max number of active particles.
  85034. */
  85035. getCapacity(): number;
  85036. /**
  85037. * Gets whether there are still active particles in the system.
  85038. * @returns True if it is alive, otherwise false.
  85039. */
  85040. isAlive(): boolean;
  85041. /**
  85042. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85043. * @returns True if it has been started, otherwise false.
  85044. */
  85045. isStarted(): boolean;
  85046. private _prepareSubEmitterInternalArray;
  85047. /**
  85048. * Starts the particle system and begins to emit
  85049. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85050. */
  85051. start(delay?: number): void;
  85052. /**
  85053. * Stops the particle system.
  85054. * @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.
  85055. */
  85056. stop(stopSubEmitters?: boolean): void;
  85057. /**
  85058. * Remove all active particles
  85059. */
  85060. reset(): void;
  85061. /**
  85062. * @hidden (for internal use only)
  85063. */
  85064. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85065. /**
  85066. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85067. * Its lifetime will start back at 0.
  85068. */
  85069. recycleParticle: (particle: Particle) => void;
  85070. private _stopSubEmitters;
  85071. private _createParticle;
  85072. private _removeFromRoot;
  85073. private _emitFromParticle;
  85074. private _update;
  85075. /** @hidden */
  85076. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85077. /** @hidden */
  85078. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85079. /** @hidden */
  85080. private _getEffect;
  85081. /**
  85082. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85083. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85084. */
  85085. animate(preWarmOnly?: boolean): void;
  85086. private _appendParticleVertices;
  85087. /**
  85088. * Rebuilds the particle system.
  85089. */
  85090. rebuild(): void;
  85091. /**
  85092. * Is this system ready to be used/rendered
  85093. * @return true if the system is ready
  85094. */
  85095. isReady(): boolean;
  85096. private _render;
  85097. /**
  85098. * Renders the particle system in its current state.
  85099. * @returns the current number of particles
  85100. */
  85101. render(): number;
  85102. /**
  85103. * Disposes the particle system and free the associated resources
  85104. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85105. */
  85106. dispose(disposeTexture?: boolean): void;
  85107. /**
  85108. * Clones the particle system.
  85109. * @param name The name of the cloned object
  85110. * @param newEmitter The new emitter to use
  85111. * @returns the cloned particle system
  85112. */
  85113. clone(name: string, newEmitter: any): ParticleSystem;
  85114. /**
  85115. * Serializes the particle system to a JSON object.
  85116. * @returns the JSON object
  85117. */
  85118. serialize(): any;
  85119. /** @hidden */
  85120. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85121. /** @hidden */
  85122. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85123. /**
  85124. * Parses a JSON object to create a particle system.
  85125. * @param parsedParticleSystem The JSON object to parse
  85126. * @param scene The scene to create the particle system in
  85127. * @param rootUrl The root url to use to load external dependencies like texture
  85128. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85129. * @returns the Parsed particle system
  85130. */
  85131. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85132. }
  85133. }
  85134. declare module BABYLON {
  85135. /**
  85136. * A particle represents one of the element emitted by a particle system.
  85137. * This is mainly define by its coordinates, direction, velocity and age.
  85138. */
  85139. export class Particle {
  85140. /**
  85141. * The particle system the particle belongs to.
  85142. */
  85143. particleSystem: ParticleSystem;
  85144. private static _Count;
  85145. /**
  85146. * Unique ID of the particle
  85147. */
  85148. id: number;
  85149. /**
  85150. * The world position of the particle in the scene.
  85151. */
  85152. position: Vector3;
  85153. /**
  85154. * The world direction of the particle in the scene.
  85155. */
  85156. direction: Vector3;
  85157. /**
  85158. * The color of the particle.
  85159. */
  85160. color: Color4;
  85161. /**
  85162. * The color change of the particle per step.
  85163. */
  85164. colorStep: Color4;
  85165. /**
  85166. * Defines how long will the life of the particle be.
  85167. */
  85168. lifeTime: number;
  85169. /**
  85170. * The current age of the particle.
  85171. */
  85172. age: number;
  85173. /**
  85174. * The current size of the particle.
  85175. */
  85176. size: number;
  85177. /**
  85178. * The current scale of the particle.
  85179. */
  85180. scale: Vector2;
  85181. /**
  85182. * The current angle of the particle.
  85183. */
  85184. angle: number;
  85185. /**
  85186. * Defines how fast is the angle changing.
  85187. */
  85188. angularSpeed: number;
  85189. /**
  85190. * Defines the cell index used by the particle to be rendered from a sprite.
  85191. */
  85192. cellIndex: number;
  85193. /**
  85194. * The information required to support color remapping
  85195. */
  85196. remapData: Vector4;
  85197. /** @hidden */
  85198. _randomCellOffset?: number;
  85199. /** @hidden */
  85200. _initialDirection: Nullable<Vector3>;
  85201. /** @hidden */
  85202. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85203. /** @hidden */
  85204. _initialStartSpriteCellID: number;
  85205. /** @hidden */
  85206. _initialEndSpriteCellID: number;
  85207. /** @hidden */
  85208. _currentColorGradient: Nullable<ColorGradient>;
  85209. /** @hidden */
  85210. _currentColor1: Color4;
  85211. /** @hidden */
  85212. _currentColor2: Color4;
  85213. /** @hidden */
  85214. _currentSizeGradient: Nullable<FactorGradient>;
  85215. /** @hidden */
  85216. _currentSize1: number;
  85217. /** @hidden */
  85218. _currentSize2: number;
  85219. /** @hidden */
  85220. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85221. /** @hidden */
  85222. _currentAngularSpeed1: number;
  85223. /** @hidden */
  85224. _currentAngularSpeed2: number;
  85225. /** @hidden */
  85226. _currentVelocityGradient: Nullable<FactorGradient>;
  85227. /** @hidden */
  85228. _currentVelocity1: number;
  85229. /** @hidden */
  85230. _currentVelocity2: number;
  85231. /** @hidden */
  85232. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85233. /** @hidden */
  85234. _currentLimitVelocity1: number;
  85235. /** @hidden */
  85236. _currentLimitVelocity2: number;
  85237. /** @hidden */
  85238. _currentDragGradient: Nullable<FactorGradient>;
  85239. /** @hidden */
  85240. _currentDrag1: number;
  85241. /** @hidden */
  85242. _currentDrag2: number;
  85243. /** @hidden */
  85244. _randomNoiseCoordinates1: Vector3;
  85245. /** @hidden */
  85246. _randomNoiseCoordinates2: Vector3;
  85247. /**
  85248. * Creates a new instance Particle
  85249. * @param particleSystem the particle system the particle belongs to
  85250. */
  85251. constructor(
  85252. /**
  85253. * The particle system the particle belongs to.
  85254. */
  85255. particleSystem: ParticleSystem);
  85256. private updateCellInfoFromSystem;
  85257. /**
  85258. * Defines how the sprite cell index is updated for the particle
  85259. */
  85260. updateCellIndex(): void;
  85261. /** @hidden */
  85262. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85263. /** @hidden */
  85264. _inheritParticleInfoToSubEmitters(): void;
  85265. /** @hidden */
  85266. _reset(): void;
  85267. /**
  85268. * Copy the properties of particle to another one.
  85269. * @param other the particle to copy the information to.
  85270. */
  85271. copyTo(other: Particle): void;
  85272. }
  85273. }
  85274. declare module BABYLON {
  85275. /**
  85276. * Particle emitter represents a volume emitting particles.
  85277. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85278. */
  85279. export interface IParticleEmitterType {
  85280. /**
  85281. * Called by the particle System when the direction is computed for the created particle.
  85282. * @param worldMatrix is the world matrix of the particle system
  85283. * @param directionToUpdate is the direction vector to update with the result
  85284. * @param particle is the particle we are computed the direction for
  85285. */
  85286. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85287. /**
  85288. * Called by the particle System when the position is computed for the created particle.
  85289. * @param worldMatrix is the world matrix of the particle system
  85290. * @param positionToUpdate is the position vector to update with the result
  85291. * @param particle is the particle we are computed the position for
  85292. */
  85293. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85294. /**
  85295. * Clones the current emitter and returns a copy of it
  85296. * @returns the new emitter
  85297. */
  85298. clone(): IParticleEmitterType;
  85299. /**
  85300. * Called by the GPUParticleSystem to setup the update shader
  85301. * @param effect defines the update shader
  85302. */
  85303. applyToShader(effect: Effect): void;
  85304. /**
  85305. * Returns a string to use to update the GPU particles update shader
  85306. * @returns the effect defines string
  85307. */
  85308. getEffectDefines(): string;
  85309. /**
  85310. * Returns a string representing the class name
  85311. * @returns a string containing the class name
  85312. */
  85313. getClassName(): string;
  85314. /**
  85315. * Serializes the particle system to a JSON object.
  85316. * @returns the JSON object
  85317. */
  85318. serialize(): any;
  85319. /**
  85320. * Parse properties from a JSON object
  85321. * @param serializationObject defines the JSON object
  85322. * @param scene defines the hosting scene
  85323. */
  85324. parse(serializationObject: any, scene: Scene): void;
  85325. }
  85326. }
  85327. declare module BABYLON {
  85328. /**
  85329. * Particle emitter emitting particles from the inside of a box.
  85330. * It emits the particles randomly between 2 given directions.
  85331. */
  85332. export class BoxParticleEmitter implements IParticleEmitterType {
  85333. /**
  85334. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85335. */
  85336. direction1: Vector3;
  85337. /**
  85338. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85339. */
  85340. direction2: Vector3;
  85341. /**
  85342. * 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.
  85343. */
  85344. minEmitBox: Vector3;
  85345. /**
  85346. * 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.
  85347. */
  85348. maxEmitBox: Vector3;
  85349. /**
  85350. * Creates a new instance BoxParticleEmitter
  85351. */
  85352. constructor();
  85353. /**
  85354. * Called by the particle System when the direction is computed for the created particle.
  85355. * @param worldMatrix is the world matrix of the particle system
  85356. * @param directionToUpdate is the direction vector to update with the result
  85357. * @param particle is the particle we are computed the direction for
  85358. */
  85359. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85360. /**
  85361. * Called by the particle System when the position is computed for the created particle.
  85362. * @param worldMatrix is the world matrix of the particle system
  85363. * @param positionToUpdate is the position vector to update with the result
  85364. * @param particle is the particle we are computed the position for
  85365. */
  85366. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85367. /**
  85368. * Clones the current emitter and returns a copy of it
  85369. * @returns the new emitter
  85370. */
  85371. clone(): BoxParticleEmitter;
  85372. /**
  85373. * Called by the GPUParticleSystem to setup the update shader
  85374. * @param effect defines the update shader
  85375. */
  85376. applyToShader(effect: Effect): void;
  85377. /**
  85378. * Returns a string to use to update the GPU particles update shader
  85379. * @returns a string containng the defines string
  85380. */
  85381. getEffectDefines(): string;
  85382. /**
  85383. * Returns the string "BoxParticleEmitter"
  85384. * @returns a string containing the class name
  85385. */
  85386. getClassName(): string;
  85387. /**
  85388. * Serializes the particle system to a JSON object.
  85389. * @returns the JSON object
  85390. */
  85391. serialize(): any;
  85392. /**
  85393. * Parse properties from a JSON object
  85394. * @param serializationObject defines the JSON object
  85395. */
  85396. parse(serializationObject: any): void;
  85397. }
  85398. }
  85399. declare module BABYLON {
  85400. /**
  85401. * Particle emitter emitting particles from the inside of a cone.
  85402. * It emits the particles alongside the cone volume from the base to the particle.
  85403. * The emission direction might be randomized.
  85404. */
  85405. export class ConeParticleEmitter implements IParticleEmitterType {
  85406. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85407. directionRandomizer: number;
  85408. private _radius;
  85409. private _angle;
  85410. private _height;
  85411. /**
  85412. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85413. */
  85414. radiusRange: number;
  85415. /**
  85416. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85417. */
  85418. heightRange: number;
  85419. /**
  85420. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85421. */
  85422. emitFromSpawnPointOnly: boolean;
  85423. /**
  85424. * Gets or sets the radius of the emission cone
  85425. */
  85426. get radius(): number;
  85427. set radius(value: number);
  85428. /**
  85429. * Gets or sets the angle of the emission cone
  85430. */
  85431. get angle(): number;
  85432. set angle(value: number);
  85433. private _buildHeight;
  85434. /**
  85435. * Creates a new instance ConeParticleEmitter
  85436. * @param radius the radius of the emission cone (1 by default)
  85437. * @param angle the cone base angle (PI by default)
  85438. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85439. */
  85440. constructor(radius?: number, angle?: number,
  85441. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85442. directionRandomizer?: number);
  85443. /**
  85444. * Called by the particle System when the direction is computed for the created particle.
  85445. * @param worldMatrix is the world matrix of the particle system
  85446. * @param directionToUpdate is the direction vector to update with the result
  85447. * @param particle is the particle we are computed the direction for
  85448. */
  85449. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85450. /**
  85451. * Called by the particle System when the position is computed for the created particle.
  85452. * @param worldMatrix is the world matrix of the particle system
  85453. * @param positionToUpdate is the position vector to update with the result
  85454. * @param particle is the particle we are computed the position for
  85455. */
  85456. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85457. /**
  85458. * Clones the current emitter and returns a copy of it
  85459. * @returns the new emitter
  85460. */
  85461. clone(): ConeParticleEmitter;
  85462. /**
  85463. * Called by the GPUParticleSystem to setup the update shader
  85464. * @param effect defines the update shader
  85465. */
  85466. applyToShader(effect: Effect): void;
  85467. /**
  85468. * Returns a string to use to update the GPU particles update shader
  85469. * @returns a string containng the defines string
  85470. */
  85471. getEffectDefines(): string;
  85472. /**
  85473. * Returns the string "ConeParticleEmitter"
  85474. * @returns a string containing the class name
  85475. */
  85476. getClassName(): string;
  85477. /**
  85478. * Serializes the particle system to a JSON object.
  85479. * @returns the JSON object
  85480. */
  85481. serialize(): any;
  85482. /**
  85483. * Parse properties from a JSON object
  85484. * @param serializationObject defines the JSON object
  85485. */
  85486. parse(serializationObject: any): void;
  85487. }
  85488. }
  85489. declare module BABYLON {
  85490. /**
  85491. * Particle emitter emitting particles from the inside of a cylinder.
  85492. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85493. */
  85494. export class CylinderParticleEmitter implements IParticleEmitterType {
  85495. /**
  85496. * The radius of the emission cylinder.
  85497. */
  85498. radius: number;
  85499. /**
  85500. * The height of the emission cylinder.
  85501. */
  85502. height: number;
  85503. /**
  85504. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85505. */
  85506. radiusRange: number;
  85507. /**
  85508. * How much to randomize the particle direction [0-1].
  85509. */
  85510. directionRandomizer: number;
  85511. /**
  85512. * Creates a new instance CylinderParticleEmitter
  85513. * @param radius the radius of the emission cylinder (1 by default)
  85514. * @param height the height of the emission cylinder (1 by default)
  85515. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85516. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85517. */
  85518. constructor(
  85519. /**
  85520. * The radius of the emission cylinder.
  85521. */
  85522. radius?: number,
  85523. /**
  85524. * The height of the emission cylinder.
  85525. */
  85526. height?: number,
  85527. /**
  85528. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85529. */
  85530. radiusRange?: number,
  85531. /**
  85532. * How much to randomize the particle direction [0-1].
  85533. */
  85534. directionRandomizer?: number);
  85535. /**
  85536. * Called by the particle System when the direction is computed for the created particle.
  85537. * @param worldMatrix is the world matrix of the particle system
  85538. * @param directionToUpdate is the direction vector to update with the result
  85539. * @param particle is the particle we are computed the direction for
  85540. */
  85541. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85542. /**
  85543. * Called by the particle System when the position is computed for the created particle.
  85544. * @param worldMatrix is the world matrix of the particle system
  85545. * @param positionToUpdate is the position vector to update with the result
  85546. * @param particle is the particle we are computed the position for
  85547. */
  85548. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85549. /**
  85550. * Clones the current emitter and returns a copy of it
  85551. * @returns the new emitter
  85552. */
  85553. clone(): CylinderParticleEmitter;
  85554. /**
  85555. * Called by the GPUParticleSystem to setup the update shader
  85556. * @param effect defines the update shader
  85557. */
  85558. applyToShader(effect: Effect): void;
  85559. /**
  85560. * Returns a string to use to update the GPU particles update shader
  85561. * @returns a string containng the defines string
  85562. */
  85563. getEffectDefines(): string;
  85564. /**
  85565. * Returns the string "CylinderParticleEmitter"
  85566. * @returns a string containing the class name
  85567. */
  85568. getClassName(): string;
  85569. /**
  85570. * Serializes the particle system to a JSON object.
  85571. * @returns the JSON object
  85572. */
  85573. serialize(): any;
  85574. /**
  85575. * Parse properties from a JSON object
  85576. * @param serializationObject defines the JSON object
  85577. */
  85578. parse(serializationObject: any): void;
  85579. }
  85580. /**
  85581. * Particle emitter emitting particles from the inside of a cylinder.
  85582. * It emits the particles randomly between two vectors.
  85583. */
  85584. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85585. /**
  85586. * The min limit of the emission direction.
  85587. */
  85588. direction1: Vector3;
  85589. /**
  85590. * The max limit of the emission direction.
  85591. */
  85592. direction2: Vector3;
  85593. /**
  85594. * Creates a new instance CylinderDirectedParticleEmitter
  85595. * @param radius the radius of the emission cylinder (1 by default)
  85596. * @param height the height of the emission cylinder (1 by default)
  85597. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85598. * @param direction1 the min limit of the emission direction (up vector by default)
  85599. * @param direction2 the max limit of the emission direction (up vector by default)
  85600. */
  85601. constructor(radius?: number, height?: number, radiusRange?: number,
  85602. /**
  85603. * The min limit of the emission direction.
  85604. */
  85605. direction1?: Vector3,
  85606. /**
  85607. * The max limit of the emission direction.
  85608. */
  85609. direction2?: Vector3);
  85610. /**
  85611. * Called by the particle System when the direction is computed for the created particle.
  85612. * @param worldMatrix is the world matrix of the particle system
  85613. * @param directionToUpdate is the direction vector to update with the result
  85614. * @param particle is the particle we are computed the direction for
  85615. */
  85616. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85617. /**
  85618. * Clones the current emitter and returns a copy of it
  85619. * @returns the new emitter
  85620. */
  85621. clone(): CylinderDirectedParticleEmitter;
  85622. /**
  85623. * Called by the GPUParticleSystem to setup the update shader
  85624. * @param effect defines the update shader
  85625. */
  85626. applyToShader(effect: Effect): void;
  85627. /**
  85628. * Returns a string to use to update the GPU particles update shader
  85629. * @returns a string containng the defines string
  85630. */
  85631. getEffectDefines(): string;
  85632. /**
  85633. * Returns the string "CylinderDirectedParticleEmitter"
  85634. * @returns a string containing the class name
  85635. */
  85636. getClassName(): string;
  85637. /**
  85638. * Serializes the particle system to a JSON object.
  85639. * @returns the JSON object
  85640. */
  85641. serialize(): any;
  85642. /**
  85643. * Parse properties from a JSON object
  85644. * @param serializationObject defines the JSON object
  85645. */
  85646. parse(serializationObject: any): void;
  85647. }
  85648. }
  85649. declare module BABYLON {
  85650. /**
  85651. * Particle emitter emitting particles from the inside of a hemisphere.
  85652. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85653. */
  85654. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85655. /**
  85656. * The radius of the emission hemisphere.
  85657. */
  85658. radius: number;
  85659. /**
  85660. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85661. */
  85662. radiusRange: number;
  85663. /**
  85664. * How much to randomize the particle direction [0-1].
  85665. */
  85666. directionRandomizer: number;
  85667. /**
  85668. * Creates a new instance HemisphericParticleEmitter
  85669. * @param radius the radius of the emission hemisphere (1 by default)
  85670. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85671. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85672. */
  85673. constructor(
  85674. /**
  85675. * The radius of the emission hemisphere.
  85676. */
  85677. radius?: number,
  85678. /**
  85679. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85680. */
  85681. radiusRange?: number,
  85682. /**
  85683. * How much to randomize the particle direction [0-1].
  85684. */
  85685. directionRandomizer?: number);
  85686. /**
  85687. * Called by the particle System when the direction is computed for the created particle.
  85688. * @param worldMatrix is the world matrix of the particle system
  85689. * @param directionToUpdate is the direction vector to update with the result
  85690. * @param particle is the particle we are computed the direction for
  85691. */
  85692. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85693. /**
  85694. * Called by the particle System when the position is computed for the created particle.
  85695. * @param worldMatrix is the world matrix of the particle system
  85696. * @param positionToUpdate is the position vector to update with the result
  85697. * @param particle is the particle we are computed the position for
  85698. */
  85699. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85700. /**
  85701. * Clones the current emitter and returns a copy of it
  85702. * @returns the new emitter
  85703. */
  85704. clone(): HemisphericParticleEmitter;
  85705. /**
  85706. * Called by the GPUParticleSystem to setup the update shader
  85707. * @param effect defines the update shader
  85708. */
  85709. applyToShader(effect: Effect): void;
  85710. /**
  85711. * Returns a string to use to update the GPU particles update shader
  85712. * @returns a string containng the defines string
  85713. */
  85714. getEffectDefines(): string;
  85715. /**
  85716. * Returns the string "HemisphericParticleEmitter"
  85717. * @returns a string containing the class name
  85718. */
  85719. getClassName(): string;
  85720. /**
  85721. * Serializes the particle system to a JSON object.
  85722. * @returns the JSON object
  85723. */
  85724. serialize(): any;
  85725. /**
  85726. * Parse properties from a JSON object
  85727. * @param serializationObject defines the JSON object
  85728. */
  85729. parse(serializationObject: any): void;
  85730. }
  85731. }
  85732. declare module BABYLON {
  85733. /**
  85734. * Particle emitter emitting particles from a point.
  85735. * It emits the particles randomly between 2 given directions.
  85736. */
  85737. export class PointParticleEmitter implements IParticleEmitterType {
  85738. /**
  85739. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85740. */
  85741. direction1: Vector3;
  85742. /**
  85743. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85744. */
  85745. direction2: Vector3;
  85746. /**
  85747. * Creates a new instance PointParticleEmitter
  85748. */
  85749. constructor();
  85750. /**
  85751. * Called by the particle System when the direction is computed for the created particle.
  85752. * @param worldMatrix is the world matrix of the particle system
  85753. * @param directionToUpdate is the direction vector to update with the result
  85754. * @param particle is the particle we are computed the direction for
  85755. */
  85756. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85757. /**
  85758. * Called by the particle System when the position is computed for the created particle.
  85759. * @param worldMatrix is the world matrix of the particle system
  85760. * @param positionToUpdate is the position vector to update with the result
  85761. * @param particle is the particle we are computed the position for
  85762. */
  85763. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85764. /**
  85765. * Clones the current emitter and returns a copy of it
  85766. * @returns the new emitter
  85767. */
  85768. clone(): PointParticleEmitter;
  85769. /**
  85770. * Called by the GPUParticleSystem to setup the update shader
  85771. * @param effect defines the update shader
  85772. */
  85773. applyToShader(effect: Effect): void;
  85774. /**
  85775. * Returns a string to use to update the GPU particles update shader
  85776. * @returns a string containng the defines string
  85777. */
  85778. getEffectDefines(): string;
  85779. /**
  85780. * Returns the string "PointParticleEmitter"
  85781. * @returns a string containing the class name
  85782. */
  85783. getClassName(): string;
  85784. /**
  85785. * Serializes the particle system to a JSON object.
  85786. * @returns the JSON object
  85787. */
  85788. serialize(): any;
  85789. /**
  85790. * Parse properties from a JSON object
  85791. * @param serializationObject defines the JSON object
  85792. */
  85793. parse(serializationObject: any): void;
  85794. }
  85795. }
  85796. declare module BABYLON {
  85797. /**
  85798. * Particle emitter emitting particles from the inside of a sphere.
  85799. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  85800. */
  85801. export class SphereParticleEmitter implements IParticleEmitterType {
  85802. /**
  85803. * The radius of the emission sphere.
  85804. */
  85805. radius: number;
  85806. /**
  85807. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85808. */
  85809. radiusRange: number;
  85810. /**
  85811. * How much to randomize the particle direction [0-1].
  85812. */
  85813. directionRandomizer: number;
  85814. /**
  85815. * Creates a new instance SphereParticleEmitter
  85816. * @param radius the radius of the emission sphere (1 by default)
  85817. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85818. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85819. */
  85820. constructor(
  85821. /**
  85822. * The radius of the emission sphere.
  85823. */
  85824. radius?: number,
  85825. /**
  85826. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85827. */
  85828. radiusRange?: number,
  85829. /**
  85830. * How much to randomize the particle direction [0-1].
  85831. */
  85832. directionRandomizer?: number);
  85833. /**
  85834. * Called by the particle System when the direction is computed for the created particle.
  85835. * @param worldMatrix is the world matrix of the particle system
  85836. * @param directionToUpdate is the direction vector to update with the result
  85837. * @param particle is the particle we are computed the direction for
  85838. */
  85839. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85840. /**
  85841. * Called by the particle System when the position is computed for the created particle.
  85842. * @param worldMatrix is the world matrix of the particle system
  85843. * @param positionToUpdate is the position vector to update with the result
  85844. * @param particle is the particle we are computed the position for
  85845. */
  85846. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85847. /**
  85848. * Clones the current emitter and returns a copy of it
  85849. * @returns the new emitter
  85850. */
  85851. clone(): SphereParticleEmitter;
  85852. /**
  85853. * Called by the GPUParticleSystem to setup the update shader
  85854. * @param effect defines the update shader
  85855. */
  85856. applyToShader(effect: Effect): void;
  85857. /**
  85858. * Returns a string to use to update the GPU particles update shader
  85859. * @returns a string containng the defines string
  85860. */
  85861. getEffectDefines(): string;
  85862. /**
  85863. * Returns the string "SphereParticleEmitter"
  85864. * @returns a string containing the class name
  85865. */
  85866. getClassName(): string;
  85867. /**
  85868. * Serializes the particle system to a JSON object.
  85869. * @returns the JSON object
  85870. */
  85871. serialize(): any;
  85872. /**
  85873. * Parse properties from a JSON object
  85874. * @param serializationObject defines the JSON object
  85875. */
  85876. parse(serializationObject: any): void;
  85877. }
  85878. /**
  85879. * Particle emitter emitting particles from the inside of a sphere.
  85880. * It emits the particles randomly between two vectors.
  85881. */
  85882. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  85883. /**
  85884. * The min limit of the emission direction.
  85885. */
  85886. direction1: Vector3;
  85887. /**
  85888. * The max limit of the emission direction.
  85889. */
  85890. direction2: Vector3;
  85891. /**
  85892. * Creates a new instance SphereDirectedParticleEmitter
  85893. * @param radius the radius of the emission sphere (1 by default)
  85894. * @param direction1 the min limit of the emission direction (up vector by default)
  85895. * @param direction2 the max limit of the emission direction (up vector by default)
  85896. */
  85897. constructor(radius?: number,
  85898. /**
  85899. * The min limit of the emission direction.
  85900. */
  85901. direction1?: Vector3,
  85902. /**
  85903. * The max limit of the emission direction.
  85904. */
  85905. direction2?: Vector3);
  85906. /**
  85907. * Called by the particle System when the direction is computed for the created particle.
  85908. * @param worldMatrix is the world matrix of the particle system
  85909. * @param directionToUpdate is the direction vector to update with the result
  85910. * @param particle is the particle we are computed the direction for
  85911. */
  85912. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85913. /**
  85914. * Clones the current emitter and returns a copy of it
  85915. * @returns the new emitter
  85916. */
  85917. clone(): SphereDirectedParticleEmitter;
  85918. /**
  85919. * Called by the GPUParticleSystem to setup the update shader
  85920. * @param effect defines the update shader
  85921. */
  85922. applyToShader(effect: Effect): void;
  85923. /**
  85924. * Returns a string to use to update the GPU particles update shader
  85925. * @returns a string containng the defines string
  85926. */
  85927. getEffectDefines(): string;
  85928. /**
  85929. * Returns the string "SphereDirectedParticleEmitter"
  85930. * @returns a string containing the class name
  85931. */
  85932. getClassName(): string;
  85933. /**
  85934. * Serializes the particle system to a JSON object.
  85935. * @returns the JSON object
  85936. */
  85937. serialize(): any;
  85938. /**
  85939. * Parse properties from a JSON object
  85940. * @param serializationObject defines the JSON object
  85941. */
  85942. parse(serializationObject: any): void;
  85943. }
  85944. }
  85945. declare module BABYLON {
  85946. /**
  85947. * Particle emitter emitting particles from a custom list of positions.
  85948. */
  85949. export class CustomParticleEmitter implements IParticleEmitterType {
  85950. /**
  85951. * Gets or sets the position generator that will create the inital position of each particle.
  85952. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  85953. */
  85954. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  85955. /**
  85956. * Gets or sets the destination generator that will create the final destination of each particle.
  85957. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  85958. */
  85959. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  85960. /**
  85961. * Creates a new instance CustomParticleEmitter
  85962. */
  85963. constructor();
  85964. /**
  85965. * Called by the particle System when the direction is computed for the created particle.
  85966. * @param worldMatrix is the world matrix of the particle system
  85967. * @param directionToUpdate is the direction vector to update with the result
  85968. * @param particle is the particle we are computed the direction for
  85969. */
  85970. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85971. /**
  85972. * Called by the particle System when the position is computed for the created particle.
  85973. * @param worldMatrix is the world matrix of the particle system
  85974. * @param positionToUpdate is the position vector to update with the result
  85975. * @param particle is the particle we are computed the position for
  85976. */
  85977. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85978. /**
  85979. * Clones the current emitter and returns a copy of it
  85980. * @returns the new emitter
  85981. */
  85982. clone(): CustomParticleEmitter;
  85983. /**
  85984. * Called by the GPUParticleSystem to setup the update shader
  85985. * @param effect defines the update shader
  85986. */
  85987. applyToShader(effect: Effect): void;
  85988. /**
  85989. * Returns a string to use to update the GPU particles update shader
  85990. * @returns a string containng the defines string
  85991. */
  85992. getEffectDefines(): string;
  85993. /**
  85994. * Returns the string "PointParticleEmitter"
  85995. * @returns a string containing the class name
  85996. */
  85997. getClassName(): string;
  85998. /**
  85999. * Serializes the particle system to a JSON object.
  86000. * @returns the JSON object
  86001. */
  86002. serialize(): any;
  86003. /**
  86004. * Parse properties from a JSON object
  86005. * @param serializationObject defines the JSON object
  86006. */
  86007. parse(serializationObject: any): void;
  86008. }
  86009. }
  86010. declare module BABYLON {
  86011. /**
  86012. * Particle emitter emitting particles from the inside of a box.
  86013. * It emits the particles randomly between 2 given directions.
  86014. */
  86015. export class MeshParticleEmitter implements IParticleEmitterType {
  86016. /** Defines the mesh to use as source */
  86017. mesh?: AbstractMesh | undefined;
  86018. private _indices;
  86019. private _positions;
  86020. private _normals;
  86021. private _storedNormal;
  86022. /**
  86023. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86024. */
  86025. direction1: Vector3;
  86026. /**
  86027. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86028. */
  86029. direction2: Vector3;
  86030. /**
  86031. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  86032. */
  86033. useMeshNormalsForDirection: boolean;
  86034. /**
  86035. * Creates a new instance MeshParticleEmitter
  86036. * @param mesh defines the mesh to use as source
  86037. */
  86038. constructor(
  86039. /** Defines the mesh to use as source */
  86040. mesh?: AbstractMesh | undefined);
  86041. /**
  86042. * Called by the particle System when the direction is computed for the created particle.
  86043. * @param worldMatrix is the world matrix of the particle system
  86044. * @param directionToUpdate is the direction vector to update with the result
  86045. * @param particle is the particle we are computed the direction for
  86046. */
  86047. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86048. /**
  86049. * Called by the particle System when the position is computed for the created particle.
  86050. * @param worldMatrix is the world matrix of the particle system
  86051. * @param positionToUpdate is the position vector to update with the result
  86052. * @param particle is the particle we are computed the position for
  86053. */
  86054. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86055. /**
  86056. * Clones the current emitter and returns a copy of it
  86057. * @returns the new emitter
  86058. */
  86059. clone(): MeshParticleEmitter;
  86060. /**
  86061. * Called by the GPUParticleSystem to setup the update shader
  86062. * @param effect defines the update shader
  86063. */
  86064. applyToShader(effect: Effect): void;
  86065. /**
  86066. * Returns a string to use to update the GPU particles update shader
  86067. * @returns a string containng the defines string
  86068. */
  86069. getEffectDefines(): string;
  86070. /**
  86071. * Returns the string "BoxParticleEmitter"
  86072. * @returns a string containing the class name
  86073. */
  86074. getClassName(): string;
  86075. /**
  86076. * Serializes the particle system to a JSON object.
  86077. * @returns the JSON object
  86078. */
  86079. serialize(): any;
  86080. /**
  86081. * Parse properties from a JSON object
  86082. * @param serializationObject defines the JSON object
  86083. * @param scene defines the hosting scene
  86084. */
  86085. parse(serializationObject: any, scene: Scene): void;
  86086. }
  86087. }
  86088. declare module BABYLON {
  86089. /**
  86090. * Interface representing a particle system in Babylon.js.
  86091. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86092. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86093. */
  86094. export interface IParticleSystem {
  86095. /**
  86096. * List of animations used by the particle system.
  86097. */
  86098. animations: Animation[];
  86099. /**
  86100. * The id of the Particle system.
  86101. */
  86102. id: string;
  86103. /**
  86104. * The name of the Particle system.
  86105. */
  86106. name: string;
  86107. /**
  86108. * The emitter represents the Mesh or position we are attaching the particle system to.
  86109. */
  86110. emitter: Nullable<AbstractMesh | Vector3>;
  86111. /**
  86112. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86113. */
  86114. isBillboardBased: boolean;
  86115. /**
  86116. * The rendering group used by the Particle system to chose when to render.
  86117. */
  86118. renderingGroupId: number;
  86119. /**
  86120. * The layer mask we are rendering the particles through.
  86121. */
  86122. layerMask: number;
  86123. /**
  86124. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86125. */
  86126. updateSpeed: number;
  86127. /**
  86128. * The amount of time the particle system is running (depends of the overall update speed).
  86129. */
  86130. targetStopDuration: number;
  86131. /**
  86132. * The texture used to render each particle. (this can be a spritesheet)
  86133. */
  86134. particleTexture: Nullable<Texture>;
  86135. /**
  86136. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86137. */
  86138. blendMode: number;
  86139. /**
  86140. * Minimum life time of emitting particles.
  86141. */
  86142. minLifeTime: number;
  86143. /**
  86144. * Maximum life time of emitting particles.
  86145. */
  86146. maxLifeTime: number;
  86147. /**
  86148. * Minimum Size of emitting particles.
  86149. */
  86150. minSize: number;
  86151. /**
  86152. * Maximum Size of emitting particles.
  86153. */
  86154. maxSize: number;
  86155. /**
  86156. * Minimum scale of emitting particles on X axis.
  86157. */
  86158. minScaleX: number;
  86159. /**
  86160. * Maximum scale of emitting particles on X axis.
  86161. */
  86162. maxScaleX: number;
  86163. /**
  86164. * Minimum scale of emitting particles on Y axis.
  86165. */
  86166. minScaleY: number;
  86167. /**
  86168. * Maximum scale of emitting particles on Y axis.
  86169. */
  86170. maxScaleY: number;
  86171. /**
  86172. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86173. */
  86174. color1: Color4;
  86175. /**
  86176. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86177. */
  86178. color2: Color4;
  86179. /**
  86180. * Color the particle will have at the end of its lifetime.
  86181. */
  86182. colorDead: Color4;
  86183. /**
  86184. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86185. */
  86186. emitRate: number;
  86187. /**
  86188. * You can use gravity if you want to give an orientation to your particles.
  86189. */
  86190. gravity: Vector3;
  86191. /**
  86192. * Minimum power of emitting particles.
  86193. */
  86194. minEmitPower: number;
  86195. /**
  86196. * Maximum power of emitting particles.
  86197. */
  86198. maxEmitPower: number;
  86199. /**
  86200. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86201. */
  86202. minAngularSpeed: number;
  86203. /**
  86204. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86205. */
  86206. maxAngularSpeed: number;
  86207. /**
  86208. * Gets or sets the minimal initial rotation in radians.
  86209. */
  86210. minInitialRotation: number;
  86211. /**
  86212. * Gets or sets the maximal initial rotation in radians.
  86213. */
  86214. maxInitialRotation: number;
  86215. /**
  86216. * The particle emitter type defines the emitter used by the particle system.
  86217. * It can be for example box, sphere, or cone...
  86218. */
  86219. particleEmitterType: Nullable<IParticleEmitterType>;
  86220. /**
  86221. * Defines the delay in milliseconds before starting the system (0 by default)
  86222. */
  86223. startDelay: number;
  86224. /**
  86225. * 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
  86226. */
  86227. preWarmCycles: number;
  86228. /**
  86229. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86230. */
  86231. preWarmStepOffset: number;
  86232. /**
  86233. * 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)
  86234. */
  86235. spriteCellChangeSpeed: number;
  86236. /**
  86237. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86238. */
  86239. startSpriteCellID: number;
  86240. /**
  86241. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86242. */
  86243. endSpriteCellID: number;
  86244. /**
  86245. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86246. */
  86247. spriteCellWidth: number;
  86248. /**
  86249. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86250. */
  86251. spriteCellHeight: number;
  86252. /**
  86253. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86254. */
  86255. spriteRandomStartCell: boolean;
  86256. /**
  86257. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86258. */
  86259. isAnimationSheetEnabled: boolean;
  86260. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86261. translationPivot: Vector2;
  86262. /**
  86263. * Gets or sets a texture used to add random noise to particle positions
  86264. */
  86265. noiseTexture: Nullable<BaseTexture>;
  86266. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86267. noiseStrength: Vector3;
  86268. /**
  86269. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86270. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86271. */
  86272. billboardMode: number;
  86273. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86274. limitVelocityDamping: number;
  86275. /**
  86276. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86277. */
  86278. beginAnimationOnStart: boolean;
  86279. /**
  86280. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86281. */
  86282. beginAnimationFrom: number;
  86283. /**
  86284. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86285. */
  86286. beginAnimationTo: number;
  86287. /**
  86288. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86289. */
  86290. beginAnimationLoop: boolean;
  86291. /**
  86292. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86293. */
  86294. disposeOnStop: boolean;
  86295. /**
  86296. * Gets the maximum number of particles active at the same time.
  86297. * @returns The max number of active particles.
  86298. */
  86299. getCapacity(): number;
  86300. /**
  86301. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86302. * @returns True if it has been started, otherwise false.
  86303. */
  86304. isStarted(): boolean;
  86305. /**
  86306. * Animates the particle system for this frame.
  86307. */
  86308. animate(): void;
  86309. /**
  86310. * Renders the particle system in its current state.
  86311. * @returns the current number of particles
  86312. */
  86313. render(): number;
  86314. /**
  86315. * Dispose the particle system and frees its associated resources.
  86316. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86317. */
  86318. dispose(disposeTexture?: boolean): void;
  86319. /**
  86320. * Clones the particle system.
  86321. * @param name The name of the cloned object
  86322. * @param newEmitter The new emitter to use
  86323. * @returns the cloned particle system
  86324. */
  86325. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86326. /**
  86327. * Serializes the particle system to a JSON object.
  86328. * @returns the JSON object
  86329. */
  86330. serialize(): any;
  86331. /**
  86332. * Rebuild the particle system
  86333. */
  86334. rebuild(): void;
  86335. /**
  86336. * Starts the particle system and begins to emit
  86337. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86338. */
  86339. start(delay?: number): void;
  86340. /**
  86341. * Stops the particle system.
  86342. */
  86343. stop(): void;
  86344. /**
  86345. * Remove all active particles
  86346. */
  86347. reset(): void;
  86348. /**
  86349. * Is this system ready to be used/rendered
  86350. * @return true if the system is ready
  86351. */
  86352. isReady(): boolean;
  86353. /**
  86354. * Adds a new color gradient
  86355. * @param gradient defines the gradient to use (between 0 and 1)
  86356. * @param color1 defines the color to affect to the specified gradient
  86357. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86358. * @returns the current particle system
  86359. */
  86360. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86361. /**
  86362. * Remove a specific color gradient
  86363. * @param gradient defines the gradient to remove
  86364. * @returns the current particle system
  86365. */
  86366. removeColorGradient(gradient: number): IParticleSystem;
  86367. /**
  86368. * Adds a new size gradient
  86369. * @param gradient defines the gradient to use (between 0 and 1)
  86370. * @param factor defines the size factor to affect to the specified gradient
  86371. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86372. * @returns the current particle system
  86373. */
  86374. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86375. /**
  86376. * Remove a specific size gradient
  86377. * @param gradient defines the gradient to remove
  86378. * @returns the current particle system
  86379. */
  86380. removeSizeGradient(gradient: number): IParticleSystem;
  86381. /**
  86382. * Gets the current list of color gradients.
  86383. * You must use addColorGradient and removeColorGradient to udpate this list
  86384. * @returns the list of color gradients
  86385. */
  86386. getColorGradients(): Nullable<Array<ColorGradient>>;
  86387. /**
  86388. * Gets the current list of size gradients.
  86389. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86390. * @returns the list of size gradients
  86391. */
  86392. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86393. /**
  86394. * Gets the current list of angular speed gradients.
  86395. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86396. * @returns the list of angular speed gradients
  86397. */
  86398. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86399. /**
  86400. * Adds a new angular speed gradient
  86401. * @param gradient defines the gradient to use (between 0 and 1)
  86402. * @param factor defines the angular speed to affect to the specified gradient
  86403. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86404. * @returns the current particle system
  86405. */
  86406. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86407. /**
  86408. * Remove a specific angular speed gradient
  86409. * @param gradient defines the gradient to remove
  86410. * @returns the current particle system
  86411. */
  86412. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86413. /**
  86414. * Gets the current list of velocity gradients.
  86415. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86416. * @returns the list of velocity gradients
  86417. */
  86418. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86419. /**
  86420. * Adds a new velocity gradient
  86421. * @param gradient defines the gradient to use (between 0 and 1)
  86422. * @param factor defines the velocity to affect to the specified gradient
  86423. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86424. * @returns the current particle system
  86425. */
  86426. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86427. /**
  86428. * Remove a specific velocity gradient
  86429. * @param gradient defines the gradient to remove
  86430. * @returns the current particle system
  86431. */
  86432. removeVelocityGradient(gradient: number): IParticleSystem;
  86433. /**
  86434. * Gets the current list of limit velocity gradients.
  86435. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86436. * @returns the list of limit velocity gradients
  86437. */
  86438. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86439. /**
  86440. * Adds a new limit velocity gradient
  86441. * @param gradient defines the gradient to use (between 0 and 1)
  86442. * @param factor defines the limit velocity to affect to the specified gradient
  86443. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86444. * @returns the current particle system
  86445. */
  86446. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86447. /**
  86448. * Remove a specific limit velocity gradient
  86449. * @param gradient defines the gradient to remove
  86450. * @returns the current particle system
  86451. */
  86452. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86453. /**
  86454. * Adds a new drag gradient
  86455. * @param gradient defines the gradient to use (between 0 and 1)
  86456. * @param factor defines the drag to affect to the specified gradient
  86457. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86458. * @returns the current particle system
  86459. */
  86460. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86461. /**
  86462. * Remove a specific drag gradient
  86463. * @param gradient defines the gradient to remove
  86464. * @returns the current particle system
  86465. */
  86466. removeDragGradient(gradient: number): IParticleSystem;
  86467. /**
  86468. * Gets the current list of drag gradients.
  86469. * You must use addDragGradient and removeDragGradient to udpate this list
  86470. * @returns the list of drag gradients
  86471. */
  86472. getDragGradients(): Nullable<Array<FactorGradient>>;
  86473. /**
  86474. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86475. * @param gradient defines the gradient to use (between 0 and 1)
  86476. * @param factor defines the emit rate to affect to the specified gradient
  86477. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86478. * @returns the current particle system
  86479. */
  86480. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86481. /**
  86482. * Remove a specific emit rate gradient
  86483. * @param gradient defines the gradient to remove
  86484. * @returns the current particle system
  86485. */
  86486. removeEmitRateGradient(gradient: number): IParticleSystem;
  86487. /**
  86488. * Gets the current list of emit rate gradients.
  86489. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86490. * @returns the list of emit rate gradients
  86491. */
  86492. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86493. /**
  86494. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86495. * @param gradient defines the gradient to use (between 0 and 1)
  86496. * @param factor defines the start size to affect to the specified gradient
  86497. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86498. * @returns the current particle system
  86499. */
  86500. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86501. /**
  86502. * Remove a specific start size gradient
  86503. * @param gradient defines the gradient to remove
  86504. * @returns the current particle system
  86505. */
  86506. removeStartSizeGradient(gradient: number): IParticleSystem;
  86507. /**
  86508. * Gets the current list of start size gradients.
  86509. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86510. * @returns the list of start size gradients
  86511. */
  86512. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86513. /**
  86514. * Adds a new life time gradient
  86515. * @param gradient defines the gradient to use (between 0 and 1)
  86516. * @param factor defines the life time factor to affect to the specified gradient
  86517. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86518. * @returns the current particle system
  86519. */
  86520. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86521. /**
  86522. * Remove a specific life time gradient
  86523. * @param gradient defines the gradient to remove
  86524. * @returns the current particle system
  86525. */
  86526. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86527. /**
  86528. * Gets the current list of life time gradients.
  86529. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86530. * @returns the list of life time gradients
  86531. */
  86532. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86533. /**
  86534. * Gets the current list of color gradients.
  86535. * You must use addColorGradient and removeColorGradient to udpate this list
  86536. * @returns the list of color gradients
  86537. */
  86538. getColorGradients(): Nullable<Array<ColorGradient>>;
  86539. /**
  86540. * Adds a new ramp gradient used to remap particle colors
  86541. * @param gradient defines the gradient to use (between 0 and 1)
  86542. * @param color defines the color to affect to the specified gradient
  86543. * @returns the current particle system
  86544. */
  86545. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86546. /**
  86547. * Gets the current list of ramp gradients.
  86548. * You must use addRampGradient and removeRampGradient to udpate this list
  86549. * @returns the list of ramp gradients
  86550. */
  86551. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86552. /** Gets or sets a boolean indicating that ramp gradients must be used
  86553. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86554. */
  86555. useRampGradients: boolean;
  86556. /**
  86557. * Adds a new color remap gradient
  86558. * @param gradient defines the gradient to use (between 0 and 1)
  86559. * @param min defines the color remap minimal range
  86560. * @param max defines the color remap maximal range
  86561. * @returns the current particle system
  86562. */
  86563. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86564. /**
  86565. * Gets the current list of color remap gradients.
  86566. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86567. * @returns the list of color remap gradients
  86568. */
  86569. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86570. /**
  86571. * Adds a new alpha remap gradient
  86572. * @param gradient defines the gradient to use (between 0 and 1)
  86573. * @param min defines the alpha remap minimal range
  86574. * @param max defines the alpha remap maximal range
  86575. * @returns the current particle system
  86576. */
  86577. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86578. /**
  86579. * Gets the current list of alpha remap gradients.
  86580. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86581. * @returns the list of alpha remap gradients
  86582. */
  86583. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86584. /**
  86585. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86586. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86587. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86588. * @returns the emitter
  86589. */
  86590. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86591. /**
  86592. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86593. * @param radius The radius of the hemisphere to emit from
  86594. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86595. * @returns the emitter
  86596. */
  86597. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86598. /**
  86599. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86600. * @param radius The radius of the sphere to emit from
  86601. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86602. * @returns the emitter
  86603. */
  86604. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86605. /**
  86606. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86607. * @param radius The radius of the sphere to emit from
  86608. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86609. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86610. * @returns the emitter
  86611. */
  86612. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86613. /**
  86614. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86615. * @param radius The radius of the emission cylinder
  86616. * @param height The height of the emission cylinder
  86617. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86618. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86619. * @returns the emitter
  86620. */
  86621. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86622. /**
  86623. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86624. * @param radius The radius of the cylinder to emit from
  86625. * @param height The height of the emission cylinder
  86626. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86627. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86628. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86629. * @returns the emitter
  86630. */
  86631. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86632. /**
  86633. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86634. * @param radius The radius of the cone to emit from
  86635. * @param angle The base angle of the cone
  86636. * @returns the emitter
  86637. */
  86638. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86639. /**
  86640. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86641. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86642. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86643. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86644. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86645. * @returns the emitter
  86646. */
  86647. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86648. /**
  86649. * Get hosting scene
  86650. * @returns the scene
  86651. */
  86652. getScene(): Scene;
  86653. }
  86654. }
  86655. declare module BABYLON {
  86656. /**
  86657. * 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.
  86658. * @see https://doc.babylonjs.com/how_to/transformnode
  86659. */
  86660. export class TransformNode extends Node {
  86661. /**
  86662. * Object will not rotate to face the camera
  86663. */
  86664. static BILLBOARDMODE_NONE: number;
  86665. /**
  86666. * Object will rotate to face the camera but only on the x axis
  86667. */
  86668. static BILLBOARDMODE_X: number;
  86669. /**
  86670. * Object will rotate to face the camera but only on the y axis
  86671. */
  86672. static BILLBOARDMODE_Y: number;
  86673. /**
  86674. * Object will rotate to face the camera but only on the z axis
  86675. */
  86676. static BILLBOARDMODE_Z: number;
  86677. /**
  86678. * Object will rotate to face the camera
  86679. */
  86680. static BILLBOARDMODE_ALL: number;
  86681. /**
  86682. * Object will rotate to face the camera's position instead of orientation
  86683. */
  86684. static BILLBOARDMODE_USE_POSITION: number;
  86685. private _forward;
  86686. private _forwardInverted;
  86687. private _up;
  86688. private _right;
  86689. private _rightInverted;
  86690. private _position;
  86691. private _rotation;
  86692. private _rotationQuaternion;
  86693. protected _scaling: Vector3;
  86694. protected _isDirty: boolean;
  86695. private _transformToBoneReferal;
  86696. private _isAbsoluteSynced;
  86697. private _billboardMode;
  86698. /**
  86699. * Gets or sets the billboard mode. Default is 0.
  86700. *
  86701. * | Value | Type | Description |
  86702. * | --- | --- | --- |
  86703. * | 0 | BILLBOARDMODE_NONE | |
  86704. * | 1 | BILLBOARDMODE_X | |
  86705. * | 2 | BILLBOARDMODE_Y | |
  86706. * | 4 | BILLBOARDMODE_Z | |
  86707. * | 7 | BILLBOARDMODE_ALL | |
  86708. *
  86709. */
  86710. get billboardMode(): number;
  86711. set billboardMode(value: number);
  86712. private _preserveParentRotationForBillboard;
  86713. /**
  86714. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  86715. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  86716. */
  86717. get preserveParentRotationForBillboard(): boolean;
  86718. set preserveParentRotationForBillboard(value: boolean);
  86719. /**
  86720. * 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
  86721. */
  86722. scalingDeterminant: number;
  86723. private _infiniteDistance;
  86724. /**
  86725. * Gets or sets the distance of the object to max, often used by skybox
  86726. */
  86727. get infiniteDistance(): boolean;
  86728. set infiniteDistance(value: boolean);
  86729. /**
  86730. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  86731. * By default the system will update normals to compensate
  86732. */
  86733. ignoreNonUniformScaling: boolean;
  86734. /**
  86735. * 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
  86736. */
  86737. reIntegrateRotationIntoRotationQuaternion: boolean;
  86738. /** @hidden */
  86739. _poseMatrix: Nullable<Matrix>;
  86740. /** @hidden */
  86741. _localMatrix: Matrix;
  86742. private _usePivotMatrix;
  86743. private _absolutePosition;
  86744. private _absoluteScaling;
  86745. private _absoluteRotationQuaternion;
  86746. private _pivotMatrix;
  86747. private _pivotMatrixInverse;
  86748. protected _postMultiplyPivotMatrix: boolean;
  86749. protected _isWorldMatrixFrozen: boolean;
  86750. /** @hidden */
  86751. _indexInSceneTransformNodesArray: number;
  86752. /**
  86753. * An event triggered after the world matrix is updated
  86754. */
  86755. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  86756. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  86757. /**
  86758. * Gets a string identifying the name of the class
  86759. * @returns "TransformNode" string
  86760. */
  86761. getClassName(): string;
  86762. /**
  86763. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  86764. */
  86765. get position(): Vector3;
  86766. set position(newPosition: Vector3);
  86767. /**
  86768. * 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)).
  86769. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  86770. */
  86771. get rotation(): Vector3;
  86772. set rotation(newRotation: Vector3);
  86773. /**
  86774. * 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)).
  86775. */
  86776. get scaling(): Vector3;
  86777. set scaling(newScaling: Vector3);
  86778. /**
  86779. * 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).
  86780. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  86781. */
  86782. get rotationQuaternion(): Nullable<Quaternion>;
  86783. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  86784. /**
  86785. * The forward direction of that transform in world space.
  86786. */
  86787. get forward(): Vector3;
  86788. /**
  86789. * The up direction of that transform in world space.
  86790. */
  86791. get up(): Vector3;
  86792. /**
  86793. * The right direction of that transform in world space.
  86794. */
  86795. get right(): Vector3;
  86796. /**
  86797. * Copies the parameter passed Matrix into the mesh Pose matrix.
  86798. * @param matrix the matrix to copy the pose from
  86799. * @returns this TransformNode.
  86800. */
  86801. updatePoseMatrix(matrix: Matrix): TransformNode;
  86802. /**
  86803. * Returns the mesh Pose matrix.
  86804. * @returns the pose matrix
  86805. */
  86806. getPoseMatrix(): Matrix;
  86807. /** @hidden */
  86808. _isSynchronized(): boolean;
  86809. /** @hidden */
  86810. _initCache(): void;
  86811. /**
  86812. * Flag the transform node as dirty (Forcing it to update everything)
  86813. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  86814. * @returns this transform node
  86815. */
  86816. markAsDirty(property: string): TransformNode;
  86817. /**
  86818. * Returns the current mesh absolute position.
  86819. * Returns a Vector3.
  86820. */
  86821. get absolutePosition(): Vector3;
  86822. /**
  86823. * Returns the current mesh absolute scaling.
  86824. * Returns a Vector3.
  86825. */
  86826. get absoluteScaling(): Vector3;
  86827. /**
  86828. * Returns the current mesh absolute rotation.
  86829. * Returns a Quaternion.
  86830. */
  86831. get absoluteRotationQuaternion(): Quaternion;
  86832. /**
  86833. * Sets a new matrix to apply before all other transformation
  86834. * @param matrix defines the transform matrix
  86835. * @returns the current TransformNode
  86836. */
  86837. setPreTransformMatrix(matrix: Matrix): TransformNode;
  86838. /**
  86839. * Sets a new pivot matrix to the current node
  86840. * @param matrix defines the new pivot matrix to use
  86841. * @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
  86842. * @returns the current TransformNode
  86843. */
  86844. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  86845. /**
  86846. * Returns the mesh pivot matrix.
  86847. * Default : Identity.
  86848. * @returns the matrix
  86849. */
  86850. getPivotMatrix(): Matrix;
  86851. /**
  86852. * Instantiate (when possible) or clone that node with its hierarchy
  86853. * @param newParent defines the new parent to use for the instance (or clone)
  86854. * @param options defines options to configure how copy is done
  86855. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  86856. * @returns an instance (or a clone) of the current node with its hiearchy
  86857. */
  86858. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  86859. doNotInstantiate: boolean;
  86860. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  86861. /**
  86862. * Prevents the World matrix to be computed any longer
  86863. * @param newWorldMatrix defines an optional matrix to use as world matrix
  86864. * @returns the TransformNode.
  86865. */
  86866. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  86867. /**
  86868. * Allows back the World matrix computation.
  86869. * @returns the TransformNode.
  86870. */
  86871. unfreezeWorldMatrix(): this;
  86872. /**
  86873. * True if the World matrix has been frozen.
  86874. */
  86875. get isWorldMatrixFrozen(): boolean;
  86876. /**
  86877. * Retuns the mesh absolute position in the World.
  86878. * @returns a Vector3.
  86879. */
  86880. getAbsolutePosition(): Vector3;
  86881. /**
  86882. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  86883. * @param absolutePosition the absolute position to set
  86884. * @returns the TransformNode.
  86885. */
  86886. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  86887. /**
  86888. * Sets the mesh position in its local space.
  86889. * @param vector3 the position to set in localspace
  86890. * @returns the TransformNode.
  86891. */
  86892. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  86893. /**
  86894. * Returns the mesh position in the local space from the current World matrix values.
  86895. * @returns a new Vector3.
  86896. */
  86897. getPositionExpressedInLocalSpace(): Vector3;
  86898. /**
  86899. * Translates the mesh along the passed Vector3 in its local space.
  86900. * @param vector3 the distance to translate in localspace
  86901. * @returns the TransformNode.
  86902. */
  86903. locallyTranslate(vector3: Vector3): TransformNode;
  86904. private static _lookAtVectorCache;
  86905. /**
  86906. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  86907. * @param targetPoint the position (must be in same space as current mesh) to look at
  86908. * @param yawCor optional yaw (y-axis) correction in radians
  86909. * @param pitchCor optional pitch (x-axis) correction in radians
  86910. * @param rollCor optional roll (z-axis) correction in radians
  86911. * @param space the choosen space of the target
  86912. * @returns the TransformNode.
  86913. */
  86914. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  86915. /**
  86916. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  86917. * This Vector3 is expressed in the World space.
  86918. * @param localAxis axis to rotate
  86919. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  86920. */
  86921. getDirection(localAxis: Vector3): Vector3;
  86922. /**
  86923. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  86924. * localAxis is expressed in the mesh local space.
  86925. * result is computed in the Wordl space from the mesh World matrix.
  86926. * @param localAxis axis to rotate
  86927. * @param result the resulting transformnode
  86928. * @returns this TransformNode.
  86929. */
  86930. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  86931. /**
  86932. * Sets this transform node rotation to the given local axis.
  86933. * @param localAxis the axis in local space
  86934. * @param yawCor optional yaw (y-axis) correction in radians
  86935. * @param pitchCor optional pitch (x-axis) correction in radians
  86936. * @param rollCor optional roll (z-axis) correction in radians
  86937. * @returns this TransformNode
  86938. */
  86939. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  86940. /**
  86941. * Sets a new pivot point to the current node
  86942. * @param point defines the new pivot point to use
  86943. * @param space defines if the point is in world or local space (local by default)
  86944. * @returns the current TransformNode
  86945. */
  86946. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  86947. /**
  86948. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  86949. * @returns the pivot point
  86950. */
  86951. getPivotPoint(): Vector3;
  86952. /**
  86953. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  86954. * @param result the vector3 to store the result
  86955. * @returns this TransformNode.
  86956. */
  86957. getPivotPointToRef(result: Vector3): TransformNode;
  86958. /**
  86959. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  86960. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  86961. */
  86962. getAbsolutePivotPoint(): Vector3;
  86963. /**
  86964. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  86965. * @param result vector3 to store the result
  86966. * @returns this TransformNode.
  86967. */
  86968. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  86969. /**
  86970. * Defines the passed node as the parent of the current node.
  86971. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  86972. * @see https://doc.babylonjs.com/how_to/parenting
  86973. * @param node the node ot set as the parent
  86974. * @returns this TransformNode.
  86975. */
  86976. setParent(node: Nullable<Node>): TransformNode;
  86977. private _nonUniformScaling;
  86978. /**
  86979. * True if the scaling property of this object is non uniform eg. (1,2,1)
  86980. */
  86981. get nonUniformScaling(): boolean;
  86982. /** @hidden */
  86983. _updateNonUniformScalingState(value: boolean): boolean;
  86984. /**
  86985. * Attach the current TransformNode to another TransformNode associated with a bone
  86986. * @param bone Bone affecting the TransformNode
  86987. * @param affectedTransformNode TransformNode associated with the bone
  86988. * @returns this object
  86989. */
  86990. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  86991. /**
  86992. * Detach the transform node if its associated with a bone
  86993. * @returns this object
  86994. */
  86995. detachFromBone(): TransformNode;
  86996. private static _rotationAxisCache;
  86997. /**
  86998. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  86999. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87000. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87001. * The passed axis is also normalized.
  87002. * @param axis the axis to rotate around
  87003. * @param amount the amount to rotate in radians
  87004. * @param space Space to rotate in (Default: local)
  87005. * @returns the TransformNode.
  87006. */
  87007. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87008. /**
  87009. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  87010. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87011. * The passed axis is also normalized. .
  87012. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  87013. * @param point the point to rotate around
  87014. * @param axis the axis to rotate around
  87015. * @param amount the amount to rotate in radians
  87016. * @returns the TransformNode
  87017. */
  87018. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  87019. /**
  87020. * Translates the mesh along the axis vector for the passed distance in the given space.
  87021. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87022. * @param axis the axis to translate in
  87023. * @param distance the distance to translate
  87024. * @param space Space to rotate in (Default: local)
  87025. * @returns the TransformNode.
  87026. */
  87027. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87028. /**
  87029. * Adds a rotation step to the mesh current rotation.
  87030. * x, y, z are Euler angles expressed in radians.
  87031. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  87032. * This means this rotation is made in the mesh local space only.
  87033. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  87034. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  87035. * ```javascript
  87036. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  87037. * ```
  87038. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  87039. * 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.
  87040. * @param x Rotation to add
  87041. * @param y Rotation to add
  87042. * @param z Rotation to add
  87043. * @returns the TransformNode.
  87044. */
  87045. addRotation(x: number, y: number, z: number): TransformNode;
  87046. /**
  87047. * @hidden
  87048. */
  87049. protected _getEffectiveParent(): Nullable<Node>;
  87050. /**
  87051. * Computes the world matrix of the node
  87052. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87053. * @returns the world matrix
  87054. */
  87055. computeWorldMatrix(force?: boolean): Matrix;
  87056. /**
  87057. * Resets this nodeTransform's local matrix to Matrix.Identity().
  87058. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  87059. */
  87060. resetLocalMatrix(independentOfChildren?: boolean): void;
  87061. protected _afterComputeWorldMatrix(): void;
  87062. /**
  87063. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  87064. * @param func callback function to add
  87065. *
  87066. * @returns the TransformNode.
  87067. */
  87068. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87069. /**
  87070. * Removes a registered callback function.
  87071. * @param func callback function to remove
  87072. * @returns the TransformNode.
  87073. */
  87074. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87075. /**
  87076. * Gets the position of the current mesh in camera space
  87077. * @param camera defines the camera to use
  87078. * @returns a position
  87079. */
  87080. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  87081. /**
  87082. * Returns the distance from the mesh to the active camera
  87083. * @param camera defines the camera to use
  87084. * @returns the distance
  87085. */
  87086. getDistanceToCamera(camera?: Nullable<Camera>): number;
  87087. /**
  87088. * Clone the current transform node
  87089. * @param name Name of the new clone
  87090. * @param newParent New parent for the clone
  87091. * @param doNotCloneChildren Do not clone children hierarchy
  87092. * @returns the new transform node
  87093. */
  87094. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  87095. /**
  87096. * Serializes the objects information.
  87097. * @param currentSerializationObject defines the object to serialize in
  87098. * @returns the serialized object
  87099. */
  87100. serialize(currentSerializationObject?: any): any;
  87101. /**
  87102. * Returns a new TransformNode object parsed from the source provided.
  87103. * @param parsedTransformNode is the source.
  87104. * @param scene the scne the object belongs to
  87105. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  87106. * @returns a new TransformNode object parsed from the source provided.
  87107. */
  87108. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  87109. /**
  87110. * Get all child-transformNodes of this node
  87111. * @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
  87112. * @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
  87113. * @returns an array of TransformNode
  87114. */
  87115. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  87116. /**
  87117. * Releases resources associated with this transform node.
  87118. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87119. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87120. */
  87121. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87122. /**
  87123. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87124. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87125. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87126. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87127. * @returns the current mesh
  87128. */
  87129. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87130. private _syncAbsoluteScalingAndRotation;
  87131. }
  87132. }
  87133. declare module BABYLON {
  87134. /**
  87135. * Class used to override all child animations of a given target
  87136. */
  87137. export class AnimationPropertiesOverride {
  87138. /**
  87139. * Gets or sets a value indicating if animation blending must be used
  87140. */
  87141. enableBlending: boolean;
  87142. /**
  87143. * Gets or sets the blending speed to use when enableBlending is true
  87144. */
  87145. blendingSpeed: number;
  87146. /**
  87147. * Gets or sets the default loop mode to use
  87148. */
  87149. loopMode: number;
  87150. }
  87151. }
  87152. declare module BABYLON {
  87153. /**
  87154. * Class used to store bone information
  87155. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87156. */
  87157. export class Bone extends Node {
  87158. /**
  87159. * defines the bone name
  87160. */
  87161. name: string;
  87162. private static _tmpVecs;
  87163. private static _tmpQuat;
  87164. private static _tmpMats;
  87165. /**
  87166. * Gets the list of child bones
  87167. */
  87168. children: Bone[];
  87169. /** Gets the animations associated with this bone */
  87170. animations: Animation[];
  87171. /**
  87172. * Gets or sets bone length
  87173. */
  87174. length: number;
  87175. /**
  87176. * @hidden Internal only
  87177. * Set this value to map this bone to a different index in the transform matrices
  87178. * Set this value to -1 to exclude the bone from the transform matrices
  87179. */
  87180. _index: Nullable<number>;
  87181. private _skeleton;
  87182. private _localMatrix;
  87183. private _restPose;
  87184. private _baseMatrix;
  87185. private _absoluteTransform;
  87186. private _invertedAbsoluteTransform;
  87187. private _parent;
  87188. private _scalingDeterminant;
  87189. private _worldTransform;
  87190. private _localScaling;
  87191. private _localRotation;
  87192. private _localPosition;
  87193. private _needToDecompose;
  87194. private _needToCompose;
  87195. /** @hidden */
  87196. _linkedTransformNode: Nullable<TransformNode>;
  87197. /** @hidden */
  87198. _waitingTransformNodeId: Nullable<string>;
  87199. /** @hidden */
  87200. get _matrix(): Matrix;
  87201. /** @hidden */
  87202. set _matrix(value: Matrix);
  87203. /**
  87204. * Create a new bone
  87205. * @param name defines the bone name
  87206. * @param skeleton defines the parent skeleton
  87207. * @param parentBone defines the parent (can be null if the bone is the root)
  87208. * @param localMatrix defines the local matrix
  87209. * @param restPose defines the rest pose matrix
  87210. * @param baseMatrix defines the base matrix
  87211. * @param index defines index of the bone in the hiearchy
  87212. */
  87213. constructor(
  87214. /**
  87215. * defines the bone name
  87216. */
  87217. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  87218. /**
  87219. * Gets the current object class name.
  87220. * @return the class name
  87221. */
  87222. getClassName(): string;
  87223. /**
  87224. * Gets the parent skeleton
  87225. * @returns a skeleton
  87226. */
  87227. getSkeleton(): Skeleton;
  87228. /**
  87229. * Gets parent bone
  87230. * @returns a bone or null if the bone is the root of the bone hierarchy
  87231. */
  87232. getParent(): Nullable<Bone>;
  87233. /**
  87234. * Returns an array containing the root bones
  87235. * @returns an array containing the root bones
  87236. */
  87237. getChildren(): Array<Bone>;
  87238. /**
  87239. * Gets the node index in matrix array generated for rendering
  87240. * @returns the node index
  87241. */
  87242. getIndex(): number;
  87243. /**
  87244. * Sets the parent bone
  87245. * @param parent defines the parent (can be null if the bone is the root)
  87246. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87247. */
  87248. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  87249. /**
  87250. * Gets the local matrix
  87251. * @returns a matrix
  87252. */
  87253. getLocalMatrix(): Matrix;
  87254. /**
  87255. * Gets the base matrix (initial matrix which remains unchanged)
  87256. * @returns a matrix
  87257. */
  87258. getBaseMatrix(): Matrix;
  87259. /**
  87260. * Gets the rest pose matrix
  87261. * @returns a matrix
  87262. */
  87263. getRestPose(): Matrix;
  87264. /**
  87265. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  87266. */
  87267. getWorldMatrix(): Matrix;
  87268. /**
  87269. * Sets the local matrix to rest pose matrix
  87270. */
  87271. returnToRest(): void;
  87272. /**
  87273. * Gets the inverse of the absolute transform matrix.
  87274. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  87275. * @returns a matrix
  87276. */
  87277. getInvertedAbsoluteTransform(): Matrix;
  87278. /**
  87279. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  87280. * @returns a matrix
  87281. */
  87282. getAbsoluteTransform(): Matrix;
  87283. /**
  87284. * Links with the given transform node.
  87285. * The local matrix of this bone is copied from the transform node every frame.
  87286. * @param transformNode defines the transform node to link to
  87287. */
  87288. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  87289. /**
  87290. * Gets the node used to drive the bone's transformation
  87291. * @returns a transform node or null
  87292. */
  87293. getTransformNode(): Nullable<TransformNode>;
  87294. /** Gets or sets current position (in local space) */
  87295. get position(): Vector3;
  87296. set position(newPosition: Vector3);
  87297. /** Gets or sets current rotation (in local space) */
  87298. get rotation(): Vector3;
  87299. set rotation(newRotation: Vector3);
  87300. /** Gets or sets current rotation quaternion (in local space) */
  87301. get rotationQuaternion(): Quaternion;
  87302. set rotationQuaternion(newRotation: Quaternion);
  87303. /** Gets or sets current scaling (in local space) */
  87304. get scaling(): Vector3;
  87305. set scaling(newScaling: Vector3);
  87306. /**
  87307. * Gets the animation properties override
  87308. */
  87309. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  87310. private _decompose;
  87311. private _compose;
  87312. /**
  87313. * Update the base and local matrices
  87314. * @param matrix defines the new base or local matrix
  87315. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87316. * @param updateLocalMatrix defines if the local matrix should be updated
  87317. */
  87318. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  87319. /** @hidden */
  87320. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  87321. /**
  87322. * Flag the bone as dirty (Forcing it to update everything)
  87323. */
  87324. markAsDirty(): void;
  87325. /** @hidden */
  87326. _markAsDirtyAndCompose(): void;
  87327. private _markAsDirtyAndDecompose;
  87328. /**
  87329. * Translate the bone in local or world space
  87330. * @param vec The amount to translate the bone
  87331. * @param space The space that the translation is in
  87332. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87333. */
  87334. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87335. /**
  87336. * Set the postion of the bone in local or world space
  87337. * @param position The position to set the bone
  87338. * @param space The space that the position is in
  87339. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87340. */
  87341. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87342. /**
  87343. * Set the absolute position of the bone (world space)
  87344. * @param position The position to set the bone
  87345. * @param mesh The mesh that this bone is attached to
  87346. */
  87347. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  87348. /**
  87349. * Scale the bone on the x, y and z axes (in local space)
  87350. * @param x The amount to scale the bone on the x axis
  87351. * @param y The amount to scale the bone on the y axis
  87352. * @param z The amount to scale the bone on the z axis
  87353. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  87354. */
  87355. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  87356. /**
  87357. * Set the bone scaling in local space
  87358. * @param scale defines the scaling vector
  87359. */
  87360. setScale(scale: Vector3): void;
  87361. /**
  87362. * Gets the current scaling in local space
  87363. * @returns the current scaling vector
  87364. */
  87365. getScale(): Vector3;
  87366. /**
  87367. * Gets the current scaling in local space and stores it in a target vector
  87368. * @param result defines the target vector
  87369. */
  87370. getScaleToRef(result: Vector3): void;
  87371. /**
  87372. * Set the yaw, pitch, and roll of the bone in local or world space
  87373. * @param yaw The rotation of the bone on the y axis
  87374. * @param pitch The rotation of the bone on the x axis
  87375. * @param roll The rotation of the bone on the z axis
  87376. * @param space The space that the axes of rotation are in
  87377. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87378. */
  87379. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  87380. /**
  87381. * Add a rotation to the bone on an axis in local or world space
  87382. * @param axis The axis to rotate the bone on
  87383. * @param amount The amount to rotate the bone
  87384. * @param space The space that the axis is in
  87385. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87386. */
  87387. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  87388. /**
  87389. * Set the rotation of the bone to a particular axis angle in local or world space
  87390. * @param axis The axis to rotate the bone on
  87391. * @param angle The angle that the bone should be rotated to
  87392. * @param space The space that the axis is in
  87393. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87394. */
  87395. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  87396. /**
  87397. * Set the euler rotation of the bone in local of world space
  87398. * @param rotation The euler rotation that the bone should be set to
  87399. * @param space The space that the rotation is in
  87400. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87401. */
  87402. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87403. /**
  87404. * Set the quaternion rotation of the bone in local of world space
  87405. * @param quat The quaternion rotation that the bone should be set to
  87406. * @param space The space that the rotation is in
  87407. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87408. */
  87409. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  87410. /**
  87411. * Set the rotation matrix of the bone in local of world space
  87412. * @param rotMat The rotation matrix that the bone should be set to
  87413. * @param space The space that the rotation is in
  87414. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87415. */
  87416. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  87417. private _rotateWithMatrix;
  87418. private _getNegativeRotationToRef;
  87419. /**
  87420. * Get the position of the bone in local or world space
  87421. * @param space The space that the returned position is in
  87422. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87423. * @returns The position of the bone
  87424. */
  87425. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87426. /**
  87427. * Copy the position of the bone to a vector3 in local or world space
  87428. * @param space The space that the returned position is in
  87429. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87430. * @param result The vector3 to copy the position to
  87431. */
  87432. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  87433. /**
  87434. * Get the absolute position of the bone (world space)
  87435. * @param mesh The mesh that this bone is attached to
  87436. * @returns The absolute position of the bone
  87437. */
  87438. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  87439. /**
  87440. * Copy the absolute position of the bone (world space) to the result param
  87441. * @param mesh The mesh that this bone is attached to
  87442. * @param result The vector3 to copy the absolute position to
  87443. */
  87444. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  87445. /**
  87446. * Compute the absolute transforms of this bone and its children
  87447. */
  87448. computeAbsoluteTransforms(): void;
  87449. /**
  87450. * Get the world direction from an axis that is in the local space of the bone
  87451. * @param localAxis The local direction that is used to compute the world direction
  87452. * @param mesh The mesh that this bone is attached to
  87453. * @returns The world direction
  87454. */
  87455. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87456. /**
  87457. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  87458. * @param localAxis The local direction that is used to compute the world direction
  87459. * @param mesh The mesh that this bone is attached to
  87460. * @param result The vector3 that the world direction will be copied to
  87461. */
  87462. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87463. /**
  87464. * Get the euler rotation of the bone in local or world space
  87465. * @param space The space that the rotation should be in
  87466. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87467. * @returns The euler rotation
  87468. */
  87469. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87470. /**
  87471. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  87472. * @param space The space that the rotation should be in
  87473. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87474. * @param result The vector3 that the rotation should be copied to
  87475. */
  87476. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87477. /**
  87478. * Get the quaternion rotation of the bone in either local or world space
  87479. * @param space The space that the rotation should be in
  87480. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87481. * @returns The quaternion rotation
  87482. */
  87483. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  87484. /**
  87485. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  87486. * @param space The space that the rotation should be in
  87487. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87488. * @param result The quaternion that the rotation should be copied to
  87489. */
  87490. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  87491. /**
  87492. * Get the rotation matrix of the bone in local or world space
  87493. * @param space The space that the rotation should be in
  87494. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87495. * @returns The rotation matrix
  87496. */
  87497. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  87498. /**
  87499. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  87500. * @param space The space that the rotation should be in
  87501. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87502. * @param result The quaternion that the rotation should be copied to
  87503. */
  87504. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  87505. /**
  87506. * Get the world position of a point that is in the local space of the bone
  87507. * @param position The local position
  87508. * @param mesh The mesh that this bone is attached to
  87509. * @returns The world position
  87510. */
  87511. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87512. /**
  87513. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  87514. * @param position The local position
  87515. * @param mesh The mesh that this bone is attached to
  87516. * @param result The vector3 that the world position should be copied to
  87517. */
  87518. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87519. /**
  87520. * Get the local position of a point that is in world space
  87521. * @param position The world position
  87522. * @param mesh The mesh that this bone is attached to
  87523. * @returns The local position
  87524. */
  87525. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87526. /**
  87527. * Get the local position of a point that is in world space and copy it to the result param
  87528. * @param position The world position
  87529. * @param mesh The mesh that this bone is attached to
  87530. * @param result The vector3 that the local position should be copied to
  87531. */
  87532. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87533. }
  87534. }
  87535. declare module BABYLON {
  87536. /**
  87537. * Defines a runtime animation
  87538. */
  87539. export class RuntimeAnimation {
  87540. private _events;
  87541. /**
  87542. * The current frame of the runtime animation
  87543. */
  87544. private _currentFrame;
  87545. /**
  87546. * The animation used by the runtime animation
  87547. */
  87548. private _animation;
  87549. /**
  87550. * The target of the runtime animation
  87551. */
  87552. private _target;
  87553. /**
  87554. * The initiating animatable
  87555. */
  87556. private _host;
  87557. /**
  87558. * The original value of the runtime animation
  87559. */
  87560. private _originalValue;
  87561. /**
  87562. * The original blend value of the runtime animation
  87563. */
  87564. private _originalBlendValue;
  87565. /**
  87566. * The offsets cache of the runtime animation
  87567. */
  87568. private _offsetsCache;
  87569. /**
  87570. * The high limits cache of the runtime animation
  87571. */
  87572. private _highLimitsCache;
  87573. /**
  87574. * Specifies if the runtime animation has been stopped
  87575. */
  87576. private _stopped;
  87577. /**
  87578. * The blending factor of the runtime animation
  87579. */
  87580. private _blendingFactor;
  87581. /**
  87582. * The BabylonJS scene
  87583. */
  87584. private _scene;
  87585. /**
  87586. * The current value of the runtime animation
  87587. */
  87588. private _currentValue;
  87589. /** @hidden */
  87590. _animationState: _IAnimationState;
  87591. /**
  87592. * The active target of the runtime animation
  87593. */
  87594. private _activeTargets;
  87595. private _currentActiveTarget;
  87596. private _directTarget;
  87597. /**
  87598. * The target path of the runtime animation
  87599. */
  87600. private _targetPath;
  87601. /**
  87602. * The weight of the runtime animation
  87603. */
  87604. private _weight;
  87605. /**
  87606. * The ratio offset of the runtime animation
  87607. */
  87608. private _ratioOffset;
  87609. /**
  87610. * The previous delay of the runtime animation
  87611. */
  87612. private _previousDelay;
  87613. /**
  87614. * The previous ratio of the runtime animation
  87615. */
  87616. private _previousRatio;
  87617. private _enableBlending;
  87618. private _keys;
  87619. private _minFrame;
  87620. private _maxFrame;
  87621. private _minValue;
  87622. private _maxValue;
  87623. private _targetIsArray;
  87624. /**
  87625. * Gets the current frame of the runtime animation
  87626. */
  87627. get currentFrame(): number;
  87628. /**
  87629. * Gets the weight of the runtime animation
  87630. */
  87631. get weight(): number;
  87632. /**
  87633. * Gets the current value of the runtime animation
  87634. */
  87635. get currentValue(): any;
  87636. /**
  87637. * Gets the target path of the runtime animation
  87638. */
  87639. get targetPath(): string;
  87640. /**
  87641. * Gets the actual target of the runtime animation
  87642. */
  87643. get target(): any;
  87644. /** @hidden */
  87645. _onLoop: () => void;
  87646. /**
  87647. * Create a new RuntimeAnimation object
  87648. * @param target defines the target of the animation
  87649. * @param animation defines the source animation object
  87650. * @param scene defines the hosting scene
  87651. * @param host defines the initiating Animatable
  87652. */
  87653. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  87654. private _preparePath;
  87655. /**
  87656. * Gets the animation from the runtime animation
  87657. */
  87658. get animation(): Animation;
  87659. /**
  87660. * Resets the runtime animation to the beginning
  87661. * @param restoreOriginal defines whether to restore the target property to the original value
  87662. */
  87663. reset(restoreOriginal?: boolean): void;
  87664. /**
  87665. * Specifies if the runtime animation is stopped
  87666. * @returns Boolean specifying if the runtime animation is stopped
  87667. */
  87668. isStopped(): boolean;
  87669. /**
  87670. * Disposes of the runtime animation
  87671. */
  87672. dispose(): void;
  87673. /**
  87674. * Apply the interpolated value to the target
  87675. * @param currentValue defines the value computed by the animation
  87676. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  87677. */
  87678. setValue(currentValue: any, weight: number): void;
  87679. private _getOriginalValues;
  87680. private _setValue;
  87681. /**
  87682. * Gets the loop pmode of the runtime animation
  87683. * @returns Loop Mode
  87684. */
  87685. private _getCorrectLoopMode;
  87686. /**
  87687. * Move the current animation to a given frame
  87688. * @param frame defines the frame to move to
  87689. */
  87690. goToFrame(frame: number): void;
  87691. /**
  87692. * @hidden Internal use only
  87693. */
  87694. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  87695. /**
  87696. * Execute the current animation
  87697. * @param delay defines the delay to add to the current frame
  87698. * @param from defines the lower bound of the animation range
  87699. * @param to defines the upper bound of the animation range
  87700. * @param loop defines if the current animation must loop
  87701. * @param speedRatio defines the current speed ratio
  87702. * @param weight defines the weight of the animation (default is -1 so no weight)
  87703. * @param onLoop optional callback called when animation loops
  87704. * @returns a boolean indicating if the animation is running
  87705. */
  87706. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  87707. }
  87708. }
  87709. declare module BABYLON {
  87710. /**
  87711. * Class used to store an actual running animation
  87712. */
  87713. export class Animatable {
  87714. /** defines the target object */
  87715. target: any;
  87716. /** defines the starting frame number (default is 0) */
  87717. fromFrame: number;
  87718. /** defines the ending frame number (default is 100) */
  87719. toFrame: number;
  87720. /** defines if the animation must loop (default is false) */
  87721. loopAnimation: boolean;
  87722. /** defines a callback to call when animation ends if it is not looping */
  87723. onAnimationEnd?: (() => void) | null | undefined;
  87724. /** defines a callback to call when animation loops */
  87725. onAnimationLoop?: (() => void) | null | undefined;
  87726. private _localDelayOffset;
  87727. private _pausedDelay;
  87728. private _runtimeAnimations;
  87729. private _paused;
  87730. private _scene;
  87731. private _speedRatio;
  87732. private _weight;
  87733. private _syncRoot;
  87734. /**
  87735. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  87736. * This will only apply for non looping animation (default is true)
  87737. */
  87738. disposeOnEnd: boolean;
  87739. /**
  87740. * Gets a boolean indicating if the animation has started
  87741. */
  87742. animationStarted: boolean;
  87743. /**
  87744. * Observer raised when the animation ends
  87745. */
  87746. onAnimationEndObservable: Observable<Animatable>;
  87747. /**
  87748. * Observer raised when the animation loops
  87749. */
  87750. onAnimationLoopObservable: Observable<Animatable>;
  87751. /**
  87752. * Gets the root Animatable used to synchronize and normalize animations
  87753. */
  87754. get syncRoot(): Nullable<Animatable>;
  87755. /**
  87756. * Gets the current frame of the first RuntimeAnimation
  87757. * Used to synchronize Animatables
  87758. */
  87759. get masterFrame(): number;
  87760. /**
  87761. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  87762. */
  87763. get weight(): number;
  87764. set weight(value: number);
  87765. /**
  87766. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  87767. */
  87768. get speedRatio(): number;
  87769. set speedRatio(value: number);
  87770. /**
  87771. * Creates a new Animatable
  87772. * @param scene defines the hosting scene
  87773. * @param target defines the target object
  87774. * @param fromFrame defines the starting frame number (default is 0)
  87775. * @param toFrame defines the ending frame number (default is 100)
  87776. * @param loopAnimation defines if the animation must loop (default is false)
  87777. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  87778. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  87779. * @param animations defines a group of animation to add to the new Animatable
  87780. * @param onAnimationLoop defines a callback to call when animation loops
  87781. */
  87782. constructor(scene: Scene,
  87783. /** defines the target object */
  87784. target: any,
  87785. /** defines the starting frame number (default is 0) */
  87786. fromFrame?: number,
  87787. /** defines the ending frame number (default is 100) */
  87788. toFrame?: number,
  87789. /** defines if the animation must loop (default is false) */
  87790. loopAnimation?: boolean, speedRatio?: number,
  87791. /** defines a callback to call when animation ends if it is not looping */
  87792. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  87793. /** defines a callback to call when animation loops */
  87794. onAnimationLoop?: (() => void) | null | undefined);
  87795. /**
  87796. * Synchronize and normalize current Animatable with a source Animatable
  87797. * This is useful when using animation weights and when animations are not of the same length
  87798. * @param root defines the root Animatable to synchronize with
  87799. * @returns the current Animatable
  87800. */
  87801. syncWith(root: Animatable): Animatable;
  87802. /**
  87803. * Gets the list of runtime animations
  87804. * @returns an array of RuntimeAnimation
  87805. */
  87806. getAnimations(): RuntimeAnimation[];
  87807. /**
  87808. * Adds more animations to the current animatable
  87809. * @param target defines the target of the animations
  87810. * @param animations defines the new animations to add
  87811. */
  87812. appendAnimations(target: any, animations: Animation[]): void;
  87813. /**
  87814. * Gets the source animation for a specific property
  87815. * @param property defines the propertyu to look for
  87816. * @returns null or the source animation for the given property
  87817. */
  87818. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  87819. /**
  87820. * Gets the runtime animation for a specific property
  87821. * @param property defines the propertyu to look for
  87822. * @returns null or the runtime animation for the given property
  87823. */
  87824. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  87825. /**
  87826. * Resets the animatable to its original state
  87827. */
  87828. reset(): void;
  87829. /**
  87830. * Allows the animatable to blend with current running animations
  87831. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87832. * @param blendingSpeed defines the blending speed to use
  87833. */
  87834. enableBlending(blendingSpeed: number): void;
  87835. /**
  87836. * Disable animation blending
  87837. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87838. */
  87839. disableBlending(): void;
  87840. /**
  87841. * Jump directly to a given frame
  87842. * @param frame defines the frame to jump to
  87843. */
  87844. goToFrame(frame: number): void;
  87845. /**
  87846. * Pause the animation
  87847. */
  87848. pause(): void;
  87849. /**
  87850. * Restart the animation
  87851. */
  87852. restart(): void;
  87853. private _raiseOnAnimationEnd;
  87854. /**
  87855. * Stop and delete the current animation
  87856. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  87857. * @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)
  87858. */
  87859. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  87860. /**
  87861. * Wait asynchronously for the animation to end
  87862. * @returns a promise which will be fullfilled when the animation ends
  87863. */
  87864. waitAsync(): Promise<Animatable>;
  87865. /** @hidden */
  87866. _animate(delay: number): boolean;
  87867. }
  87868. interface Scene {
  87869. /** @hidden */
  87870. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  87871. /** @hidden */
  87872. _processLateAnimationBindingsForMatrices(holder: {
  87873. totalWeight: number;
  87874. animations: RuntimeAnimation[];
  87875. originalValue: Matrix;
  87876. }): any;
  87877. /** @hidden */
  87878. _processLateAnimationBindingsForQuaternions(holder: {
  87879. totalWeight: number;
  87880. animations: RuntimeAnimation[];
  87881. originalValue: Quaternion;
  87882. }, refQuaternion: Quaternion): Quaternion;
  87883. /** @hidden */
  87884. _processLateAnimationBindings(): void;
  87885. /**
  87886. * Will start the animation sequence of a given target
  87887. * @param target defines the target
  87888. * @param from defines from which frame should animation start
  87889. * @param to defines until which frame should animation run.
  87890. * @param weight defines the weight to apply to the animation (1.0 by default)
  87891. * @param loop defines if the animation loops
  87892. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87893. * @param onAnimationEnd defines the function to be executed when the animation ends
  87894. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87895. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  87896. * @param onAnimationLoop defines the callback to call when an animation loops
  87897. * @returns the animatable object created for this animation
  87898. */
  87899. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  87900. /**
  87901. * Will start the animation sequence of a given target
  87902. * @param target defines the target
  87903. * @param from defines from which frame should animation start
  87904. * @param to defines until which frame should animation run.
  87905. * @param loop defines if the animation loops
  87906. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87907. * @param onAnimationEnd defines the function to be executed when the animation ends
  87908. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87909. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  87910. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  87911. * @param onAnimationLoop defines the callback to call when an animation loops
  87912. * @returns the animatable object created for this animation
  87913. */
  87914. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  87915. /**
  87916. * Will start the animation sequence of a given target and its hierarchy
  87917. * @param target defines the target
  87918. * @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.
  87919. * @param from defines from which frame should animation start
  87920. * @param to defines until which frame should animation run.
  87921. * @param loop defines if the animation loops
  87922. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87923. * @param onAnimationEnd defines the function to be executed when the animation ends
  87924. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  87925. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  87926. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  87927. * @param onAnimationLoop defines the callback to call when an animation loops
  87928. * @returns the list of created animatables
  87929. */
  87930. 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[];
  87931. /**
  87932. * Begin a new animation on a given node
  87933. * @param target defines the target where the animation will take place
  87934. * @param animations defines the list of animations to start
  87935. * @param from defines the initial value
  87936. * @param to defines the final value
  87937. * @param loop defines if you want animation to loop (off by default)
  87938. * @param speedRatio defines the speed ratio to apply to all animations
  87939. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  87940. * @param onAnimationLoop defines the callback to call when an animation loops
  87941. * @returns the list of created animatables
  87942. */
  87943. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  87944. /**
  87945. * Begin a new animation on a given node and its hierarchy
  87946. * @param target defines the root node where the animation will take place
  87947. * @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.
  87948. * @param animations defines the list of animations to start
  87949. * @param from defines the initial value
  87950. * @param to defines the final value
  87951. * @param loop defines if you want animation to loop (off by default)
  87952. * @param speedRatio defines the speed ratio to apply to all animations
  87953. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  87954. * @param onAnimationLoop defines the callback to call when an animation loops
  87955. * @returns the list of animatables created for all nodes
  87956. */
  87957. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  87958. /**
  87959. * Gets the animatable associated with a specific target
  87960. * @param target defines the target of the animatable
  87961. * @returns the required animatable if found
  87962. */
  87963. getAnimatableByTarget(target: any): Nullable<Animatable>;
  87964. /**
  87965. * Gets all animatables associated with a given target
  87966. * @param target defines the target to look animatables for
  87967. * @returns an array of Animatables
  87968. */
  87969. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  87970. /**
  87971. * Stops and removes all animations that have been applied to the scene
  87972. */
  87973. stopAllAnimations(): void;
  87974. /**
  87975. * Gets the current delta time used by animation engine
  87976. */
  87977. deltaTime: number;
  87978. }
  87979. interface Bone {
  87980. /**
  87981. * Copy an animation range from another bone
  87982. * @param source defines the source bone
  87983. * @param rangeName defines the range name to copy
  87984. * @param frameOffset defines the frame offset
  87985. * @param rescaleAsRequired defines if rescaling must be applied if required
  87986. * @param skelDimensionsRatio defines the scaling ratio
  87987. * @returns true if operation was successful
  87988. */
  87989. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  87990. }
  87991. }
  87992. declare module BABYLON {
  87993. /**
  87994. * Class used to handle skinning animations
  87995. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87996. */
  87997. export class Skeleton implements IAnimatable {
  87998. /** defines the skeleton name */
  87999. name: string;
  88000. /** defines the skeleton Id */
  88001. id: string;
  88002. /**
  88003. * Defines the list of child bones
  88004. */
  88005. bones: Bone[];
  88006. /**
  88007. * Defines an estimate of the dimension of the skeleton at rest
  88008. */
  88009. dimensionsAtRest: Vector3;
  88010. /**
  88011. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  88012. */
  88013. needInitialSkinMatrix: boolean;
  88014. /**
  88015. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  88016. */
  88017. overrideMesh: Nullable<AbstractMesh>;
  88018. /**
  88019. * Gets the list of animations attached to this skeleton
  88020. */
  88021. animations: Array<Animation>;
  88022. private _scene;
  88023. private _isDirty;
  88024. private _transformMatrices;
  88025. private _transformMatrixTexture;
  88026. private _meshesWithPoseMatrix;
  88027. private _animatables;
  88028. private _identity;
  88029. private _synchronizedWithMesh;
  88030. private _ranges;
  88031. private _lastAbsoluteTransformsUpdateId;
  88032. private _canUseTextureForBones;
  88033. private _uniqueId;
  88034. /** @hidden */
  88035. _numBonesWithLinkedTransformNode: number;
  88036. /** @hidden */
  88037. _hasWaitingData: Nullable<boolean>;
  88038. /**
  88039. * Specifies if the skeleton should be serialized
  88040. */
  88041. doNotSerialize: boolean;
  88042. private _useTextureToStoreBoneMatrices;
  88043. /**
  88044. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  88045. * Please note that this option is not available if the hardware does not support it
  88046. */
  88047. get useTextureToStoreBoneMatrices(): boolean;
  88048. set useTextureToStoreBoneMatrices(value: boolean);
  88049. private _animationPropertiesOverride;
  88050. /**
  88051. * Gets or sets the animation properties override
  88052. */
  88053. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88054. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  88055. /**
  88056. * List of inspectable custom properties (used by the Inspector)
  88057. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88058. */
  88059. inspectableCustomProperties: IInspectable[];
  88060. /**
  88061. * An observable triggered before computing the skeleton's matrices
  88062. */
  88063. onBeforeComputeObservable: Observable<Skeleton>;
  88064. /**
  88065. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  88066. */
  88067. get isUsingTextureForMatrices(): boolean;
  88068. /**
  88069. * Gets the unique ID of this skeleton
  88070. */
  88071. get uniqueId(): number;
  88072. /**
  88073. * Creates a new skeleton
  88074. * @param name defines the skeleton name
  88075. * @param id defines the skeleton Id
  88076. * @param scene defines the hosting scene
  88077. */
  88078. constructor(
  88079. /** defines the skeleton name */
  88080. name: string,
  88081. /** defines the skeleton Id */
  88082. id: string, scene: Scene);
  88083. /**
  88084. * Gets the current object class name.
  88085. * @return the class name
  88086. */
  88087. getClassName(): string;
  88088. /**
  88089. * Returns an array containing the root bones
  88090. * @returns an array containing the root bones
  88091. */
  88092. getChildren(): Array<Bone>;
  88093. /**
  88094. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  88095. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88096. * @returns a Float32Array containing matrices data
  88097. */
  88098. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  88099. /**
  88100. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  88101. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88102. * @returns a raw texture containing the data
  88103. */
  88104. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  88105. /**
  88106. * Gets the current hosting scene
  88107. * @returns a scene object
  88108. */
  88109. getScene(): Scene;
  88110. /**
  88111. * Gets a string representing the current skeleton data
  88112. * @param fullDetails defines a boolean indicating if we want a verbose version
  88113. * @returns a string representing the current skeleton data
  88114. */
  88115. toString(fullDetails?: boolean): string;
  88116. /**
  88117. * Get bone's index searching by name
  88118. * @param name defines bone's name to search for
  88119. * @return the indice of the bone. Returns -1 if not found
  88120. */
  88121. getBoneIndexByName(name: string): number;
  88122. /**
  88123. * Creater a new animation range
  88124. * @param name defines the name of the range
  88125. * @param from defines the start key
  88126. * @param to defines the end key
  88127. */
  88128. createAnimationRange(name: string, from: number, to: number): void;
  88129. /**
  88130. * Delete a specific animation range
  88131. * @param name defines the name of the range
  88132. * @param deleteFrames defines if frames must be removed as well
  88133. */
  88134. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88135. /**
  88136. * Gets a specific animation range
  88137. * @param name defines the name of the range to look for
  88138. * @returns the requested animation range or null if not found
  88139. */
  88140. getAnimationRange(name: string): Nullable<AnimationRange>;
  88141. /**
  88142. * Gets the list of all animation ranges defined on this skeleton
  88143. * @returns an array
  88144. */
  88145. getAnimationRanges(): Nullable<AnimationRange>[];
  88146. /**
  88147. * Copy animation range from a source skeleton.
  88148. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  88149. * @param source defines the source skeleton
  88150. * @param name defines the name of the range to copy
  88151. * @param rescaleAsRequired defines if rescaling must be applied if required
  88152. * @returns true if operation was successful
  88153. */
  88154. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  88155. /**
  88156. * Forces the skeleton to go to rest pose
  88157. */
  88158. returnToRest(): void;
  88159. private _getHighestAnimationFrame;
  88160. /**
  88161. * Begin a specific animation range
  88162. * @param name defines the name of the range to start
  88163. * @param loop defines if looping must be turned on (false by default)
  88164. * @param speedRatio defines the speed ratio to apply (1 by default)
  88165. * @param onAnimationEnd defines a callback which will be called when animation will end
  88166. * @returns a new animatable
  88167. */
  88168. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88169. /** @hidden */
  88170. _markAsDirty(): void;
  88171. /** @hidden */
  88172. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88173. /** @hidden */
  88174. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88175. private _computeTransformMatrices;
  88176. /**
  88177. * Build all resources required to render a skeleton
  88178. */
  88179. prepare(): void;
  88180. /**
  88181. * Gets the list of animatables currently running for this skeleton
  88182. * @returns an array of animatables
  88183. */
  88184. getAnimatables(): IAnimatable[];
  88185. /**
  88186. * Clone the current skeleton
  88187. * @param name defines the name of the new skeleton
  88188. * @param id defines the id of the new skeleton
  88189. * @returns the new skeleton
  88190. */
  88191. clone(name: string, id?: string): Skeleton;
  88192. /**
  88193. * Enable animation blending for this skeleton
  88194. * @param blendingSpeed defines the blending speed to apply
  88195. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88196. */
  88197. enableBlending(blendingSpeed?: number): void;
  88198. /**
  88199. * Releases all resources associated with the current skeleton
  88200. */
  88201. dispose(): void;
  88202. /**
  88203. * Serialize the skeleton in a JSON object
  88204. * @returns a JSON object
  88205. */
  88206. serialize(): any;
  88207. /**
  88208. * Creates a new skeleton from serialized data
  88209. * @param parsedSkeleton defines the serialized data
  88210. * @param scene defines the hosting scene
  88211. * @returns a new skeleton
  88212. */
  88213. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  88214. /**
  88215. * Compute all node absolute transforms
  88216. * @param forceUpdate defines if computation must be done even if cache is up to date
  88217. */
  88218. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  88219. /**
  88220. * Gets the root pose matrix
  88221. * @returns a matrix
  88222. */
  88223. getPoseMatrix(): Nullable<Matrix>;
  88224. /**
  88225. * Sorts bones per internal index
  88226. */
  88227. sortBones(): void;
  88228. private _sortBones;
  88229. }
  88230. }
  88231. declare module BABYLON {
  88232. /**
  88233. * Creates an instance based on a source mesh.
  88234. */
  88235. export class InstancedMesh extends AbstractMesh {
  88236. private _sourceMesh;
  88237. private _currentLOD;
  88238. /** @hidden */
  88239. _indexInSourceMeshInstanceArray: number;
  88240. constructor(name: string, source: Mesh);
  88241. /**
  88242. * Returns the string "InstancedMesh".
  88243. */
  88244. getClassName(): string;
  88245. /** Gets the list of lights affecting that mesh */
  88246. get lightSources(): Light[];
  88247. _resyncLightSources(): void;
  88248. _resyncLightSource(light: Light): void;
  88249. _removeLightSource(light: Light, dispose: boolean): void;
  88250. /**
  88251. * If the source mesh receives shadows
  88252. */
  88253. get receiveShadows(): boolean;
  88254. /**
  88255. * The material of the source mesh
  88256. */
  88257. get material(): Nullable<Material>;
  88258. /**
  88259. * Visibility of the source mesh
  88260. */
  88261. get visibility(): number;
  88262. /**
  88263. * Skeleton of the source mesh
  88264. */
  88265. get skeleton(): Nullable<Skeleton>;
  88266. /**
  88267. * Rendering ground id of the source mesh
  88268. */
  88269. get renderingGroupId(): number;
  88270. set renderingGroupId(value: number);
  88271. /**
  88272. * Returns the total number of vertices (integer).
  88273. */
  88274. getTotalVertices(): number;
  88275. /**
  88276. * Returns a positive integer : the total number of indices in this mesh geometry.
  88277. * @returns the numner of indices or zero if the mesh has no geometry.
  88278. */
  88279. getTotalIndices(): number;
  88280. /**
  88281. * The source mesh of the instance
  88282. */
  88283. get sourceMesh(): Mesh;
  88284. /**
  88285. * Is this node ready to be used/rendered
  88286. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88287. * @return {boolean} is it ready
  88288. */
  88289. isReady(completeCheck?: boolean): boolean;
  88290. /**
  88291. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88292. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88293. * @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.
  88294. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88295. */
  88296. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  88297. /**
  88298. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88299. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88300. * The `data` are either a numeric array either a Float32Array.
  88301. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88302. * 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).
  88303. * Note that a new underlying VertexBuffer object is created each call.
  88304. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88305. *
  88306. * Possible `kind` values :
  88307. * - VertexBuffer.PositionKind
  88308. * - VertexBuffer.UVKind
  88309. * - VertexBuffer.UV2Kind
  88310. * - VertexBuffer.UV3Kind
  88311. * - VertexBuffer.UV4Kind
  88312. * - VertexBuffer.UV5Kind
  88313. * - VertexBuffer.UV6Kind
  88314. * - VertexBuffer.ColorKind
  88315. * - VertexBuffer.MatricesIndicesKind
  88316. * - VertexBuffer.MatricesIndicesExtraKind
  88317. * - VertexBuffer.MatricesWeightsKind
  88318. * - VertexBuffer.MatricesWeightsExtraKind
  88319. *
  88320. * Returns the Mesh.
  88321. */
  88322. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88323. /**
  88324. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88325. * If the mesh has no geometry, it is simply returned as it is.
  88326. * The `data` are either a numeric array either a Float32Array.
  88327. * No new underlying VertexBuffer object is created.
  88328. * 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.
  88329. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88330. *
  88331. * Possible `kind` values :
  88332. * - VertexBuffer.PositionKind
  88333. * - VertexBuffer.UVKind
  88334. * - VertexBuffer.UV2Kind
  88335. * - VertexBuffer.UV3Kind
  88336. * - VertexBuffer.UV4Kind
  88337. * - VertexBuffer.UV5Kind
  88338. * - VertexBuffer.UV6Kind
  88339. * - VertexBuffer.ColorKind
  88340. * - VertexBuffer.MatricesIndicesKind
  88341. * - VertexBuffer.MatricesIndicesExtraKind
  88342. * - VertexBuffer.MatricesWeightsKind
  88343. * - VertexBuffer.MatricesWeightsExtraKind
  88344. *
  88345. * Returns the Mesh.
  88346. */
  88347. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88348. /**
  88349. * Sets the mesh indices.
  88350. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88351. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88352. * This method creates a new index buffer each call.
  88353. * Returns the Mesh.
  88354. */
  88355. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88356. /**
  88357. * Boolean : True if the mesh owns the requested kind of data.
  88358. */
  88359. isVerticesDataPresent(kind: string): boolean;
  88360. /**
  88361. * Returns an array of indices (IndicesArray).
  88362. */
  88363. getIndices(): Nullable<IndicesArray>;
  88364. get _positions(): Nullable<Vector3[]>;
  88365. /**
  88366. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88367. * This means the mesh underlying bounding box and sphere are recomputed.
  88368. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88369. * @returns the current mesh
  88370. */
  88371. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88372. /** @hidden */
  88373. _preActivate(): InstancedMesh;
  88374. /** @hidden */
  88375. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88376. /** @hidden */
  88377. _postActivate(): void;
  88378. getWorldMatrix(): Matrix;
  88379. get isAnInstance(): boolean;
  88380. /**
  88381. * Returns the current associated LOD AbstractMesh.
  88382. */
  88383. getLOD(camera: Camera): AbstractMesh;
  88384. /** @hidden */
  88385. _preActivateForIntermediateRendering(renderId: number): Mesh;
  88386. /** @hidden */
  88387. _syncSubMeshes(): InstancedMesh;
  88388. /** @hidden */
  88389. _generatePointsArray(): boolean;
  88390. /**
  88391. * Creates a new InstancedMesh from the current mesh.
  88392. * - name (string) : the cloned mesh name
  88393. * - newParent (optional Node) : the optional Node to parent the clone to.
  88394. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88395. *
  88396. * Returns the clone.
  88397. */
  88398. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  88399. /**
  88400. * Disposes the InstancedMesh.
  88401. * Returns nothing.
  88402. */
  88403. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88404. }
  88405. interface Mesh {
  88406. /**
  88407. * Register a custom buffer that will be instanced
  88408. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88409. * @param kind defines the buffer kind
  88410. * @param stride defines the stride in floats
  88411. */
  88412. registerInstancedBuffer(kind: string, stride: number): void;
  88413. /** @hidden */
  88414. _userInstancedBuffersStorage: {
  88415. data: {
  88416. [key: string]: Float32Array;
  88417. };
  88418. sizes: {
  88419. [key: string]: number;
  88420. };
  88421. vertexBuffers: {
  88422. [key: string]: Nullable<VertexBuffer>;
  88423. };
  88424. strides: {
  88425. [key: string]: number;
  88426. };
  88427. };
  88428. }
  88429. interface AbstractMesh {
  88430. /**
  88431. * Object used to store instanced buffers defined by user
  88432. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88433. */
  88434. instancedBuffers: {
  88435. [key: string]: any;
  88436. };
  88437. }
  88438. }
  88439. declare module BABYLON {
  88440. /**
  88441. * Defines the options associated with the creation of a shader material.
  88442. */
  88443. export interface IShaderMaterialOptions {
  88444. /**
  88445. * Does the material work in alpha blend mode
  88446. */
  88447. needAlphaBlending: boolean;
  88448. /**
  88449. * Does the material work in alpha test mode
  88450. */
  88451. needAlphaTesting: boolean;
  88452. /**
  88453. * The list of attribute names used in the shader
  88454. */
  88455. attributes: string[];
  88456. /**
  88457. * The list of unifrom names used in the shader
  88458. */
  88459. uniforms: string[];
  88460. /**
  88461. * The list of UBO names used in the shader
  88462. */
  88463. uniformBuffers: string[];
  88464. /**
  88465. * The list of sampler names used in the shader
  88466. */
  88467. samplers: string[];
  88468. /**
  88469. * The list of defines used in the shader
  88470. */
  88471. defines: string[];
  88472. }
  88473. /**
  88474. * 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.
  88475. *
  88476. * This returned material effects how the mesh will look based on the code in the shaders.
  88477. *
  88478. * @see http://doc.babylonjs.com/how_to/shader_material
  88479. */
  88480. export class ShaderMaterial extends Material {
  88481. private _shaderPath;
  88482. private _options;
  88483. private _textures;
  88484. private _textureArrays;
  88485. private _floats;
  88486. private _ints;
  88487. private _floatsArrays;
  88488. private _colors3;
  88489. private _colors3Arrays;
  88490. private _colors4;
  88491. private _colors4Arrays;
  88492. private _vectors2;
  88493. private _vectors3;
  88494. private _vectors4;
  88495. private _matrices;
  88496. private _matrixArrays;
  88497. private _matrices3x3;
  88498. private _matrices2x2;
  88499. private _vectors2Arrays;
  88500. private _vectors3Arrays;
  88501. private _vectors4Arrays;
  88502. private _cachedWorldViewMatrix;
  88503. private _cachedWorldViewProjectionMatrix;
  88504. private _renderId;
  88505. private _multiview;
  88506. /**
  88507. * Instantiate a new shader material.
  88508. * 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.
  88509. * This returned material effects how the mesh will look based on the code in the shaders.
  88510. * @see http://doc.babylonjs.com/how_to/shader_material
  88511. * @param name Define the name of the material in the scene
  88512. * @param scene Define the scene the material belongs to
  88513. * @param shaderPath Defines the route to the shader code in one of three ways:
  88514. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88515. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88516. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88517. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88518. * @param options Define the options used to create the shader
  88519. */
  88520. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88521. /**
  88522. * Gets the shader path used to define the shader code
  88523. * It can be modified to trigger a new compilation
  88524. */
  88525. get shaderPath(): any;
  88526. /**
  88527. * Sets the shader path used to define the shader code
  88528. * It can be modified to trigger a new compilation
  88529. */
  88530. set shaderPath(shaderPath: any);
  88531. /**
  88532. * Gets the options used to compile the shader.
  88533. * They can be modified to trigger a new compilation
  88534. */
  88535. get options(): IShaderMaterialOptions;
  88536. /**
  88537. * Gets the current class name of the material e.g. "ShaderMaterial"
  88538. * Mainly use in serialization.
  88539. * @returns the class name
  88540. */
  88541. getClassName(): string;
  88542. /**
  88543. * Specifies if the material will require alpha blending
  88544. * @returns a boolean specifying if alpha blending is needed
  88545. */
  88546. needAlphaBlending(): boolean;
  88547. /**
  88548. * Specifies if this material should be rendered in alpha test mode
  88549. * @returns a boolean specifying if an alpha test is needed.
  88550. */
  88551. needAlphaTesting(): boolean;
  88552. private _checkUniform;
  88553. /**
  88554. * Set a texture in the shader.
  88555. * @param name Define the name of the uniform samplers as defined in the shader
  88556. * @param texture Define the texture to bind to this sampler
  88557. * @return the material itself allowing "fluent" like uniform updates
  88558. */
  88559. setTexture(name: string, texture: Texture): ShaderMaterial;
  88560. /**
  88561. * Set a texture array in the shader.
  88562. * @param name Define the name of the uniform sampler array as defined in the shader
  88563. * @param textures Define the list of textures to bind to this sampler
  88564. * @return the material itself allowing "fluent" like uniform updates
  88565. */
  88566. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88567. /**
  88568. * Set a float in the shader.
  88569. * @param name Define the name of the uniform as defined in the shader
  88570. * @param value Define the value to give to the uniform
  88571. * @return the material itself allowing "fluent" like uniform updates
  88572. */
  88573. setFloat(name: string, value: number): ShaderMaterial;
  88574. /**
  88575. * Set a int in the shader.
  88576. * @param name Define the name of the uniform as defined in the shader
  88577. * @param value Define the value to give to the uniform
  88578. * @return the material itself allowing "fluent" like uniform updates
  88579. */
  88580. setInt(name: string, value: number): ShaderMaterial;
  88581. /**
  88582. * Set an array of floats in the shader.
  88583. * @param name Define the name of the uniform as defined in the shader
  88584. * @param value Define the value to give to the uniform
  88585. * @return the material itself allowing "fluent" like uniform updates
  88586. */
  88587. setFloats(name: string, value: number[]): ShaderMaterial;
  88588. /**
  88589. * Set a vec3 in the shader from a Color3.
  88590. * @param name Define the name of the uniform as defined in the shader
  88591. * @param value Define the value to give to the uniform
  88592. * @return the material itself allowing "fluent" like uniform updates
  88593. */
  88594. setColor3(name: string, value: Color3): ShaderMaterial;
  88595. /**
  88596. * Set a vec3 array in the shader from a Color3 array.
  88597. * @param name Define the name of the uniform as defined in the shader
  88598. * @param value Define the value to give to the uniform
  88599. * @return the material itself allowing "fluent" like uniform updates
  88600. */
  88601. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88602. /**
  88603. * Set a vec4 in the shader from a Color4.
  88604. * @param name Define the name of the uniform as defined in the shader
  88605. * @param value Define the value to give to the uniform
  88606. * @return the material itself allowing "fluent" like uniform updates
  88607. */
  88608. setColor4(name: string, value: Color4): ShaderMaterial;
  88609. /**
  88610. * Set a vec4 array in the shader from a Color4 array.
  88611. * @param name Define the name of the uniform as defined in the shader
  88612. * @param value Define the value to give to the uniform
  88613. * @return the material itself allowing "fluent" like uniform updates
  88614. */
  88615. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88616. /**
  88617. * Set a vec2 in the shader from a Vector2.
  88618. * @param name Define the name of the uniform as defined in the shader
  88619. * @param value Define the value to give to the uniform
  88620. * @return the material itself allowing "fluent" like uniform updates
  88621. */
  88622. setVector2(name: string, value: Vector2): ShaderMaterial;
  88623. /**
  88624. * Set a vec3 in the shader from a Vector3.
  88625. * @param name Define the name of the uniform as defined in the shader
  88626. * @param value Define the value to give to the uniform
  88627. * @return the material itself allowing "fluent" like uniform updates
  88628. */
  88629. setVector3(name: string, value: Vector3): ShaderMaterial;
  88630. /**
  88631. * Set a vec4 in the shader from a Vector4.
  88632. * @param name Define the name of the uniform as defined in the shader
  88633. * @param value Define the value to give to the uniform
  88634. * @return the material itself allowing "fluent" like uniform updates
  88635. */
  88636. setVector4(name: string, value: Vector4): ShaderMaterial;
  88637. /**
  88638. * Set a mat4 in the shader from a Matrix.
  88639. * @param name Define the name of the uniform as defined in the shader
  88640. * @param value Define the value to give to the uniform
  88641. * @return the material itself allowing "fluent" like uniform updates
  88642. */
  88643. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88644. /**
  88645. * Set a float32Array in the shader from a matrix array.
  88646. * @param name Define the name of the uniform as defined in the shader
  88647. * @param value Define the value to give to the uniform
  88648. * @return the material itself allowing "fluent" like uniform updates
  88649. */
  88650. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88651. /**
  88652. * Set a mat3 in the shader from a Float32Array.
  88653. * @param name Define the name of the uniform as defined in the shader
  88654. * @param value Define the value to give to the uniform
  88655. * @return the material itself allowing "fluent" like uniform updates
  88656. */
  88657. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88658. /**
  88659. * Set a mat2 in the shader from a Float32Array.
  88660. * @param name Define the name of the uniform as defined in the shader
  88661. * @param value Define the value to give to the uniform
  88662. * @return the material itself allowing "fluent" like uniform updates
  88663. */
  88664. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88665. /**
  88666. * Set a vec2 array in the shader from a number array.
  88667. * @param name Define the name of the uniform as defined in the shader
  88668. * @param value Define the value to give to the uniform
  88669. * @return the material itself allowing "fluent" like uniform updates
  88670. */
  88671. setArray2(name: string, value: number[]): ShaderMaterial;
  88672. /**
  88673. * Set a vec3 array in the shader from a number array.
  88674. * @param name Define the name of the uniform as defined in the shader
  88675. * @param value Define the value to give to the uniform
  88676. * @return the material itself allowing "fluent" like uniform updates
  88677. */
  88678. setArray3(name: string, value: number[]): ShaderMaterial;
  88679. /**
  88680. * Set a vec4 array in the shader from a number array.
  88681. * @param name Define the name of the uniform as defined in the shader
  88682. * @param value Define the value to give to the uniform
  88683. * @return the material itself allowing "fluent" like uniform updates
  88684. */
  88685. setArray4(name: string, value: number[]): ShaderMaterial;
  88686. private _checkCache;
  88687. /**
  88688. * Specifies that the submesh is ready to be used
  88689. * @param mesh defines the mesh to check
  88690. * @param subMesh defines which submesh to check
  88691. * @param useInstances specifies that instances should be used
  88692. * @returns a boolean indicating that the submesh is ready or not
  88693. */
  88694. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88695. /**
  88696. * Checks if the material is ready to render the requested mesh
  88697. * @param mesh Define the mesh to render
  88698. * @param useInstances Define whether or not the material is used with instances
  88699. * @returns true if ready, otherwise false
  88700. */
  88701. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88702. /**
  88703. * Binds the world matrix to the material
  88704. * @param world defines the world transformation matrix
  88705. */
  88706. bindOnlyWorldMatrix(world: Matrix): void;
  88707. /**
  88708. * Binds the material to the mesh
  88709. * @param world defines the world transformation matrix
  88710. * @param mesh defines the mesh to bind the material to
  88711. */
  88712. bind(world: Matrix, mesh?: Mesh): void;
  88713. /**
  88714. * Gets the active textures from the material
  88715. * @returns an array of textures
  88716. */
  88717. getActiveTextures(): BaseTexture[];
  88718. /**
  88719. * Specifies if the material uses a texture
  88720. * @param texture defines the texture to check against the material
  88721. * @returns a boolean specifying if the material uses the texture
  88722. */
  88723. hasTexture(texture: BaseTexture): boolean;
  88724. /**
  88725. * Makes a duplicate of the material, and gives it a new name
  88726. * @param name defines the new name for the duplicated material
  88727. * @returns the cloned material
  88728. */
  88729. clone(name: string): ShaderMaterial;
  88730. /**
  88731. * Disposes the material
  88732. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88733. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88734. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88735. */
  88736. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88737. /**
  88738. * Serializes this material in a JSON representation
  88739. * @returns the serialized material object
  88740. */
  88741. serialize(): any;
  88742. /**
  88743. * Creates a shader material from parsed shader material data
  88744. * @param source defines the JSON represnetation of the material
  88745. * @param scene defines the hosting scene
  88746. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88747. * @returns a new material
  88748. */
  88749. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  88750. }
  88751. }
  88752. declare module BABYLON {
  88753. /** @hidden */
  88754. export var colorPixelShader: {
  88755. name: string;
  88756. shader: string;
  88757. };
  88758. }
  88759. declare module BABYLON {
  88760. /** @hidden */
  88761. export var colorVertexShader: {
  88762. name: string;
  88763. shader: string;
  88764. };
  88765. }
  88766. declare module BABYLON {
  88767. /**
  88768. * Line mesh
  88769. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  88770. */
  88771. export class LinesMesh extends Mesh {
  88772. /**
  88773. * If vertex color should be applied to the mesh
  88774. */
  88775. readonly useVertexColor?: boolean | undefined;
  88776. /**
  88777. * If vertex alpha should be applied to the mesh
  88778. */
  88779. readonly useVertexAlpha?: boolean | undefined;
  88780. /**
  88781. * Color of the line (Default: White)
  88782. */
  88783. color: Color3;
  88784. /**
  88785. * Alpha of the line (Default: 1)
  88786. */
  88787. alpha: number;
  88788. /**
  88789. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88790. * This margin is expressed in world space coordinates, so its value may vary.
  88791. * Default value is 0.1
  88792. */
  88793. intersectionThreshold: number;
  88794. private _colorShader;
  88795. private color4;
  88796. /**
  88797. * Creates a new LinesMesh
  88798. * @param name defines the name
  88799. * @param scene defines the hosting scene
  88800. * @param parent defines the parent mesh if any
  88801. * @param source defines the optional source LinesMesh used to clone data from
  88802. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88803. * When false, achieved by calling a clone(), also passing False.
  88804. * This will make creation of children, recursive.
  88805. * @param useVertexColor defines if this LinesMesh supports vertex color
  88806. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  88807. */
  88808. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  88809. /**
  88810. * If vertex color should be applied to the mesh
  88811. */
  88812. useVertexColor?: boolean | undefined,
  88813. /**
  88814. * If vertex alpha should be applied to the mesh
  88815. */
  88816. useVertexAlpha?: boolean | undefined);
  88817. private _addClipPlaneDefine;
  88818. private _removeClipPlaneDefine;
  88819. isReady(): boolean;
  88820. /**
  88821. * Returns the string "LineMesh"
  88822. */
  88823. getClassName(): string;
  88824. /**
  88825. * @hidden
  88826. */
  88827. get material(): Material;
  88828. /**
  88829. * @hidden
  88830. */
  88831. set material(value: Material);
  88832. /**
  88833. * @hidden
  88834. */
  88835. get checkCollisions(): boolean;
  88836. /** @hidden */
  88837. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88838. /** @hidden */
  88839. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88840. /**
  88841. * Disposes of the line mesh
  88842. * @param doNotRecurse If children should be disposed
  88843. */
  88844. dispose(doNotRecurse?: boolean): void;
  88845. /**
  88846. * Returns a new LineMesh object cloned from the current one.
  88847. */
  88848. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  88849. /**
  88850. * Creates a new InstancedLinesMesh object from the mesh model.
  88851. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88852. * @param name defines the name of the new instance
  88853. * @returns a new InstancedLinesMesh
  88854. */
  88855. createInstance(name: string): InstancedLinesMesh;
  88856. }
  88857. /**
  88858. * Creates an instance based on a source LinesMesh
  88859. */
  88860. export class InstancedLinesMesh extends InstancedMesh {
  88861. /**
  88862. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88863. * This margin is expressed in world space coordinates, so its value may vary.
  88864. * Initilized with the intersectionThreshold value of the source LinesMesh
  88865. */
  88866. intersectionThreshold: number;
  88867. constructor(name: string, source: LinesMesh);
  88868. /**
  88869. * Returns the string "InstancedLinesMesh".
  88870. */
  88871. getClassName(): string;
  88872. }
  88873. }
  88874. declare module BABYLON {
  88875. /** @hidden */
  88876. export var linePixelShader: {
  88877. name: string;
  88878. shader: string;
  88879. };
  88880. }
  88881. declare module BABYLON {
  88882. /** @hidden */
  88883. export var lineVertexShader: {
  88884. name: string;
  88885. shader: string;
  88886. };
  88887. }
  88888. declare module BABYLON {
  88889. interface AbstractMesh {
  88890. /**
  88891. * Gets the edgesRenderer associated with the mesh
  88892. */
  88893. edgesRenderer: Nullable<EdgesRenderer>;
  88894. }
  88895. interface LinesMesh {
  88896. /**
  88897. * Enables the edge rendering mode on the mesh.
  88898. * This mode makes the mesh edges visible
  88899. * @param epsilon defines the maximal distance between two angles to detect a face
  88900. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88901. * @returns the currentAbstractMesh
  88902. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88903. */
  88904. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  88905. }
  88906. interface InstancedLinesMesh {
  88907. /**
  88908. * Enables the edge rendering mode on the mesh.
  88909. * This mode makes the mesh edges visible
  88910. * @param epsilon defines the maximal distance between two angles to detect a face
  88911. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  88912. * @returns the current InstancedLinesMesh
  88913. * @see https://www.babylonjs-playground.com/#19O9TU#0
  88914. */
  88915. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  88916. }
  88917. /**
  88918. * Defines the minimum contract an Edges renderer should follow.
  88919. */
  88920. export interface IEdgesRenderer extends IDisposable {
  88921. /**
  88922. * Gets or sets a boolean indicating if the edgesRenderer is active
  88923. */
  88924. isEnabled: boolean;
  88925. /**
  88926. * Renders the edges of the attached mesh,
  88927. */
  88928. render(): void;
  88929. /**
  88930. * Checks wether or not the edges renderer is ready to render.
  88931. * @return true if ready, otherwise false.
  88932. */
  88933. isReady(): boolean;
  88934. }
  88935. /**
  88936. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  88937. */
  88938. export class EdgesRenderer implements IEdgesRenderer {
  88939. /**
  88940. * Define the size of the edges with an orthographic camera
  88941. */
  88942. edgesWidthScalerForOrthographic: number;
  88943. /**
  88944. * Define the size of the edges with a perspective camera
  88945. */
  88946. edgesWidthScalerForPerspective: number;
  88947. protected _source: AbstractMesh;
  88948. protected _linesPositions: number[];
  88949. protected _linesNormals: number[];
  88950. protected _linesIndices: number[];
  88951. protected _epsilon: number;
  88952. protected _indicesCount: number;
  88953. protected _lineShader: ShaderMaterial;
  88954. protected _ib: DataBuffer;
  88955. protected _buffers: {
  88956. [key: string]: Nullable<VertexBuffer>;
  88957. };
  88958. protected _checkVerticesInsteadOfIndices: boolean;
  88959. private _meshRebuildObserver;
  88960. private _meshDisposeObserver;
  88961. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  88962. isEnabled: boolean;
  88963. /**
  88964. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  88965. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  88966. * @param source Mesh used to create edges
  88967. * @param epsilon sum of angles in adjacency to check for edge
  88968. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  88969. * @param generateEdgesLines - should generate Lines or only prepare resources.
  88970. */
  88971. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  88972. protected _prepareRessources(): void;
  88973. /** @hidden */
  88974. _rebuild(): void;
  88975. /**
  88976. * Releases the required resources for the edges renderer
  88977. */
  88978. dispose(): void;
  88979. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  88980. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  88981. /**
  88982. * Checks if the pair of p0 and p1 is en edge
  88983. * @param faceIndex
  88984. * @param edge
  88985. * @param faceNormals
  88986. * @param p0
  88987. * @param p1
  88988. * @private
  88989. */
  88990. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  88991. /**
  88992. * push line into the position, normal and index buffer
  88993. * @protected
  88994. */
  88995. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  88996. /**
  88997. * Generates lines edges from adjacencjes
  88998. * @private
  88999. */
  89000. _generateEdgesLines(): void;
  89001. /**
  89002. * Checks wether or not the edges renderer is ready to render.
  89003. * @return true if ready, otherwise false.
  89004. */
  89005. isReady(): boolean;
  89006. /**
  89007. * Renders the edges of the attached mesh,
  89008. */
  89009. render(): void;
  89010. }
  89011. /**
  89012. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  89013. */
  89014. export class LineEdgesRenderer extends EdgesRenderer {
  89015. /**
  89016. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  89017. * @param source LineMesh used to generate edges
  89018. * @param epsilon not important (specified angle for edge detection)
  89019. * @param checkVerticesInsteadOfIndices not important for LineMesh
  89020. */
  89021. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  89022. /**
  89023. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  89024. */
  89025. _generateEdgesLines(): void;
  89026. }
  89027. }
  89028. declare module BABYLON {
  89029. /**
  89030. * This represents the object necessary to create a rendering group.
  89031. * This is exclusively used and created by the rendering manager.
  89032. * To modify the behavior, you use the available helpers in your scene or meshes.
  89033. * @hidden
  89034. */
  89035. export class RenderingGroup {
  89036. index: number;
  89037. private static _zeroVector;
  89038. private _scene;
  89039. private _opaqueSubMeshes;
  89040. private _transparentSubMeshes;
  89041. private _alphaTestSubMeshes;
  89042. private _depthOnlySubMeshes;
  89043. private _particleSystems;
  89044. private _spriteManagers;
  89045. private _opaqueSortCompareFn;
  89046. private _alphaTestSortCompareFn;
  89047. private _transparentSortCompareFn;
  89048. private _renderOpaque;
  89049. private _renderAlphaTest;
  89050. private _renderTransparent;
  89051. /** @hidden */
  89052. _edgesRenderers: SmartArray<IEdgesRenderer>;
  89053. onBeforeTransparentRendering: () => void;
  89054. /**
  89055. * Set the opaque sort comparison function.
  89056. * If null the sub meshes will be render in the order they were created
  89057. */
  89058. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89059. /**
  89060. * Set the alpha test sort comparison function.
  89061. * If null the sub meshes will be render in the order they were created
  89062. */
  89063. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89064. /**
  89065. * Set the transparent sort comparison function.
  89066. * If null the sub meshes will be render in the order they were created
  89067. */
  89068. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89069. /**
  89070. * Creates a new rendering group.
  89071. * @param index The rendering group index
  89072. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  89073. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  89074. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  89075. */
  89076. 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>);
  89077. /**
  89078. * Render all the sub meshes contained in the group.
  89079. * @param customRenderFunction Used to override the default render behaviour of the group.
  89080. * @returns true if rendered some submeshes.
  89081. */
  89082. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  89083. /**
  89084. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  89085. * @param subMeshes The submeshes to render
  89086. */
  89087. private renderOpaqueSorted;
  89088. /**
  89089. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  89090. * @param subMeshes The submeshes to render
  89091. */
  89092. private renderAlphaTestSorted;
  89093. /**
  89094. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  89095. * @param subMeshes The submeshes to render
  89096. */
  89097. private renderTransparentSorted;
  89098. /**
  89099. * Renders the submeshes in a specified order.
  89100. * @param subMeshes The submeshes to sort before render
  89101. * @param sortCompareFn The comparison function use to sort
  89102. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  89103. * @param transparent Specifies to activate blending if true
  89104. */
  89105. private static renderSorted;
  89106. /**
  89107. * Renders the submeshes in the order they were dispatched (no sort applied).
  89108. * @param subMeshes The submeshes to render
  89109. */
  89110. private static renderUnsorted;
  89111. /**
  89112. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89113. * are rendered back to front if in the same alpha index.
  89114. *
  89115. * @param a The first submesh
  89116. * @param b The second submesh
  89117. * @returns The result of the comparison
  89118. */
  89119. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  89120. /**
  89121. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89122. * are rendered back to front.
  89123. *
  89124. * @param a The first submesh
  89125. * @param b The second submesh
  89126. * @returns The result of the comparison
  89127. */
  89128. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  89129. /**
  89130. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89131. * are rendered front to back (prevent overdraw).
  89132. *
  89133. * @param a The first submesh
  89134. * @param b The second submesh
  89135. * @returns The result of the comparison
  89136. */
  89137. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  89138. /**
  89139. * Resets the different lists of submeshes to prepare a new frame.
  89140. */
  89141. prepare(): void;
  89142. dispose(): void;
  89143. /**
  89144. * Inserts the submesh in its correct queue depending on its material.
  89145. * @param subMesh The submesh to dispatch
  89146. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89147. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89148. */
  89149. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89150. dispatchSprites(spriteManager: ISpriteManager): void;
  89151. dispatchParticles(particleSystem: IParticleSystem): void;
  89152. private _renderParticles;
  89153. private _renderSprites;
  89154. }
  89155. }
  89156. declare module BABYLON {
  89157. /**
  89158. * Interface describing the different options available in the rendering manager
  89159. * regarding Auto Clear between groups.
  89160. */
  89161. export interface IRenderingManagerAutoClearSetup {
  89162. /**
  89163. * Defines whether or not autoclear is enable.
  89164. */
  89165. autoClear: boolean;
  89166. /**
  89167. * Defines whether or not to autoclear the depth buffer.
  89168. */
  89169. depth: boolean;
  89170. /**
  89171. * Defines whether or not to autoclear the stencil buffer.
  89172. */
  89173. stencil: boolean;
  89174. }
  89175. /**
  89176. * This class is used by the onRenderingGroupObservable
  89177. */
  89178. export class RenderingGroupInfo {
  89179. /**
  89180. * The Scene that being rendered
  89181. */
  89182. scene: Scene;
  89183. /**
  89184. * The camera currently used for the rendering pass
  89185. */
  89186. camera: Nullable<Camera>;
  89187. /**
  89188. * The ID of the renderingGroup being processed
  89189. */
  89190. renderingGroupId: number;
  89191. }
  89192. /**
  89193. * This is the manager responsible of all the rendering for meshes sprites and particles.
  89194. * It is enable to manage the different groups as well as the different necessary sort functions.
  89195. * This should not be used directly aside of the few static configurations
  89196. */
  89197. export class RenderingManager {
  89198. /**
  89199. * The max id used for rendering groups (not included)
  89200. */
  89201. static MAX_RENDERINGGROUPS: number;
  89202. /**
  89203. * The min id used for rendering groups (included)
  89204. */
  89205. static MIN_RENDERINGGROUPS: number;
  89206. /**
  89207. * Used to globally prevent autoclearing scenes.
  89208. */
  89209. static AUTOCLEAR: boolean;
  89210. /**
  89211. * @hidden
  89212. */
  89213. _useSceneAutoClearSetup: boolean;
  89214. private _scene;
  89215. private _renderingGroups;
  89216. private _depthStencilBufferAlreadyCleaned;
  89217. private _autoClearDepthStencil;
  89218. private _customOpaqueSortCompareFn;
  89219. private _customAlphaTestSortCompareFn;
  89220. private _customTransparentSortCompareFn;
  89221. private _renderingGroupInfo;
  89222. /**
  89223. * Instantiates a new rendering group for a particular scene
  89224. * @param scene Defines the scene the groups belongs to
  89225. */
  89226. constructor(scene: Scene);
  89227. private _clearDepthStencilBuffer;
  89228. /**
  89229. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  89230. * @hidden
  89231. */
  89232. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  89233. /**
  89234. * Resets the different information of the group to prepare a new frame
  89235. * @hidden
  89236. */
  89237. reset(): void;
  89238. /**
  89239. * Dispose and release the group and its associated resources.
  89240. * @hidden
  89241. */
  89242. dispose(): void;
  89243. /**
  89244. * Clear the info related to rendering groups preventing retention points during dispose.
  89245. */
  89246. freeRenderingGroups(): void;
  89247. private _prepareRenderingGroup;
  89248. /**
  89249. * Add a sprite manager to the rendering manager in order to render it this frame.
  89250. * @param spriteManager Define the sprite manager to render
  89251. */
  89252. dispatchSprites(spriteManager: ISpriteManager): void;
  89253. /**
  89254. * Add a particle system to the rendering manager in order to render it this frame.
  89255. * @param particleSystem Define the particle system to render
  89256. */
  89257. dispatchParticles(particleSystem: IParticleSystem): void;
  89258. /**
  89259. * Add a submesh to the manager in order to render it this frame
  89260. * @param subMesh The submesh to dispatch
  89261. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89262. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89263. */
  89264. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89265. /**
  89266. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89267. * This allowed control for front to back rendering or reversly depending of the special needs.
  89268. *
  89269. * @param renderingGroupId The rendering group id corresponding to its index
  89270. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89271. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89272. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89273. */
  89274. 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;
  89275. /**
  89276. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89277. *
  89278. * @param renderingGroupId The rendering group id corresponding to its index
  89279. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89280. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89281. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89282. */
  89283. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89284. /**
  89285. * Gets the current auto clear configuration for one rendering group of the rendering
  89286. * manager.
  89287. * @param index the rendering group index to get the information for
  89288. * @returns The auto clear setup for the requested rendering group
  89289. */
  89290. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89291. }
  89292. }
  89293. declare module BABYLON {
  89294. /**
  89295. * Defines the options associated with the creation of a custom shader for a shadow generator.
  89296. */
  89297. export interface ICustomShaderOptions {
  89298. /**
  89299. * Gets or sets the custom shader name to use
  89300. */
  89301. shaderName: string;
  89302. /**
  89303. * The list of attribute names used in the shader
  89304. */
  89305. attributes?: string[];
  89306. /**
  89307. * The list of unifrom names used in the shader
  89308. */
  89309. uniforms?: string[];
  89310. /**
  89311. * The list of sampler names used in the shader
  89312. */
  89313. samplers?: string[];
  89314. /**
  89315. * The list of defines used in the shader
  89316. */
  89317. defines?: string[];
  89318. }
  89319. /**
  89320. * Interface to implement to create a shadow generator compatible with BJS.
  89321. */
  89322. export interface IShadowGenerator {
  89323. /**
  89324. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89325. * @returns The render target texture if present otherwise, null
  89326. */
  89327. getShadowMap(): Nullable<RenderTargetTexture>;
  89328. /**
  89329. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89330. * @param subMesh The submesh we want to render in the shadow map
  89331. * @param useInstances Defines wether will draw in the map using instances
  89332. * @returns true if ready otherwise, false
  89333. */
  89334. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89335. /**
  89336. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89337. * @param defines Defines of the material we want to update
  89338. * @param lightIndex Index of the light in the enabled light list of the material
  89339. */
  89340. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  89341. /**
  89342. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89343. * defined in the generator but impacting the effect).
  89344. * It implies the unifroms available on the materials are the standard BJS ones.
  89345. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89346. * @param effect The effect we are binfing the information for
  89347. */
  89348. bindShadowLight(lightIndex: string, effect: Effect): void;
  89349. /**
  89350. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89351. * (eq to shadow prjection matrix * light transform matrix)
  89352. * @returns The transform matrix used to create the shadow map
  89353. */
  89354. getTransformMatrix(): Matrix;
  89355. /**
  89356. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89357. * Cube and 2D textures for instance.
  89358. */
  89359. recreateShadowMap(): void;
  89360. /**
  89361. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89362. * @param onCompiled Callback triggered at the and of the effects compilation
  89363. * @param options Sets of optional options forcing the compilation with different modes
  89364. */
  89365. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89366. useInstances: boolean;
  89367. }>): void;
  89368. /**
  89369. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89370. * @param options Sets of optional options forcing the compilation with different modes
  89371. * @returns A promise that resolves when the compilation completes
  89372. */
  89373. forceCompilationAsync(options?: Partial<{
  89374. useInstances: boolean;
  89375. }>): Promise<void>;
  89376. /**
  89377. * Serializes the shadow generator setup to a json object.
  89378. * @returns The serialized JSON object
  89379. */
  89380. serialize(): any;
  89381. /**
  89382. * Disposes the Shadow map and related Textures and effects.
  89383. */
  89384. dispose(): void;
  89385. }
  89386. /**
  89387. * Default implementation IShadowGenerator.
  89388. * This is the main object responsible of generating shadows in the framework.
  89389. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  89390. */
  89391. export class ShadowGenerator implements IShadowGenerator {
  89392. /**
  89393. * Name of the shadow generator class
  89394. */
  89395. static CLASSNAME: string;
  89396. /**
  89397. * Shadow generator mode None: no filtering applied.
  89398. */
  89399. static readonly FILTER_NONE: number;
  89400. /**
  89401. * Shadow generator mode ESM: Exponential Shadow Mapping.
  89402. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89403. */
  89404. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  89405. /**
  89406. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  89407. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  89408. */
  89409. static readonly FILTER_POISSONSAMPLING: number;
  89410. /**
  89411. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  89412. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89413. */
  89414. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  89415. /**
  89416. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  89417. * edge artifacts on steep falloff.
  89418. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89419. */
  89420. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  89421. /**
  89422. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  89423. * edge artifacts on steep falloff.
  89424. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89425. */
  89426. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  89427. /**
  89428. * Shadow generator mode PCF: Percentage Closer Filtering
  89429. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89430. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  89431. */
  89432. static readonly FILTER_PCF: number;
  89433. /**
  89434. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  89435. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89436. * Contact Hardening
  89437. */
  89438. static readonly FILTER_PCSS: number;
  89439. /**
  89440. * Reserved for PCF and PCSS
  89441. * Highest Quality.
  89442. *
  89443. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  89444. *
  89445. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  89446. */
  89447. static readonly QUALITY_HIGH: number;
  89448. /**
  89449. * Reserved for PCF and PCSS
  89450. * Good tradeoff for quality/perf cross devices
  89451. *
  89452. * Execute PCF on a 3*3 kernel.
  89453. *
  89454. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  89455. */
  89456. static readonly QUALITY_MEDIUM: number;
  89457. /**
  89458. * Reserved for PCF and PCSS
  89459. * The lowest quality but the fastest.
  89460. *
  89461. * Execute PCF on a 1*1 kernel.
  89462. *
  89463. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  89464. */
  89465. static readonly QUALITY_LOW: number;
  89466. /** Gets or sets the custom shader name to use */
  89467. customShaderOptions: ICustomShaderOptions;
  89468. /**
  89469. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  89470. */
  89471. onBeforeShadowMapRenderObservable: Observable<Effect>;
  89472. /**
  89473. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  89474. */
  89475. onAfterShadowMapRenderObservable: Observable<Effect>;
  89476. /**
  89477. * Observable triggered before a mesh is rendered in the shadow map.
  89478. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  89479. */
  89480. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  89481. /**
  89482. * Observable triggered after a mesh is rendered in the shadow map.
  89483. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  89484. */
  89485. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  89486. protected _bias: number;
  89487. /**
  89488. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  89489. */
  89490. get bias(): number;
  89491. /**
  89492. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  89493. */
  89494. set bias(bias: number);
  89495. protected _normalBias: number;
  89496. /**
  89497. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89498. */
  89499. get normalBias(): number;
  89500. /**
  89501. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89502. */
  89503. set normalBias(normalBias: number);
  89504. protected _blurBoxOffset: number;
  89505. /**
  89506. * Gets the blur box offset: offset applied during the blur pass.
  89507. * Only useful if useKernelBlur = false
  89508. */
  89509. get blurBoxOffset(): number;
  89510. /**
  89511. * Sets the blur box offset: offset applied during the blur pass.
  89512. * Only useful if useKernelBlur = false
  89513. */
  89514. set blurBoxOffset(value: number);
  89515. protected _blurScale: number;
  89516. /**
  89517. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  89518. * 2 means half of the size.
  89519. */
  89520. get blurScale(): number;
  89521. /**
  89522. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  89523. * 2 means half of the size.
  89524. */
  89525. set blurScale(value: number);
  89526. protected _blurKernel: number;
  89527. /**
  89528. * Gets the blur kernel: kernel size of the blur pass.
  89529. * Only useful if useKernelBlur = true
  89530. */
  89531. get blurKernel(): number;
  89532. /**
  89533. * Sets the blur kernel: kernel size of the blur pass.
  89534. * Only useful if useKernelBlur = true
  89535. */
  89536. set blurKernel(value: number);
  89537. protected _useKernelBlur: boolean;
  89538. /**
  89539. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  89540. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89541. */
  89542. get useKernelBlur(): boolean;
  89543. /**
  89544. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  89545. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89546. */
  89547. set useKernelBlur(value: boolean);
  89548. protected _depthScale: number;
  89549. /**
  89550. * Gets the depth scale used in ESM mode.
  89551. */
  89552. get depthScale(): number;
  89553. /**
  89554. * Sets the depth scale used in ESM mode.
  89555. * This can override the scale stored on the light.
  89556. */
  89557. set depthScale(value: number);
  89558. protected _validateFilter(filter: number): number;
  89559. protected _filter: number;
  89560. /**
  89561. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  89562. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89563. */
  89564. get filter(): number;
  89565. /**
  89566. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  89567. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89568. */
  89569. set filter(value: number);
  89570. /**
  89571. * Gets if the current filter is set to Poisson Sampling.
  89572. */
  89573. get usePoissonSampling(): boolean;
  89574. /**
  89575. * Sets the current filter to Poisson Sampling.
  89576. */
  89577. set usePoissonSampling(value: boolean);
  89578. /**
  89579. * Gets if the current filter is set to ESM.
  89580. */
  89581. get useExponentialShadowMap(): boolean;
  89582. /**
  89583. * Sets the current filter is to ESM.
  89584. */
  89585. set useExponentialShadowMap(value: boolean);
  89586. /**
  89587. * Gets if the current filter is set to filtered ESM.
  89588. */
  89589. get useBlurExponentialShadowMap(): boolean;
  89590. /**
  89591. * Gets if the current filter is set to filtered ESM.
  89592. */
  89593. set useBlurExponentialShadowMap(value: boolean);
  89594. /**
  89595. * Gets if the current filter is set to "close ESM" (using the inverse of the
  89596. * exponential to prevent steep falloff artifacts).
  89597. */
  89598. get useCloseExponentialShadowMap(): boolean;
  89599. /**
  89600. * Sets the current filter to "close ESM" (using the inverse of the
  89601. * exponential to prevent steep falloff artifacts).
  89602. */
  89603. set useCloseExponentialShadowMap(value: boolean);
  89604. /**
  89605. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  89606. * exponential to prevent steep falloff artifacts).
  89607. */
  89608. get useBlurCloseExponentialShadowMap(): boolean;
  89609. /**
  89610. * Sets the current filter to filtered "close ESM" (using the inverse of the
  89611. * exponential to prevent steep falloff artifacts).
  89612. */
  89613. set useBlurCloseExponentialShadowMap(value: boolean);
  89614. /**
  89615. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  89616. */
  89617. get usePercentageCloserFiltering(): boolean;
  89618. /**
  89619. * Sets the current filter to "PCF" (percentage closer filtering).
  89620. */
  89621. set usePercentageCloserFiltering(value: boolean);
  89622. protected _filteringQuality: number;
  89623. /**
  89624. * Gets the PCF or PCSS Quality.
  89625. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89626. */
  89627. get filteringQuality(): number;
  89628. /**
  89629. * Sets the PCF or PCSS Quality.
  89630. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89631. */
  89632. set filteringQuality(filteringQuality: number);
  89633. /**
  89634. * Gets if the current filter is set to "PCSS" (contact hardening).
  89635. */
  89636. get useContactHardeningShadow(): boolean;
  89637. /**
  89638. * Sets the current filter to "PCSS" (contact hardening).
  89639. */
  89640. set useContactHardeningShadow(value: boolean);
  89641. protected _contactHardeningLightSizeUVRatio: number;
  89642. /**
  89643. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89644. * Using a ratio helps keeping shape stability independently of the map size.
  89645. *
  89646. * It does not account for the light projection as it was having too much
  89647. * instability during the light setup or during light position changes.
  89648. *
  89649. * Only valid if useContactHardeningShadow is true.
  89650. */
  89651. get contactHardeningLightSizeUVRatio(): number;
  89652. /**
  89653. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89654. * Using a ratio helps keeping shape stability independently of the map size.
  89655. *
  89656. * It does not account for the light projection as it was having too much
  89657. * instability during the light setup or during light position changes.
  89658. *
  89659. * Only valid if useContactHardeningShadow is true.
  89660. */
  89661. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  89662. protected _darkness: number;
  89663. /** Gets or sets the actual darkness of a shadow */
  89664. get darkness(): number;
  89665. set darkness(value: number);
  89666. /**
  89667. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  89668. * 0 means strongest and 1 would means no shadow.
  89669. * @returns the darkness.
  89670. */
  89671. getDarkness(): number;
  89672. /**
  89673. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  89674. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  89675. * @returns the shadow generator allowing fluent coding.
  89676. */
  89677. setDarkness(darkness: number): ShadowGenerator;
  89678. protected _transparencyShadow: boolean;
  89679. /** Gets or sets the ability to have transparent shadow */
  89680. get transparencyShadow(): boolean;
  89681. set transparencyShadow(value: boolean);
  89682. /**
  89683. * Sets the ability to have transparent shadow (boolean).
  89684. * @param transparent True if transparent else False
  89685. * @returns the shadow generator allowing fluent coding
  89686. */
  89687. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  89688. protected _shadowMap: Nullable<RenderTargetTexture>;
  89689. protected _shadowMap2: Nullable<RenderTargetTexture>;
  89690. /**
  89691. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89692. * @returns The render target texture if present otherwise, null
  89693. */
  89694. getShadowMap(): Nullable<RenderTargetTexture>;
  89695. /**
  89696. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  89697. * @returns The render target texture if the shadow map is present otherwise, null
  89698. */
  89699. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  89700. /**
  89701. * Gets the class name of that object
  89702. * @returns "ShadowGenerator"
  89703. */
  89704. getClassName(): string;
  89705. /**
  89706. * Helper function to add a mesh and its descendants to the list of shadow casters.
  89707. * @param mesh Mesh to add
  89708. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  89709. * @returns the Shadow Generator itself
  89710. */
  89711. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89712. /**
  89713. * Helper function to remove a mesh and its descendants from the list of shadow casters
  89714. * @param mesh Mesh to remove
  89715. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  89716. * @returns the Shadow Generator itself
  89717. */
  89718. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89719. /**
  89720. * Controls the extent to which the shadows fade out at the edge of the frustum
  89721. */
  89722. frustumEdgeFalloff: number;
  89723. protected _light: IShadowLight;
  89724. /**
  89725. * Returns the associated light object.
  89726. * @returns the light generating the shadow
  89727. */
  89728. getLight(): IShadowLight;
  89729. /**
  89730. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  89731. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  89732. * It might on the other hand introduce peter panning.
  89733. */
  89734. forceBackFacesOnly: boolean;
  89735. protected _scene: Scene;
  89736. protected _lightDirection: Vector3;
  89737. protected _effect: Effect;
  89738. protected _viewMatrix: Matrix;
  89739. protected _projectionMatrix: Matrix;
  89740. protected _transformMatrix: Matrix;
  89741. protected _cachedPosition: Vector3;
  89742. protected _cachedDirection: Vector3;
  89743. protected _cachedDefines: string;
  89744. protected _currentRenderID: number;
  89745. protected _boxBlurPostprocess: Nullable<PostProcess>;
  89746. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  89747. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  89748. protected _blurPostProcesses: PostProcess[];
  89749. protected _mapSize: number;
  89750. protected _currentFaceIndex: number;
  89751. protected _currentFaceIndexCache: number;
  89752. protected _textureType: number;
  89753. protected _defaultTextureMatrix: Matrix;
  89754. protected _storedUniqueId: Nullable<number>;
  89755. /** @hidden */
  89756. static _SceneComponentInitialization: (scene: Scene) => void;
  89757. /**
  89758. * Creates a ShadowGenerator object.
  89759. * A ShadowGenerator is the required tool to use the shadows.
  89760. * Each light casting shadows needs to use its own ShadowGenerator.
  89761. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  89762. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  89763. * @param light The light object generating the shadows.
  89764. * @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.
  89765. */
  89766. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  89767. protected _initializeGenerator(): void;
  89768. protected _createTargetRenderTexture(): void;
  89769. protected _initializeShadowMap(): void;
  89770. protected _initializeBlurRTTAndPostProcesses(): void;
  89771. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  89772. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  89773. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  89774. protected _applyFilterValues(): void;
  89775. /**
  89776. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89777. * @param onCompiled Callback triggered at the and of the effects compilation
  89778. * @param options Sets of optional options forcing the compilation with different modes
  89779. */
  89780. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89781. useInstances: boolean;
  89782. }>): void;
  89783. /**
  89784. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89785. * @param options Sets of optional options forcing the compilation with different modes
  89786. * @returns A promise that resolves when the compilation completes
  89787. */
  89788. forceCompilationAsync(options?: Partial<{
  89789. useInstances: boolean;
  89790. }>): Promise<void>;
  89791. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  89792. /**
  89793. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89794. * @param subMesh The submesh we want to render in the shadow map
  89795. * @param useInstances Defines wether will draw in the map using instances
  89796. * @returns true if ready otherwise, false
  89797. */
  89798. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89799. /**
  89800. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89801. * @param defines Defines of the material we want to update
  89802. * @param lightIndex Index of the light in the enabled light list of the material
  89803. */
  89804. prepareDefines(defines: any, lightIndex: number): void;
  89805. /**
  89806. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89807. * defined in the generator but impacting the effect).
  89808. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89809. * @param effect The effect we are binfing the information for
  89810. */
  89811. bindShadowLight(lightIndex: string, effect: Effect): void;
  89812. /**
  89813. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89814. * (eq to shadow prjection matrix * light transform matrix)
  89815. * @returns The transform matrix used to create the shadow map
  89816. */
  89817. getTransformMatrix(): Matrix;
  89818. /**
  89819. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89820. * Cube and 2D textures for instance.
  89821. */
  89822. recreateShadowMap(): void;
  89823. protected _disposeBlurPostProcesses(): void;
  89824. protected _disposeRTTandPostProcesses(): void;
  89825. /**
  89826. * Disposes the ShadowGenerator.
  89827. * Returns nothing.
  89828. */
  89829. dispose(): void;
  89830. /**
  89831. * Serializes the shadow generator setup to a json object.
  89832. * @returns The serialized JSON object
  89833. */
  89834. serialize(): any;
  89835. /**
  89836. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  89837. * @param parsedShadowGenerator The JSON object to parse
  89838. * @param scene The scene to create the shadow map for
  89839. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  89840. * @returns The parsed shadow generator
  89841. */
  89842. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  89843. }
  89844. }
  89845. declare module BABYLON {
  89846. /**
  89847. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  89848. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  89849. * 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.
  89850. */
  89851. export abstract class Light extends Node {
  89852. /**
  89853. * Falloff Default: light is falling off following the material specification:
  89854. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  89855. */
  89856. static readonly FALLOFF_DEFAULT: number;
  89857. /**
  89858. * Falloff Physical: light is falling off following the inverse squared distance law.
  89859. */
  89860. static readonly FALLOFF_PHYSICAL: number;
  89861. /**
  89862. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  89863. * to enhance interoperability with other engines.
  89864. */
  89865. static readonly FALLOFF_GLTF: number;
  89866. /**
  89867. * Falloff Standard: light is falling off like in the standard material
  89868. * to enhance interoperability with other materials.
  89869. */
  89870. static readonly FALLOFF_STANDARD: number;
  89871. /**
  89872. * If every light affecting the material is in this lightmapMode,
  89873. * material.lightmapTexture adds or multiplies
  89874. * (depends on material.useLightmapAsShadowmap)
  89875. * after every other light calculations.
  89876. */
  89877. static readonly LIGHTMAP_DEFAULT: number;
  89878. /**
  89879. * material.lightmapTexture as only diffuse lighting from this light
  89880. * adds only specular lighting from this light
  89881. * adds dynamic shadows
  89882. */
  89883. static readonly LIGHTMAP_SPECULAR: number;
  89884. /**
  89885. * material.lightmapTexture as only lighting
  89886. * no light calculation from this light
  89887. * only adds dynamic shadows from this light
  89888. */
  89889. static readonly LIGHTMAP_SHADOWSONLY: number;
  89890. /**
  89891. * Each light type uses the default quantity according to its type:
  89892. * point/spot lights use luminous intensity
  89893. * directional lights use illuminance
  89894. */
  89895. static readonly INTENSITYMODE_AUTOMATIC: number;
  89896. /**
  89897. * lumen (lm)
  89898. */
  89899. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  89900. /**
  89901. * candela (lm/sr)
  89902. */
  89903. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  89904. /**
  89905. * lux (lm/m^2)
  89906. */
  89907. static readonly INTENSITYMODE_ILLUMINANCE: number;
  89908. /**
  89909. * nit (cd/m^2)
  89910. */
  89911. static readonly INTENSITYMODE_LUMINANCE: number;
  89912. /**
  89913. * Light type const id of the point light.
  89914. */
  89915. static readonly LIGHTTYPEID_POINTLIGHT: number;
  89916. /**
  89917. * Light type const id of the directional light.
  89918. */
  89919. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  89920. /**
  89921. * Light type const id of the spot light.
  89922. */
  89923. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  89924. /**
  89925. * Light type const id of the hemispheric light.
  89926. */
  89927. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  89928. /**
  89929. * Diffuse gives the basic color to an object.
  89930. */
  89931. diffuse: Color3;
  89932. /**
  89933. * Specular produces a highlight color on an object.
  89934. * Note: This is note affecting PBR materials.
  89935. */
  89936. specular: Color3;
  89937. /**
  89938. * Defines the falloff type for this light. This lets overrriding how punctual light are
  89939. * falling off base on range or angle.
  89940. * This can be set to any values in Light.FALLOFF_x.
  89941. *
  89942. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  89943. * other types of materials.
  89944. */
  89945. falloffType: number;
  89946. /**
  89947. * Strength of the light.
  89948. * Note: By default it is define in the framework own unit.
  89949. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  89950. */
  89951. intensity: number;
  89952. private _range;
  89953. protected _inverseSquaredRange: number;
  89954. /**
  89955. * Defines how far from the source the light is impacting in scene units.
  89956. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  89957. */
  89958. get range(): number;
  89959. /**
  89960. * Defines how far from the source the light is impacting in scene units.
  89961. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  89962. */
  89963. set range(value: number);
  89964. /**
  89965. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  89966. * of light.
  89967. */
  89968. private _photometricScale;
  89969. private _intensityMode;
  89970. /**
  89971. * Gets the photometric scale used to interpret the intensity.
  89972. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  89973. */
  89974. get intensityMode(): number;
  89975. /**
  89976. * Sets the photometric scale used to interpret the intensity.
  89977. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  89978. */
  89979. set intensityMode(value: number);
  89980. private _radius;
  89981. /**
  89982. * Gets the light radius used by PBR Materials to simulate soft area lights.
  89983. */
  89984. get radius(): number;
  89985. /**
  89986. * sets the light radius used by PBR Materials to simulate soft area lights.
  89987. */
  89988. set radius(value: number);
  89989. private _renderPriority;
  89990. /**
  89991. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  89992. * exceeding the number allowed of the materials.
  89993. */
  89994. renderPriority: number;
  89995. private _shadowEnabled;
  89996. /**
  89997. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  89998. * the current shadow generator.
  89999. */
  90000. get shadowEnabled(): boolean;
  90001. /**
  90002. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90003. * the current shadow generator.
  90004. */
  90005. set shadowEnabled(value: boolean);
  90006. private _includedOnlyMeshes;
  90007. /**
  90008. * Gets the only meshes impacted by this light.
  90009. */
  90010. get includedOnlyMeshes(): AbstractMesh[];
  90011. /**
  90012. * Sets the only meshes impacted by this light.
  90013. */
  90014. set includedOnlyMeshes(value: AbstractMesh[]);
  90015. private _excludedMeshes;
  90016. /**
  90017. * Gets the meshes not impacted by this light.
  90018. */
  90019. get excludedMeshes(): AbstractMesh[];
  90020. /**
  90021. * Sets the meshes not impacted by this light.
  90022. */
  90023. set excludedMeshes(value: AbstractMesh[]);
  90024. private _excludeWithLayerMask;
  90025. /**
  90026. * Gets the layer id use to find what meshes are not impacted by the light.
  90027. * Inactive if 0
  90028. */
  90029. get excludeWithLayerMask(): number;
  90030. /**
  90031. * Sets the layer id use to find what meshes are not impacted by the light.
  90032. * Inactive if 0
  90033. */
  90034. set excludeWithLayerMask(value: number);
  90035. private _includeOnlyWithLayerMask;
  90036. /**
  90037. * Gets the layer id use to find what meshes are impacted by the light.
  90038. * Inactive if 0
  90039. */
  90040. get includeOnlyWithLayerMask(): number;
  90041. /**
  90042. * Sets the layer id use to find what meshes are impacted by the light.
  90043. * Inactive if 0
  90044. */
  90045. set includeOnlyWithLayerMask(value: number);
  90046. private _lightmapMode;
  90047. /**
  90048. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90049. */
  90050. get lightmapMode(): number;
  90051. /**
  90052. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90053. */
  90054. set lightmapMode(value: number);
  90055. /**
  90056. * Shadow generator associted to the light.
  90057. * @hidden Internal use only.
  90058. */
  90059. _shadowGenerator: Nullable<IShadowGenerator>;
  90060. /**
  90061. * @hidden Internal use only.
  90062. */
  90063. _excludedMeshesIds: string[];
  90064. /**
  90065. * @hidden Internal use only.
  90066. */
  90067. _includedOnlyMeshesIds: string[];
  90068. /**
  90069. * The current light unifom buffer.
  90070. * @hidden Internal use only.
  90071. */
  90072. _uniformBuffer: UniformBuffer;
  90073. /** @hidden */
  90074. _renderId: number;
  90075. /**
  90076. * Creates a Light object in the scene.
  90077. * Documentation : https://doc.babylonjs.com/babylon101/lights
  90078. * @param name The firendly name of the light
  90079. * @param scene The scene the light belongs too
  90080. */
  90081. constructor(name: string, scene: Scene);
  90082. protected abstract _buildUniformLayout(): void;
  90083. /**
  90084. * Sets the passed Effect "effect" with the Light information.
  90085. * @param effect The effect to update
  90086. * @param lightIndex The index of the light in the effect to update
  90087. * @returns The light
  90088. */
  90089. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  90090. /**
  90091. * Sets the passed Effect "effect" with the Light textures.
  90092. * @param effect The effect to update
  90093. * @param lightIndex The index of the light in the effect to update
  90094. * @returns The light
  90095. */
  90096. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  90097. /**
  90098. * Binds the lights information from the scene to the effect for the given mesh.
  90099. * @param lightIndex Light index
  90100. * @param scene The scene where the light belongs to
  90101. * @param effect The effect we are binding the data to
  90102. * @param useSpecular Defines if specular is supported
  90103. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  90104. */
  90105. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  90106. /**
  90107. * Sets the passed Effect "effect" with the Light information.
  90108. * @param effect The effect to update
  90109. * @param lightDataUniformName The uniform used to store light data (position or direction)
  90110. * @returns The light
  90111. */
  90112. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  90113. /**
  90114. * Returns the string "Light".
  90115. * @returns the class name
  90116. */
  90117. getClassName(): string;
  90118. /** @hidden */
  90119. readonly _isLight: boolean;
  90120. /**
  90121. * Converts the light information to a readable string for debug purpose.
  90122. * @param fullDetails Supports for multiple levels of logging within scene loading
  90123. * @returns the human readable light info
  90124. */
  90125. toString(fullDetails?: boolean): string;
  90126. /** @hidden */
  90127. protected _syncParentEnabledState(): void;
  90128. /**
  90129. * Set the enabled state of this node.
  90130. * @param value - the new enabled state
  90131. */
  90132. setEnabled(value: boolean): void;
  90133. /**
  90134. * Returns the Light associated shadow generator if any.
  90135. * @return the associated shadow generator.
  90136. */
  90137. getShadowGenerator(): Nullable<IShadowGenerator>;
  90138. /**
  90139. * Returns a Vector3, the absolute light position in the World.
  90140. * @returns the world space position of the light
  90141. */
  90142. getAbsolutePosition(): Vector3;
  90143. /**
  90144. * Specifies if the light will affect the passed mesh.
  90145. * @param mesh The mesh to test against the light
  90146. * @return true the mesh is affected otherwise, false.
  90147. */
  90148. canAffectMesh(mesh: AbstractMesh): boolean;
  90149. /**
  90150. * Sort function to order lights for rendering.
  90151. * @param a First Light object to compare to second.
  90152. * @param b Second Light object to compare first.
  90153. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  90154. */
  90155. static CompareLightsPriority(a: Light, b: Light): number;
  90156. /**
  90157. * Releases resources associated with this node.
  90158. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90159. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90160. */
  90161. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90162. /**
  90163. * Returns the light type ID (integer).
  90164. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  90165. */
  90166. getTypeID(): number;
  90167. /**
  90168. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  90169. * @returns the scaled intensity in intensity mode unit
  90170. */
  90171. getScaledIntensity(): number;
  90172. /**
  90173. * Returns a new Light object, named "name", from the current one.
  90174. * @param name The name of the cloned light
  90175. * @returns the new created light
  90176. */
  90177. clone(name: string): Nullable<Light>;
  90178. /**
  90179. * Serializes the current light into a Serialization object.
  90180. * @returns the serialized object.
  90181. */
  90182. serialize(): any;
  90183. /**
  90184. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  90185. * This new light is named "name" and added to the passed scene.
  90186. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90187. * @param name The friendly name of the light
  90188. * @param scene The scene the new light will belong to
  90189. * @returns the constructor function
  90190. */
  90191. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90192. /**
  90193. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90194. * @param parsedLight The JSON representation of the light
  90195. * @param scene The scene to create the parsed light in
  90196. * @returns the created light after parsing
  90197. */
  90198. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90199. private _hookArrayForExcluded;
  90200. private _hookArrayForIncludedOnly;
  90201. private _resyncMeshes;
  90202. /**
  90203. * Forces the meshes to update their light related information in their rendering used effects
  90204. * @hidden Internal Use Only
  90205. */
  90206. _markMeshesAsLightDirty(): void;
  90207. /**
  90208. * Recomputes the cached photometric scale if needed.
  90209. */
  90210. private _computePhotometricScale;
  90211. /**
  90212. * Returns the Photometric Scale according to the light type and intensity mode.
  90213. */
  90214. private _getPhotometricScale;
  90215. /**
  90216. * Reorder the light in the scene according to their defined priority.
  90217. * @hidden Internal Use Only
  90218. */
  90219. _reorderLightsInScene(): void;
  90220. /**
  90221. * Prepares the list of defines specific to the light type.
  90222. * @param defines the list of defines
  90223. * @param lightIndex defines the index of the light for the effect
  90224. */
  90225. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90226. }
  90227. }
  90228. declare module BABYLON {
  90229. /**
  90230. * Interface used to define Action
  90231. */
  90232. export interface IAction {
  90233. /**
  90234. * Trigger for the action
  90235. */
  90236. trigger: number;
  90237. /** Options of the trigger */
  90238. triggerOptions: any;
  90239. /**
  90240. * Gets the trigger parameters
  90241. * @returns the trigger parameters
  90242. */
  90243. getTriggerParameter(): any;
  90244. /**
  90245. * Internal only - executes current action event
  90246. * @hidden
  90247. */
  90248. _executeCurrent(evt?: ActionEvent): void;
  90249. /**
  90250. * Serialize placeholder for child classes
  90251. * @param parent of child
  90252. * @returns the serialized object
  90253. */
  90254. serialize(parent: any): any;
  90255. /**
  90256. * Internal only
  90257. * @hidden
  90258. */
  90259. _prepare(): void;
  90260. /**
  90261. * Internal only - manager for action
  90262. * @hidden
  90263. */
  90264. _actionManager: AbstractActionManager;
  90265. /**
  90266. * Adds action to chain of actions, may be a DoNothingAction
  90267. * @param action defines the next action to execute
  90268. * @returns The action passed in
  90269. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90270. */
  90271. then(action: IAction): IAction;
  90272. }
  90273. /**
  90274. * The action to be carried out following a trigger
  90275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90276. */
  90277. export class Action implements IAction {
  90278. /** the trigger, with or without parameters, for the action */
  90279. triggerOptions: any;
  90280. /**
  90281. * Trigger for the action
  90282. */
  90283. trigger: number;
  90284. /**
  90285. * Internal only - manager for action
  90286. * @hidden
  90287. */
  90288. _actionManager: ActionManager;
  90289. private _nextActiveAction;
  90290. private _child;
  90291. private _condition?;
  90292. private _triggerParameter;
  90293. /**
  90294. * An event triggered prior to action being executed.
  90295. */
  90296. onBeforeExecuteObservable: Observable<Action>;
  90297. /**
  90298. * Creates a new Action
  90299. * @param triggerOptions the trigger, with or without parameters, for the action
  90300. * @param condition an optional determinant of action
  90301. */
  90302. constructor(
  90303. /** the trigger, with or without parameters, for the action */
  90304. triggerOptions: any, condition?: Condition);
  90305. /**
  90306. * Internal only
  90307. * @hidden
  90308. */
  90309. _prepare(): void;
  90310. /**
  90311. * Gets the trigger parameters
  90312. * @returns the trigger parameters
  90313. */
  90314. getTriggerParameter(): any;
  90315. /**
  90316. * Internal only - executes current action event
  90317. * @hidden
  90318. */
  90319. _executeCurrent(evt?: ActionEvent): void;
  90320. /**
  90321. * Execute placeholder for child classes
  90322. * @param evt optional action event
  90323. */
  90324. execute(evt?: ActionEvent): void;
  90325. /**
  90326. * Skips to next active action
  90327. */
  90328. skipToNextActiveAction(): void;
  90329. /**
  90330. * Adds action to chain of actions, may be a DoNothingAction
  90331. * @param action defines the next action to execute
  90332. * @returns The action passed in
  90333. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90334. */
  90335. then(action: Action): Action;
  90336. /**
  90337. * Internal only
  90338. * @hidden
  90339. */
  90340. _getProperty(propertyPath: string): string;
  90341. /**
  90342. * Internal only
  90343. * @hidden
  90344. */
  90345. _getEffectiveTarget(target: any, propertyPath: string): any;
  90346. /**
  90347. * Serialize placeholder for child classes
  90348. * @param parent of child
  90349. * @returns the serialized object
  90350. */
  90351. serialize(parent: any): any;
  90352. /**
  90353. * Internal only called by serialize
  90354. * @hidden
  90355. */
  90356. protected _serialize(serializedAction: any, parent?: any): any;
  90357. /**
  90358. * Internal only
  90359. * @hidden
  90360. */
  90361. static _SerializeValueAsString: (value: any) => string;
  90362. /**
  90363. * Internal only
  90364. * @hidden
  90365. */
  90366. static _GetTargetProperty: (target: Node | Scene) => {
  90367. name: string;
  90368. targetType: string;
  90369. value: string;
  90370. };
  90371. }
  90372. }
  90373. declare module BABYLON {
  90374. /**
  90375. * A Condition applied to an Action
  90376. */
  90377. export class Condition {
  90378. /**
  90379. * Internal only - manager for action
  90380. * @hidden
  90381. */
  90382. _actionManager: ActionManager;
  90383. /**
  90384. * Internal only
  90385. * @hidden
  90386. */
  90387. _evaluationId: number;
  90388. /**
  90389. * Internal only
  90390. * @hidden
  90391. */
  90392. _currentResult: boolean;
  90393. /**
  90394. * Creates a new Condition
  90395. * @param actionManager the manager of the action the condition is applied to
  90396. */
  90397. constructor(actionManager: ActionManager);
  90398. /**
  90399. * Check if the current condition is valid
  90400. * @returns a boolean
  90401. */
  90402. isValid(): boolean;
  90403. /**
  90404. * Internal only
  90405. * @hidden
  90406. */
  90407. _getProperty(propertyPath: string): string;
  90408. /**
  90409. * Internal only
  90410. * @hidden
  90411. */
  90412. _getEffectiveTarget(target: any, propertyPath: string): any;
  90413. /**
  90414. * Serialize placeholder for child classes
  90415. * @returns the serialized object
  90416. */
  90417. serialize(): any;
  90418. /**
  90419. * Internal only
  90420. * @hidden
  90421. */
  90422. protected _serialize(serializedCondition: any): any;
  90423. }
  90424. /**
  90425. * Defines specific conditional operators as extensions of Condition
  90426. */
  90427. export class ValueCondition extends Condition {
  90428. /** path to specify the property of the target the conditional operator uses */
  90429. propertyPath: string;
  90430. /** the value compared by the conditional operator against the current value of the property */
  90431. value: any;
  90432. /** the conditional operator, default ValueCondition.IsEqual */
  90433. operator: number;
  90434. /**
  90435. * Internal only
  90436. * @hidden
  90437. */
  90438. private static _IsEqual;
  90439. /**
  90440. * Internal only
  90441. * @hidden
  90442. */
  90443. private static _IsDifferent;
  90444. /**
  90445. * Internal only
  90446. * @hidden
  90447. */
  90448. private static _IsGreater;
  90449. /**
  90450. * Internal only
  90451. * @hidden
  90452. */
  90453. private static _IsLesser;
  90454. /**
  90455. * returns the number for IsEqual
  90456. */
  90457. static get IsEqual(): number;
  90458. /**
  90459. * Returns the number for IsDifferent
  90460. */
  90461. static get IsDifferent(): number;
  90462. /**
  90463. * Returns the number for IsGreater
  90464. */
  90465. static get IsGreater(): number;
  90466. /**
  90467. * Returns the number for IsLesser
  90468. */
  90469. static get IsLesser(): number;
  90470. /**
  90471. * Internal only The action manager for the condition
  90472. * @hidden
  90473. */
  90474. _actionManager: ActionManager;
  90475. /**
  90476. * Internal only
  90477. * @hidden
  90478. */
  90479. private _target;
  90480. /**
  90481. * Internal only
  90482. * @hidden
  90483. */
  90484. private _effectiveTarget;
  90485. /**
  90486. * Internal only
  90487. * @hidden
  90488. */
  90489. private _property;
  90490. /**
  90491. * Creates a new ValueCondition
  90492. * @param actionManager manager for the action the condition applies to
  90493. * @param target for the action
  90494. * @param propertyPath path to specify the property of the target the conditional operator uses
  90495. * @param value the value compared by the conditional operator against the current value of the property
  90496. * @param operator the conditional operator, default ValueCondition.IsEqual
  90497. */
  90498. constructor(actionManager: ActionManager, target: any,
  90499. /** path to specify the property of the target the conditional operator uses */
  90500. propertyPath: string,
  90501. /** the value compared by the conditional operator against the current value of the property */
  90502. value: any,
  90503. /** the conditional operator, default ValueCondition.IsEqual */
  90504. operator?: number);
  90505. /**
  90506. * Compares the given value with the property value for the specified conditional operator
  90507. * @returns the result of the comparison
  90508. */
  90509. isValid(): boolean;
  90510. /**
  90511. * Serialize the ValueCondition into a JSON compatible object
  90512. * @returns serialization object
  90513. */
  90514. serialize(): any;
  90515. /**
  90516. * Gets the name of the conditional operator for the ValueCondition
  90517. * @param operator the conditional operator
  90518. * @returns the name
  90519. */
  90520. static GetOperatorName(operator: number): string;
  90521. }
  90522. /**
  90523. * Defines a predicate condition as an extension of Condition
  90524. */
  90525. export class PredicateCondition extends Condition {
  90526. /** defines the predicate function used to validate the condition */
  90527. predicate: () => boolean;
  90528. /**
  90529. * Internal only - manager for action
  90530. * @hidden
  90531. */
  90532. _actionManager: ActionManager;
  90533. /**
  90534. * Creates a new PredicateCondition
  90535. * @param actionManager manager for the action the condition applies to
  90536. * @param predicate defines the predicate function used to validate the condition
  90537. */
  90538. constructor(actionManager: ActionManager,
  90539. /** defines the predicate function used to validate the condition */
  90540. predicate: () => boolean);
  90541. /**
  90542. * @returns the validity of the predicate condition
  90543. */
  90544. isValid(): boolean;
  90545. }
  90546. /**
  90547. * Defines a state condition as an extension of Condition
  90548. */
  90549. export class StateCondition extends Condition {
  90550. /** Value to compare with target state */
  90551. value: string;
  90552. /**
  90553. * Internal only - manager for action
  90554. * @hidden
  90555. */
  90556. _actionManager: ActionManager;
  90557. /**
  90558. * Internal only
  90559. * @hidden
  90560. */
  90561. private _target;
  90562. /**
  90563. * Creates a new StateCondition
  90564. * @param actionManager manager for the action the condition applies to
  90565. * @param target of the condition
  90566. * @param value to compare with target state
  90567. */
  90568. constructor(actionManager: ActionManager, target: any,
  90569. /** Value to compare with target state */
  90570. value: string);
  90571. /**
  90572. * Gets a boolean indicating if the current condition is met
  90573. * @returns the validity of the state
  90574. */
  90575. isValid(): boolean;
  90576. /**
  90577. * Serialize the StateCondition into a JSON compatible object
  90578. * @returns serialization object
  90579. */
  90580. serialize(): any;
  90581. }
  90582. }
  90583. declare module BABYLON {
  90584. /**
  90585. * This defines an action responsible to toggle a boolean once triggered.
  90586. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90587. */
  90588. export class SwitchBooleanAction extends Action {
  90589. /**
  90590. * The path to the boolean property in the target object
  90591. */
  90592. propertyPath: string;
  90593. private _target;
  90594. private _effectiveTarget;
  90595. private _property;
  90596. /**
  90597. * Instantiate the action
  90598. * @param triggerOptions defines the trigger options
  90599. * @param target defines the object containing the boolean
  90600. * @param propertyPath defines the path to the boolean property in the target object
  90601. * @param condition defines the trigger related conditions
  90602. */
  90603. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90604. /** @hidden */
  90605. _prepare(): void;
  90606. /**
  90607. * Execute the action toggle the boolean value.
  90608. */
  90609. execute(): void;
  90610. /**
  90611. * Serializes the actions and its related information.
  90612. * @param parent defines the object to serialize in
  90613. * @returns the serialized object
  90614. */
  90615. serialize(parent: any): any;
  90616. }
  90617. /**
  90618. * This defines an action responsible to set a the state field of the target
  90619. * to a desired value once triggered.
  90620. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90621. */
  90622. export class SetStateAction extends Action {
  90623. /**
  90624. * The value to store in the state field.
  90625. */
  90626. value: string;
  90627. private _target;
  90628. /**
  90629. * Instantiate the action
  90630. * @param triggerOptions defines the trigger options
  90631. * @param target defines the object containing the state property
  90632. * @param value defines the value to store in the state field
  90633. * @param condition defines the trigger related conditions
  90634. */
  90635. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90636. /**
  90637. * Execute the action and store the value on the target state property.
  90638. */
  90639. execute(): void;
  90640. /**
  90641. * Serializes the actions and its related information.
  90642. * @param parent defines the object to serialize in
  90643. * @returns the serialized object
  90644. */
  90645. serialize(parent: any): any;
  90646. }
  90647. /**
  90648. * This defines an action responsible to set a property of the target
  90649. * to a desired value once triggered.
  90650. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90651. */
  90652. export class SetValueAction extends Action {
  90653. /**
  90654. * The path of the property to set in the target.
  90655. */
  90656. propertyPath: string;
  90657. /**
  90658. * The value to set in the property
  90659. */
  90660. value: any;
  90661. private _target;
  90662. private _effectiveTarget;
  90663. private _property;
  90664. /**
  90665. * Instantiate the action
  90666. * @param triggerOptions defines the trigger options
  90667. * @param target defines the object containing the property
  90668. * @param propertyPath defines the path of the property to set in the target
  90669. * @param value defines the value to set in the property
  90670. * @param condition defines the trigger related conditions
  90671. */
  90672. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90673. /** @hidden */
  90674. _prepare(): void;
  90675. /**
  90676. * Execute the action and set the targetted property to the desired value.
  90677. */
  90678. execute(): void;
  90679. /**
  90680. * Serializes the actions and its related information.
  90681. * @param parent defines the object to serialize in
  90682. * @returns the serialized object
  90683. */
  90684. serialize(parent: any): any;
  90685. }
  90686. /**
  90687. * This defines an action responsible to increment the target value
  90688. * to a desired value once triggered.
  90689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90690. */
  90691. export class IncrementValueAction extends Action {
  90692. /**
  90693. * The path of the property to increment in the target.
  90694. */
  90695. propertyPath: string;
  90696. /**
  90697. * The value we should increment the property by.
  90698. */
  90699. value: any;
  90700. private _target;
  90701. private _effectiveTarget;
  90702. private _property;
  90703. /**
  90704. * Instantiate the action
  90705. * @param triggerOptions defines the trigger options
  90706. * @param target defines the object containing the property
  90707. * @param propertyPath defines the path of the property to increment in the target
  90708. * @param value defines the value value we should increment the property by
  90709. * @param condition defines the trigger related conditions
  90710. */
  90711. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90712. /** @hidden */
  90713. _prepare(): void;
  90714. /**
  90715. * Execute the action and increment the target of the value amount.
  90716. */
  90717. execute(): void;
  90718. /**
  90719. * Serializes the actions and its related information.
  90720. * @param parent defines the object to serialize in
  90721. * @returns the serialized object
  90722. */
  90723. serialize(parent: any): any;
  90724. }
  90725. /**
  90726. * This defines an action responsible to start an animation once triggered.
  90727. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90728. */
  90729. export class PlayAnimationAction extends Action {
  90730. /**
  90731. * Where the animation should start (animation frame)
  90732. */
  90733. from: number;
  90734. /**
  90735. * Where the animation should stop (animation frame)
  90736. */
  90737. to: number;
  90738. /**
  90739. * Define if the animation should loop or stop after the first play.
  90740. */
  90741. loop?: boolean;
  90742. private _target;
  90743. /**
  90744. * Instantiate the action
  90745. * @param triggerOptions defines the trigger options
  90746. * @param target defines the target animation or animation name
  90747. * @param from defines from where the animation should start (animation frame)
  90748. * @param end defines where the animation should stop (animation frame)
  90749. * @param loop defines if the animation should loop or stop after the first play
  90750. * @param condition defines the trigger related conditions
  90751. */
  90752. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90753. /** @hidden */
  90754. _prepare(): void;
  90755. /**
  90756. * Execute the action and play the animation.
  90757. */
  90758. execute(): void;
  90759. /**
  90760. * Serializes the actions and its related information.
  90761. * @param parent defines the object to serialize in
  90762. * @returns the serialized object
  90763. */
  90764. serialize(parent: any): any;
  90765. }
  90766. /**
  90767. * This defines an action responsible to stop an animation once triggered.
  90768. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90769. */
  90770. export class StopAnimationAction extends Action {
  90771. private _target;
  90772. /**
  90773. * Instantiate the action
  90774. * @param triggerOptions defines the trigger options
  90775. * @param target defines the target animation or animation name
  90776. * @param condition defines the trigger related conditions
  90777. */
  90778. constructor(triggerOptions: any, target: any, condition?: Condition);
  90779. /** @hidden */
  90780. _prepare(): void;
  90781. /**
  90782. * Execute the action and stop the animation.
  90783. */
  90784. execute(): void;
  90785. /**
  90786. * Serializes the actions and its related information.
  90787. * @param parent defines the object to serialize in
  90788. * @returns the serialized object
  90789. */
  90790. serialize(parent: any): any;
  90791. }
  90792. /**
  90793. * This defines an action responsible that does nothing once triggered.
  90794. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90795. */
  90796. export class DoNothingAction extends Action {
  90797. /**
  90798. * Instantiate the action
  90799. * @param triggerOptions defines the trigger options
  90800. * @param condition defines the trigger related conditions
  90801. */
  90802. constructor(triggerOptions?: any, condition?: Condition);
  90803. /**
  90804. * Execute the action and do nothing.
  90805. */
  90806. execute(): void;
  90807. /**
  90808. * Serializes the actions and its related information.
  90809. * @param parent defines the object to serialize in
  90810. * @returns the serialized object
  90811. */
  90812. serialize(parent: any): any;
  90813. }
  90814. /**
  90815. * This defines an action responsible to trigger several actions once triggered.
  90816. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90817. */
  90818. export class CombineAction extends Action {
  90819. /**
  90820. * The list of aggregated animations to run.
  90821. */
  90822. children: Action[];
  90823. /**
  90824. * Instantiate the action
  90825. * @param triggerOptions defines the trigger options
  90826. * @param children defines the list of aggregated animations to run
  90827. * @param condition defines the trigger related conditions
  90828. */
  90829. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90830. /** @hidden */
  90831. _prepare(): void;
  90832. /**
  90833. * Execute the action and executes all the aggregated actions.
  90834. */
  90835. execute(evt: ActionEvent): void;
  90836. /**
  90837. * Serializes the actions and its related information.
  90838. * @param parent defines the object to serialize in
  90839. * @returns the serialized object
  90840. */
  90841. serialize(parent: any): any;
  90842. }
  90843. /**
  90844. * This defines an action responsible to run code (external event) once triggered.
  90845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90846. */
  90847. export class ExecuteCodeAction extends Action {
  90848. /**
  90849. * The callback function to run.
  90850. */
  90851. func: (evt: ActionEvent) => void;
  90852. /**
  90853. * Instantiate the action
  90854. * @param triggerOptions defines the trigger options
  90855. * @param func defines the callback function to run
  90856. * @param condition defines the trigger related conditions
  90857. */
  90858. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90859. /**
  90860. * Execute the action and run the attached code.
  90861. */
  90862. execute(evt: ActionEvent): void;
  90863. }
  90864. /**
  90865. * This defines an action responsible to set the parent property of the target once triggered.
  90866. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90867. */
  90868. export class SetParentAction extends Action {
  90869. private _parent;
  90870. private _target;
  90871. /**
  90872. * Instantiate the action
  90873. * @param triggerOptions defines the trigger options
  90874. * @param target defines the target containing the parent property
  90875. * @param parent defines from where the animation should start (animation frame)
  90876. * @param condition defines the trigger related conditions
  90877. */
  90878. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90879. /** @hidden */
  90880. _prepare(): void;
  90881. /**
  90882. * Execute the action and set the parent property.
  90883. */
  90884. execute(): void;
  90885. /**
  90886. * Serializes the actions and its related information.
  90887. * @param parent defines the object to serialize in
  90888. * @returns the serialized object
  90889. */
  90890. serialize(parent: any): any;
  90891. }
  90892. }
  90893. declare module BABYLON {
  90894. /**
  90895. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90896. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90898. */
  90899. export class ActionManager extends AbstractActionManager {
  90900. /**
  90901. * Nothing
  90902. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90903. */
  90904. static readonly NothingTrigger: number;
  90905. /**
  90906. * On pick
  90907. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90908. */
  90909. static readonly OnPickTrigger: number;
  90910. /**
  90911. * On left pick
  90912. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90913. */
  90914. static readonly OnLeftPickTrigger: number;
  90915. /**
  90916. * On right pick
  90917. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90918. */
  90919. static readonly OnRightPickTrigger: number;
  90920. /**
  90921. * On center pick
  90922. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90923. */
  90924. static readonly OnCenterPickTrigger: number;
  90925. /**
  90926. * On pick down
  90927. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90928. */
  90929. static readonly OnPickDownTrigger: number;
  90930. /**
  90931. * On double pick
  90932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90933. */
  90934. static readonly OnDoublePickTrigger: number;
  90935. /**
  90936. * On pick up
  90937. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90938. */
  90939. static readonly OnPickUpTrigger: number;
  90940. /**
  90941. * On pick out.
  90942. * This trigger will only be raised if you also declared a OnPickDown
  90943. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90944. */
  90945. static readonly OnPickOutTrigger: number;
  90946. /**
  90947. * On long press
  90948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90949. */
  90950. static readonly OnLongPressTrigger: number;
  90951. /**
  90952. * On pointer over
  90953. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90954. */
  90955. static readonly OnPointerOverTrigger: number;
  90956. /**
  90957. * On pointer out
  90958. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90959. */
  90960. static readonly OnPointerOutTrigger: number;
  90961. /**
  90962. * On every frame
  90963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90964. */
  90965. static readonly OnEveryFrameTrigger: number;
  90966. /**
  90967. * On intersection enter
  90968. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90969. */
  90970. static readonly OnIntersectionEnterTrigger: number;
  90971. /**
  90972. * On intersection exit
  90973. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90974. */
  90975. static readonly OnIntersectionExitTrigger: number;
  90976. /**
  90977. * On key down
  90978. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90979. */
  90980. static readonly OnKeyDownTrigger: number;
  90981. /**
  90982. * On key up
  90983. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90984. */
  90985. static readonly OnKeyUpTrigger: number;
  90986. private _scene;
  90987. /**
  90988. * Creates a new action manager
  90989. * @param scene defines the hosting scene
  90990. */
  90991. constructor(scene: Scene);
  90992. /**
  90993. * Releases all associated resources
  90994. */
  90995. dispose(): void;
  90996. /**
  90997. * Gets hosting scene
  90998. * @returns the hosting scene
  90999. */
  91000. getScene(): Scene;
  91001. /**
  91002. * Does this action manager handles actions of any of the given triggers
  91003. * @param triggers defines the triggers to be tested
  91004. * @return a boolean indicating whether one (or more) of the triggers is handled
  91005. */
  91006. hasSpecificTriggers(triggers: number[]): boolean;
  91007. /**
  91008. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91009. * speed.
  91010. * @param triggerA defines the trigger to be tested
  91011. * @param triggerB defines the trigger to be tested
  91012. * @return a boolean indicating whether one (or more) of the triggers is handled
  91013. */
  91014. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91015. /**
  91016. * Does this action manager handles actions of a given trigger
  91017. * @param trigger defines the trigger to be tested
  91018. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91019. * @return whether the trigger is handled
  91020. */
  91021. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91022. /**
  91023. * Does this action manager has pointer triggers
  91024. */
  91025. get hasPointerTriggers(): boolean;
  91026. /**
  91027. * Does this action manager has pick triggers
  91028. */
  91029. get hasPickTriggers(): boolean;
  91030. /**
  91031. * Registers an action to this action manager
  91032. * @param action defines the action to be registered
  91033. * @return the action amended (prepared) after registration
  91034. */
  91035. registerAction(action: IAction): Nullable<IAction>;
  91036. /**
  91037. * Unregisters an action to this action manager
  91038. * @param action defines the action to be unregistered
  91039. * @return a boolean indicating whether the action has been unregistered
  91040. */
  91041. unregisterAction(action: IAction): Boolean;
  91042. /**
  91043. * Process a specific trigger
  91044. * @param trigger defines the trigger to process
  91045. * @param evt defines the event details to be processed
  91046. */
  91047. processTrigger(trigger: number, evt?: IActionEvent): void;
  91048. /** @hidden */
  91049. _getEffectiveTarget(target: any, propertyPath: string): any;
  91050. /** @hidden */
  91051. _getProperty(propertyPath: string): string;
  91052. /**
  91053. * Serialize this manager to a JSON object
  91054. * @param name defines the property name to store this manager
  91055. * @returns a JSON representation of this manager
  91056. */
  91057. serialize(name: string): any;
  91058. /**
  91059. * Creates a new ActionManager from a JSON data
  91060. * @param parsedActions defines the JSON data to read from
  91061. * @param object defines the hosting mesh
  91062. * @param scene defines the hosting scene
  91063. */
  91064. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91065. /**
  91066. * Get a trigger name by index
  91067. * @param trigger defines the trigger index
  91068. * @returns a trigger name
  91069. */
  91070. static GetTriggerName(trigger: number): string;
  91071. }
  91072. }
  91073. declare module BABYLON {
  91074. /**
  91075. * Class used to represent a sprite
  91076. * @see http://doc.babylonjs.com/babylon101/sprites
  91077. */
  91078. export class Sprite {
  91079. /** defines the name */
  91080. name: string;
  91081. /** Gets or sets the current world position */
  91082. position: Vector3;
  91083. /** Gets or sets the main color */
  91084. color: Color4;
  91085. /** Gets or sets the width */
  91086. width: number;
  91087. /** Gets or sets the height */
  91088. height: number;
  91089. /** Gets or sets rotation angle */
  91090. angle: number;
  91091. /** Gets or sets the cell index in the sprite sheet */
  91092. cellIndex: number;
  91093. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91094. cellRef: string;
  91095. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91096. invertU: number;
  91097. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91098. invertV: number;
  91099. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91100. disposeWhenFinishedAnimating: boolean;
  91101. /** Gets the list of attached animations */
  91102. animations: Animation[];
  91103. /** Gets or sets a boolean indicating if the sprite can be picked */
  91104. isPickable: boolean;
  91105. /**
  91106. * Gets or sets the associated action manager
  91107. */
  91108. actionManager: Nullable<ActionManager>;
  91109. private _animationStarted;
  91110. private _loopAnimation;
  91111. private _fromIndex;
  91112. private _toIndex;
  91113. private _delay;
  91114. private _direction;
  91115. private _manager;
  91116. private _time;
  91117. private _onAnimationEnd;
  91118. /**
  91119. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91120. */
  91121. isVisible: boolean;
  91122. /**
  91123. * Gets or sets the sprite size
  91124. */
  91125. get size(): number;
  91126. set size(value: number);
  91127. /**
  91128. * Creates a new Sprite
  91129. * @param name defines the name
  91130. * @param manager defines the manager
  91131. */
  91132. constructor(
  91133. /** defines the name */
  91134. name: string, manager: ISpriteManager);
  91135. /**
  91136. * Starts an animation
  91137. * @param from defines the initial key
  91138. * @param to defines the end key
  91139. * @param loop defines if the animation must loop
  91140. * @param delay defines the start delay (in ms)
  91141. * @param onAnimationEnd defines a callback to call when animation ends
  91142. */
  91143. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  91144. /** Stops current animation (if any) */
  91145. stopAnimation(): void;
  91146. /** @hidden */
  91147. _animate(deltaTime: number): void;
  91148. /** Release associated resources */
  91149. dispose(): void;
  91150. }
  91151. }
  91152. declare module BABYLON {
  91153. /**
  91154. * Information about the result of picking within a scene
  91155. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91156. */
  91157. export class PickingInfo {
  91158. /** @hidden */
  91159. _pickingUnavailable: boolean;
  91160. /**
  91161. * If the pick collided with an object
  91162. */
  91163. hit: boolean;
  91164. /**
  91165. * Distance away where the pick collided
  91166. */
  91167. distance: number;
  91168. /**
  91169. * The location of pick collision
  91170. */
  91171. pickedPoint: Nullable<Vector3>;
  91172. /**
  91173. * The mesh corresponding the the pick collision
  91174. */
  91175. pickedMesh: Nullable<AbstractMesh>;
  91176. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91177. bu: number;
  91178. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91179. bv: number;
  91180. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91181. faceId: number;
  91182. /** Id of the the submesh that was picked */
  91183. subMeshId: number;
  91184. /** If a sprite was picked, this will be the sprite the pick collided with */
  91185. pickedSprite: Nullable<Sprite>;
  91186. /**
  91187. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91188. */
  91189. originMesh: Nullable<AbstractMesh>;
  91190. /**
  91191. * The ray that was used to perform the picking.
  91192. */
  91193. ray: Nullable<Ray>;
  91194. /**
  91195. * Gets the normal correspodning to the face the pick collided with
  91196. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91197. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91198. * @returns The normal correspodning to the face the pick collided with
  91199. */
  91200. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91201. /**
  91202. * Gets the texture coordinates of where the pick occured
  91203. * @returns the vector containing the coordnates of the texture
  91204. */
  91205. getTextureCoordinates(): Nullable<Vector2>;
  91206. }
  91207. }
  91208. declare module BABYLON {
  91209. /**
  91210. * Gather the list of pointer event types as constants.
  91211. */
  91212. export class PointerEventTypes {
  91213. /**
  91214. * 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.
  91215. */
  91216. static readonly POINTERDOWN: number;
  91217. /**
  91218. * The pointerup event is fired when a pointer is no longer active.
  91219. */
  91220. static readonly POINTERUP: number;
  91221. /**
  91222. * The pointermove event is fired when a pointer changes coordinates.
  91223. */
  91224. static readonly POINTERMOVE: number;
  91225. /**
  91226. * The pointerwheel event is fired when a mouse wheel has been rotated.
  91227. */
  91228. static readonly POINTERWHEEL: number;
  91229. /**
  91230. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  91231. */
  91232. static readonly POINTERPICK: number;
  91233. /**
  91234. * The pointertap event is fired when a the object has been touched and released without drag.
  91235. */
  91236. static readonly POINTERTAP: number;
  91237. /**
  91238. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  91239. */
  91240. static readonly POINTERDOUBLETAP: number;
  91241. }
  91242. /**
  91243. * Base class of pointer info types.
  91244. */
  91245. export class PointerInfoBase {
  91246. /**
  91247. * Defines the type of event (PointerEventTypes)
  91248. */
  91249. type: number;
  91250. /**
  91251. * Defines the related dom event
  91252. */
  91253. event: PointerEvent | MouseWheelEvent;
  91254. /**
  91255. * Instantiates the base class of pointers info.
  91256. * @param type Defines the type of event (PointerEventTypes)
  91257. * @param event Defines the related dom event
  91258. */
  91259. constructor(
  91260. /**
  91261. * Defines the type of event (PointerEventTypes)
  91262. */
  91263. type: number,
  91264. /**
  91265. * Defines the related dom event
  91266. */
  91267. event: PointerEvent | MouseWheelEvent);
  91268. }
  91269. /**
  91270. * This class is used to store pointer related info for the onPrePointerObservable event.
  91271. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  91272. */
  91273. export class PointerInfoPre extends PointerInfoBase {
  91274. /**
  91275. * Ray from a pointer if availible (eg. 6dof controller)
  91276. */
  91277. ray: Nullable<Ray>;
  91278. /**
  91279. * Defines the local position of the pointer on the canvas.
  91280. */
  91281. localPosition: Vector2;
  91282. /**
  91283. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  91284. */
  91285. skipOnPointerObservable: boolean;
  91286. /**
  91287. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  91288. * @param type Defines the type of event (PointerEventTypes)
  91289. * @param event Defines the related dom event
  91290. * @param localX Defines the local x coordinates of the pointer when the event occured
  91291. * @param localY Defines the local y coordinates of the pointer when the event occured
  91292. */
  91293. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  91294. }
  91295. /**
  91296. * This type contains all the data related to a pointer event in Babylon.js.
  91297. * 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.
  91298. */
  91299. export class PointerInfo extends PointerInfoBase {
  91300. /**
  91301. * Defines the picking info associated to the info (if any)\
  91302. */
  91303. pickInfo: Nullable<PickingInfo>;
  91304. /**
  91305. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  91306. * @param type Defines the type of event (PointerEventTypes)
  91307. * @param event Defines the related dom event
  91308. * @param pickInfo Defines the picking info associated to the info (if any)\
  91309. */
  91310. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  91311. /**
  91312. * Defines the picking info associated to the info (if any)\
  91313. */
  91314. pickInfo: Nullable<PickingInfo>);
  91315. }
  91316. /**
  91317. * Data relating to a touch event on the screen.
  91318. */
  91319. export interface PointerTouch {
  91320. /**
  91321. * X coordinate of touch.
  91322. */
  91323. x: number;
  91324. /**
  91325. * Y coordinate of touch.
  91326. */
  91327. y: number;
  91328. /**
  91329. * Id of touch. Unique for each finger.
  91330. */
  91331. pointerId: number;
  91332. /**
  91333. * Event type passed from DOM.
  91334. */
  91335. type: any;
  91336. }
  91337. }
  91338. declare module BABYLON {
  91339. /**
  91340. * Manage the mouse inputs to control the movement of a free camera.
  91341. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91342. */
  91343. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  91344. /**
  91345. * Define if touch is enabled in the mouse input
  91346. */
  91347. touchEnabled: boolean;
  91348. /**
  91349. * Defines the camera the input is attached to.
  91350. */
  91351. camera: FreeCamera;
  91352. /**
  91353. * Defines the buttons associated with the input to handle camera move.
  91354. */
  91355. buttons: number[];
  91356. /**
  91357. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  91358. */
  91359. angularSensibility: number;
  91360. private _pointerInput;
  91361. private _onMouseMove;
  91362. private _observer;
  91363. private previousPosition;
  91364. /**
  91365. * Observable for when a pointer move event occurs containing the move offset
  91366. */
  91367. onPointerMovedObservable: Observable<{
  91368. offsetX: number;
  91369. offsetY: number;
  91370. }>;
  91371. /**
  91372. * @hidden
  91373. * If the camera should be rotated automatically based on pointer movement
  91374. */
  91375. _allowCameraRotation: boolean;
  91376. /**
  91377. * Manage the mouse inputs to control the movement of a free camera.
  91378. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91379. * @param touchEnabled Defines if touch is enabled or not
  91380. */
  91381. constructor(
  91382. /**
  91383. * Define if touch is enabled in the mouse input
  91384. */
  91385. touchEnabled?: boolean);
  91386. /**
  91387. * Attach the input controls to a specific dom element to get the input from.
  91388. * @param element Defines the element the controls should be listened from
  91389. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91390. */
  91391. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91392. /**
  91393. * Called on JS contextmenu event.
  91394. * Override this method to provide functionality.
  91395. */
  91396. protected onContextMenu(evt: PointerEvent): void;
  91397. /**
  91398. * Detach the current controls from the specified dom element.
  91399. * @param element Defines the element to stop listening the inputs from
  91400. */
  91401. detachControl(element: Nullable<HTMLElement>): void;
  91402. /**
  91403. * Gets the class name of the current intput.
  91404. * @returns the class name
  91405. */
  91406. getClassName(): string;
  91407. /**
  91408. * Get the friendly name associated with the input class.
  91409. * @returns the input friendly name
  91410. */
  91411. getSimpleName(): string;
  91412. }
  91413. }
  91414. declare module BABYLON {
  91415. /**
  91416. * Manage the touch inputs to control the movement of a free camera.
  91417. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91418. */
  91419. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  91420. /**
  91421. * Defines the camera the input is attached to.
  91422. */
  91423. camera: FreeCamera;
  91424. /**
  91425. * Defines the touch sensibility for rotation.
  91426. * The higher the faster.
  91427. */
  91428. touchAngularSensibility: number;
  91429. /**
  91430. * Defines the touch sensibility for move.
  91431. * The higher the faster.
  91432. */
  91433. touchMoveSensibility: number;
  91434. private _offsetX;
  91435. private _offsetY;
  91436. private _pointerPressed;
  91437. private _pointerInput;
  91438. private _observer;
  91439. private _onLostFocus;
  91440. /**
  91441. * Attach the input controls to a specific dom element to get the input from.
  91442. * @param element Defines the element the controls should be listened from
  91443. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91444. */
  91445. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91446. /**
  91447. * Detach the current controls from the specified dom element.
  91448. * @param element Defines the element to stop listening the inputs from
  91449. */
  91450. detachControl(element: Nullable<HTMLElement>): void;
  91451. /**
  91452. * Update the current camera state depending on the inputs that have been used this frame.
  91453. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91454. */
  91455. checkInputs(): void;
  91456. /**
  91457. * Gets the class name of the current intput.
  91458. * @returns the class name
  91459. */
  91460. getClassName(): string;
  91461. /**
  91462. * Get the friendly name associated with the input class.
  91463. * @returns the input friendly name
  91464. */
  91465. getSimpleName(): string;
  91466. }
  91467. }
  91468. declare module BABYLON {
  91469. /**
  91470. * Default Inputs manager for the FreeCamera.
  91471. * It groups all the default supported inputs for ease of use.
  91472. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91473. */
  91474. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  91475. /**
  91476. * @hidden
  91477. */
  91478. _mouseInput: Nullable<FreeCameraMouseInput>;
  91479. /**
  91480. * Instantiates a new FreeCameraInputsManager.
  91481. * @param camera Defines the camera the inputs belong to
  91482. */
  91483. constructor(camera: FreeCamera);
  91484. /**
  91485. * Add keyboard input support to the input manager.
  91486. * @returns the current input manager
  91487. */
  91488. addKeyboard(): FreeCameraInputsManager;
  91489. /**
  91490. * Add mouse input support to the input manager.
  91491. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  91492. * @returns the current input manager
  91493. */
  91494. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  91495. /**
  91496. * Removes the mouse input support from the manager
  91497. * @returns the current input manager
  91498. */
  91499. removeMouse(): FreeCameraInputsManager;
  91500. /**
  91501. * Add touch input support to the input manager.
  91502. * @returns the current input manager
  91503. */
  91504. addTouch(): FreeCameraInputsManager;
  91505. /**
  91506. * Remove all attached input methods from a camera
  91507. */
  91508. clear(): void;
  91509. }
  91510. }
  91511. declare module BABYLON {
  91512. /**
  91513. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91514. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  91515. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91516. */
  91517. export class FreeCamera extends TargetCamera {
  91518. /**
  91519. * Define the collision ellipsoid of the camera.
  91520. * This is helpful to simulate a camera body like the player body around the camera
  91521. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91522. */
  91523. ellipsoid: Vector3;
  91524. /**
  91525. * Define an offset for the position of the ellipsoid around the camera.
  91526. * This can be helpful to determine the center of the body near the gravity center of the body
  91527. * instead of its head.
  91528. */
  91529. ellipsoidOffset: Vector3;
  91530. /**
  91531. * Enable or disable collisions of the camera with the rest of the scene objects.
  91532. */
  91533. checkCollisions: boolean;
  91534. /**
  91535. * Enable or disable gravity on the camera.
  91536. */
  91537. applyGravity: boolean;
  91538. /**
  91539. * Define the input manager associated to the camera.
  91540. */
  91541. inputs: FreeCameraInputsManager;
  91542. /**
  91543. * Gets the input sensibility for a mouse input. (default is 2000.0)
  91544. * Higher values reduce sensitivity.
  91545. */
  91546. get angularSensibility(): number;
  91547. /**
  91548. * Sets the input sensibility for a mouse input. (default is 2000.0)
  91549. * Higher values reduce sensitivity.
  91550. */
  91551. set angularSensibility(value: number);
  91552. /**
  91553. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  91554. */
  91555. get keysUp(): number[];
  91556. set keysUp(value: number[]);
  91557. /**
  91558. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  91559. */
  91560. get keysDown(): number[];
  91561. set keysDown(value: number[]);
  91562. /**
  91563. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  91564. */
  91565. get keysLeft(): number[];
  91566. set keysLeft(value: number[]);
  91567. /**
  91568. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  91569. */
  91570. get keysRight(): number[];
  91571. set keysRight(value: number[]);
  91572. /**
  91573. * Event raised when the camera collide with a mesh in the scene.
  91574. */
  91575. onCollide: (collidedMesh: AbstractMesh) => void;
  91576. private _collider;
  91577. private _needMoveForGravity;
  91578. private _oldPosition;
  91579. private _diffPosition;
  91580. private _newPosition;
  91581. /** @hidden */
  91582. _localDirection: Vector3;
  91583. /** @hidden */
  91584. _transformedDirection: Vector3;
  91585. /**
  91586. * Instantiates a Free Camera.
  91587. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91588. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  91589. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91590. * @param name Define the name of the camera in the scene
  91591. * @param position Define the start position of the camera in the scene
  91592. * @param scene Define the scene the camera belongs to
  91593. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91594. */
  91595. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91596. /**
  91597. * Attached controls to the current camera.
  91598. * @param element Defines the element the controls should be listened from
  91599. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91600. */
  91601. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91602. /**
  91603. * Detach the current controls from the camera.
  91604. * The camera will stop reacting to inputs.
  91605. * @param element Defines the element to stop listening the inputs from
  91606. */
  91607. detachControl(element: HTMLElement): void;
  91608. private _collisionMask;
  91609. /**
  91610. * Define a collision mask to limit the list of object the camera can collide with
  91611. */
  91612. get collisionMask(): number;
  91613. set collisionMask(mask: number);
  91614. /** @hidden */
  91615. _collideWithWorld(displacement: Vector3): void;
  91616. private _onCollisionPositionChange;
  91617. /** @hidden */
  91618. _checkInputs(): void;
  91619. /** @hidden */
  91620. _decideIfNeedsToMove(): boolean;
  91621. /** @hidden */
  91622. _updatePosition(): void;
  91623. /**
  91624. * Destroy the camera and release the current resources hold by it.
  91625. */
  91626. dispose(): void;
  91627. /**
  91628. * Gets the current object class name.
  91629. * @return the class name
  91630. */
  91631. getClassName(): string;
  91632. }
  91633. }
  91634. declare module BABYLON {
  91635. /**
  91636. * Represents a gamepad control stick position
  91637. */
  91638. export class StickValues {
  91639. /**
  91640. * The x component of the control stick
  91641. */
  91642. x: number;
  91643. /**
  91644. * The y component of the control stick
  91645. */
  91646. y: number;
  91647. /**
  91648. * Initializes the gamepad x and y control stick values
  91649. * @param x The x component of the gamepad control stick value
  91650. * @param y The y component of the gamepad control stick value
  91651. */
  91652. constructor(
  91653. /**
  91654. * The x component of the control stick
  91655. */
  91656. x: number,
  91657. /**
  91658. * The y component of the control stick
  91659. */
  91660. y: number);
  91661. }
  91662. /**
  91663. * An interface which manages callbacks for gamepad button changes
  91664. */
  91665. export interface GamepadButtonChanges {
  91666. /**
  91667. * Called when a gamepad has been changed
  91668. */
  91669. changed: boolean;
  91670. /**
  91671. * Called when a gamepad press event has been triggered
  91672. */
  91673. pressChanged: boolean;
  91674. /**
  91675. * Called when a touch event has been triggered
  91676. */
  91677. touchChanged: boolean;
  91678. /**
  91679. * Called when a value has changed
  91680. */
  91681. valueChanged: boolean;
  91682. }
  91683. /**
  91684. * Represents a gamepad
  91685. */
  91686. export class Gamepad {
  91687. /**
  91688. * The id of the gamepad
  91689. */
  91690. id: string;
  91691. /**
  91692. * The index of the gamepad
  91693. */
  91694. index: number;
  91695. /**
  91696. * The browser gamepad
  91697. */
  91698. browserGamepad: any;
  91699. /**
  91700. * Specifies what type of gamepad this represents
  91701. */
  91702. type: number;
  91703. private _leftStick;
  91704. private _rightStick;
  91705. /** @hidden */
  91706. _isConnected: boolean;
  91707. private _leftStickAxisX;
  91708. private _leftStickAxisY;
  91709. private _rightStickAxisX;
  91710. private _rightStickAxisY;
  91711. /**
  91712. * Triggered when the left control stick has been changed
  91713. */
  91714. private _onleftstickchanged;
  91715. /**
  91716. * Triggered when the right control stick has been changed
  91717. */
  91718. private _onrightstickchanged;
  91719. /**
  91720. * Represents a gamepad controller
  91721. */
  91722. static GAMEPAD: number;
  91723. /**
  91724. * Represents a generic controller
  91725. */
  91726. static GENERIC: number;
  91727. /**
  91728. * Represents an XBox controller
  91729. */
  91730. static XBOX: number;
  91731. /**
  91732. * Represents a pose-enabled controller
  91733. */
  91734. static POSE_ENABLED: number;
  91735. /**
  91736. * Represents an Dual Shock controller
  91737. */
  91738. static DUALSHOCK: number;
  91739. /**
  91740. * Specifies whether the left control stick should be Y-inverted
  91741. */
  91742. protected _invertLeftStickY: boolean;
  91743. /**
  91744. * Specifies if the gamepad has been connected
  91745. */
  91746. get isConnected(): boolean;
  91747. /**
  91748. * Initializes the gamepad
  91749. * @param id The id of the gamepad
  91750. * @param index The index of the gamepad
  91751. * @param browserGamepad The browser gamepad
  91752. * @param leftStickX The x component of the left joystick
  91753. * @param leftStickY The y component of the left joystick
  91754. * @param rightStickX The x component of the right joystick
  91755. * @param rightStickY The y component of the right joystick
  91756. */
  91757. constructor(
  91758. /**
  91759. * The id of the gamepad
  91760. */
  91761. id: string,
  91762. /**
  91763. * The index of the gamepad
  91764. */
  91765. index: number,
  91766. /**
  91767. * The browser gamepad
  91768. */
  91769. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  91770. /**
  91771. * Callback triggered when the left joystick has changed
  91772. * @param callback
  91773. */
  91774. onleftstickchanged(callback: (values: StickValues) => void): void;
  91775. /**
  91776. * Callback triggered when the right joystick has changed
  91777. * @param callback
  91778. */
  91779. onrightstickchanged(callback: (values: StickValues) => void): void;
  91780. /**
  91781. * Gets the left joystick
  91782. */
  91783. get leftStick(): StickValues;
  91784. /**
  91785. * Sets the left joystick values
  91786. */
  91787. set leftStick(newValues: StickValues);
  91788. /**
  91789. * Gets the right joystick
  91790. */
  91791. get rightStick(): StickValues;
  91792. /**
  91793. * Sets the right joystick value
  91794. */
  91795. set rightStick(newValues: StickValues);
  91796. /**
  91797. * Updates the gamepad joystick positions
  91798. */
  91799. update(): void;
  91800. /**
  91801. * Disposes the gamepad
  91802. */
  91803. dispose(): void;
  91804. }
  91805. /**
  91806. * Represents a generic gamepad
  91807. */
  91808. export class GenericPad extends Gamepad {
  91809. private _buttons;
  91810. private _onbuttondown;
  91811. private _onbuttonup;
  91812. /**
  91813. * Observable triggered when a button has been pressed
  91814. */
  91815. onButtonDownObservable: Observable<number>;
  91816. /**
  91817. * Observable triggered when a button has been released
  91818. */
  91819. onButtonUpObservable: Observable<number>;
  91820. /**
  91821. * Callback triggered when a button has been pressed
  91822. * @param callback Called when a button has been pressed
  91823. */
  91824. onbuttondown(callback: (buttonPressed: number) => void): void;
  91825. /**
  91826. * Callback triggered when a button has been released
  91827. * @param callback Called when a button has been released
  91828. */
  91829. onbuttonup(callback: (buttonReleased: number) => void): void;
  91830. /**
  91831. * Initializes the generic gamepad
  91832. * @param id The id of the generic gamepad
  91833. * @param index The index of the generic gamepad
  91834. * @param browserGamepad The browser gamepad
  91835. */
  91836. constructor(id: string, index: number, browserGamepad: any);
  91837. private _setButtonValue;
  91838. /**
  91839. * Updates the generic gamepad
  91840. */
  91841. update(): void;
  91842. /**
  91843. * Disposes the generic gamepad
  91844. */
  91845. dispose(): void;
  91846. }
  91847. }
  91848. declare module BABYLON {
  91849. /**
  91850. * Defines the types of pose enabled controllers that are supported
  91851. */
  91852. export enum PoseEnabledControllerType {
  91853. /**
  91854. * HTC Vive
  91855. */
  91856. VIVE = 0,
  91857. /**
  91858. * Oculus Rift
  91859. */
  91860. OCULUS = 1,
  91861. /**
  91862. * Windows mixed reality
  91863. */
  91864. WINDOWS = 2,
  91865. /**
  91866. * Samsung gear VR
  91867. */
  91868. GEAR_VR = 3,
  91869. /**
  91870. * Google Daydream
  91871. */
  91872. DAYDREAM = 4,
  91873. /**
  91874. * Generic
  91875. */
  91876. GENERIC = 5
  91877. }
  91878. /**
  91879. * Defines the MutableGamepadButton interface for the state of a gamepad button
  91880. */
  91881. export interface MutableGamepadButton {
  91882. /**
  91883. * Value of the button/trigger
  91884. */
  91885. value: number;
  91886. /**
  91887. * If the button/trigger is currently touched
  91888. */
  91889. touched: boolean;
  91890. /**
  91891. * If the button/trigger is currently pressed
  91892. */
  91893. pressed: boolean;
  91894. }
  91895. /**
  91896. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  91897. * @hidden
  91898. */
  91899. export interface ExtendedGamepadButton extends GamepadButton {
  91900. /**
  91901. * If the button/trigger is currently pressed
  91902. */
  91903. readonly pressed: boolean;
  91904. /**
  91905. * If the button/trigger is currently touched
  91906. */
  91907. readonly touched: boolean;
  91908. /**
  91909. * Value of the button/trigger
  91910. */
  91911. readonly value: number;
  91912. }
  91913. /** @hidden */
  91914. export interface _GamePadFactory {
  91915. /**
  91916. * Returns whether or not the current gamepad can be created for this type of controller.
  91917. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  91918. * @returns true if it can be created, otherwise false
  91919. */
  91920. canCreate(gamepadInfo: any): boolean;
  91921. /**
  91922. * Creates a new instance of the Gamepad.
  91923. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  91924. * @returns the new gamepad instance
  91925. */
  91926. create(gamepadInfo: any): Gamepad;
  91927. }
  91928. /**
  91929. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  91930. */
  91931. export class PoseEnabledControllerHelper {
  91932. /** @hidden */
  91933. static _ControllerFactories: _GamePadFactory[];
  91934. /** @hidden */
  91935. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  91936. /**
  91937. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  91938. * @param vrGamepad the gamepad to initialized
  91939. * @returns a vr controller of the type the gamepad identified as
  91940. */
  91941. static InitiateController(vrGamepad: any): Gamepad;
  91942. }
  91943. /**
  91944. * Defines the PoseEnabledController object that contains state of a vr capable controller
  91945. */
  91946. export class PoseEnabledController extends Gamepad implements PoseControlled {
  91947. /**
  91948. * If the controller is used in a webXR session
  91949. */
  91950. isXR: boolean;
  91951. private _deviceRoomPosition;
  91952. private _deviceRoomRotationQuaternion;
  91953. /**
  91954. * The device position in babylon space
  91955. */
  91956. devicePosition: Vector3;
  91957. /**
  91958. * The device rotation in babylon space
  91959. */
  91960. deviceRotationQuaternion: Quaternion;
  91961. /**
  91962. * The scale factor of the device in babylon space
  91963. */
  91964. deviceScaleFactor: number;
  91965. /**
  91966. * (Likely devicePosition should be used instead) The device position in its room space
  91967. */
  91968. position: Vector3;
  91969. /**
  91970. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  91971. */
  91972. rotationQuaternion: Quaternion;
  91973. /**
  91974. * The type of controller (Eg. Windows mixed reality)
  91975. */
  91976. controllerType: PoseEnabledControllerType;
  91977. protected _calculatedPosition: Vector3;
  91978. private _calculatedRotation;
  91979. /**
  91980. * The raw pose from the device
  91981. */
  91982. rawPose: DevicePose;
  91983. private _trackPosition;
  91984. private _maxRotationDistFromHeadset;
  91985. private _draggedRoomRotation;
  91986. /**
  91987. * @hidden
  91988. */
  91989. _disableTrackPosition(fixedPosition: Vector3): void;
  91990. /**
  91991. * Internal, the mesh attached to the controller
  91992. * @hidden
  91993. */
  91994. _mesh: Nullable<AbstractMesh>;
  91995. private _poseControlledCamera;
  91996. private _leftHandSystemQuaternion;
  91997. /**
  91998. * Internal, matrix used to convert room space to babylon space
  91999. * @hidden
  92000. */
  92001. _deviceToWorld: Matrix;
  92002. /**
  92003. * Node to be used when casting a ray from the controller
  92004. * @hidden
  92005. */
  92006. _pointingPoseNode: Nullable<TransformNode>;
  92007. /**
  92008. * Name of the child mesh that can be used to cast a ray from the controller
  92009. */
  92010. static readonly POINTING_POSE: string;
  92011. /**
  92012. * Creates a new PoseEnabledController from a gamepad
  92013. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  92014. */
  92015. constructor(browserGamepad: any);
  92016. private _workingMatrix;
  92017. /**
  92018. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  92019. */
  92020. update(): void;
  92021. /**
  92022. * Updates only the pose device and mesh without doing any button event checking
  92023. */
  92024. protected _updatePoseAndMesh(): void;
  92025. /**
  92026. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  92027. * @param poseData raw pose fromthe device
  92028. */
  92029. updateFromDevice(poseData: DevicePose): void;
  92030. /**
  92031. * @hidden
  92032. */
  92033. _meshAttachedObservable: Observable<AbstractMesh>;
  92034. /**
  92035. * Attaches a mesh to the controller
  92036. * @param mesh the mesh to be attached
  92037. */
  92038. attachToMesh(mesh: AbstractMesh): void;
  92039. /**
  92040. * Attaches the controllers mesh to a camera
  92041. * @param camera the camera the mesh should be attached to
  92042. */
  92043. attachToPoseControlledCamera(camera: TargetCamera): void;
  92044. /**
  92045. * Disposes of the controller
  92046. */
  92047. dispose(): void;
  92048. /**
  92049. * The mesh that is attached to the controller
  92050. */
  92051. get mesh(): Nullable<AbstractMesh>;
  92052. /**
  92053. * Gets the ray of the controller in the direction the controller is pointing
  92054. * @param length the length the resulting ray should be
  92055. * @returns a ray in the direction the controller is pointing
  92056. */
  92057. getForwardRay(length?: number): Ray;
  92058. }
  92059. }
  92060. declare module BABYLON {
  92061. /**
  92062. * Defines the WebVRController object that represents controllers tracked in 3D space
  92063. */
  92064. export abstract class WebVRController extends PoseEnabledController {
  92065. /**
  92066. * Internal, the default controller model for the controller
  92067. */
  92068. protected _defaultModel: Nullable<AbstractMesh>;
  92069. /**
  92070. * Fired when the trigger state has changed
  92071. */
  92072. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  92073. /**
  92074. * Fired when the main button state has changed
  92075. */
  92076. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92077. /**
  92078. * Fired when the secondary button state has changed
  92079. */
  92080. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92081. /**
  92082. * Fired when the pad state has changed
  92083. */
  92084. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  92085. /**
  92086. * Fired when controllers stick values have changed
  92087. */
  92088. onPadValuesChangedObservable: Observable<StickValues>;
  92089. /**
  92090. * Array of button availible on the controller
  92091. */
  92092. protected _buttons: Array<MutableGamepadButton>;
  92093. private _onButtonStateChange;
  92094. /**
  92095. * Fired when a controller button's state has changed
  92096. * @param callback the callback containing the button that was modified
  92097. */
  92098. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  92099. /**
  92100. * X and Y axis corresponding to the controllers joystick
  92101. */
  92102. pad: StickValues;
  92103. /**
  92104. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  92105. */
  92106. hand: string;
  92107. /**
  92108. * The default controller model for the controller
  92109. */
  92110. get defaultModel(): Nullable<AbstractMesh>;
  92111. /**
  92112. * Creates a new WebVRController from a gamepad
  92113. * @param vrGamepad the gamepad that the WebVRController should be created from
  92114. */
  92115. constructor(vrGamepad: any);
  92116. /**
  92117. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  92118. */
  92119. update(): void;
  92120. /**
  92121. * Function to be called when a button is modified
  92122. */
  92123. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  92124. /**
  92125. * Loads a mesh and attaches it to the controller
  92126. * @param scene the scene the mesh should be added to
  92127. * @param meshLoaded callback for when the mesh has been loaded
  92128. */
  92129. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  92130. private _setButtonValue;
  92131. private _changes;
  92132. private _checkChanges;
  92133. /**
  92134. * Disposes of th webVRCOntroller
  92135. */
  92136. dispose(): void;
  92137. }
  92138. }
  92139. declare module BABYLON {
  92140. /**
  92141. * The HemisphericLight simulates the ambient environment light,
  92142. * so the passed direction is the light reflection direction, not the incoming direction.
  92143. */
  92144. export class HemisphericLight extends Light {
  92145. /**
  92146. * The groundColor is the light in the opposite direction to the one specified during creation.
  92147. * 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.
  92148. */
  92149. groundColor: Color3;
  92150. /**
  92151. * The light reflection direction, not the incoming direction.
  92152. */
  92153. direction: Vector3;
  92154. /**
  92155. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  92156. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  92157. * The HemisphericLight can't cast shadows.
  92158. * Documentation : https://doc.babylonjs.com/babylon101/lights
  92159. * @param name The friendly name of the light
  92160. * @param direction The direction of the light reflection
  92161. * @param scene The scene the light belongs to
  92162. */
  92163. constructor(name: string, direction: Vector3, scene: Scene);
  92164. protected _buildUniformLayout(): void;
  92165. /**
  92166. * Returns the string "HemisphericLight".
  92167. * @return The class name
  92168. */
  92169. getClassName(): string;
  92170. /**
  92171. * Sets the HemisphericLight direction towards the passed target (Vector3).
  92172. * Returns the updated direction.
  92173. * @param target The target the direction should point to
  92174. * @return The computed direction
  92175. */
  92176. setDirectionToTarget(target: Vector3): Vector3;
  92177. /**
  92178. * Returns the shadow generator associated to the light.
  92179. * @returns Always null for hemispheric lights because it does not support shadows.
  92180. */
  92181. getShadowGenerator(): Nullable<IShadowGenerator>;
  92182. /**
  92183. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  92184. * @param effect The effect to update
  92185. * @param lightIndex The index of the light in the effect to update
  92186. * @returns The hemispheric light
  92187. */
  92188. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  92189. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  92190. /**
  92191. * Computes the world matrix of the node
  92192. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92193. * @param useWasUpdatedFlag defines a reserved property
  92194. * @returns the world matrix
  92195. */
  92196. computeWorldMatrix(): Matrix;
  92197. /**
  92198. * Returns the integer 3.
  92199. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  92200. */
  92201. getTypeID(): number;
  92202. /**
  92203. * Prepares the list of defines specific to the light type.
  92204. * @param defines the list of defines
  92205. * @param lightIndex defines the index of the light for the effect
  92206. */
  92207. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  92208. }
  92209. }
  92210. declare module BABYLON {
  92211. /** @hidden */
  92212. export var vrMultiviewToSingleviewPixelShader: {
  92213. name: string;
  92214. shader: string;
  92215. };
  92216. }
  92217. declare module BABYLON {
  92218. /**
  92219. * Renders to multiple views with a single draw call
  92220. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  92221. */
  92222. export class MultiviewRenderTarget extends RenderTargetTexture {
  92223. /**
  92224. * Creates a multiview render target
  92225. * @param scene scene used with the render target
  92226. * @param size the size of the render target (used for each view)
  92227. */
  92228. constructor(scene: Scene, size?: number | {
  92229. width: number;
  92230. height: number;
  92231. } | {
  92232. ratio: number;
  92233. });
  92234. /**
  92235. * @hidden
  92236. * @param faceIndex the face index, if its a cube texture
  92237. */
  92238. _bindFrameBuffer(faceIndex?: number): void;
  92239. /**
  92240. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  92241. * @returns the view count
  92242. */
  92243. getViewCount(): number;
  92244. }
  92245. }
  92246. declare module BABYLON {
  92247. /**
  92248. * Represents a camera frustum
  92249. */
  92250. export class Frustum {
  92251. /**
  92252. * Gets the planes representing the frustum
  92253. * @param transform matrix to be applied to the returned planes
  92254. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  92255. */
  92256. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  92257. /**
  92258. * Gets the near frustum plane transformed by the transform matrix
  92259. * @param transform transformation matrix to be applied to the resulting frustum plane
  92260. * @param frustumPlane the resuling frustum plane
  92261. */
  92262. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92263. /**
  92264. * Gets the far frustum plane transformed by the transform matrix
  92265. * @param transform transformation matrix to be applied to the resulting frustum plane
  92266. * @param frustumPlane the resuling frustum plane
  92267. */
  92268. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92269. /**
  92270. * Gets the left frustum plane transformed by the transform matrix
  92271. * @param transform transformation matrix to be applied to the resulting frustum plane
  92272. * @param frustumPlane the resuling frustum plane
  92273. */
  92274. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92275. /**
  92276. * Gets the right frustum plane transformed by the transform matrix
  92277. * @param transform transformation matrix to be applied to the resulting frustum plane
  92278. * @param frustumPlane the resuling frustum plane
  92279. */
  92280. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92281. /**
  92282. * Gets the top frustum plane transformed by the transform matrix
  92283. * @param transform transformation matrix to be applied to the resulting frustum plane
  92284. * @param frustumPlane the resuling frustum plane
  92285. */
  92286. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92287. /**
  92288. * Gets the bottom frustum plane transformed by the transform matrix
  92289. * @param transform transformation matrix to be applied to the resulting frustum plane
  92290. * @param frustumPlane the resuling frustum plane
  92291. */
  92292. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92293. /**
  92294. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  92295. * @param transform transformation matrix to be applied to the resulting frustum planes
  92296. * @param frustumPlanes the resuling frustum planes
  92297. */
  92298. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  92299. }
  92300. }
  92301. declare module BABYLON {
  92302. interface Engine {
  92303. /**
  92304. * Creates a new multiview render target
  92305. * @param width defines the width of the texture
  92306. * @param height defines the height of the texture
  92307. * @returns the created multiview texture
  92308. */
  92309. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  92310. /**
  92311. * Binds a multiview framebuffer to be drawn to
  92312. * @param multiviewTexture texture to bind
  92313. */
  92314. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  92315. }
  92316. interface Camera {
  92317. /**
  92318. * @hidden
  92319. * 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)
  92320. */
  92321. _useMultiviewToSingleView: boolean;
  92322. /**
  92323. * @hidden
  92324. * 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)
  92325. */
  92326. _multiviewTexture: Nullable<RenderTargetTexture>;
  92327. /**
  92328. * @hidden
  92329. * ensures the multiview texture of the camera exists and has the specified width/height
  92330. * @param width height to set on the multiview texture
  92331. * @param height width to set on the multiview texture
  92332. */
  92333. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  92334. }
  92335. interface Scene {
  92336. /** @hidden */
  92337. _transformMatrixR: Matrix;
  92338. /** @hidden */
  92339. _multiviewSceneUbo: Nullable<UniformBuffer>;
  92340. /** @hidden */
  92341. _createMultiviewUbo(): void;
  92342. /** @hidden */
  92343. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  92344. /** @hidden */
  92345. _renderMultiviewToSingleView(camera: Camera): void;
  92346. }
  92347. }
  92348. declare module BABYLON {
  92349. /**
  92350. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  92351. * This will not be used for webXR as it supports displaying texture arrays directly
  92352. */
  92353. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  92354. /**
  92355. * Initializes a VRMultiviewToSingleview
  92356. * @param name name of the post process
  92357. * @param camera camera to be applied to
  92358. * @param scaleFactor scaling factor to the size of the output texture
  92359. */
  92360. constructor(name: string, camera: Camera, scaleFactor: number);
  92361. }
  92362. }
  92363. declare module BABYLON {
  92364. /**
  92365. * Interface used to define additional presentation attributes
  92366. */
  92367. export interface IVRPresentationAttributes {
  92368. /**
  92369. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  92370. */
  92371. highRefreshRate: boolean;
  92372. /**
  92373. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  92374. */
  92375. foveationLevel: number;
  92376. }
  92377. interface Engine {
  92378. /** @hidden */
  92379. _vrDisplay: any;
  92380. /** @hidden */
  92381. _vrSupported: boolean;
  92382. /** @hidden */
  92383. _oldSize: Size;
  92384. /** @hidden */
  92385. _oldHardwareScaleFactor: number;
  92386. /** @hidden */
  92387. _vrExclusivePointerMode: boolean;
  92388. /** @hidden */
  92389. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  92390. /** @hidden */
  92391. _onVRDisplayPointerRestricted: () => void;
  92392. /** @hidden */
  92393. _onVRDisplayPointerUnrestricted: () => void;
  92394. /** @hidden */
  92395. _onVrDisplayConnect: Nullable<(display: any) => void>;
  92396. /** @hidden */
  92397. _onVrDisplayDisconnect: Nullable<() => void>;
  92398. /** @hidden */
  92399. _onVrDisplayPresentChange: Nullable<() => void>;
  92400. /**
  92401. * Observable signaled when VR display mode changes
  92402. */
  92403. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  92404. /**
  92405. * Observable signaled when VR request present is complete
  92406. */
  92407. onVRRequestPresentComplete: Observable<boolean>;
  92408. /**
  92409. * Observable signaled when VR request present starts
  92410. */
  92411. onVRRequestPresentStart: Observable<Engine>;
  92412. /**
  92413. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  92414. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  92415. */
  92416. isInVRExclusivePointerMode: boolean;
  92417. /**
  92418. * Gets a boolean indicating if a webVR device was detected
  92419. * @returns true if a webVR device was detected
  92420. */
  92421. isVRDevicePresent(): boolean;
  92422. /**
  92423. * Gets the current webVR device
  92424. * @returns the current webVR device (or null)
  92425. */
  92426. getVRDevice(): any;
  92427. /**
  92428. * Initializes a webVR display and starts listening to display change events
  92429. * The onVRDisplayChangedObservable will be notified upon these changes
  92430. * @returns A promise containing a VRDisplay and if vr is supported
  92431. */
  92432. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  92433. /** @hidden */
  92434. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  92435. /**
  92436. * Gets or sets the presentation attributes used to configure VR rendering
  92437. */
  92438. vrPresentationAttributes?: IVRPresentationAttributes;
  92439. /**
  92440. * Call this function to switch to webVR mode
  92441. * Will do nothing if webVR is not supported or if there is no webVR device
  92442. * @param options the webvr options provided to the camera. mainly used for multiview
  92443. * @see http://doc.babylonjs.com/how_to/webvr_camera
  92444. */
  92445. enableVR(options: WebVROptions): void;
  92446. /** @hidden */
  92447. _onVRFullScreenTriggered(): void;
  92448. }
  92449. }
  92450. declare module BABYLON {
  92451. /**
  92452. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  92453. * IMPORTANT!! The data is right-hand data.
  92454. * @export
  92455. * @interface DevicePose
  92456. */
  92457. export interface DevicePose {
  92458. /**
  92459. * The position of the device, values in array are [x,y,z].
  92460. */
  92461. readonly position: Nullable<Float32Array>;
  92462. /**
  92463. * The linearVelocity of the device, values in array are [x,y,z].
  92464. */
  92465. readonly linearVelocity: Nullable<Float32Array>;
  92466. /**
  92467. * The linearAcceleration of the device, values in array are [x,y,z].
  92468. */
  92469. readonly linearAcceleration: Nullable<Float32Array>;
  92470. /**
  92471. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  92472. */
  92473. readonly orientation: Nullable<Float32Array>;
  92474. /**
  92475. * The angularVelocity of the device, values in array are [x,y,z].
  92476. */
  92477. readonly angularVelocity: Nullable<Float32Array>;
  92478. /**
  92479. * The angularAcceleration of the device, values in array are [x,y,z].
  92480. */
  92481. readonly angularAcceleration: Nullable<Float32Array>;
  92482. }
  92483. /**
  92484. * Interface representing a pose controlled object in Babylon.
  92485. * A pose controlled object has both regular pose values as well as pose values
  92486. * from an external device such as a VR head mounted display
  92487. */
  92488. export interface PoseControlled {
  92489. /**
  92490. * The position of the object in babylon space.
  92491. */
  92492. position: Vector3;
  92493. /**
  92494. * The rotation quaternion of the object in babylon space.
  92495. */
  92496. rotationQuaternion: Quaternion;
  92497. /**
  92498. * The position of the device in babylon space.
  92499. */
  92500. devicePosition?: Vector3;
  92501. /**
  92502. * The rotation quaternion of the device in babylon space.
  92503. */
  92504. deviceRotationQuaternion: Quaternion;
  92505. /**
  92506. * The raw pose coming from the device.
  92507. */
  92508. rawPose: Nullable<DevicePose>;
  92509. /**
  92510. * The scale of the device to be used when translating from device space to babylon space.
  92511. */
  92512. deviceScaleFactor: number;
  92513. /**
  92514. * Updates the poseControlled values based on the input device pose.
  92515. * @param poseData the pose data to update the object with
  92516. */
  92517. updateFromDevice(poseData: DevicePose): void;
  92518. }
  92519. /**
  92520. * Set of options to customize the webVRCamera
  92521. */
  92522. export interface WebVROptions {
  92523. /**
  92524. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  92525. */
  92526. trackPosition?: boolean;
  92527. /**
  92528. * Sets the scale of the vrDevice in babylon space. (default: 1)
  92529. */
  92530. positionScale?: number;
  92531. /**
  92532. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  92533. */
  92534. displayName?: string;
  92535. /**
  92536. * Should the native controller meshes be initialized. (default: true)
  92537. */
  92538. controllerMeshes?: boolean;
  92539. /**
  92540. * Creating a default HemiLight only on controllers. (default: true)
  92541. */
  92542. defaultLightingOnControllers?: boolean;
  92543. /**
  92544. * If you don't want to use the default VR button of the helper. (default: false)
  92545. */
  92546. useCustomVRButton?: boolean;
  92547. /**
  92548. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  92549. */
  92550. customVRButton?: HTMLButtonElement;
  92551. /**
  92552. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  92553. */
  92554. rayLength?: number;
  92555. /**
  92556. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  92557. */
  92558. defaultHeight?: number;
  92559. /**
  92560. * If multiview should be used if availible (default: false)
  92561. */
  92562. useMultiview?: boolean;
  92563. }
  92564. /**
  92565. * This represents a WebVR camera.
  92566. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  92567. * @example http://doc.babylonjs.com/how_to/webvr_camera
  92568. */
  92569. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  92570. private webVROptions;
  92571. /**
  92572. * @hidden
  92573. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  92574. */
  92575. _vrDevice: any;
  92576. /**
  92577. * The rawPose of the vrDevice.
  92578. */
  92579. rawPose: Nullable<DevicePose>;
  92580. private _onVREnabled;
  92581. private _specsVersion;
  92582. private _attached;
  92583. private _frameData;
  92584. protected _descendants: Array<Node>;
  92585. private _deviceRoomPosition;
  92586. /** @hidden */
  92587. _deviceRoomRotationQuaternion: Quaternion;
  92588. private _standingMatrix;
  92589. /**
  92590. * Represents device position in babylon space.
  92591. */
  92592. devicePosition: Vector3;
  92593. /**
  92594. * Represents device rotation in babylon space.
  92595. */
  92596. deviceRotationQuaternion: Quaternion;
  92597. /**
  92598. * The scale of the device to be used when translating from device space to babylon space.
  92599. */
  92600. deviceScaleFactor: number;
  92601. private _deviceToWorld;
  92602. private _worldToDevice;
  92603. /**
  92604. * References to the webVR controllers for the vrDevice.
  92605. */
  92606. controllers: Array<WebVRController>;
  92607. /**
  92608. * Emits an event when a controller is attached.
  92609. */
  92610. onControllersAttachedObservable: Observable<WebVRController[]>;
  92611. /**
  92612. * Emits an event when a controller's mesh has been loaded;
  92613. */
  92614. onControllerMeshLoadedObservable: Observable<WebVRController>;
  92615. /**
  92616. * Emits an event when the HMD's pose has been updated.
  92617. */
  92618. onPoseUpdatedFromDeviceObservable: Observable<any>;
  92619. private _poseSet;
  92620. /**
  92621. * If the rig cameras be used as parent instead of this camera.
  92622. */
  92623. rigParenting: boolean;
  92624. private _lightOnControllers;
  92625. private _defaultHeight?;
  92626. /**
  92627. * Instantiates a WebVRFreeCamera.
  92628. * @param name The name of the WebVRFreeCamera
  92629. * @param position The starting anchor position for the camera
  92630. * @param scene The scene the camera belongs to
  92631. * @param webVROptions a set of customizable options for the webVRCamera
  92632. */
  92633. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  92634. /**
  92635. * Gets the device distance from the ground in meters.
  92636. * @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.
  92637. */
  92638. deviceDistanceToRoomGround(): number;
  92639. /**
  92640. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92641. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  92642. */
  92643. useStandingMatrix(callback?: (bool: boolean) => void): void;
  92644. /**
  92645. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92646. * @returns A promise with a boolean set to if the standing matrix is supported.
  92647. */
  92648. useStandingMatrixAsync(): Promise<boolean>;
  92649. /**
  92650. * Disposes the camera
  92651. */
  92652. dispose(): void;
  92653. /**
  92654. * Gets a vrController by name.
  92655. * @param name The name of the controller to retreive
  92656. * @returns the controller matching the name specified or null if not found
  92657. */
  92658. getControllerByName(name: string): Nullable<WebVRController>;
  92659. private _leftController;
  92660. /**
  92661. * The controller corresponding to the users left hand.
  92662. */
  92663. get leftController(): Nullable<WebVRController>;
  92664. private _rightController;
  92665. /**
  92666. * The controller corresponding to the users right hand.
  92667. */
  92668. get rightController(): Nullable<WebVRController>;
  92669. /**
  92670. * Casts a ray forward from the vrCamera's gaze.
  92671. * @param length Length of the ray (default: 100)
  92672. * @returns the ray corresponding to the gaze
  92673. */
  92674. getForwardRay(length?: number): Ray;
  92675. /**
  92676. * @hidden
  92677. * Updates the camera based on device's frame data
  92678. */
  92679. _checkInputs(): void;
  92680. /**
  92681. * Updates the poseControlled values based on the input device pose.
  92682. * @param poseData Pose coming from the device
  92683. */
  92684. updateFromDevice(poseData: DevicePose): void;
  92685. private _htmlElementAttached;
  92686. private _detachIfAttached;
  92687. /**
  92688. * WebVR's attach control will start broadcasting frames to the device.
  92689. * Note that in certain browsers (chrome for example) this function must be called
  92690. * within a user-interaction callback. Example:
  92691. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  92692. *
  92693. * @param element html element to attach the vrDevice to
  92694. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  92695. */
  92696. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92697. /**
  92698. * Detaches the camera from the html element and disables VR
  92699. *
  92700. * @param element html element to detach from
  92701. */
  92702. detachControl(element: HTMLElement): void;
  92703. /**
  92704. * @returns the name of this class
  92705. */
  92706. getClassName(): string;
  92707. /**
  92708. * Calls resetPose on the vrDisplay
  92709. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  92710. */
  92711. resetToCurrentRotation(): void;
  92712. /**
  92713. * @hidden
  92714. * Updates the rig cameras (left and right eye)
  92715. */
  92716. _updateRigCameras(): void;
  92717. private _workingVector;
  92718. private _oneVector;
  92719. private _workingMatrix;
  92720. private updateCacheCalled;
  92721. private _correctPositionIfNotTrackPosition;
  92722. /**
  92723. * @hidden
  92724. * Updates the cached values of the camera
  92725. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  92726. */
  92727. _updateCache(ignoreParentClass?: boolean): void;
  92728. /**
  92729. * @hidden
  92730. * Get current device position in babylon world
  92731. */
  92732. _computeDevicePosition(): void;
  92733. /**
  92734. * Updates the current device position and rotation in the babylon world
  92735. */
  92736. update(): void;
  92737. /**
  92738. * @hidden
  92739. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  92740. * @returns an identity matrix
  92741. */
  92742. _getViewMatrix(): Matrix;
  92743. private _tmpMatrix;
  92744. /**
  92745. * This function is called by the two RIG cameras.
  92746. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  92747. * @hidden
  92748. */
  92749. _getWebVRViewMatrix(): Matrix;
  92750. /** @hidden */
  92751. _getWebVRProjectionMatrix(): Matrix;
  92752. private _onGamepadConnectedObserver;
  92753. private _onGamepadDisconnectedObserver;
  92754. private _updateCacheWhenTrackingDisabledObserver;
  92755. /**
  92756. * Initializes the controllers and their meshes
  92757. */
  92758. initControllers(): void;
  92759. }
  92760. }
  92761. declare module BABYLON {
  92762. /**
  92763. * Size options for a post process
  92764. */
  92765. export type PostProcessOptions = {
  92766. width: number;
  92767. height: number;
  92768. };
  92769. /**
  92770. * PostProcess can be used to apply a shader to a texture after it has been rendered
  92771. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  92772. */
  92773. export class PostProcess {
  92774. /** Name of the PostProcess. */
  92775. name: string;
  92776. /**
  92777. * Gets or sets the unique id of the post process
  92778. */
  92779. uniqueId: number;
  92780. /**
  92781. * Width of the texture to apply the post process on
  92782. */
  92783. width: number;
  92784. /**
  92785. * Height of the texture to apply the post process on
  92786. */
  92787. height: number;
  92788. /**
  92789. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  92790. * @hidden
  92791. */
  92792. _outputTexture: Nullable<InternalTexture>;
  92793. /**
  92794. * Sampling mode used by the shader
  92795. * See https://doc.babylonjs.com/classes/3.1/texture
  92796. */
  92797. renderTargetSamplingMode: number;
  92798. /**
  92799. * Clear color to use when screen clearing
  92800. */
  92801. clearColor: Color4;
  92802. /**
  92803. * If the buffer needs to be cleared before applying the post process. (default: true)
  92804. * Should be set to false if shader will overwrite all previous pixels.
  92805. */
  92806. autoClear: boolean;
  92807. /**
  92808. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  92809. */
  92810. alphaMode: number;
  92811. /**
  92812. * Sets the setAlphaBlendConstants of the babylon engine
  92813. */
  92814. alphaConstants: Color4;
  92815. /**
  92816. * Animations to be used for the post processing
  92817. */
  92818. animations: Animation[];
  92819. /**
  92820. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  92821. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  92822. */
  92823. enablePixelPerfectMode: boolean;
  92824. /**
  92825. * Force the postprocess to be applied without taking in account viewport
  92826. */
  92827. forceFullscreenViewport: boolean;
  92828. /**
  92829. * List of inspectable custom properties (used by the Inspector)
  92830. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92831. */
  92832. inspectableCustomProperties: IInspectable[];
  92833. /**
  92834. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  92835. *
  92836. * | Value | Type | Description |
  92837. * | ----- | ----------------------------------- | ----------- |
  92838. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  92839. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  92840. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  92841. *
  92842. */
  92843. scaleMode: number;
  92844. /**
  92845. * Force textures to be a power of two (default: false)
  92846. */
  92847. alwaysForcePOT: boolean;
  92848. private _samples;
  92849. /**
  92850. * Number of sample textures (default: 1)
  92851. */
  92852. get samples(): number;
  92853. set samples(n: number);
  92854. /**
  92855. * Modify the scale of the post process to be the same as the viewport (default: false)
  92856. */
  92857. adaptScaleToCurrentViewport: boolean;
  92858. private _camera;
  92859. private _scene;
  92860. private _engine;
  92861. private _options;
  92862. private _reusable;
  92863. private _textureType;
  92864. private _textureFormat;
  92865. /**
  92866. * Smart array of input and output textures for the post process.
  92867. * @hidden
  92868. */
  92869. _textures: SmartArray<InternalTexture>;
  92870. /**
  92871. * The index in _textures that corresponds to the output texture.
  92872. * @hidden
  92873. */
  92874. _currentRenderTextureInd: number;
  92875. private _effect;
  92876. private _samplers;
  92877. private _fragmentUrl;
  92878. private _vertexUrl;
  92879. private _parameters;
  92880. private _scaleRatio;
  92881. protected _indexParameters: any;
  92882. private _shareOutputWithPostProcess;
  92883. private _texelSize;
  92884. private _forcedOutputTexture;
  92885. /**
  92886. * Returns the fragment url or shader name used in the post process.
  92887. * @returns the fragment url or name in the shader store.
  92888. */
  92889. getEffectName(): string;
  92890. /**
  92891. * An event triggered when the postprocess is activated.
  92892. */
  92893. onActivateObservable: Observable<Camera>;
  92894. private _onActivateObserver;
  92895. /**
  92896. * A function that is added to the onActivateObservable
  92897. */
  92898. set onActivate(callback: Nullable<(camera: Camera) => void>);
  92899. /**
  92900. * An event triggered when the postprocess changes its size.
  92901. */
  92902. onSizeChangedObservable: Observable<PostProcess>;
  92903. private _onSizeChangedObserver;
  92904. /**
  92905. * A function that is added to the onSizeChangedObservable
  92906. */
  92907. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  92908. /**
  92909. * An event triggered when the postprocess applies its effect.
  92910. */
  92911. onApplyObservable: Observable<Effect>;
  92912. private _onApplyObserver;
  92913. /**
  92914. * A function that is added to the onApplyObservable
  92915. */
  92916. set onApply(callback: (effect: Effect) => void);
  92917. /**
  92918. * An event triggered before rendering the postprocess
  92919. */
  92920. onBeforeRenderObservable: Observable<Effect>;
  92921. private _onBeforeRenderObserver;
  92922. /**
  92923. * A function that is added to the onBeforeRenderObservable
  92924. */
  92925. set onBeforeRender(callback: (effect: Effect) => void);
  92926. /**
  92927. * An event triggered after rendering the postprocess
  92928. */
  92929. onAfterRenderObservable: Observable<Effect>;
  92930. private _onAfterRenderObserver;
  92931. /**
  92932. * A function that is added to the onAfterRenderObservable
  92933. */
  92934. set onAfterRender(callback: (efect: Effect) => void);
  92935. /**
  92936. * 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
  92937. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  92938. */
  92939. get inputTexture(): InternalTexture;
  92940. set inputTexture(value: InternalTexture);
  92941. /**
  92942. * Gets the camera which post process is applied to.
  92943. * @returns The camera the post process is applied to.
  92944. */
  92945. getCamera(): Camera;
  92946. /**
  92947. * Gets the texel size of the postprocess.
  92948. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  92949. */
  92950. get texelSize(): Vector2;
  92951. /**
  92952. * Creates a new instance PostProcess
  92953. * @param name The name of the PostProcess.
  92954. * @param fragmentUrl The url of the fragment shader to be used.
  92955. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  92956. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  92957. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  92958. * @param camera The camera to apply the render pass to.
  92959. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  92960. * @param engine The engine which the post process will be applied. (default: current engine)
  92961. * @param reusable If the post process can be reused on the same frame. (default: false)
  92962. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  92963. * @param textureType Type of textures used when performing the post process. (default: 0)
  92964. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  92965. * @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
  92966. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  92967. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  92968. */
  92969. constructor(
  92970. /** Name of the PostProcess. */
  92971. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  92972. /**
  92973. * Gets a string idenfifying the name of the class
  92974. * @returns "PostProcess" string
  92975. */
  92976. getClassName(): string;
  92977. /**
  92978. * Gets the engine which this post process belongs to.
  92979. * @returns The engine the post process was enabled with.
  92980. */
  92981. getEngine(): Engine;
  92982. /**
  92983. * The effect that is created when initializing the post process.
  92984. * @returns The created effect corresponding the the postprocess.
  92985. */
  92986. getEffect(): Effect;
  92987. /**
  92988. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  92989. * @param postProcess The post process to share the output with.
  92990. * @returns This post process.
  92991. */
  92992. shareOutputWith(postProcess: PostProcess): PostProcess;
  92993. /**
  92994. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  92995. * This should be called if the post process that shares output with this post process is disabled/disposed.
  92996. */
  92997. useOwnOutput(): void;
  92998. /**
  92999. * Updates the effect with the current post process compile time values and recompiles the shader.
  93000. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93001. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93002. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93003. * @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
  93004. * @param onCompiled Called when the shader has been compiled.
  93005. * @param onError Called if there is an error when compiling a shader.
  93006. */
  93007. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93008. /**
  93009. * The post process is reusable if it can be used multiple times within one frame.
  93010. * @returns If the post process is reusable
  93011. */
  93012. isReusable(): boolean;
  93013. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  93014. markTextureDirty(): void;
  93015. /**
  93016. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  93017. * 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.
  93018. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  93019. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  93020. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  93021. * @returns The target texture that was bound to be written to.
  93022. */
  93023. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  93024. /**
  93025. * If the post process is supported.
  93026. */
  93027. get isSupported(): boolean;
  93028. /**
  93029. * The aspect ratio of the output texture.
  93030. */
  93031. get aspectRatio(): number;
  93032. /**
  93033. * Get a value indicating if the post-process is ready to be used
  93034. * @returns true if the post-process is ready (shader is compiled)
  93035. */
  93036. isReady(): boolean;
  93037. /**
  93038. * Binds all textures and uniforms to the shader, this will be run on every pass.
  93039. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  93040. */
  93041. apply(): Nullable<Effect>;
  93042. private _disposeTextures;
  93043. /**
  93044. * Disposes the post process.
  93045. * @param camera The camera to dispose the post process on.
  93046. */
  93047. dispose(camera?: Camera): void;
  93048. }
  93049. }
  93050. declare module BABYLON {
  93051. /** @hidden */
  93052. export var kernelBlurVaryingDeclaration: {
  93053. name: string;
  93054. shader: string;
  93055. };
  93056. }
  93057. declare module BABYLON {
  93058. /** @hidden */
  93059. export var kernelBlurFragment: {
  93060. name: string;
  93061. shader: string;
  93062. };
  93063. }
  93064. declare module BABYLON {
  93065. /** @hidden */
  93066. export var kernelBlurFragment2: {
  93067. name: string;
  93068. shader: string;
  93069. };
  93070. }
  93071. declare module BABYLON {
  93072. /** @hidden */
  93073. export var kernelBlurPixelShader: {
  93074. name: string;
  93075. shader: string;
  93076. };
  93077. }
  93078. declare module BABYLON {
  93079. /** @hidden */
  93080. export var kernelBlurVertex: {
  93081. name: string;
  93082. shader: string;
  93083. };
  93084. }
  93085. declare module BABYLON {
  93086. /** @hidden */
  93087. export var kernelBlurVertexShader: {
  93088. name: string;
  93089. shader: string;
  93090. };
  93091. }
  93092. declare module BABYLON {
  93093. /**
  93094. * The Blur Post Process which blurs an image based on a kernel and direction.
  93095. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  93096. */
  93097. export class BlurPostProcess extends PostProcess {
  93098. /** The direction in which to blur the image. */
  93099. direction: Vector2;
  93100. private blockCompilation;
  93101. protected _kernel: number;
  93102. protected _idealKernel: number;
  93103. protected _packedFloat: boolean;
  93104. private _staticDefines;
  93105. /**
  93106. * Sets the length in pixels of the blur sample region
  93107. */
  93108. set kernel(v: number);
  93109. /**
  93110. * Gets the length in pixels of the blur sample region
  93111. */
  93112. get kernel(): number;
  93113. /**
  93114. * Sets wether or not the blur needs to unpack/repack floats
  93115. */
  93116. set packedFloat(v: boolean);
  93117. /**
  93118. * Gets wether or not the blur is unpacking/repacking floats
  93119. */
  93120. get packedFloat(): boolean;
  93121. /**
  93122. * Creates a new instance BlurPostProcess
  93123. * @param name The name of the effect.
  93124. * @param direction The direction in which to blur the image.
  93125. * @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.
  93126. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93127. * @param camera The camera to apply the render pass to.
  93128. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93129. * @param engine The engine which the post process will be applied. (default: current engine)
  93130. * @param reusable If the post process can be reused on the same frame. (default: false)
  93131. * @param textureType Type of textures used when performing the post process. (default: 0)
  93132. * @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)
  93133. */
  93134. constructor(name: string,
  93135. /** The direction in which to blur the image. */
  93136. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  93137. /**
  93138. * Updates the effect with the current post process compile time values and recompiles the shader.
  93139. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93140. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93141. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93142. * @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
  93143. * @param onCompiled Called when the shader has been compiled.
  93144. * @param onError Called if there is an error when compiling a shader.
  93145. */
  93146. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93147. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93148. /**
  93149. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  93150. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  93151. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  93152. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  93153. * The gaps between physical kernels are compensated for in the weighting of the samples
  93154. * @param idealKernel Ideal blur kernel.
  93155. * @return Nearest best kernel.
  93156. */
  93157. protected _nearestBestKernel(idealKernel: number): number;
  93158. /**
  93159. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  93160. * @param x The point on the Gaussian distribution to sample.
  93161. * @return the value of the Gaussian function at x.
  93162. */
  93163. protected _gaussianWeight(x: number): number;
  93164. /**
  93165. * Generates a string that can be used as a floating point number in GLSL.
  93166. * @param x Value to print.
  93167. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  93168. * @return GLSL float string.
  93169. */
  93170. protected _glslFloat(x: number, decimalFigures?: number): string;
  93171. }
  93172. }
  93173. declare module BABYLON {
  93174. /**
  93175. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93176. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93177. * You can then easily use it as a reflectionTexture on a flat surface.
  93178. * In case the surface is not a plane, please consider relying on reflection probes.
  93179. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93180. */
  93181. export class MirrorTexture extends RenderTargetTexture {
  93182. private scene;
  93183. /**
  93184. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  93185. * 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.
  93186. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93187. */
  93188. mirrorPlane: Plane;
  93189. /**
  93190. * Define the blur ratio used to blur the reflection if needed.
  93191. */
  93192. set blurRatio(value: number);
  93193. get blurRatio(): number;
  93194. /**
  93195. * Define the adaptive blur kernel used to blur the reflection if needed.
  93196. * This will autocompute the closest best match for the `blurKernel`
  93197. */
  93198. set adaptiveBlurKernel(value: number);
  93199. /**
  93200. * Define the blur kernel used to blur the reflection if needed.
  93201. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93202. */
  93203. set blurKernel(value: number);
  93204. /**
  93205. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  93206. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93207. */
  93208. set blurKernelX(value: number);
  93209. get blurKernelX(): number;
  93210. /**
  93211. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  93212. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93213. */
  93214. set blurKernelY(value: number);
  93215. get blurKernelY(): number;
  93216. private _autoComputeBlurKernel;
  93217. protected _onRatioRescale(): void;
  93218. private _updateGammaSpace;
  93219. private _imageProcessingConfigChangeObserver;
  93220. private _transformMatrix;
  93221. private _mirrorMatrix;
  93222. private _savedViewMatrix;
  93223. private _blurX;
  93224. private _blurY;
  93225. private _adaptiveBlurKernel;
  93226. private _blurKernelX;
  93227. private _blurKernelY;
  93228. private _blurRatio;
  93229. /**
  93230. * Instantiates a Mirror Texture.
  93231. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93232. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93233. * You can then easily use it as a reflectionTexture on a flat surface.
  93234. * In case the surface is not a plane, please consider relying on reflection probes.
  93235. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93236. * @param name
  93237. * @param size
  93238. * @param scene
  93239. * @param generateMipMaps
  93240. * @param type
  93241. * @param samplingMode
  93242. * @param generateDepthBuffer
  93243. */
  93244. constructor(name: string, size: number | {
  93245. width: number;
  93246. height: number;
  93247. } | {
  93248. ratio: number;
  93249. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  93250. private _preparePostProcesses;
  93251. /**
  93252. * Clone the mirror texture.
  93253. * @returns the cloned texture
  93254. */
  93255. clone(): MirrorTexture;
  93256. /**
  93257. * Serialize the texture to a JSON representation you could use in Parse later on
  93258. * @returns the serialized JSON representation
  93259. */
  93260. serialize(): any;
  93261. /**
  93262. * Dispose the texture and release its associated resources.
  93263. */
  93264. dispose(): void;
  93265. }
  93266. }
  93267. declare module BABYLON {
  93268. /**
  93269. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93270. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93271. */
  93272. export class Texture extends BaseTexture {
  93273. /**
  93274. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  93275. */
  93276. static SerializeBuffers: boolean;
  93277. /** @hidden */
  93278. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  93279. /** @hidden */
  93280. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  93281. /** @hidden */
  93282. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  93283. /** nearest is mag = nearest and min = nearest and mip = linear */
  93284. static readonly NEAREST_SAMPLINGMODE: number;
  93285. /** nearest is mag = nearest and min = nearest and mip = linear */
  93286. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  93287. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93288. static readonly BILINEAR_SAMPLINGMODE: number;
  93289. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93290. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  93291. /** Trilinear is mag = linear and min = linear and mip = linear */
  93292. static readonly TRILINEAR_SAMPLINGMODE: number;
  93293. /** Trilinear is mag = linear and min = linear and mip = linear */
  93294. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  93295. /** mag = nearest and min = nearest and mip = nearest */
  93296. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  93297. /** mag = nearest and min = linear and mip = nearest */
  93298. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  93299. /** mag = nearest and min = linear and mip = linear */
  93300. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  93301. /** mag = nearest and min = linear and mip = none */
  93302. static readonly NEAREST_LINEAR: number;
  93303. /** mag = nearest and min = nearest and mip = none */
  93304. static readonly NEAREST_NEAREST: number;
  93305. /** mag = linear and min = nearest and mip = nearest */
  93306. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  93307. /** mag = linear and min = nearest and mip = linear */
  93308. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  93309. /** mag = linear and min = linear and mip = none */
  93310. static readonly LINEAR_LINEAR: number;
  93311. /** mag = linear and min = nearest and mip = none */
  93312. static readonly LINEAR_NEAREST: number;
  93313. /** Explicit coordinates mode */
  93314. static readonly EXPLICIT_MODE: number;
  93315. /** Spherical coordinates mode */
  93316. static readonly SPHERICAL_MODE: number;
  93317. /** Planar coordinates mode */
  93318. static readonly PLANAR_MODE: number;
  93319. /** Cubic coordinates mode */
  93320. static readonly CUBIC_MODE: number;
  93321. /** Projection coordinates mode */
  93322. static readonly PROJECTION_MODE: number;
  93323. /** Inverse Cubic coordinates mode */
  93324. static readonly SKYBOX_MODE: number;
  93325. /** Inverse Cubic coordinates mode */
  93326. static readonly INVCUBIC_MODE: number;
  93327. /** Equirectangular coordinates mode */
  93328. static readonly EQUIRECTANGULAR_MODE: number;
  93329. /** Equirectangular Fixed coordinates mode */
  93330. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  93331. /** Equirectangular Fixed Mirrored coordinates mode */
  93332. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93333. /** Texture is not repeating outside of 0..1 UVs */
  93334. static readonly CLAMP_ADDRESSMODE: number;
  93335. /** Texture is repeating outside of 0..1 UVs */
  93336. static readonly WRAP_ADDRESSMODE: number;
  93337. /** Texture is repeating and mirrored */
  93338. static readonly MIRROR_ADDRESSMODE: number;
  93339. /**
  93340. * 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
  93341. */
  93342. static UseSerializedUrlIfAny: boolean;
  93343. /**
  93344. * Define the url of the texture.
  93345. */
  93346. url: Nullable<string>;
  93347. /**
  93348. * Define an offset on the texture to offset the u coordinates of the UVs
  93349. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93350. */
  93351. uOffset: number;
  93352. /**
  93353. * Define an offset on the texture to offset the v coordinates of the UVs
  93354. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93355. */
  93356. vOffset: number;
  93357. /**
  93358. * Define an offset on the texture to scale the u coordinates of the UVs
  93359. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93360. */
  93361. uScale: number;
  93362. /**
  93363. * Define an offset on the texture to scale the v coordinates of the UVs
  93364. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93365. */
  93366. vScale: number;
  93367. /**
  93368. * Define an offset on the texture to rotate around the u coordinates of the UVs
  93369. * @see http://doc.babylonjs.com/how_to/more_materials
  93370. */
  93371. uAng: number;
  93372. /**
  93373. * Define an offset on the texture to rotate around the v coordinates of the UVs
  93374. * @see http://doc.babylonjs.com/how_to/more_materials
  93375. */
  93376. vAng: number;
  93377. /**
  93378. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  93379. * @see http://doc.babylonjs.com/how_to/more_materials
  93380. */
  93381. wAng: number;
  93382. /**
  93383. * Defines the center of rotation (U)
  93384. */
  93385. uRotationCenter: number;
  93386. /**
  93387. * Defines the center of rotation (V)
  93388. */
  93389. vRotationCenter: number;
  93390. /**
  93391. * Defines the center of rotation (W)
  93392. */
  93393. wRotationCenter: number;
  93394. /**
  93395. * Are mip maps generated for this texture or not.
  93396. */
  93397. get noMipmap(): boolean;
  93398. /**
  93399. * List of inspectable custom properties (used by the Inspector)
  93400. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93401. */
  93402. inspectableCustomProperties: Nullable<IInspectable[]>;
  93403. private _noMipmap;
  93404. /** @hidden */
  93405. _invertY: boolean;
  93406. private _rowGenerationMatrix;
  93407. private _cachedTextureMatrix;
  93408. private _projectionModeMatrix;
  93409. private _t0;
  93410. private _t1;
  93411. private _t2;
  93412. private _cachedUOffset;
  93413. private _cachedVOffset;
  93414. private _cachedUScale;
  93415. private _cachedVScale;
  93416. private _cachedUAng;
  93417. private _cachedVAng;
  93418. private _cachedWAng;
  93419. private _cachedProjectionMatrixId;
  93420. private _cachedCoordinatesMode;
  93421. /** @hidden */
  93422. protected _initialSamplingMode: number;
  93423. /** @hidden */
  93424. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  93425. private _deleteBuffer;
  93426. protected _format: Nullable<number>;
  93427. private _delayedOnLoad;
  93428. private _delayedOnError;
  93429. private _mimeType?;
  93430. /**
  93431. * Observable triggered once the texture has been loaded.
  93432. */
  93433. onLoadObservable: Observable<Texture>;
  93434. protected _isBlocking: boolean;
  93435. /**
  93436. * Is the texture preventing material to render while loading.
  93437. * If false, a default texture will be used instead of the loading one during the preparation step.
  93438. */
  93439. set isBlocking(value: boolean);
  93440. get isBlocking(): boolean;
  93441. /**
  93442. * Get the current sampling mode associated with the texture.
  93443. */
  93444. get samplingMode(): number;
  93445. /**
  93446. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  93447. */
  93448. get invertY(): boolean;
  93449. /**
  93450. * Instantiates a new texture.
  93451. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93452. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93453. * @param url defines the url of the picture to load as a texture
  93454. * @param scene defines the scene or engine the texture will belong to
  93455. * @param noMipmap defines if the texture will require mip maps or not
  93456. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  93457. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93458. * @param onLoad defines a callback triggered when the texture has been loaded
  93459. * @param onError defines a callback triggered when an error occurred during the loading session
  93460. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  93461. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  93462. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93463. * @param mimeType defines an optional mime type information
  93464. */
  93465. 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);
  93466. /**
  93467. * Update the url (and optional buffer) of this texture if url was null during construction.
  93468. * @param url the url of the texture
  93469. * @param buffer the buffer of the texture (defaults to null)
  93470. * @param onLoad callback called when the texture is loaded (defaults to null)
  93471. */
  93472. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  93473. /**
  93474. * Finish the loading sequence of a texture flagged as delayed load.
  93475. * @hidden
  93476. */
  93477. delayLoad(): void;
  93478. private _prepareRowForTextureGeneration;
  93479. /**
  93480. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  93481. * @returns the transform matrix of the texture.
  93482. */
  93483. getTextureMatrix(uBase?: number): Matrix;
  93484. /**
  93485. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  93486. * @returns The reflection texture transform
  93487. */
  93488. getReflectionTextureMatrix(): Matrix;
  93489. /**
  93490. * Clones the texture.
  93491. * @returns the cloned texture
  93492. */
  93493. clone(): Texture;
  93494. /**
  93495. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93496. * @returns The JSON representation of the texture
  93497. */
  93498. serialize(): any;
  93499. /**
  93500. * Get the current class name of the texture useful for serialization or dynamic coding.
  93501. * @returns "Texture"
  93502. */
  93503. getClassName(): string;
  93504. /**
  93505. * Dispose the texture and release its associated resources.
  93506. */
  93507. dispose(): void;
  93508. /**
  93509. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  93510. * @param parsedTexture Define the JSON representation of the texture
  93511. * @param scene Define the scene the parsed texture should be instantiated in
  93512. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  93513. * @returns The parsed texture if successful
  93514. */
  93515. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  93516. /**
  93517. * Creates a texture from its base 64 representation.
  93518. * @param data Define the base64 payload without the data: prefix
  93519. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93520. * @param scene Define the scene the texture should belong to
  93521. * @param noMipmap Forces the texture to not create mip map information if true
  93522. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93523. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93524. * @param onLoad define a callback triggered when the texture has been loaded
  93525. * @param onError define a callback triggered when an error occurred during the loading session
  93526. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93527. * @returns the created texture
  93528. */
  93529. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  93530. /**
  93531. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  93532. * @param data Define the base64 payload without the data: prefix
  93533. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93534. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  93535. * @param scene Define the scene the texture should belong to
  93536. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  93537. * @param noMipmap Forces the texture to not create mip map information if true
  93538. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93539. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93540. * @param onLoad define a callback triggered when the texture has been loaded
  93541. * @param onError define a callback triggered when an error occurred during the loading session
  93542. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93543. * @returns the created texture
  93544. */
  93545. 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;
  93546. }
  93547. }
  93548. declare module BABYLON {
  93549. /**
  93550. * PostProcessManager is used to manage one or more post processes or post process pipelines
  93551. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  93552. */
  93553. export class PostProcessManager {
  93554. private _scene;
  93555. private _indexBuffer;
  93556. private _vertexBuffers;
  93557. /**
  93558. * Creates a new instance PostProcess
  93559. * @param scene The scene that the post process is associated with.
  93560. */
  93561. constructor(scene: Scene);
  93562. private _prepareBuffers;
  93563. private _buildIndexBuffer;
  93564. /**
  93565. * Rebuilds the vertex buffers of the manager.
  93566. * @hidden
  93567. */
  93568. _rebuild(): void;
  93569. /**
  93570. * Prepares a frame to be run through a post process.
  93571. * @param sourceTexture The input texture to the post procesess. (default: null)
  93572. * @param postProcesses An array of post processes to be run. (default: null)
  93573. * @returns True if the post processes were able to be run.
  93574. * @hidden
  93575. */
  93576. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  93577. /**
  93578. * Manually render a set of post processes to a texture.
  93579. * @param postProcesses An array of post processes to be run.
  93580. * @param targetTexture The target texture to render to.
  93581. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  93582. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  93583. * @param lodLevel defines which lod of the texture to render to
  93584. */
  93585. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  93586. /**
  93587. * Finalize the result of the output of the postprocesses.
  93588. * @param doNotPresent If true the result will not be displayed to the screen.
  93589. * @param targetTexture The target texture to render to.
  93590. * @param faceIndex The index of the face to bind the target texture to.
  93591. * @param postProcesses The array of post processes to render.
  93592. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  93593. * @hidden
  93594. */
  93595. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  93596. /**
  93597. * Disposes of the post process manager.
  93598. */
  93599. dispose(): void;
  93600. }
  93601. }
  93602. declare module BABYLON {
  93603. /**
  93604. * This Helps creating a texture that will be created from a camera in your scene.
  93605. * It is basically a dynamic texture that could be used to create special effects for instance.
  93606. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  93607. */
  93608. export class RenderTargetTexture extends Texture {
  93609. isCube: boolean;
  93610. /**
  93611. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  93612. */
  93613. static readonly REFRESHRATE_RENDER_ONCE: number;
  93614. /**
  93615. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  93616. */
  93617. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  93618. /**
  93619. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  93620. * the central point of your effect and can save a lot of performances.
  93621. */
  93622. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  93623. /**
  93624. * Use this predicate to dynamically define the list of mesh you want to render.
  93625. * If set, the renderList property will be overwritten.
  93626. */
  93627. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  93628. private _renderList;
  93629. /**
  93630. * Use this list to define the list of mesh you want to render.
  93631. */
  93632. get renderList(): Nullable<Array<AbstractMesh>>;
  93633. set renderList(value: Nullable<Array<AbstractMesh>>);
  93634. /**
  93635. * Use this function to overload the renderList array at rendering time.
  93636. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  93637. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  93638. * the cube (if the RTT is a cube, else layerOrFace=0).
  93639. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  93640. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  93641. * hold dummy elements!
  93642. */
  93643. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  93644. private _hookArray;
  93645. /**
  93646. * Define if particles should be rendered in your texture.
  93647. */
  93648. renderParticles: boolean;
  93649. /**
  93650. * Define if sprites should be rendered in your texture.
  93651. */
  93652. renderSprites: boolean;
  93653. /**
  93654. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  93655. */
  93656. coordinatesMode: number;
  93657. /**
  93658. * Define the camera used to render the texture.
  93659. */
  93660. activeCamera: Nullable<Camera>;
  93661. /**
  93662. * Override the render function of the texture with your own one.
  93663. */
  93664. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  93665. /**
  93666. * Define if camera post processes should be use while rendering the texture.
  93667. */
  93668. useCameraPostProcesses: boolean;
  93669. /**
  93670. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  93671. */
  93672. ignoreCameraViewport: boolean;
  93673. private _postProcessManager;
  93674. private _postProcesses;
  93675. private _resizeObserver;
  93676. /**
  93677. * An event triggered when the texture is unbind.
  93678. */
  93679. onBeforeBindObservable: Observable<RenderTargetTexture>;
  93680. /**
  93681. * An event triggered when the texture is unbind.
  93682. */
  93683. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  93684. private _onAfterUnbindObserver;
  93685. /**
  93686. * Set a after unbind callback in the texture.
  93687. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  93688. */
  93689. set onAfterUnbind(callback: () => void);
  93690. /**
  93691. * An event triggered before rendering the texture
  93692. */
  93693. onBeforeRenderObservable: Observable<number>;
  93694. private _onBeforeRenderObserver;
  93695. /**
  93696. * Set a before render callback in the texture.
  93697. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  93698. */
  93699. set onBeforeRender(callback: (faceIndex: number) => void);
  93700. /**
  93701. * An event triggered after rendering the texture
  93702. */
  93703. onAfterRenderObservable: Observable<number>;
  93704. private _onAfterRenderObserver;
  93705. /**
  93706. * Set a after render callback in the texture.
  93707. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  93708. */
  93709. set onAfterRender(callback: (faceIndex: number) => void);
  93710. /**
  93711. * An event triggered after the texture clear
  93712. */
  93713. onClearObservable: Observable<Engine>;
  93714. private _onClearObserver;
  93715. /**
  93716. * Set a clear callback in the texture.
  93717. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  93718. */
  93719. set onClear(callback: (Engine: Engine) => void);
  93720. /**
  93721. * An event triggered when the texture is resized.
  93722. */
  93723. onResizeObservable: Observable<RenderTargetTexture>;
  93724. /**
  93725. * Define the clear color of the Render Target if it should be different from the scene.
  93726. */
  93727. clearColor: Color4;
  93728. protected _size: number | {
  93729. width: number;
  93730. height: number;
  93731. layers?: number;
  93732. };
  93733. protected _initialSizeParameter: number | {
  93734. width: number;
  93735. height: number;
  93736. } | {
  93737. ratio: number;
  93738. };
  93739. protected _sizeRatio: Nullable<number>;
  93740. /** @hidden */
  93741. _generateMipMaps: boolean;
  93742. protected _renderingManager: RenderingManager;
  93743. /** @hidden */
  93744. _waitingRenderList: string[];
  93745. protected _doNotChangeAspectRatio: boolean;
  93746. protected _currentRefreshId: number;
  93747. protected _refreshRate: number;
  93748. protected _textureMatrix: Matrix;
  93749. protected _samples: number;
  93750. protected _renderTargetOptions: RenderTargetCreationOptions;
  93751. /**
  93752. * Gets render target creation options that were used.
  93753. */
  93754. get renderTargetOptions(): RenderTargetCreationOptions;
  93755. protected _engine: Engine;
  93756. protected _onRatioRescale(): void;
  93757. /**
  93758. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  93759. * It must define where the camera used to render the texture is set
  93760. */
  93761. boundingBoxPosition: Vector3;
  93762. private _boundingBoxSize;
  93763. /**
  93764. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  93765. * When defined, the cubemap will switch to local mode
  93766. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  93767. * @example https://www.babylonjs-playground.com/#RNASML
  93768. */
  93769. set boundingBoxSize(value: Vector3);
  93770. get boundingBoxSize(): Vector3;
  93771. /**
  93772. * In case the RTT has been created with a depth texture, get the associated
  93773. * depth texture.
  93774. * Otherwise, return null.
  93775. */
  93776. get depthStencilTexture(): Nullable<InternalTexture>;
  93777. /**
  93778. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  93779. * or used a shadow, depth texture...
  93780. * @param name The friendly name of the texture
  93781. * @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)
  93782. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  93783. * @param generateMipMaps True if mip maps need to be generated after render.
  93784. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  93785. * @param type The type of the buffer in the RTT (int, half float, float...)
  93786. * @param isCube True if a cube texture needs to be created
  93787. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  93788. * @param generateDepthBuffer True to generate a depth buffer
  93789. * @param generateStencilBuffer True to generate a stencil buffer
  93790. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  93791. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  93792. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93793. */
  93794. constructor(name: string, size: number | {
  93795. width: number;
  93796. height: number;
  93797. layers?: number;
  93798. } | {
  93799. ratio: number;
  93800. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  93801. /**
  93802. * Creates a depth stencil texture.
  93803. * This is only available in WebGL 2 or with the depth texture extension available.
  93804. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  93805. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  93806. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  93807. */
  93808. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  93809. private _processSizeParameter;
  93810. /**
  93811. * Define the number of samples to use in case of MSAA.
  93812. * It defaults to one meaning no MSAA has been enabled.
  93813. */
  93814. get samples(): number;
  93815. set samples(value: number);
  93816. /**
  93817. * Resets the refresh counter of the texture and start bak from scratch.
  93818. * Could be useful to regenerate the texture if it is setup to render only once.
  93819. */
  93820. resetRefreshCounter(): void;
  93821. /**
  93822. * Define the refresh rate of the texture or the rendering frequency.
  93823. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  93824. */
  93825. get refreshRate(): number;
  93826. set refreshRate(value: number);
  93827. /**
  93828. * Adds a post process to the render target rendering passes.
  93829. * @param postProcess define the post process to add
  93830. */
  93831. addPostProcess(postProcess: PostProcess): void;
  93832. /**
  93833. * Clear all the post processes attached to the render target
  93834. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  93835. */
  93836. clearPostProcesses(dispose?: boolean): void;
  93837. /**
  93838. * Remove one of the post process from the list of attached post processes to the texture
  93839. * @param postProcess define the post process to remove from the list
  93840. */
  93841. removePostProcess(postProcess: PostProcess): void;
  93842. /** @hidden */
  93843. _shouldRender(): boolean;
  93844. /**
  93845. * Gets the actual render size of the texture.
  93846. * @returns the width of the render size
  93847. */
  93848. getRenderSize(): number;
  93849. /**
  93850. * Gets the actual render width of the texture.
  93851. * @returns the width of the render size
  93852. */
  93853. getRenderWidth(): number;
  93854. /**
  93855. * Gets the actual render height of the texture.
  93856. * @returns the height of the render size
  93857. */
  93858. getRenderHeight(): number;
  93859. /**
  93860. * Gets the actual number of layers of the texture.
  93861. * @returns the number of layers
  93862. */
  93863. getRenderLayers(): number;
  93864. /**
  93865. * Get if the texture can be rescaled or not.
  93866. */
  93867. get canRescale(): boolean;
  93868. /**
  93869. * Resize the texture using a ratio.
  93870. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  93871. */
  93872. scale(ratio: number): void;
  93873. /**
  93874. * Get the texture reflection matrix used to rotate/transform the reflection.
  93875. * @returns the reflection matrix
  93876. */
  93877. getReflectionTextureMatrix(): Matrix;
  93878. /**
  93879. * Resize the texture to a new desired size.
  93880. * Be carrefull as it will recreate all the data in the new texture.
  93881. * @param size Define the new size. It can be:
  93882. * - a number for squared texture,
  93883. * - an object containing { width: number, height: number }
  93884. * - or an object containing a ratio { ratio: number }
  93885. */
  93886. resize(size: number | {
  93887. width: number;
  93888. height: number;
  93889. } | {
  93890. ratio: number;
  93891. }): void;
  93892. private _defaultRenderListPrepared;
  93893. /**
  93894. * Renders all the objects from the render list into the texture.
  93895. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  93896. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  93897. */
  93898. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  93899. private _bestReflectionRenderTargetDimension;
  93900. private _prepareRenderingManager;
  93901. /**
  93902. * @hidden
  93903. * @param faceIndex face index to bind to if this is a cubetexture
  93904. * @param layer defines the index of the texture to bind in the array
  93905. */
  93906. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  93907. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  93908. private renderToTarget;
  93909. /**
  93910. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93911. * This allowed control for front to back rendering or reversly depending of the special needs.
  93912. *
  93913. * @param renderingGroupId The rendering group id corresponding to its index
  93914. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93915. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93916. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93917. */
  93918. 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;
  93919. /**
  93920. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93921. *
  93922. * @param renderingGroupId The rendering group id corresponding to its index
  93923. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93924. */
  93925. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  93926. /**
  93927. * Clones the texture.
  93928. * @returns the cloned texture
  93929. */
  93930. clone(): RenderTargetTexture;
  93931. /**
  93932. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93933. * @returns The JSON representation of the texture
  93934. */
  93935. serialize(): any;
  93936. /**
  93937. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  93938. */
  93939. disposeFramebufferObjects(): void;
  93940. /**
  93941. * Dispose the texture and release its associated resources.
  93942. */
  93943. dispose(): void;
  93944. /** @hidden */
  93945. _rebuild(): void;
  93946. /**
  93947. * Clear the info related to rendering groups preventing retention point in material dispose.
  93948. */
  93949. freeRenderingGroups(): void;
  93950. /**
  93951. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  93952. * @returns the view count
  93953. */
  93954. getViewCount(): number;
  93955. }
  93956. }
  93957. declare module BABYLON {
  93958. /**
  93959. * Options for compiling materials.
  93960. */
  93961. export interface IMaterialCompilationOptions {
  93962. /**
  93963. * Defines whether clip planes are enabled.
  93964. */
  93965. clipPlane: boolean;
  93966. /**
  93967. * Defines whether instances are enabled.
  93968. */
  93969. useInstances: boolean;
  93970. }
  93971. /**
  93972. * Base class for the main features of a material in Babylon.js
  93973. */
  93974. export class Material implements IAnimatable {
  93975. /**
  93976. * Returns the triangle fill mode
  93977. */
  93978. static readonly TriangleFillMode: number;
  93979. /**
  93980. * Returns the wireframe mode
  93981. */
  93982. static readonly WireFrameFillMode: number;
  93983. /**
  93984. * Returns the point fill mode
  93985. */
  93986. static readonly PointFillMode: number;
  93987. /**
  93988. * Returns the point list draw mode
  93989. */
  93990. static readonly PointListDrawMode: number;
  93991. /**
  93992. * Returns the line list draw mode
  93993. */
  93994. static readonly LineListDrawMode: number;
  93995. /**
  93996. * Returns the line loop draw mode
  93997. */
  93998. static readonly LineLoopDrawMode: number;
  93999. /**
  94000. * Returns the line strip draw mode
  94001. */
  94002. static readonly LineStripDrawMode: number;
  94003. /**
  94004. * Returns the triangle strip draw mode
  94005. */
  94006. static readonly TriangleStripDrawMode: number;
  94007. /**
  94008. * Returns the triangle fan draw mode
  94009. */
  94010. static readonly TriangleFanDrawMode: number;
  94011. /**
  94012. * Stores the clock-wise side orientation
  94013. */
  94014. static readonly ClockWiseSideOrientation: number;
  94015. /**
  94016. * Stores the counter clock-wise side orientation
  94017. */
  94018. static readonly CounterClockWiseSideOrientation: number;
  94019. /**
  94020. * The dirty texture flag value
  94021. */
  94022. static readonly TextureDirtyFlag: number;
  94023. /**
  94024. * The dirty light flag value
  94025. */
  94026. static readonly LightDirtyFlag: number;
  94027. /**
  94028. * The dirty fresnel flag value
  94029. */
  94030. static readonly FresnelDirtyFlag: number;
  94031. /**
  94032. * The dirty attribute flag value
  94033. */
  94034. static readonly AttributesDirtyFlag: number;
  94035. /**
  94036. * The dirty misc flag value
  94037. */
  94038. static readonly MiscDirtyFlag: number;
  94039. /**
  94040. * The all dirty flag value
  94041. */
  94042. static readonly AllDirtyFlag: number;
  94043. /**
  94044. * The ID of the material
  94045. */
  94046. id: string;
  94047. /**
  94048. * Gets or sets the unique id of the material
  94049. */
  94050. uniqueId: number;
  94051. /**
  94052. * The name of the material
  94053. */
  94054. name: string;
  94055. /**
  94056. * Gets or sets user defined metadata
  94057. */
  94058. metadata: any;
  94059. /**
  94060. * For internal use only. Please do not use.
  94061. */
  94062. reservedDataStore: any;
  94063. /**
  94064. * Specifies if the ready state should be checked on each call
  94065. */
  94066. checkReadyOnEveryCall: boolean;
  94067. /**
  94068. * Specifies if the ready state should be checked once
  94069. */
  94070. checkReadyOnlyOnce: boolean;
  94071. /**
  94072. * The state of the material
  94073. */
  94074. state: string;
  94075. /**
  94076. * The alpha value of the material
  94077. */
  94078. protected _alpha: number;
  94079. /**
  94080. * List of inspectable custom properties (used by the Inspector)
  94081. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94082. */
  94083. inspectableCustomProperties: IInspectable[];
  94084. /**
  94085. * Sets the alpha value of the material
  94086. */
  94087. set alpha(value: number);
  94088. /**
  94089. * Gets the alpha value of the material
  94090. */
  94091. get alpha(): number;
  94092. /**
  94093. * Specifies if back face culling is enabled
  94094. */
  94095. protected _backFaceCulling: boolean;
  94096. /**
  94097. * Sets the back-face culling state
  94098. */
  94099. set backFaceCulling(value: boolean);
  94100. /**
  94101. * Gets the back-face culling state
  94102. */
  94103. get backFaceCulling(): boolean;
  94104. /**
  94105. * Stores the value for side orientation
  94106. */
  94107. sideOrientation: number;
  94108. /**
  94109. * Callback triggered when the material is compiled
  94110. */
  94111. onCompiled: Nullable<(effect: Effect) => void>;
  94112. /**
  94113. * Callback triggered when an error occurs
  94114. */
  94115. onError: Nullable<(effect: Effect, errors: string) => void>;
  94116. /**
  94117. * Callback triggered to get the render target textures
  94118. */
  94119. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  94120. /**
  94121. * Gets a boolean indicating that current material needs to register RTT
  94122. */
  94123. get hasRenderTargetTextures(): boolean;
  94124. /**
  94125. * Specifies if the material should be serialized
  94126. */
  94127. doNotSerialize: boolean;
  94128. /**
  94129. * @hidden
  94130. */
  94131. _storeEffectOnSubMeshes: boolean;
  94132. /**
  94133. * Stores the animations for the material
  94134. */
  94135. animations: Nullable<Array<Animation>>;
  94136. /**
  94137. * An event triggered when the material is disposed
  94138. */
  94139. onDisposeObservable: Observable<Material>;
  94140. /**
  94141. * An observer which watches for dispose events
  94142. */
  94143. private _onDisposeObserver;
  94144. private _onUnBindObservable;
  94145. /**
  94146. * Called during a dispose event
  94147. */
  94148. set onDispose(callback: () => void);
  94149. private _onBindObservable;
  94150. /**
  94151. * An event triggered when the material is bound
  94152. */
  94153. get onBindObservable(): Observable<AbstractMesh>;
  94154. /**
  94155. * An observer which watches for bind events
  94156. */
  94157. private _onBindObserver;
  94158. /**
  94159. * Called during a bind event
  94160. */
  94161. set onBind(callback: (Mesh: AbstractMesh) => void);
  94162. /**
  94163. * An event triggered when the material is unbound
  94164. */
  94165. get onUnBindObservable(): Observable<Material>;
  94166. /**
  94167. * Stores the value of the alpha mode
  94168. */
  94169. private _alphaMode;
  94170. /**
  94171. * Sets the value of the alpha mode.
  94172. *
  94173. * | Value | Type | Description |
  94174. * | --- | --- | --- |
  94175. * | 0 | ALPHA_DISABLE | |
  94176. * | 1 | ALPHA_ADD | |
  94177. * | 2 | ALPHA_COMBINE | |
  94178. * | 3 | ALPHA_SUBTRACT | |
  94179. * | 4 | ALPHA_MULTIPLY | |
  94180. * | 5 | ALPHA_MAXIMIZED | |
  94181. * | 6 | ALPHA_ONEONE | |
  94182. * | 7 | ALPHA_PREMULTIPLIED | |
  94183. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  94184. * | 9 | ALPHA_INTERPOLATE | |
  94185. * | 10 | ALPHA_SCREENMODE | |
  94186. *
  94187. */
  94188. set alphaMode(value: number);
  94189. /**
  94190. * Gets the value of the alpha mode
  94191. */
  94192. get alphaMode(): number;
  94193. /**
  94194. * Stores the state of the need depth pre-pass value
  94195. */
  94196. private _needDepthPrePass;
  94197. /**
  94198. * Sets the need depth pre-pass value
  94199. */
  94200. set needDepthPrePass(value: boolean);
  94201. /**
  94202. * Gets the depth pre-pass value
  94203. */
  94204. get needDepthPrePass(): boolean;
  94205. /**
  94206. * Specifies if depth writing should be disabled
  94207. */
  94208. disableDepthWrite: boolean;
  94209. /**
  94210. * Specifies if depth writing should be forced
  94211. */
  94212. forceDepthWrite: boolean;
  94213. /**
  94214. * Specifies the depth function that should be used. 0 means the default engine function
  94215. */
  94216. depthFunction: number;
  94217. /**
  94218. * Specifies if there should be a separate pass for culling
  94219. */
  94220. separateCullingPass: boolean;
  94221. /**
  94222. * Stores the state specifing if fog should be enabled
  94223. */
  94224. private _fogEnabled;
  94225. /**
  94226. * Sets the state for enabling fog
  94227. */
  94228. set fogEnabled(value: boolean);
  94229. /**
  94230. * Gets the value of the fog enabled state
  94231. */
  94232. get fogEnabled(): boolean;
  94233. /**
  94234. * Stores the size of points
  94235. */
  94236. pointSize: number;
  94237. /**
  94238. * Stores the z offset value
  94239. */
  94240. zOffset: number;
  94241. /**
  94242. * Gets a value specifying if wireframe mode is enabled
  94243. */
  94244. get wireframe(): boolean;
  94245. /**
  94246. * Sets the state of wireframe mode
  94247. */
  94248. set wireframe(value: boolean);
  94249. /**
  94250. * Gets the value specifying if point clouds are enabled
  94251. */
  94252. get pointsCloud(): boolean;
  94253. /**
  94254. * Sets the state of point cloud mode
  94255. */
  94256. set pointsCloud(value: boolean);
  94257. /**
  94258. * Gets the material fill mode
  94259. */
  94260. get fillMode(): number;
  94261. /**
  94262. * Sets the material fill mode
  94263. */
  94264. set fillMode(value: number);
  94265. /**
  94266. * @hidden
  94267. * Stores the effects for the material
  94268. */
  94269. _effect: Nullable<Effect>;
  94270. /**
  94271. * Specifies if uniform buffers should be used
  94272. */
  94273. private _useUBO;
  94274. /**
  94275. * Stores a reference to the scene
  94276. */
  94277. private _scene;
  94278. /**
  94279. * Stores the fill mode state
  94280. */
  94281. private _fillMode;
  94282. /**
  94283. * Specifies if the depth write state should be cached
  94284. */
  94285. private _cachedDepthWriteState;
  94286. /**
  94287. * Specifies if the depth function state should be cached
  94288. */
  94289. private _cachedDepthFunctionState;
  94290. /**
  94291. * Stores the uniform buffer
  94292. */
  94293. protected _uniformBuffer: UniformBuffer;
  94294. /** @hidden */
  94295. _indexInSceneMaterialArray: number;
  94296. /** @hidden */
  94297. meshMap: Nullable<{
  94298. [id: string]: AbstractMesh | undefined;
  94299. }>;
  94300. /**
  94301. * Creates a material instance
  94302. * @param name defines the name of the material
  94303. * @param scene defines the scene to reference
  94304. * @param doNotAdd specifies if the material should be added to the scene
  94305. */
  94306. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  94307. /**
  94308. * Returns a string representation of the current material
  94309. * @param fullDetails defines a boolean indicating which levels of logging is desired
  94310. * @returns a string with material information
  94311. */
  94312. toString(fullDetails?: boolean): string;
  94313. /**
  94314. * Gets the class name of the material
  94315. * @returns a string with the class name of the material
  94316. */
  94317. getClassName(): string;
  94318. /**
  94319. * Specifies if updates for the material been locked
  94320. */
  94321. get isFrozen(): boolean;
  94322. /**
  94323. * Locks updates for the material
  94324. */
  94325. freeze(): void;
  94326. /**
  94327. * Unlocks updates for the material
  94328. */
  94329. unfreeze(): void;
  94330. /**
  94331. * Specifies if the material is ready to be used
  94332. * @param mesh defines the mesh to check
  94333. * @param useInstances specifies if instances should be used
  94334. * @returns a boolean indicating if the material is ready to be used
  94335. */
  94336. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94337. /**
  94338. * Specifies that the submesh is ready to be used
  94339. * @param mesh defines the mesh to check
  94340. * @param subMesh defines which submesh to check
  94341. * @param useInstances specifies that instances should be used
  94342. * @returns a boolean indicating that the submesh is ready or not
  94343. */
  94344. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94345. /**
  94346. * Returns the material effect
  94347. * @returns the effect associated with the material
  94348. */
  94349. getEffect(): Nullable<Effect>;
  94350. /**
  94351. * Returns the current scene
  94352. * @returns a Scene
  94353. */
  94354. getScene(): Scene;
  94355. /**
  94356. * Specifies if the material will require alpha blending
  94357. * @returns a boolean specifying if alpha blending is needed
  94358. */
  94359. needAlphaBlending(): boolean;
  94360. /**
  94361. * Specifies if the mesh will require alpha blending
  94362. * @param mesh defines the mesh to check
  94363. * @returns a boolean specifying if alpha blending is needed for the mesh
  94364. */
  94365. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  94366. /**
  94367. * Specifies if this material should be rendered in alpha test mode
  94368. * @returns a boolean specifying if an alpha test is needed.
  94369. */
  94370. needAlphaTesting(): boolean;
  94371. /**
  94372. * Gets the texture used for the alpha test
  94373. * @returns the texture to use for alpha testing
  94374. */
  94375. getAlphaTestTexture(): Nullable<BaseTexture>;
  94376. /**
  94377. * Marks the material to indicate that it needs to be re-calculated
  94378. */
  94379. markDirty(): void;
  94380. /** @hidden */
  94381. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  94382. /**
  94383. * Binds the material to the mesh
  94384. * @param world defines the world transformation matrix
  94385. * @param mesh defines the mesh to bind the material to
  94386. */
  94387. bind(world: Matrix, mesh?: Mesh): void;
  94388. /**
  94389. * Binds the submesh to the material
  94390. * @param world defines the world transformation matrix
  94391. * @param mesh defines the mesh containing the submesh
  94392. * @param subMesh defines the submesh to bind the material to
  94393. */
  94394. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94395. /**
  94396. * Binds the world matrix to the material
  94397. * @param world defines the world transformation matrix
  94398. */
  94399. bindOnlyWorldMatrix(world: Matrix): void;
  94400. /**
  94401. * Binds the scene's uniform buffer to the effect.
  94402. * @param effect defines the effect to bind to the scene uniform buffer
  94403. * @param sceneUbo defines the uniform buffer storing scene data
  94404. */
  94405. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  94406. /**
  94407. * Binds the view matrix to the effect
  94408. * @param effect defines the effect to bind the view matrix to
  94409. */
  94410. bindView(effect: Effect): void;
  94411. /**
  94412. * Binds the view projection matrix to the effect
  94413. * @param effect defines the effect to bind the view projection matrix to
  94414. */
  94415. bindViewProjection(effect: Effect): void;
  94416. /**
  94417. * Specifies if material alpha testing should be turned on for the mesh
  94418. * @param mesh defines the mesh to check
  94419. */
  94420. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  94421. /**
  94422. * Processes to execute after binding the material to a mesh
  94423. * @param mesh defines the rendered mesh
  94424. */
  94425. protected _afterBind(mesh?: Mesh): void;
  94426. /**
  94427. * Unbinds the material from the mesh
  94428. */
  94429. unbind(): void;
  94430. /**
  94431. * Gets the active textures from the material
  94432. * @returns an array of textures
  94433. */
  94434. getActiveTextures(): BaseTexture[];
  94435. /**
  94436. * Specifies if the material uses a texture
  94437. * @param texture defines the texture to check against the material
  94438. * @returns a boolean specifying if the material uses the texture
  94439. */
  94440. hasTexture(texture: BaseTexture): boolean;
  94441. /**
  94442. * Makes a duplicate of the material, and gives it a new name
  94443. * @param name defines the new name for the duplicated material
  94444. * @returns the cloned material
  94445. */
  94446. clone(name: string): Nullable<Material>;
  94447. /**
  94448. * Gets the meshes bound to the material
  94449. * @returns an array of meshes bound to the material
  94450. */
  94451. getBindedMeshes(): AbstractMesh[];
  94452. /**
  94453. * Force shader compilation
  94454. * @param mesh defines the mesh associated with this material
  94455. * @param onCompiled defines a function to execute once the material is compiled
  94456. * @param options defines the options to configure the compilation
  94457. * @param onError defines a function to execute if the material fails compiling
  94458. */
  94459. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  94460. /**
  94461. * Force shader compilation
  94462. * @param mesh defines the mesh that will use this material
  94463. * @param options defines additional options for compiling the shaders
  94464. * @returns a promise that resolves when the compilation completes
  94465. */
  94466. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  94467. private static readonly _AllDirtyCallBack;
  94468. private static readonly _ImageProcessingDirtyCallBack;
  94469. private static readonly _TextureDirtyCallBack;
  94470. private static readonly _FresnelDirtyCallBack;
  94471. private static readonly _MiscDirtyCallBack;
  94472. private static readonly _LightsDirtyCallBack;
  94473. private static readonly _AttributeDirtyCallBack;
  94474. private static _FresnelAndMiscDirtyCallBack;
  94475. private static _TextureAndMiscDirtyCallBack;
  94476. private static readonly _DirtyCallbackArray;
  94477. private static readonly _RunDirtyCallBacks;
  94478. /**
  94479. * Marks a define in the material to indicate that it needs to be re-computed
  94480. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  94481. */
  94482. markAsDirty(flag: number): void;
  94483. /**
  94484. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  94485. * @param func defines a function which checks material defines against the submeshes
  94486. */
  94487. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  94488. /**
  94489. * Indicates that we need to re-calculated for all submeshes
  94490. */
  94491. protected _markAllSubMeshesAsAllDirty(): void;
  94492. /**
  94493. * Indicates that image processing needs to be re-calculated for all submeshes
  94494. */
  94495. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  94496. /**
  94497. * Indicates that textures need to be re-calculated for all submeshes
  94498. */
  94499. protected _markAllSubMeshesAsTexturesDirty(): void;
  94500. /**
  94501. * Indicates that fresnel needs to be re-calculated for all submeshes
  94502. */
  94503. protected _markAllSubMeshesAsFresnelDirty(): void;
  94504. /**
  94505. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  94506. */
  94507. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  94508. /**
  94509. * Indicates that lights need to be re-calculated for all submeshes
  94510. */
  94511. protected _markAllSubMeshesAsLightsDirty(): void;
  94512. /**
  94513. * Indicates that attributes need to be re-calculated for all submeshes
  94514. */
  94515. protected _markAllSubMeshesAsAttributesDirty(): void;
  94516. /**
  94517. * Indicates that misc needs to be re-calculated for all submeshes
  94518. */
  94519. protected _markAllSubMeshesAsMiscDirty(): void;
  94520. /**
  94521. * Indicates that textures and misc need to be re-calculated for all submeshes
  94522. */
  94523. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  94524. /**
  94525. * Disposes the material
  94526. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94527. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94528. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94529. */
  94530. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94531. /** @hidden */
  94532. private releaseVertexArrayObject;
  94533. /**
  94534. * Serializes this material
  94535. * @returns the serialized material object
  94536. */
  94537. serialize(): any;
  94538. /**
  94539. * Creates a material from parsed material data
  94540. * @param parsedMaterial defines parsed material data
  94541. * @param scene defines the hosting scene
  94542. * @param rootUrl defines the root URL to use to load textures
  94543. * @returns a new material
  94544. */
  94545. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  94546. }
  94547. }
  94548. declare module BABYLON {
  94549. /**
  94550. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94551. * separate meshes. This can be use to improve performances.
  94552. * @see http://doc.babylonjs.com/how_to/multi_materials
  94553. */
  94554. export class MultiMaterial extends Material {
  94555. private _subMaterials;
  94556. /**
  94557. * Gets or Sets the list of Materials used within the multi material.
  94558. * They need to be ordered according to the submeshes order in the associated mesh
  94559. */
  94560. get subMaterials(): Nullable<Material>[];
  94561. set subMaterials(value: Nullable<Material>[]);
  94562. /**
  94563. * Function used to align with Node.getChildren()
  94564. * @returns the list of Materials used within the multi material
  94565. */
  94566. getChildren(): Nullable<Material>[];
  94567. /**
  94568. * Instantiates a new Multi Material
  94569. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94570. * separate meshes. This can be use to improve performances.
  94571. * @see http://doc.babylonjs.com/how_to/multi_materials
  94572. * @param name Define the name in the scene
  94573. * @param scene Define the scene the material belongs to
  94574. */
  94575. constructor(name: string, scene: Scene);
  94576. private _hookArray;
  94577. /**
  94578. * Get one of the submaterial by its index in the submaterials array
  94579. * @param index The index to look the sub material at
  94580. * @returns The Material if the index has been defined
  94581. */
  94582. getSubMaterial(index: number): Nullable<Material>;
  94583. /**
  94584. * Get the list of active textures for the whole sub materials list.
  94585. * @returns All the textures that will be used during the rendering
  94586. */
  94587. getActiveTextures(): BaseTexture[];
  94588. /**
  94589. * Gets the current class name of the material e.g. "MultiMaterial"
  94590. * Mainly use in serialization.
  94591. * @returns the class name
  94592. */
  94593. getClassName(): string;
  94594. /**
  94595. * Checks if the material is ready to render the requested sub mesh
  94596. * @param mesh Define the mesh the submesh belongs to
  94597. * @param subMesh Define the sub mesh to look readyness for
  94598. * @param useInstances Define whether or not the material is used with instances
  94599. * @returns true if ready, otherwise false
  94600. */
  94601. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94602. /**
  94603. * Clones the current material and its related sub materials
  94604. * @param name Define the name of the newly cloned material
  94605. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  94606. * @returns the cloned material
  94607. */
  94608. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  94609. /**
  94610. * Serializes the materials into a JSON representation.
  94611. * @returns the JSON representation
  94612. */
  94613. serialize(): any;
  94614. /**
  94615. * Dispose the material and release its associated resources
  94616. * @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)
  94617. * @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)
  94618. * @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)
  94619. */
  94620. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  94621. /**
  94622. * Creates a MultiMaterial from parsed MultiMaterial data.
  94623. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  94624. * @param scene defines the hosting scene
  94625. * @returns a new MultiMaterial
  94626. */
  94627. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  94628. }
  94629. }
  94630. declare module BABYLON {
  94631. /**
  94632. * Base class for submeshes
  94633. */
  94634. export class BaseSubMesh {
  94635. /** @hidden */
  94636. _materialDefines: Nullable<MaterialDefines>;
  94637. /** @hidden */
  94638. _materialEffect: Nullable<Effect>;
  94639. /**
  94640. * Gets material defines used by the effect associated to the sub mesh
  94641. */
  94642. get materialDefines(): Nullable<MaterialDefines>;
  94643. /**
  94644. * Sets material defines used by the effect associated to the sub mesh
  94645. */
  94646. set materialDefines(defines: Nullable<MaterialDefines>);
  94647. /**
  94648. * Gets associated effect
  94649. */
  94650. get effect(): Nullable<Effect>;
  94651. /**
  94652. * Sets associated effect (effect used to render this submesh)
  94653. * @param effect defines the effect to associate with
  94654. * @param defines defines the set of defines used to compile this effect
  94655. */
  94656. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  94657. }
  94658. /**
  94659. * Defines a subdivision inside a mesh
  94660. */
  94661. export class SubMesh extends BaseSubMesh implements ICullable {
  94662. /** the material index to use */
  94663. materialIndex: number;
  94664. /** vertex index start */
  94665. verticesStart: number;
  94666. /** vertices count */
  94667. verticesCount: number;
  94668. /** index start */
  94669. indexStart: number;
  94670. /** indices count */
  94671. indexCount: number;
  94672. /** @hidden */
  94673. _linesIndexCount: number;
  94674. private _mesh;
  94675. private _renderingMesh;
  94676. private _boundingInfo;
  94677. private _linesIndexBuffer;
  94678. /** @hidden */
  94679. _lastColliderWorldVertices: Nullable<Vector3[]>;
  94680. /** @hidden */
  94681. _trianglePlanes: Plane[];
  94682. /** @hidden */
  94683. _lastColliderTransformMatrix: Nullable<Matrix>;
  94684. /** @hidden */
  94685. _renderId: number;
  94686. /** @hidden */
  94687. _alphaIndex: number;
  94688. /** @hidden */
  94689. _distanceToCamera: number;
  94690. /** @hidden */
  94691. _id: number;
  94692. private _currentMaterial;
  94693. /**
  94694. * Add a new submesh to a mesh
  94695. * @param materialIndex defines the material index to use
  94696. * @param verticesStart defines vertex index start
  94697. * @param verticesCount defines vertices count
  94698. * @param indexStart defines index start
  94699. * @param indexCount defines indices count
  94700. * @param mesh defines the parent mesh
  94701. * @param renderingMesh defines an optional rendering mesh
  94702. * @param createBoundingBox defines if bounding box should be created for this submesh
  94703. * @returns the new submesh
  94704. */
  94705. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  94706. /**
  94707. * Creates a new submesh
  94708. * @param materialIndex defines the material index to use
  94709. * @param verticesStart defines vertex index start
  94710. * @param verticesCount defines vertices count
  94711. * @param indexStart defines index start
  94712. * @param indexCount defines indices count
  94713. * @param mesh defines the parent mesh
  94714. * @param renderingMesh defines an optional rendering mesh
  94715. * @param createBoundingBox defines if bounding box should be created for this submesh
  94716. */
  94717. constructor(
  94718. /** the material index to use */
  94719. materialIndex: number,
  94720. /** vertex index start */
  94721. verticesStart: number,
  94722. /** vertices count */
  94723. verticesCount: number,
  94724. /** index start */
  94725. indexStart: number,
  94726. /** indices count */
  94727. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  94728. /**
  94729. * Returns true if this submesh covers the entire parent mesh
  94730. * @ignorenaming
  94731. */
  94732. get IsGlobal(): boolean;
  94733. /**
  94734. * Returns the submesh BoudingInfo object
  94735. * @returns current bounding info (or mesh's one if the submesh is global)
  94736. */
  94737. getBoundingInfo(): BoundingInfo;
  94738. /**
  94739. * Sets the submesh BoundingInfo
  94740. * @param boundingInfo defines the new bounding info to use
  94741. * @returns the SubMesh
  94742. */
  94743. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  94744. /**
  94745. * Returns the mesh of the current submesh
  94746. * @return the parent mesh
  94747. */
  94748. getMesh(): AbstractMesh;
  94749. /**
  94750. * Returns the rendering mesh of the submesh
  94751. * @returns the rendering mesh (could be different from parent mesh)
  94752. */
  94753. getRenderingMesh(): Mesh;
  94754. /**
  94755. * Returns the submesh material
  94756. * @returns null or the current material
  94757. */
  94758. getMaterial(): Nullable<Material>;
  94759. /**
  94760. * Sets a new updated BoundingInfo object to the submesh
  94761. * @param data defines an optional position array to use to determine the bounding info
  94762. * @returns the SubMesh
  94763. */
  94764. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  94765. /** @hidden */
  94766. _checkCollision(collider: Collider): boolean;
  94767. /**
  94768. * Updates the submesh BoundingInfo
  94769. * @param world defines the world matrix to use to update the bounding info
  94770. * @returns the submesh
  94771. */
  94772. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  94773. /**
  94774. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  94775. * @param frustumPlanes defines the frustum planes
  94776. * @returns true if the submesh is intersecting with the frustum
  94777. */
  94778. isInFrustum(frustumPlanes: Plane[]): boolean;
  94779. /**
  94780. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  94781. * @param frustumPlanes defines the frustum planes
  94782. * @returns true if the submesh is inside the frustum
  94783. */
  94784. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94785. /**
  94786. * Renders the submesh
  94787. * @param enableAlphaMode defines if alpha needs to be used
  94788. * @returns the submesh
  94789. */
  94790. render(enableAlphaMode: boolean): SubMesh;
  94791. /**
  94792. * @hidden
  94793. */
  94794. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  94795. /**
  94796. * Checks if the submesh intersects with a ray
  94797. * @param ray defines the ray to test
  94798. * @returns true is the passed ray intersects the submesh bounding box
  94799. */
  94800. canIntersects(ray: Ray): boolean;
  94801. /**
  94802. * Intersects current submesh with a ray
  94803. * @param ray defines the ray to test
  94804. * @param positions defines mesh's positions array
  94805. * @param indices defines mesh's indices array
  94806. * @param fastCheck defines if only bounding info should be used
  94807. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94808. * @returns intersection info or null if no intersection
  94809. */
  94810. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  94811. /** @hidden */
  94812. private _intersectLines;
  94813. /** @hidden */
  94814. private _intersectUnIndexedLines;
  94815. /** @hidden */
  94816. private _intersectTriangles;
  94817. /** @hidden */
  94818. private _intersectUnIndexedTriangles;
  94819. /** @hidden */
  94820. _rebuild(): void;
  94821. /**
  94822. * Creates a new submesh from the passed mesh
  94823. * @param newMesh defines the new hosting mesh
  94824. * @param newRenderingMesh defines an optional rendering mesh
  94825. * @returns the new submesh
  94826. */
  94827. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  94828. /**
  94829. * Release associated resources
  94830. */
  94831. dispose(): void;
  94832. /**
  94833. * Gets the class name
  94834. * @returns the string "SubMesh".
  94835. */
  94836. getClassName(): string;
  94837. /**
  94838. * Creates a new submesh from indices data
  94839. * @param materialIndex the index of the main mesh material
  94840. * @param startIndex the index where to start the copy in the mesh indices array
  94841. * @param indexCount the number of indices to copy then from the startIndex
  94842. * @param mesh the main mesh to create the submesh from
  94843. * @param renderingMesh the optional rendering mesh
  94844. * @returns a new submesh
  94845. */
  94846. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  94847. }
  94848. }
  94849. declare module BABYLON {
  94850. /**
  94851. * Class used to represent data loading progression
  94852. */
  94853. export class SceneLoaderFlags {
  94854. private static _ForceFullSceneLoadingForIncremental;
  94855. private static _ShowLoadingScreen;
  94856. private static _CleanBoneMatrixWeights;
  94857. private static _loggingLevel;
  94858. /**
  94859. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  94860. */
  94861. static get ForceFullSceneLoadingForIncremental(): boolean;
  94862. static set ForceFullSceneLoadingForIncremental(value: boolean);
  94863. /**
  94864. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  94865. */
  94866. static get ShowLoadingScreen(): boolean;
  94867. static set ShowLoadingScreen(value: boolean);
  94868. /**
  94869. * Defines the current logging level (while loading the scene)
  94870. * @ignorenaming
  94871. */
  94872. static get loggingLevel(): number;
  94873. static set loggingLevel(value: number);
  94874. /**
  94875. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  94876. */
  94877. static get CleanBoneMatrixWeights(): boolean;
  94878. static set CleanBoneMatrixWeights(value: boolean);
  94879. }
  94880. }
  94881. declare module BABYLON {
  94882. /**
  94883. * Class used to store geometry data (vertex buffers + index buffer)
  94884. */
  94885. export class Geometry implements IGetSetVerticesData {
  94886. /**
  94887. * Gets or sets the ID of the geometry
  94888. */
  94889. id: string;
  94890. /**
  94891. * Gets or sets the unique ID of the geometry
  94892. */
  94893. uniqueId: number;
  94894. /**
  94895. * Gets the delay loading state of the geometry (none by default which means not delayed)
  94896. */
  94897. delayLoadState: number;
  94898. /**
  94899. * Gets the file containing the data to load when running in delay load state
  94900. */
  94901. delayLoadingFile: Nullable<string>;
  94902. /**
  94903. * Callback called when the geometry is updated
  94904. */
  94905. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  94906. private _scene;
  94907. private _engine;
  94908. private _meshes;
  94909. private _totalVertices;
  94910. /** @hidden */
  94911. _indices: IndicesArray;
  94912. /** @hidden */
  94913. _vertexBuffers: {
  94914. [key: string]: VertexBuffer;
  94915. };
  94916. private _isDisposed;
  94917. private _extend;
  94918. private _boundingBias;
  94919. /** @hidden */
  94920. _delayInfo: Array<string>;
  94921. private _indexBuffer;
  94922. private _indexBufferIsUpdatable;
  94923. /** @hidden */
  94924. _boundingInfo: Nullable<BoundingInfo>;
  94925. /** @hidden */
  94926. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  94927. /** @hidden */
  94928. _softwareSkinningFrameId: number;
  94929. private _vertexArrayObjects;
  94930. private _updatable;
  94931. /** @hidden */
  94932. _positions: Nullable<Vector3[]>;
  94933. /**
  94934. * 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
  94935. */
  94936. get boundingBias(): Vector2;
  94937. /**
  94938. * 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
  94939. */
  94940. set boundingBias(value: Vector2);
  94941. /**
  94942. * Static function used to attach a new empty geometry to a mesh
  94943. * @param mesh defines the mesh to attach the geometry to
  94944. * @returns the new Geometry
  94945. */
  94946. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  94947. /**
  94948. * Creates a new geometry
  94949. * @param id defines the unique ID
  94950. * @param scene defines the hosting scene
  94951. * @param vertexData defines the VertexData used to get geometry data
  94952. * @param updatable defines if geometry must be updatable (false by default)
  94953. * @param mesh defines the mesh that will be associated with the geometry
  94954. */
  94955. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  94956. /**
  94957. * Gets the current extend of the geometry
  94958. */
  94959. get extend(): {
  94960. minimum: Vector3;
  94961. maximum: Vector3;
  94962. };
  94963. /**
  94964. * Gets the hosting scene
  94965. * @returns the hosting Scene
  94966. */
  94967. getScene(): Scene;
  94968. /**
  94969. * Gets the hosting engine
  94970. * @returns the hosting Engine
  94971. */
  94972. getEngine(): Engine;
  94973. /**
  94974. * Defines if the geometry is ready to use
  94975. * @returns true if the geometry is ready to be used
  94976. */
  94977. isReady(): boolean;
  94978. /**
  94979. * Gets a value indicating that the geometry should not be serialized
  94980. */
  94981. get doNotSerialize(): boolean;
  94982. /** @hidden */
  94983. _rebuild(): void;
  94984. /**
  94985. * Affects all geometry data in one call
  94986. * @param vertexData defines the geometry data
  94987. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  94988. */
  94989. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  94990. /**
  94991. * Set specific vertex data
  94992. * @param kind defines the data kind (Position, normal, etc...)
  94993. * @param data defines the vertex data to use
  94994. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  94995. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  94996. */
  94997. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  94998. /**
  94999. * Removes a specific vertex data
  95000. * @param kind defines the data kind (Position, normal, etc...)
  95001. */
  95002. removeVerticesData(kind: string): void;
  95003. /**
  95004. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  95005. * @param buffer defines the vertex buffer to use
  95006. * @param totalVertices defines the total number of vertices for position kind (could be null)
  95007. */
  95008. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  95009. /**
  95010. * Update a specific vertex buffer
  95011. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  95012. * It will do nothing if the buffer is not updatable
  95013. * @param kind defines the data kind (Position, normal, etc...)
  95014. * @param data defines the data to use
  95015. * @param offset defines the offset in the target buffer where to store the data
  95016. * @param useBytes set to true if the offset is in bytes
  95017. */
  95018. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  95019. /**
  95020. * Update a specific vertex buffer
  95021. * This function will create a new buffer if the current one is not updatable
  95022. * @param kind defines the data kind (Position, normal, etc...)
  95023. * @param data defines the data to use
  95024. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  95025. */
  95026. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  95027. private _updateBoundingInfo;
  95028. /** @hidden */
  95029. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  95030. /**
  95031. * Gets total number of vertices
  95032. * @returns the total number of vertices
  95033. */
  95034. getTotalVertices(): number;
  95035. /**
  95036. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95037. * @param kind defines the data kind (Position, normal, etc...)
  95038. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95039. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95040. * @returns a float array containing vertex data
  95041. */
  95042. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95043. /**
  95044. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  95045. * @param kind defines the data kind (Position, normal, etc...)
  95046. * @returns true if the vertex buffer with the specified kind is updatable
  95047. */
  95048. isVertexBufferUpdatable(kind: string): boolean;
  95049. /**
  95050. * Gets a specific vertex buffer
  95051. * @param kind defines the data kind (Position, normal, etc...)
  95052. * @returns a VertexBuffer
  95053. */
  95054. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  95055. /**
  95056. * Returns all vertex buffers
  95057. * @return an object holding all vertex buffers indexed by kind
  95058. */
  95059. getVertexBuffers(): Nullable<{
  95060. [key: string]: VertexBuffer;
  95061. }>;
  95062. /**
  95063. * Gets a boolean indicating if specific vertex buffer is present
  95064. * @param kind defines the data kind (Position, normal, etc...)
  95065. * @returns true if data is present
  95066. */
  95067. isVerticesDataPresent(kind: string): boolean;
  95068. /**
  95069. * Gets a list of all attached data kinds (Position, normal, etc...)
  95070. * @returns a list of string containing all kinds
  95071. */
  95072. getVerticesDataKinds(): string[];
  95073. /**
  95074. * Update index buffer
  95075. * @param indices defines the indices to store in the index buffer
  95076. * @param offset defines the offset in the target buffer where to store the data
  95077. * @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)
  95078. */
  95079. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  95080. /**
  95081. * Creates a new index buffer
  95082. * @param indices defines the indices to store in the index buffer
  95083. * @param totalVertices defines the total number of vertices (could be null)
  95084. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95085. */
  95086. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  95087. /**
  95088. * Return the total number of indices
  95089. * @returns the total number of indices
  95090. */
  95091. getTotalIndices(): number;
  95092. /**
  95093. * Gets the index buffer array
  95094. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95095. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95096. * @returns the index buffer array
  95097. */
  95098. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95099. /**
  95100. * Gets the index buffer
  95101. * @return the index buffer
  95102. */
  95103. getIndexBuffer(): Nullable<DataBuffer>;
  95104. /** @hidden */
  95105. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  95106. /**
  95107. * Release the associated resources for a specific mesh
  95108. * @param mesh defines the source mesh
  95109. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  95110. */
  95111. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  95112. /**
  95113. * Apply current geometry to a given mesh
  95114. * @param mesh defines the mesh to apply geometry to
  95115. */
  95116. applyToMesh(mesh: Mesh): void;
  95117. private _updateExtend;
  95118. private _applyToMesh;
  95119. private notifyUpdate;
  95120. /**
  95121. * Load the geometry if it was flagged as delay loaded
  95122. * @param scene defines the hosting scene
  95123. * @param onLoaded defines a callback called when the geometry is loaded
  95124. */
  95125. load(scene: Scene, onLoaded?: () => void): void;
  95126. private _queueLoad;
  95127. /**
  95128. * Invert the geometry to move from a right handed system to a left handed one.
  95129. */
  95130. toLeftHanded(): void;
  95131. /** @hidden */
  95132. _resetPointsArrayCache(): void;
  95133. /** @hidden */
  95134. _generatePointsArray(): boolean;
  95135. /**
  95136. * Gets a value indicating if the geometry is disposed
  95137. * @returns true if the geometry was disposed
  95138. */
  95139. isDisposed(): boolean;
  95140. private _disposeVertexArrayObjects;
  95141. /**
  95142. * Free all associated resources
  95143. */
  95144. dispose(): void;
  95145. /**
  95146. * Clone the current geometry into a new geometry
  95147. * @param id defines the unique ID of the new geometry
  95148. * @returns a new geometry object
  95149. */
  95150. copy(id: string): Geometry;
  95151. /**
  95152. * Serialize the current geometry info (and not the vertices data) into a JSON object
  95153. * @return a JSON representation of the current geometry data (without the vertices data)
  95154. */
  95155. serialize(): any;
  95156. private toNumberArray;
  95157. /**
  95158. * Serialize all vertices data into a JSON oject
  95159. * @returns a JSON representation of the current geometry data
  95160. */
  95161. serializeVerticeData(): any;
  95162. /**
  95163. * Extracts a clone of a mesh geometry
  95164. * @param mesh defines the source mesh
  95165. * @param id defines the unique ID of the new geometry object
  95166. * @returns the new geometry object
  95167. */
  95168. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  95169. /**
  95170. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  95171. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95172. * Be aware Math.random() could cause collisions, but:
  95173. * "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"
  95174. * @returns a string containing a new GUID
  95175. */
  95176. static RandomId(): string;
  95177. /** @hidden */
  95178. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  95179. private static _CleanMatricesWeights;
  95180. /**
  95181. * Create a new geometry from persisted data (Using .babylon file format)
  95182. * @param parsedVertexData defines the persisted data
  95183. * @param scene defines the hosting scene
  95184. * @param rootUrl defines the root url to use to load assets (like delayed data)
  95185. * @returns the new geometry object
  95186. */
  95187. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  95188. }
  95189. }
  95190. declare module BABYLON {
  95191. /**
  95192. * Define an interface for all classes that will get and set the data on vertices
  95193. */
  95194. export interface IGetSetVerticesData {
  95195. /**
  95196. * Gets a boolean indicating if specific vertex data is present
  95197. * @param kind defines the vertex data kind to use
  95198. * @returns true is data kind is present
  95199. */
  95200. isVerticesDataPresent(kind: string): boolean;
  95201. /**
  95202. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95203. * @param kind defines the data kind (Position, normal, etc...)
  95204. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95205. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95206. * @returns a float array containing vertex data
  95207. */
  95208. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95209. /**
  95210. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95211. * @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.
  95212. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95213. * @returns the indices array or an empty array if the mesh has no geometry
  95214. */
  95215. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95216. /**
  95217. * Set specific vertex data
  95218. * @param kind defines the data kind (Position, normal, etc...)
  95219. * @param data defines the vertex data to use
  95220. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95221. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95222. */
  95223. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  95224. /**
  95225. * Update a specific associated vertex buffer
  95226. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95227. * - VertexBuffer.PositionKind
  95228. * - VertexBuffer.UVKind
  95229. * - VertexBuffer.UV2Kind
  95230. * - VertexBuffer.UV3Kind
  95231. * - VertexBuffer.UV4Kind
  95232. * - VertexBuffer.UV5Kind
  95233. * - VertexBuffer.UV6Kind
  95234. * - VertexBuffer.ColorKind
  95235. * - VertexBuffer.MatricesIndicesKind
  95236. * - VertexBuffer.MatricesIndicesExtraKind
  95237. * - VertexBuffer.MatricesWeightsKind
  95238. * - VertexBuffer.MatricesWeightsExtraKind
  95239. * @param data defines the data source
  95240. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95241. * @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)
  95242. */
  95243. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  95244. /**
  95245. * Creates a new index buffer
  95246. * @param indices defines the indices to store in the index buffer
  95247. * @param totalVertices defines the total number of vertices (could be null)
  95248. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95249. */
  95250. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  95251. }
  95252. /**
  95253. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  95254. */
  95255. export class VertexData {
  95256. /**
  95257. * Mesh side orientation : usually the external or front surface
  95258. */
  95259. static readonly FRONTSIDE: number;
  95260. /**
  95261. * Mesh side orientation : usually the internal or back surface
  95262. */
  95263. static readonly BACKSIDE: number;
  95264. /**
  95265. * Mesh side orientation : both internal and external or front and back surfaces
  95266. */
  95267. static readonly DOUBLESIDE: number;
  95268. /**
  95269. * Mesh side orientation : by default, `FRONTSIDE`
  95270. */
  95271. static readonly DEFAULTSIDE: number;
  95272. /**
  95273. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  95274. */
  95275. positions: Nullable<FloatArray>;
  95276. /**
  95277. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  95278. */
  95279. normals: Nullable<FloatArray>;
  95280. /**
  95281. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  95282. */
  95283. tangents: Nullable<FloatArray>;
  95284. /**
  95285. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95286. */
  95287. uvs: Nullable<FloatArray>;
  95288. /**
  95289. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95290. */
  95291. uvs2: Nullable<FloatArray>;
  95292. /**
  95293. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95294. */
  95295. uvs3: Nullable<FloatArray>;
  95296. /**
  95297. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95298. */
  95299. uvs4: Nullable<FloatArray>;
  95300. /**
  95301. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95302. */
  95303. uvs5: Nullable<FloatArray>;
  95304. /**
  95305. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95306. */
  95307. uvs6: Nullable<FloatArray>;
  95308. /**
  95309. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  95310. */
  95311. colors: Nullable<FloatArray>;
  95312. /**
  95313. * 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).
  95314. */
  95315. matricesIndices: Nullable<FloatArray>;
  95316. /**
  95317. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  95318. */
  95319. matricesWeights: Nullable<FloatArray>;
  95320. /**
  95321. * An array extending the number of possible indices
  95322. */
  95323. matricesIndicesExtra: Nullable<FloatArray>;
  95324. /**
  95325. * An array extending the number of possible weights when the number of indices is extended
  95326. */
  95327. matricesWeightsExtra: Nullable<FloatArray>;
  95328. /**
  95329. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  95330. */
  95331. indices: Nullable<IndicesArray>;
  95332. /**
  95333. * Uses the passed data array to set the set the values for the specified kind of data
  95334. * @param data a linear array of floating numbers
  95335. * @param kind the type of data that is being set, eg positions, colors etc
  95336. */
  95337. set(data: FloatArray, kind: string): void;
  95338. /**
  95339. * Associates the vertexData to the passed Mesh.
  95340. * Sets it as updatable or not (default `false`)
  95341. * @param mesh the mesh the vertexData is applied to
  95342. * @param updatable when used and having the value true allows new data to update the vertexData
  95343. * @returns the VertexData
  95344. */
  95345. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  95346. /**
  95347. * Associates the vertexData to the passed Geometry.
  95348. * Sets it as updatable or not (default `false`)
  95349. * @param geometry the geometry the vertexData is applied to
  95350. * @param updatable when used and having the value true allows new data to update the vertexData
  95351. * @returns VertexData
  95352. */
  95353. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  95354. /**
  95355. * Updates the associated mesh
  95356. * @param mesh the mesh to be updated
  95357. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95358. * @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
  95359. * @returns VertexData
  95360. */
  95361. updateMesh(mesh: Mesh): VertexData;
  95362. /**
  95363. * Updates the associated geometry
  95364. * @param geometry the geometry to be updated
  95365. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95366. * @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
  95367. * @returns VertexData.
  95368. */
  95369. updateGeometry(geometry: Geometry): VertexData;
  95370. private _applyTo;
  95371. private _update;
  95372. /**
  95373. * Transforms each position and each normal of the vertexData according to the passed Matrix
  95374. * @param matrix the transforming matrix
  95375. * @returns the VertexData
  95376. */
  95377. transform(matrix: Matrix): VertexData;
  95378. /**
  95379. * Merges the passed VertexData into the current one
  95380. * @param other the VertexData to be merged into the current one
  95381. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  95382. * @returns the modified VertexData
  95383. */
  95384. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  95385. private _mergeElement;
  95386. private _validate;
  95387. /**
  95388. * Serializes the VertexData
  95389. * @returns a serialized object
  95390. */
  95391. serialize(): any;
  95392. /**
  95393. * Extracts the vertexData from a mesh
  95394. * @param mesh the mesh from which to extract the VertexData
  95395. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  95396. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95397. * @returns the object VertexData associated to the passed mesh
  95398. */
  95399. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95400. /**
  95401. * Extracts the vertexData from the geometry
  95402. * @param geometry the geometry from which to extract the VertexData
  95403. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  95404. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95405. * @returns the object VertexData associated to the passed mesh
  95406. */
  95407. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95408. private static _ExtractFrom;
  95409. /**
  95410. * Creates the VertexData for a Ribbon
  95411. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  95412. * * pathArray array of paths, each of which an array of successive Vector3
  95413. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  95414. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  95415. * * 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
  95416. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95417. * * 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)
  95418. * * 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)
  95419. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  95420. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  95421. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  95422. * @returns the VertexData of the ribbon
  95423. */
  95424. static CreateRibbon(options: {
  95425. pathArray: Vector3[][];
  95426. closeArray?: boolean;
  95427. closePath?: boolean;
  95428. offset?: number;
  95429. sideOrientation?: number;
  95430. frontUVs?: Vector4;
  95431. backUVs?: Vector4;
  95432. invertUV?: boolean;
  95433. uvs?: Vector2[];
  95434. colors?: Color4[];
  95435. }): VertexData;
  95436. /**
  95437. * Creates the VertexData for a box
  95438. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95439. * * size sets the width, height and depth of the box to the value of size, optional default 1
  95440. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  95441. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  95442. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  95443. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95444. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95445. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95446. * * 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)
  95447. * * 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)
  95448. * @returns the VertexData of the box
  95449. */
  95450. static CreateBox(options: {
  95451. size?: number;
  95452. width?: number;
  95453. height?: number;
  95454. depth?: number;
  95455. faceUV?: Vector4[];
  95456. faceColors?: Color4[];
  95457. sideOrientation?: number;
  95458. frontUVs?: Vector4;
  95459. backUVs?: Vector4;
  95460. }): VertexData;
  95461. /**
  95462. * Creates the VertexData for a tiled box
  95463. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95464. * * faceTiles sets the pattern, tile size and number of tiles for a face
  95465. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95466. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95467. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95468. * @returns the VertexData of the box
  95469. */
  95470. static CreateTiledBox(options: {
  95471. pattern?: number;
  95472. width?: number;
  95473. height?: number;
  95474. depth?: number;
  95475. tileSize?: number;
  95476. tileWidth?: number;
  95477. tileHeight?: number;
  95478. alignHorizontal?: number;
  95479. alignVertical?: number;
  95480. faceUV?: Vector4[];
  95481. faceColors?: Color4[];
  95482. sideOrientation?: number;
  95483. }): VertexData;
  95484. /**
  95485. * Creates the VertexData for a tiled plane
  95486. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95487. * * pattern a limited pattern arrangement depending on the number
  95488. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  95489. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  95490. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  95491. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95492. * * 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)
  95493. * * 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)
  95494. * @returns the VertexData of the tiled plane
  95495. */
  95496. static CreateTiledPlane(options: {
  95497. pattern?: number;
  95498. tileSize?: number;
  95499. tileWidth?: number;
  95500. tileHeight?: number;
  95501. size?: number;
  95502. width?: number;
  95503. height?: number;
  95504. alignHorizontal?: number;
  95505. alignVertical?: number;
  95506. sideOrientation?: number;
  95507. frontUVs?: Vector4;
  95508. backUVs?: Vector4;
  95509. }): VertexData;
  95510. /**
  95511. * Creates the VertexData for an ellipsoid, defaults to a sphere
  95512. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95513. * * segments sets the number of horizontal strips optional, default 32
  95514. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  95515. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  95516. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  95517. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  95518. * * 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
  95519. * * 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
  95520. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95521. * * 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)
  95522. * * 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)
  95523. * @returns the VertexData of the ellipsoid
  95524. */
  95525. static CreateSphere(options: {
  95526. segments?: number;
  95527. diameter?: number;
  95528. diameterX?: number;
  95529. diameterY?: number;
  95530. diameterZ?: number;
  95531. arc?: number;
  95532. slice?: number;
  95533. sideOrientation?: number;
  95534. frontUVs?: Vector4;
  95535. backUVs?: Vector4;
  95536. }): VertexData;
  95537. /**
  95538. * Creates the VertexData for a cylinder, cone or prism
  95539. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95540. * * height sets the height (y direction) of the cylinder, optional, default 2
  95541. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  95542. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  95543. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  95544. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95545. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  95546. * * 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
  95547. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95548. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95549. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  95550. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  95551. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95552. * * 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)
  95553. * * 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)
  95554. * @returns the VertexData of the cylinder, cone or prism
  95555. */
  95556. static CreateCylinder(options: {
  95557. height?: number;
  95558. diameterTop?: number;
  95559. diameterBottom?: number;
  95560. diameter?: number;
  95561. tessellation?: number;
  95562. subdivisions?: number;
  95563. arc?: number;
  95564. faceColors?: Color4[];
  95565. faceUV?: Vector4[];
  95566. hasRings?: boolean;
  95567. enclose?: boolean;
  95568. sideOrientation?: number;
  95569. frontUVs?: Vector4;
  95570. backUVs?: Vector4;
  95571. }): VertexData;
  95572. /**
  95573. * Creates the VertexData for a torus
  95574. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95575. * * diameter the diameter of the torus, optional default 1
  95576. * * thickness the diameter of the tube forming the torus, optional default 0.5
  95577. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95578. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95579. * * 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)
  95580. * * 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)
  95581. * @returns the VertexData of the torus
  95582. */
  95583. static CreateTorus(options: {
  95584. diameter?: number;
  95585. thickness?: number;
  95586. tessellation?: number;
  95587. sideOrientation?: number;
  95588. frontUVs?: Vector4;
  95589. backUVs?: Vector4;
  95590. }): VertexData;
  95591. /**
  95592. * Creates the VertexData of the LineSystem
  95593. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  95594. * - lines an array of lines, each line being an array of successive Vector3
  95595. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  95596. * @returns the VertexData of the LineSystem
  95597. */
  95598. static CreateLineSystem(options: {
  95599. lines: Vector3[][];
  95600. colors?: Nullable<Color4[][]>;
  95601. }): VertexData;
  95602. /**
  95603. * Create the VertexData for a DashedLines
  95604. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  95605. * - points an array successive Vector3
  95606. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  95607. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  95608. * - dashNb the intended total number of dashes, optional, default 200
  95609. * @returns the VertexData for the DashedLines
  95610. */
  95611. static CreateDashedLines(options: {
  95612. points: Vector3[];
  95613. dashSize?: number;
  95614. gapSize?: number;
  95615. dashNb?: number;
  95616. }): VertexData;
  95617. /**
  95618. * Creates the VertexData for a Ground
  95619. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95620. * - width the width (x direction) of the ground, optional, default 1
  95621. * - height the height (z direction) of the ground, optional, default 1
  95622. * - subdivisions the number of subdivisions per side, optional, default 1
  95623. * @returns the VertexData of the Ground
  95624. */
  95625. static CreateGround(options: {
  95626. width?: number;
  95627. height?: number;
  95628. subdivisions?: number;
  95629. subdivisionsX?: number;
  95630. subdivisionsY?: number;
  95631. }): VertexData;
  95632. /**
  95633. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  95634. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95635. * * xmin the ground minimum X coordinate, optional, default -1
  95636. * * zmin the ground minimum Z coordinate, optional, default -1
  95637. * * xmax the ground maximum X coordinate, optional, default 1
  95638. * * zmax the ground maximum Z coordinate, optional, default 1
  95639. * * 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}
  95640. * * 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}
  95641. * @returns the VertexData of the TiledGround
  95642. */
  95643. static CreateTiledGround(options: {
  95644. xmin: number;
  95645. zmin: number;
  95646. xmax: number;
  95647. zmax: number;
  95648. subdivisions?: {
  95649. w: number;
  95650. h: number;
  95651. };
  95652. precision?: {
  95653. w: number;
  95654. h: number;
  95655. };
  95656. }): VertexData;
  95657. /**
  95658. * Creates the VertexData of the Ground designed from a heightmap
  95659. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  95660. * * width the width (x direction) of the ground
  95661. * * height the height (z direction) of the ground
  95662. * * subdivisions the number of subdivisions per side
  95663. * * minHeight the minimum altitude on the ground, optional, default 0
  95664. * * maxHeight the maximum altitude on the ground, optional default 1
  95665. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  95666. * * buffer the array holding the image color data
  95667. * * bufferWidth the width of image
  95668. * * bufferHeight the height of image
  95669. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  95670. * @returns the VertexData of the Ground designed from a heightmap
  95671. */
  95672. static CreateGroundFromHeightMap(options: {
  95673. width: number;
  95674. height: number;
  95675. subdivisions: number;
  95676. minHeight: number;
  95677. maxHeight: number;
  95678. colorFilter: Color3;
  95679. buffer: Uint8Array;
  95680. bufferWidth: number;
  95681. bufferHeight: number;
  95682. alphaFilter: number;
  95683. }): VertexData;
  95684. /**
  95685. * Creates the VertexData for a Plane
  95686. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  95687. * * size sets the width and height of the plane to the value of size, optional default 1
  95688. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  95689. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  95690. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95691. * * 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)
  95692. * * 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)
  95693. * @returns the VertexData of the box
  95694. */
  95695. static CreatePlane(options: {
  95696. size?: number;
  95697. width?: number;
  95698. height?: number;
  95699. sideOrientation?: number;
  95700. frontUVs?: Vector4;
  95701. backUVs?: Vector4;
  95702. }): VertexData;
  95703. /**
  95704. * Creates the VertexData of the Disc or regular Polygon
  95705. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  95706. * * radius the radius of the disc, optional default 0.5
  95707. * * tessellation the number of polygon sides, optional, default 64
  95708. * * 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
  95709. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95710. * * 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)
  95711. * * 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)
  95712. * @returns the VertexData of the box
  95713. */
  95714. static CreateDisc(options: {
  95715. radius?: number;
  95716. tessellation?: number;
  95717. arc?: number;
  95718. sideOrientation?: number;
  95719. frontUVs?: Vector4;
  95720. backUVs?: Vector4;
  95721. }): VertexData;
  95722. /**
  95723. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  95724. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  95725. * @param polygon a mesh built from polygonTriangulation.build()
  95726. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95727. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95728. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95729. * @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)
  95730. * @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)
  95731. * @returns the VertexData of the Polygon
  95732. */
  95733. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  95734. /**
  95735. * Creates the VertexData of the IcoSphere
  95736. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  95737. * * radius the radius of the IcoSphere, optional default 1
  95738. * * radiusX allows stretching in the x direction, optional, default radius
  95739. * * radiusY allows stretching in the y direction, optional, default radius
  95740. * * radiusZ allows stretching in the z direction, optional, default radius
  95741. * * flat when true creates a flat shaded mesh, optional, default true
  95742. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95743. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95744. * * 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)
  95745. * * 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)
  95746. * @returns the VertexData of the IcoSphere
  95747. */
  95748. static CreateIcoSphere(options: {
  95749. radius?: number;
  95750. radiusX?: number;
  95751. radiusY?: number;
  95752. radiusZ?: number;
  95753. flat?: boolean;
  95754. subdivisions?: number;
  95755. sideOrientation?: number;
  95756. frontUVs?: Vector4;
  95757. backUVs?: Vector4;
  95758. }): VertexData;
  95759. /**
  95760. * Creates the VertexData for a Polyhedron
  95761. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  95762. * * type provided types are:
  95763. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  95764. * * 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)
  95765. * * size the size of the IcoSphere, optional default 1
  95766. * * sizeX allows stretching in the x direction, optional, default size
  95767. * * sizeY allows stretching in the y direction, optional, default size
  95768. * * sizeZ allows stretching in the z direction, optional, default size
  95769. * * 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
  95770. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95771. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95772. * * flat when true creates a flat shaded mesh, optional, default true
  95773. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95774. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95775. * * 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)
  95776. * * 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)
  95777. * @returns the VertexData of the Polyhedron
  95778. */
  95779. static CreatePolyhedron(options: {
  95780. type?: number;
  95781. size?: number;
  95782. sizeX?: number;
  95783. sizeY?: number;
  95784. sizeZ?: number;
  95785. custom?: any;
  95786. faceUV?: Vector4[];
  95787. faceColors?: Color4[];
  95788. flat?: boolean;
  95789. sideOrientation?: number;
  95790. frontUVs?: Vector4;
  95791. backUVs?: Vector4;
  95792. }): VertexData;
  95793. /**
  95794. * Creates the VertexData for a TorusKnot
  95795. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  95796. * * radius the radius of the torus knot, optional, default 2
  95797. * * tube the thickness of the tube, optional, default 0.5
  95798. * * radialSegments the number of sides on each tube segments, optional, default 32
  95799. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  95800. * * p the number of windings around the z axis, optional, default 2
  95801. * * q the number of windings around the x axis, optional, default 3
  95802. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95803. * * 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)
  95804. * * 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)
  95805. * @returns the VertexData of the Torus Knot
  95806. */
  95807. static CreateTorusKnot(options: {
  95808. radius?: number;
  95809. tube?: number;
  95810. radialSegments?: number;
  95811. tubularSegments?: number;
  95812. p?: number;
  95813. q?: number;
  95814. sideOrientation?: number;
  95815. frontUVs?: Vector4;
  95816. backUVs?: Vector4;
  95817. }): VertexData;
  95818. /**
  95819. * Compute normals for given positions and indices
  95820. * @param positions an array of vertex positions, [...., x, y, z, ......]
  95821. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  95822. * @param normals an array of vertex normals, [...., x, y, z, ......]
  95823. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  95824. * * facetNormals : optional array of facet normals (vector3)
  95825. * * facetPositions : optional array of facet positions (vector3)
  95826. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  95827. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  95828. * * bInfo : optional bounding info, required for facetPartitioning computation
  95829. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  95830. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  95831. * * useRightHandedSystem: optional boolean to for right handed system computation
  95832. * * depthSort : optional boolean to enable the facet depth sort computation
  95833. * * distanceTo : optional Vector3 to compute the facet depth from this location
  95834. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  95835. */
  95836. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  95837. facetNormals?: any;
  95838. facetPositions?: any;
  95839. facetPartitioning?: any;
  95840. ratio?: number;
  95841. bInfo?: any;
  95842. bbSize?: Vector3;
  95843. subDiv?: any;
  95844. useRightHandedSystem?: boolean;
  95845. depthSort?: boolean;
  95846. distanceTo?: Vector3;
  95847. depthSortedFacets?: any;
  95848. }): void;
  95849. /** @hidden */
  95850. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  95851. /**
  95852. * Applies VertexData created from the imported parameters to the geometry
  95853. * @param parsedVertexData the parsed data from an imported file
  95854. * @param geometry the geometry to apply the VertexData to
  95855. */
  95856. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  95857. }
  95858. }
  95859. declare module BABYLON {
  95860. /**
  95861. * Defines a target to use with MorphTargetManager
  95862. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95863. */
  95864. export class MorphTarget implements IAnimatable {
  95865. /** defines the name of the target */
  95866. name: string;
  95867. /**
  95868. * Gets or sets the list of animations
  95869. */
  95870. animations: Animation[];
  95871. private _scene;
  95872. private _positions;
  95873. private _normals;
  95874. private _tangents;
  95875. private _uvs;
  95876. private _influence;
  95877. private _uniqueId;
  95878. /**
  95879. * Observable raised when the influence changes
  95880. */
  95881. onInfluenceChanged: Observable<boolean>;
  95882. /** @hidden */
  95883. _onDataLayoutChanged: Observable<void>;
  95884. /**
  95885. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  95886. */
  95887. get influence(): number;
  95888. set influence(influence: number);
  95889. /**
  95890. * Gets or sets the id of the morph Target
  95891. */
  95892. id: string;
  95893. private _animationPropertiesOverride;
  95894. /**
  95895. * Gets or sets the animation properties override
  95896. */
  95897. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95898. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  95899. /**
  95900. * Creates a new MorphTarget
  95901. * @param name defines the name of the target
  95902. * @param influence defines the influence to use
  95903. * @param scene defines the scene the morphtarget belongs to
  95904. */
  95905. constructor(
  95906. /** defines the name of the target */
  95907. name: string, influence?: number, scene?: Nullable<Scene>);
  95908. /**
  95909. * Gets the unique ID of this manager
  95910. */
  95911. get uniqueId(): number;
  95912. /**
  95913. * Gets a boolean defining if the target contains position data
  95914. */
  95915. get hasPositions(): boolean;
  95916. /**
  95917. * Gets a boolean defining if the target contains normal data
  95918. */
  95919. get hasNormals(): boolean;
  95920. /**
  95921. * Gets a boolean defining if the target contains tangent data
  95922. */
  95923. get hasTangents(): boolean;
  95924. /**
  95925. * Gets a boolean defining if the target contains texture coordinates data
  95926. */
  95927. get hasUVs(): boolean;
  95928. /**
  95929. * Affects position data to this target
  95930. * @param data defines the position data to use
  95931. */
  95932. setPositions(data: Nullable<FloatArray>): void;
  95933. /**
  95934. * Gets the position data stored in this target
  95935. * @returns a FloatArray containing the position data (or null if not present)
  95936. */
  95937. getPositions(): Nullable<FloatArray>;
  95938. /**
  95939. * Affects normal data to this target
  95940. * @param data defines the normal data to use
  95941. */
  95942. setNormals(data: Nullable<FloatArray>): void;
  95943. /**
  95944. * Gets the normal data stored in this target
  95945. * @returns a FloatArray containing the normal data (or null if not present)
  95946. */
  95947. getNormals(): Nullable<FloatArray>;
  95948. /**
  95949. * Affects tangent data to this target
  95950. * @param data defines the tangent data to use
  95951. */
  95952. setTangents(data: Nullable<FloatArray>): void;
  95953. /**
  95954. * Gets the tangent data stored in this target
  95955. * @returns a FloatArray containing the tangent data (or null if not present)
  95956. */
  95957. getTangents(): Nullable<FloatArray>;
  95958. /**
  95959. * Affects texture coordinates data to this target
  95960. * @param data defines the texture coordinates data to use
  95961. */
  95962. setUVs(data: Nullable<FloatArray>): void;
  95963. /**
  95964. * Gets the texture coordinates data stored in this target
  95965. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  95966. */
  95967. getUVs(): Nullable<FloatArray>;
  95968. /**
  95969. * Clone the current target
  95970. * @returns a new MorphTarget
  95971. */
  95972. clone(): MorphTarget;
  95973. /**
  95974. * Serializes the current target into a Serialization object
  95975. * @returns the serialized object
  95976. */
  95977. serialize(): any;
  95978. /**
  95979. * Returns the string "MorphTarget"
  95980. * @returns "MorphTarget"
  95981. */
  95982. getClassName(): string;
  95983. /**
  95984. * Creates a new target from serialized data
  95985. * @param serializationObject defines the serialized data to use
  95986. * @returns a new MorphTarget
  95987. */
  95988. static Parse(serializationObject: any): MorphTarget;
  95989. /**
  95990. * Creates a MorphTarget from mesh data
  95991. * @param mesh defines the source mesh
  95992. * @param name defines the name to use for the new target
  95993. * @param influence defines the influence to attach to the target
  95994. * @returns a new MorphTarget
  95995. */
  95996. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  95997. }
  95998. }
  95999. declare module BABYLON {
  96000. /**
  96001. * This class is used to deform meshes using morphing between different targets
  96002. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96003. */
  96004. export class MorphTargetManager {
  96005. private _targets;
  96006. private _targetInfluenceChangedObservers;
  96007. private _targetDataLayoutChangedObservers;
  96008. private _activeTargets;
  96009. private _scene;
  96010. private _influences;
  96011. private _supportsNormals;
  96012. private _supportsTangents;
  96013. private _supportsUVs;
  96014. private _vertexCount;
  96015. private _uniqueId;
  96016. private _tempInfluences;
  96017. /**
  96018. * Gets or sets a boolean indicating if normals must be morphed
  96019. */
  96020. enableNormalMorphing: boolean;
  96021. /**
  96022. * Gets or sets a boolean indicating if tangents must be morphed
  96023. */
  96024. enableTangentMorphing: boolean;
  96025. /**
  96026. * Gets or sets a boolean indicating if UV must be morphed
  96027. */
  96028. enableUVMorphing: boolean;
  96029. /**
  96030. * Creates a new MorphTargetManager
  96031. * @param scene defines the current scene
  96032. */
  96033. constructor(scene?: Nullable<Scene>);
  96034. /**
  96035. * Gets the unique ID of this manager
  96036. */
  96037. get uniqueId(): number;
  96038. /**
  96039. * Gets the number of vertices handled by this manager
  96040. */
  96041. get vertexCount(): number;
  96042. /**
  96043. * Gets a boolean indicating if this manager supports morphing of normals
  96044. */
  96045. get supportsNormals(): boolean;
  96046. /**
  96047. * Gets a boolean indicating if this manager supports morphing of tangents
  96048. */
  96049. get supportsTangents(): boolean;
  96050. /**
  96051. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  96052. */
  96053. get supportsUVs(): boolean;
  96054. /**
  96055. * Gets the number of targets stored in this manager
  96056. */
  96057. get numTargets(): number;
  96058. /**
  96059. * Gets the number of influencers (ie. the number of targets with influences > 0)
  96060. */
  96061. get numInfluencers(): number;
  96062. /**
  96063. * Gets the list of influences (one per target)
  96064. */
  96065. get influences(): Float32Array;
  96066. /**
  96067. * Gets the active target at specified index. An active target is a target with an influence > 0
  96068. * @param index defines the index to check
  96069. * @returns the requested target
  96070. */
  96071. getActiveTarget(index: number): MorphTarget;
  96072. /**
  96073. * Gets the target at specified index
  96074. * @param index defines the index to check
  96075. * @returns the requested target
  96076. */
  96077. getTarget(index: number): MorphTarget;
  96078. /**
  96079. * Add a new target to this manager
  96080. * @param target defines the target to add
  96081. */
  96082. addTarget(target: MorphTarget): void;
  96083. /**
  96084. * Removes a target from the manager
  96085. * @param target defines the target to remove
  96086. */
  96087. removeTarget(target: MorphTarget): void;
  96088. /**
  96089. * Clone the current manager
  96090. * @returns a new MorphTargetManager
  96091. */
  96092. clone(): MorphTargetManager;
  96093. /**
  96094. * Serializes the current manager into a Serialization object
  96095. * @returns the serialized object
  96096. */
  96097. serialize(): any;
  96098. private _syncActiveTargets;
  96099. /**
  96100. * Syncrhonize the targets with all the meshes using this morph target manager
  96101. */
  96102. synchronize(): void;
  96103. /**
  96104. * Creates a new MorphTargetManager from serialized data
  96105. * @param serializationObject defines the serialized data
  96106. * @param scene defines the hosting scene
  96107. * @returns the new MorphTargetManager
  96108. */
  96109. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  96110. }
  96111. }
  96112. declare module BABYLON {
  96113. /**
  96114. * Class used to represent a specific level of detail of a mesh
  96115. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  96116. */
  96117. export class MeshLODLevel {
  96118. /** Defines the distance where this level should start being displayed */
  96119. distance: number;
  96120. /** Defines the mesh to use to render this level */
  96121. mesh: Nullable<Mesh>;
  96122. /**
  96123. * Creates a new LOD level
  96124. * @param distance defines the distance where this level should star being displayed
  96125. * @param mesh defines the mesh to use to render this level
  96126. */
  96127. constructor(
  96128. /** Defines the distance where this level should start being displayed */
  96129. distance: number,
  96130. /** Defines the mesh to use to render this level */
  96131. mesh: Nullable<Mesh>);
  96132. }
  96133. }
  96134. declare module BABYLON {
  96135. /**
  96136. * Mesh representing the gorund
  96137. */
  96138. export class GroundMesh extends Mesh {
  96139. /** If octree should be generated */
  96140. generateOctree: boolean;
  96141. private _heightQuads;
  96142. /** @hidden */
  96143. _subdivisionsX: number;
  96144. /** @hidden */
  96145. _subdivisionsY: number;
  96146. /** @hidden */
  96147. _width: number;
  96148. /** @hidden */
  96149. _height: number;
  96150. /** @hidden */
  96151. _minX: number;
  96152. /** @hidden */
  96153. _maxX: number;
  96154. /** @hidden */
  96155. _minZ: number;
  96156. /** @hidden */
  96157. _maxZ: number;
  96158. constructor(name: string, scene: Scene);
  96159. /**
  96160. * "GroundMesh"
  96161. * @returns "GroundMesh"
  96162. */
  96163. getClassName(): string;
  96164. /**
  96165. * The minimum of x and y subdivisions
  96166. */
  96167. get subdivisions(): number;
  96168. /**
  96169. * X subdivisions
  96170. */
  96171. get subdivisionsX(): number;
  96172. /**
  96173. * Y subdivisions
  96174. */
  96175. get subdivisionsY(): number;
  96176. /**
  96177. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  96178. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96179. * @param chunksCount the number of subdivisions for x and y
  96180. * @param octreeBlocksSize (Default: 32)
  96181. */
  96182. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  96183. /**
  96184. * Returns a height (y) value in the Worl system :
  96185. * the ground altitude at the coordinates (x, z) expressed in the World system.
  96186. * @param x x coordinate
  96187. * @param z z coordinate
  96188. * @returns the ground y position if (x, z) are outside the ground surface.
  96189. */
  96190. getHeightAtCoordinates(x: number, z: number): number;
  96191. /**
  96192. * Returns a normalized vector (Vector3) orthogonal to the ground
  96193. * at the ground coordinates (x, z) expressed in the World system.
  96194. * @param x x coordinate
  96195. * @param z z coordinate
  96196. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  96197. */
  96198. getNormalAtCoordinates(x: number, z: number): Vector3;
  96199. /**
  96200. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  96201. * at the ground coordinates (x, z) expressed in the World system.
  96202. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  96203. * @param x x coordinate
  96204. * @param z z coordinate
  96205. * @param ref vector to store the result
  96206. * @returns the GroundMesh.
  96207. */
  96208. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  96209. /**
  96210. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  96211. * if the ground has been updated.
  96212. * This can be used in the render loop.
  96213. * @returns the GroundMesh.
  96214. */
  96215. updateCoordinateHeights(): GroundMesh;
  96216. private _getFacetAt;
  96217. private _initHeightQuads;
  96218. private _computeHeightQuads;
  96219. /**
  96220. * Serializes this ground mesh
  96221. * @param serializationObject object to write serialization to
  96222. */
  96223. serialize(serializationObject: any): void;
  96224. /**
  96225. * Parses a serialized ground mesh
  96226. * @param parsedMesh the serialized mesh
  96227. * @param scene the scene to create the ground mesh in
  96228. * @returns the created ground mesh
  96229. */
  96230. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  96231. }
  96232. }
  96233. declare module BABYLON {
  96234. /**
  96235. * Interface for Physics-Joint data
  96236. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96237. */
  96238. export interface PhysicsJointData {
  96239. /**
  96240. * The main pivot of the joint
  96241. */
  96242. mainPivot?: Vector3;
  96243. /**
  96244. * The connected pivot of the joint
  96245. */
  96246. connectedPivot?: Vector3;
  96247. /**
  96248. * The main axis of the joint
  96249. */
  96250. mainAxis?: Vector3;
  96251. /**
  96252. * The connected axis of the joint
  96253. */
  96254. connectedAxis?: Vector3;
  96255. /**
  96256. * The collision of the joint
  96257. */
  96258. collision?: boolean;
  96259. /**
  96260. * Native Oimo/Cannon/Energy data
  96261. */
  96262. nativeParams?: any;
  96263. }
  96264. /**
  96265. * This is a holder class for the physics joint created by the physics plugin
  96266. * It holds a set of functions to control the underlying joint
  96267. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96268. */
  96269. export class PhysicsJoint {
  96270. /**
  96271. * The type of the physics joint
  96272. */
  96273. type: number;
  96274. /**
  96275. * The data for the physics joint
  96276. */
  96277. jointData: PhysicsJointData;
  96278. private _physicsJoint;
  96279. protected _physicsPlugin: IPhysicsEnginePlugin;
  96280. /**
  96281. * Initializes the physics joint
  96282. * @param type The type of the physics joint
  96283. * @param jointData The data for the physics joint
  96284. */
  96285. constructor(
  96286. /**
  96287. * The type of the physics joint
  96288. */
  96289. type: number,
  96290. /**
  96291. * The data for the physics joint
  96292. */
  96293. jointData: PhysicsJointData);
  96294. /**
  96295. * Gets the physics joint
  96296. */
  96297. get physicsJoint(): any;
  96298. /**
  96299. * Sets the physics joint
  96300. */
  96301. set physicsJoint(newJoint: any);
  96302. /**
  96303. * Sets the physics plugin
  96304. */
  96305. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  96306. /**
  96307. * Execute a function that is physics-plugin specific.
  96308. * @param {Function} func the function that will be executed.
  96309. * It accepts two parameters: the physics world and the physics joint
  96310. */
  96311. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  96312. /**
  96313. * Distance-Joint type
  96314. */
  96315. static DistanceJoint: number;
  96316. /**
  96317. * Hinge-Joint type
  96318. */
  96319. static HingeJoint: number;
  96320. /**
  96321. * Ball-and-Socket joint type
  96322. */
  96323. static BallAndSocketJoint: number;
  96324. /**
  96325. * Wheel-Joint type
  96326. */
  96327. static WheelJoint: number;
  96328. /**
  96329. * Slider-Joint type
  96330. */
  96331. static SliderJoint: number;
  96332. /**
  96333. * Prismatic-Joint type
  96334. */
  96335. static PrismaticJoint: number;
  96336. /**
  96337. * Universal-Joint type
  96338. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  96339. */
  96340. static UniversalJoint: number;
  96341. /**
  96342. * Hinge-Joint 2 type
  96343. */
  96344. static Hinge2Joint: number;
  96345. /**
  96346. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  96347. */
  96348. static PointToPointJoint: number;
  96349. /**
  96350. * Spring-Joint type
  96351. */
  96352. static SpringJoint: number;
  96353. /**
  96354. * Lock-Joint type
  96355. */
  96356. static LockJoint: number;
  96357. }
  96358. /**
  96359. * A class representing a physics distance joint
  96360. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96361. */
  96362. export class DistanceJoint extends PhysicsJoint {
  96363. /**
  96364. *
  96365. * @param jointData The data for the Distance-Joint
  96366. */
  96367. constructor(jointData: DistanceJointData);
  96368. /**
  96369. * Update the predefined distance.
  96370. * @param maxDistance The maximum preferred distance
  96371. * @param minDistance The minimum preferred distance
  96372. */
  96373. updateDistance(maxDistance: number, minDistance?: number): void;
  96374. }
  96375. /**
  96376. * Represents a Motor-Enabled Joint
  96377. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96378. */
  96379. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  96380. /**
  96381. * Initializes the Motor-Enabled Joint
  96382. * @param type The type of the joint
  96383. * @param jointData The physica joint data for the joint
  96384. */
  96385. constructor(type: number, jointData: PhysicsJointData);
  96386. /**
  96387. * Set the motor values.
  96388. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96389. * @param force the force to apply
  96390. * @param maxForce max force for this motor.
  96391. */
  96392. setMotor(force?: number, maxForce?: number): void;
  96393. /**
  96394. * Set the motor's limits.
  96395. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96396. * @param upperLimit The upper limit of the motor
  96397. * @param lowerLimit The lower limit of the motor
  96398. */
  96399. setLimit(upperLimit: number, lowerLimit?: number): void;
  96400. }
  96401. /**
  96402. * This class represents a single physics Hinge-Joint
  96403. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96404. */
  96405. export class HingeJoint extends MotorEnabledJoint {
  96406. /**
  96407. * Initializes the Hinge-Joint
  96408. * @param jointData The joint data for the Hinge-Joint
  96409. */
  96410. constructor(jointData: PhysicsJointData);
  96411. /**
  96412. * Set the motor values.
  96413. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96414. * @param {number} force the force to apply
  96415. * @param {number} maxForce max force for this motor.
  96416. */
  96417. setMotor(force?: number, maxForce?: number): void;
  96418. /**
  96419. * Set the motor's limits.
  96420. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96421. * @param upperLimit The upper limit of the motor
  96422. * @param lowerLimit The lower limit of the motor
  96423. */
  96424. setLimit(upperLimit: number, lowerLimit?: number): void;
  96425. }
  96426. /**
  96427. * This class represents a dual hinge physics joint (same as wheel joint)
  96428. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96429. */
  96430. export class Hinge2Joint extends MotorEnabledJoint {
  96431. /**
  96432. * Initializes the Hinge2-Joint
  96433. * @param jointData The joint data for the Hinge2-Joint
  96434. */
  96435. constructor(jointData: PhysicsJointData);
  96436. /**
  96437. * Set the motor values.
  96438. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96439. * @param {number} targetSpeed the speed the motor is to reach
  96440. * @param {number} maxForce max force for this motor.
  96441. * @param {motorIndex} the motor's index, 0 or 1.
  96442. */
  96443. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  96444. /**
  96445. * Set the motor limits.
  96446. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96447. * @param {number} upperLimit the upper limit
  96448. * @param {number} lowerLimit lower limit
  96449. * @param {motorIndex} the motor's index, 0 or 1.
  96450. */
  96451. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96452. }
  96453. /**
  96454. * Interface for a motor enabled joint
  96455. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96456. */
  96457. export interface IMotorEnabledJoint {
  96458. /**
  96459. * Physics joint
  96460. */
  96461. physicsJoint: any;
  96462. /**
  96463. * Sets the motor of the motor-enabled joint
  96464. * @param force The force of the motor
  96465. * @param maxForce The maximum force of the motor
  96466. * @param motorIndex The index of the motor
  96467. */
  96468. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  96469. /**
  96470. * Sets the limit of the motor
  96471. * @param upperLimit The upper limit of the motor
  96472. * @param lowerLimit The lower limit of the motor
  96473. * @param motorIndex The index of the motor
  96474. */
  96475. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96476. }
  96477. /**
  96478. * Joint data for a Distance-Joint
  96479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96480. */
  96481. export interface DistanceJointData extends PhysicsJointData {
  96482. /**
  96483. * Max distance the 2 joint objects can be apart
  96484. */
  96485. maxDistance: number;
  96486. }
  96487. /**
  96488. * Joint data from a spring joint
  96489. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96490. */
  96491. export interface SpringJointData extends PhysicsJointData {
  96492. /**
  96493. * Length of the spring
  96494. */
  96495. length: number;
  96496. /**
  96497. * Stiffness of the spring
  96498. */
  96499. stiffness: number;
  96500. /**
  96501. * Damping of the spring
  96502. */
  96503. damping: number;
  96504. /** this callback will be called when applying the force to the impostors. */
  96505. forceApplicationCallback: () => void;
  96506. }
  96507. }
  96508. declare module BABYLON {
  96509. /**
  96510. * Holds the data for the raycast result
  96511. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96512. */
  96513. export class PhysicsRaycastResult {
  96514. private _hasHit;
  96515. private _hitDistance;
  96516. private _hitNormalWorld;
  96517. private _hitPointWorld;
  96518. private _rayFromWorld;
  96519. private _rayToWorld;
  96520. /**
  96521. * Gets if there was a hit
  96522. */
  96523. get hasHit(): boolean;
  96524. /**
  96525. * Gets the distance from the hit
  96526. */
  96527. get hitDistance(): number;
  96528. /**
  96529. * Gets the hit normal/direction in the world
  96530. */
  96531. get hitNormalWorld(): Vector3;
  96532. /**
  96533. * Gets the hit point in the world
  96534. */
  96535. get hitPointWorld(): Vector3;
  96536. /**
  96537. * Gets the ray "start point" of the ray in the world
  96538. */
  96539. get rayFromWorld(): Vector3;
  96540. /**
  96541. * Gets the ray "end point" of the ray in the world
  96542. */
  96543. get rayToWorld(): Vector3;
  96544. /**
  96545. * Sets the hit data (normal & point in world space)
  96546. * @param hitNormalWorld defines the normal in world space
  96547. * @param hitPointWorld defines the point in world space
  96548. */
  96549. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  96550. /**
  96551. * Sets the distance from the start point to the hit point
  96552. * @param distance
  96553. */
  96554. setHitDistance(distance: number): void;
  96555. /**
  96556. * Calculates the distance manually
  96557. */
  96558. calculateHitDistance(): void;
  96559. /**
  96560. * Resets all the values to default
  96561. * @param from The from point on world space
  96562. * @param to The to point on world space
  96563. */
  96564. reset(from?: Vector3, to?: Vector3): void;
  96565. }
  96566. /**
  96567. * Interface for the size containing width and height
  96568. */
  96569. interface IXYZ {
  96570. /**
  96571. * X
  96572. */
  96573. x: number;
  96574. /**
  96575. * Y
  96576. */
  96577. y: number;
  96578. /**
  96579. * Z
  96580. */
  96581. z: number;
  96582. }
  96583. }
  96584. declare module BABYLON {
  96585. /**
  96586. * Interface used to describe a physics joint
  96587. */
  96588. export interface PhysicsImpostorJoint {
  96589. /** Defines the main impostor to which the joint is linked */
  96590. mainImpostor: PhysicsImpostor;
  96591. /** Defines the impostor that is connected to the main impostor using this joint */
  96592. connectedImpostor: PhysicsImpostor;
  96593. /** Defines the joint itself */
  96594. joint: PhysicsJoint;
  96595. }
  96596. /** @hidden */
  96597. export interface IPhysicsEnginePlugin {
  96598. world: any;
  96599. name: string;
  96600. setGravity(gravity: Vector3): void;
  96601. setTimeStep(timeStep: number): void;
  96602. getTimeStep(): number;
  96603. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  96604. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96605. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96606. generatePhysicsBody(impostor: PhysicsImpostor): void;
  96607. removePhysicsBody(impostor: PhysicsImpostor): void;
  96608. generateJoint(joint: PhysicsImpostorJoint): void;
  96609. removeJoint(joint: PhysicsImpostorJoint): void;
  96610. isSupported(): boolean;
  96611. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  96612. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  96613. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96614. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96615. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96616. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96617. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  96618. getBodyMass(impostor: PhysicsImpostor): number;
  96619. getBodyFriction(impostor: PhysicsImpostor): number;
  96620. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  96621. getBodyRestitution(impostor: PhysicsImpostor): number;
  96622. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  96623. getBodyPressure?(impostor: PhysicsImpostor): number;
  96624. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  96625. getBodyStiffness?(impostor: PhysicsImpostor): number;
  96626. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  96627. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  96628. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  96629. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  96630. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  96631. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96632. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96633. sleepBody(impostor: PhysicsImpostor): void;
  96634. wakeUpBody(impostor: PhysicsImpostor): void;
  96635. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96636. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  96637. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  96638. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96639. getRadius(impostor: PhysicsImpostor): number;
  96640. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  96641. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  96642. dispose(): void;
  96643. }
  96644. /**
  96645. * Interface used to define a physics engine
  96646. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  96647. */
  96648. export interface IPhysicsEngine {
  96649. /**
  96650. * Gets the gravity vector used by the simulation
  96651. */
  96652. gravity: Vector3;
  96653. /**
  96654. * Sets the gravity vector used by the simulation
  96655. * @param gravity defines the gravity vector to use
  96656. */
  96657. setGravity(gravity: Vector3): void;
  96658. /**
  96659. * Set the time step of the physics engine.
  96660. * Default is 1/60.
  96661. * To slow it down, enter 1/600 for example.
  96662. * To speed it up, 1/30
  96663. * @param newTimeStep the new timestep to apply to this world.
  96664. */
  96665. setTimeStep(newTimeStep: number): void;
  96666. /**
  96667. * Get the time step of the physics engine.
  96668. * @returns the current time step
  96669. */
  96670. getTimeStep(): number;
  96671. /**
  96672. * Set the sub time step of the physics engine.
  96673. * Default is 0 meaning there is no sub steps
  96674. * To increase physics resolution precision, set a small value (like 1 ms)
  96675. * @param subTimeStep defines the new sub timestep used for physics resolution.
  96676. */
  96677. setSubTimeStep(subTimeStep: number): void;
  96678. /**
  96679. * Get the sub time step of the physics engine.
  96680. * @returns the current sub time step
  96681. */
  96682. getSubTimeStep(): number;
  96683. /**
  96684. * Release all resources
  96685. */
  96686. dispose(): void;
  96687. /**
  96688. * Gets the name of the current physics plugin
  96689. * @returns the name of the plugin
  96690. */
  96691. getPhysicsPluginName(): string;
  96692. /**
  96693. * Adding a new impostor for the impostor tracking.
  96694. * This will be done by the impostor itself.
  96695. * @param impostor the impostor to add
  96696. */
  96697. addImpostor(impostor: PhysicsImpostor): void;
  96698. /**
  96699. * Remove an impostor from the engine.
  96700. * This impostor and its mesh will not longer be updated by the physics engine.
  96701. * @param impostor the impostor to remove
  96702. */
  96703. removeImpostor(impostor: PhysicsImpostor): void;
  96704. /**
  96705. * Add a joint to the physics engine
  96706. * @param mainImpostor defines the main impostor to which the joint is added.
  96707. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  96708. * @param joint defines the joint that will connect both impostors.
  96709. */
  96710. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96711. /**
  96712. * Removes a joint from the simulation
  96713. * @param mainImpostor defines the impostor used with the joint
  96714. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  96715. * @param joint defines the joint to remove
  96716. */
  96717. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96718. /**
  96719. * Gets the current plugin used to run the simulation
  96720. * @returns current plugin
  96721. */
  96722. getPhysicsPlugin(): IPhysicsEnginePlugin;
  96723. /**
  96724. * Gets the list of physic impostors
  96725. * @returns an array of PhysicsImpostor
  96726. */
  96727. getImpostors(): Array<PhysicsImpostor>;
  96728. /**
  96729. * Gets the impostor for a physics enabled object
  96730. * @param object defines the object impersonated by the impostor
  96731. * @returns the PhysicsImpostor or null if not found
  96732. */
  96733. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  96734. /**
  96735. * Gets the impostor for a physics body object
  96736. * @param body defines physics body used by the impostor
  96737. * @returns the PhysicsImpostor or null if not found
  96738. */
  96739. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  96740. /**
  96741. * Does a raycast in the physics world
  96742. * @param from when should the ray start?
  96743. * @param to when should the ray end?
  96744. * @returns PhysicsRaycastResult
  96745. */
  96746. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96747. /**
  96748. * Called by the scene. No need to call it.
  96749. * @param delta defines the timespam between frames
  96750. */
  96751. _step(delta: number): void;
  96752. }
  96753. }
  96754. declare module BABYLON {
  96755. /**
  96756. * The interface for the physics imposter parameters
  96757. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96758. */
  96759. export interface PhysicsImpostorParameters {
  96760. /**
  96761. * The mass of the physics imposter
  96762. */
  96763. mass: number;
  96764. /**
  96765. * The friction of the physics imposter
  96766. */
  96767. friction?: number;
  96768. /**
  96769. * The coefficient of restitution of the physics imposter
  96770. */
  96771. restitution?: number;
  96772. /**
  96773. * The native options of the physics imposter
  96774. */
  96775. nativeOptions?: any;
  96776. /**
  96777. * Specifies if the parent should be ignored
  96778. */
  96779. ignoreParent?: boolean;
  96780. /**
  96781. * Specifies if bi-directional transformations should be disabled
  96782. */
  96783. disableBidirectionalTransformation?: boolean;
  96784. /**
  96785. * The pressure inside the physics imposter, soft object only
  96786. */
  96787. pressure?: number;
  96788. /**
  96789. * The stiffness the physics imposter, soft object only
  96790. */
  96791. stiffness?: number;
  96792. /**
  96793. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  96794. */
  96795. velocityIterations?: number;
  96796. /**
  96797. * The number of iterations used in maintaining consistent vertex positions, soft object only
  96798. */
  96799. positionIterations?: number;
  96800. /**
  96801. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  96802. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  96803. * Add to fix multiple points
  96804. */
  96805. fixedPoints?: number;
  96806. /**
  96807. * The collision margin around a soft object
  96808. */
  96809. margin?: number;
  96810. /**
  96811. * The collision margin around a soft object
  96812. */
  96813. damping?: number;
  96814. /**
  96815. * The path for a rope based on an extrusion
  96816. */
  96817. path?: any;
  96818. /**
  96819. * The shape of an extrusion used for a rope based on an extrusion
  96820. */
  96821. shape?: any;
  96822. }
  96823. /**
  96824. * Interface for a physics-enabled object
  96825. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96826. */
  96827. export interface IPhysicsEnabledObject {
  96828. /**
  96829. * The position of the physics-enabled object
  96830. */
  96831. position: Vector3;
  96832. /**
  96833. * The rotation of the physics-enabled object
  96834. */
  96835. rotationQuaternion: Nullable<Quaternion>;
  96836. /**
  96837. * The scale of the physics-enabled object
  96838. */
  96839. scaling: Vector3;
  96840. /**
  96841. * The rotation of the physics-enabled object
  96842. */
  96843. rotation?: Vector3;
  96844. /**
  96845. * The parent of the physics-enabled object
  96846. */
  96847. parent?: any;
  96848. /**
  96849. * The bounding info of the physics-enabled object
  96850. * @returns The bounding info of the physics-enabled object
  96851. */
  96852. getBoundingInfo(): BoundingInfo;
  96853. /**
  96854. * Computes the world matrix
  96855. * @param force Specifies if the world matrix should be computed by force
  96856. * @returns A world matrix
  96857. */
  96858. computeWorldMatrix(force: boolean): Matrix;
  96859. /**
  96860. * Gets the world matrix
  96861. * @returns A world matrix
  96862. */
  96863. getWorldMatrix?(): Matrix;
  96864. /**
  96865. * Gets the child meshes
  96866. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  96867. * @returns An array of abstract meshes
  96868. */
  96869. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  96870. /**
  96871. * Gets the vertex data
  96872. * @param kind The type of vertex data
  96873. * @returns A nullable array of numbers, or a float32 array
  96874. */
  96875. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  96876. /**
  96877. * Gets the indices from the mesh
  96878. * @returns A nullable array of index arrays
  96879. */
  96880. getIndices?(): Nullable<IndicesArray>;
  96881. /**
  96882. * Gets the scene from the mesh
  96883. * @returns the indices array or null
  96884. */
  96885. getScene?(): Scene;
  96886. /**
  96887. * Gets the absolute position from the mesh
  96888. * @returns the absolute position
  96889. */
  96890. getAbsolutePosition(): Vector3;
  96891. /**
  96892. * Gets the absolute pivot point from the mesh
  96893. * @returns the absolute pivot point
  96894. */
  96895. getAbsolutePivotPoint(): Vector3;
  96896. /**
  96897. * Rotates the mesh
  96898. * @param axis The axis of rotation
  96899. * @param amount The amount of rotation
  96900. * @param space The space of the rotation
  96901. * @returns The rotation transform node
  96902. */
  96903. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  96904. /**
  96905. * Translates the mesh
  96906. * @param axis The axis of translation
  96907. * @param distance The distance of translation
  96908. * @param space The space of the translation
  96909. * @returns The transform node
  96910. */
  96911. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  96912. /**
  96913. * Sets the absolute position of the mesh
  96914. * @param absolutePosition The absolute position of the mesh
  96915. * @returns The transform node
  96916. */
  96917. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  96918. /**
  96919. * Gets the class name of the mesh
  96920. * @returns The class name
  96921. */
  96922. getClassName(): string;
  96923. }
  96924. /**
  96925. * Represents a physics imposter
  96926. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96927. */
  96928. export class PhysicsImpostor {
  96929. /**
  96930. * The physics-enabled object used as the physics imposter
  96931. */
  96932. object: IPhysicsEnabledObject;
  96933. /**
  96934. * The type of the physics imposter
  96935. */
  96936. type: number;
  96937. private _options;
  96938. private _scene?;
  96939. /**
  96940. * The default object size of the imposter
  96941. */
  96942. static DEFAULT_OBJECT_SIZE: Vector3;
  96943. /**
  96944. * The identity quaternion of the imposter
  96945. */
  96946. static IDENTITY_QUATERNION: Quaternion;
  96947. /** @hidden */
  96948. _pluginData: any;
  96949. private _physicsEngine;
  96950. private _physicsBody;
  96951. private _bodyUpdateRequired;
  96952. private _onBeforePhysicsStepCallbacks;
  96953. private _onAfterPhysicsStepCallbacks;
  96954. /** @hidden */
  96955. _onPhysicsCollideCallbacks: Array<{
  96956. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  96957. otherImpostors: Array<PhysicsImpostor>;
  96958. }>;
  96959. private _deltaPosition;
  96960. private _deltaRotation;
  96961. private _deltaRotationConjugated;
  96962. /** @hidden */
  96963. _isFromLine: boolean;
  96964. private _parent;
  96965. private _isDisposed;
  96966. private static _tmpVecs;
  96967. private static _tmpQuat;
  96968. /**
  96969. * Specifies if the physics imposter is disposed
  96970. */
  96971. get isDisposed(): boolean;
  96972. /**
  96973. * Gets the mass of the physics imposter
  96974. */
  96975. get mass(): number;
  96976. set mass(value: number);
  96977. /**
  96978. * Gets the coefficient of friction
  96979. */
  96980. get friction(): number;
  96981. /**
  96982. * Sets the coefficient of friction
  96983. */
  96984. set friction(value: number);
  96985. /**
  96986. * Gets the coefficient of restitution
  96987. */
  96988. get restitution(): number;
  96989. /**
  96990. * Sets the coefficient of restitution
  96991. */
  96992. set restitution(value: number);
  96993. /**
  96994. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  96995. */
  96996. get pressure(): number;
  96997. /**
  96998. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  96999. */
  97000. set pressure(value: number);
  97001. /**
  97002. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97003. */
  97004. get stiffness(): number;
  97005. /**
  97006. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97007. */
  97008. set stiffness(value: number);
  97009. /**
  97010. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97011. */
  97012. get velocityIterations(): number;
  97013. /**
  97014. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97015. */
  97016. set velocityIterations(value: number);
  97017. /**
  97018. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97019. */
  97020. get positionIterations(): number;
  97021. /**
  97022. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97023. */
  97024. set positionIterations(value: number);
  97025. /**
  97026. * The unique id of the physics imposter
  97027. * set by the physics engine when adding this impostor to the array
  97028. */
  97029. uniqueId: number;
  97030. /**
  97031. * @hidden
  97032. */
  97033. soft: boolean;
  97034. /**
  97035. * @hidden
  97036. */
  97037. segments: number;
  97038. private _joints;
  97039. /**
  97040. * Initializes the physics imposter
  97041. * @param object The physics-enabled object used as the physics imposter
  97042. * @param type The type of the physics imposter
  97043. * @param _options The options for the physics imposter
  97044. * @param _scene The Babylon scene
  97045. */
  97046. constructor(
  97047. /**
  97048. * The physics-enabled object used as the physics imposter
  97049. */
  97050. object: IPhysicsEnabledObject,
  97051. /**
  97052. * The type of the physics imposter
  97053. */
  97054. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  97055. /**
  97056. * This function will completly initialize this impostor.
  97057. * It will create a new body - but only if this mesh has no parent.
  97058. * If it has, this impostor will not be used other than to define the impostor
  97059. * of the child mesh.
  97060. * @hidden
  97061. */
  97062. _init(): void;
  97063. private _getPhysicsParent;
  97064. /**
  97065. * Should a new body be generated.
  97066. * @returns boolean specifying if body initialization is required
  97067. */
  97068. isBodyInitRequired(): boolean;
  97069. /**
  97070. * Sets the updated scaling
  97071. * @param updated Specifies if the scaling is updated
  97072. */
  97073. setScalingUpdated(): void;
  97074. /**
  97075. * Force a regeneration of this or the parent's impostor's body.
  97076. * Use under cautious - This will remove all joints already implemented.
  97077. */
  97078. forceUpdate(): void;
  97079. /**
  97080. * Gets the body that holds this impostor. Either its own, or its parent.
  97081. */
  97082. get physicsBody(): any;
  97083. /**
  97084. * Get the parent of the physics imposter
  97085. * @returns Physics imposter or null
  97086. */
  97087. get parent(): Nullable<PhysicsImpostor>;
  97088. /**
  97089. * Sets the parent of the physics imposter
  97090. */
  97091. set parent(value: Nullable<PhysicsImpostor>);
  97092. /**
  97093. * Set the physics body. Used mainly by the physics engine/plugin
  97094. */
  97095. set physicsBody(physicsBody: any);
  97096. /**
  97097. * Resets the update flags
  97098. */
  97099. resetUpdateFlags(): void;
  97100. /**
  97101. * Gets the object extend size
  97102. * @returns the object extend size
  97103. */
  97104. getObjectExtendSize(): Vector3;
  97105. /**
  97106. * Gets the object center
  97107. * @returns The object center
  97108. */
  97109. getObjectCenter(): Vector3;
  97110. /**
  97111. * Get a specific parameter from the options parameters
  97112. * @param paramName The object parameter name
  97113. * @returns The object parameter
  97114. */
  97115. getParam(paramName: string): any;
  97116. /**
  97117. * Sets a specific parameter in the options given to the physics plugin
  97118. * @param paramName The parameter name
  97119. * @param value The value of the parameter
  97120. */
  97121. setParam(paramName: string, value: number): void;
  97122. /**
  97123. * Specifically change the body's mass option. Won't recreate the physics body object
  97124. * @param mass The mass of the physics imposter
  97125. */
  97126. setMass(mass: number): void;
  97127. /**
  97128. * Gets the linear velocity
  97129. * @returns linear velocity or null
  97130. */
  97131. getLinearVelocity(): Nullable<Vector3>;
  97132. /**
  97133. * Sets the linear velocity
  97134. * @param velocity linear velocity or null
  97135. */
  97136. setLinearVelocity(velocity: Nullable<Vector3>): void;
  97137. /**
  97138. * Gets the angular velocity
  97139. * @returns angular velocity or null
  97140. */
  97141. getAngularVelocity(): Nullable<Vector3>;
  97142. /**
  97143. * Sets the angular velocity
  97144. * @param velocity The velocity or null
  97145. */
  97146. setAngularVelocity(velocity: Nullable<Vector3>): void;
  97147. /**
  97148. * Execute a function with the physics plugin native code
  97149. * Provide a function the will have two variables - the world object and the physics body object
  97150. * @param func The function to execute with the physics plugin native code
  97151. */
  97152. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  97153. /**
  97154. * Register a function that will be executed before the physics world is stepping forward
  97155. * @param func The function to execute before the physics world is stepped forward
  97156. */
  97157. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97158. /**
  97159. * Unregister a function that will be executed before the physics world is stepping forward
  97160. * @param func The function to execute before the physics world is stepped forward
  97161. */
  97162. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97163. /**
  97164. * Register a function that will be executed after the physics step
  97165. * @param func The function to execute after physics step
  97166. */
  97167. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97168. /**
  97169. * Unregisters a function that will be executed after the physics step
  97170. * @param func The function to execute after physics step
  97171. */
  97172. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97173. /**
  97174. * register a function that will be executed when this impostor collides against a different body
  97175. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  97176. * @param func Callback that is executed on collision
  97177. */
  97178. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  97179. /**
  97180. * Unregisters the physics imposter on contact
  97181. * @param collideAgainst The physics object to collide against
  97182. * @param func Callback to execute on collision
  97183. */
  97184. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  97185. private _tmpQuat;
  97186. private _tmpQuat2;
  97187. /**
  97188. * Get the parent rotation
  97189. * @returns The parent rotation
  97190. */
  97191. getParentsRotation(): Quaternion;
  97192. /**
  97193. * this function is executed by the physics engine.
  97194. */
  97195. beforeStep: () => void;
  97196. /**
  97197. * this function is executed by the physics engine
  97198. */
  97199. afterStep: () => void;
  97200. /**
  97201. * Legacy collision detection event support
  97202. */
  97203. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  97204. /**
  97205. * event and body object due to cannon's event-based architecture.
  97206. */
  97207. onCollide: (e: {
  97208. body: any;
  97209. }) => void;
  97210. /**
  97211. * Apply a force
  97212. * @param force The force to apply
  97213. * @param contactPoint The contact point for the force
  97214. * @returns The physics imposter
  97215. */
  97216. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97217. /**
  97218. * Apply an impulse
  97219. * @param force The impulse force
  97220. * @param contactPoint The contact point for the impulse force
  97221. * @returns The physics imposter
  97222. */
  97223. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97224. /**
  97225. * A help function to create a joint
  97226. * @param otherImpostor A physics imposter used to create a joint
  97227. * @param jointType The type of joint
  97228. * @param jointData The data for the joint
  97229. * @returns The physics imposter
  97230. */
  97231. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  97232. /**
  97233. * Add a joint to this impostor with a different impostor
  97234. * @param otherImpostor A physics imposter used to add a joint
  97235. * @param joint The joint to add
  97236. * @returns The physics imposter
  97237. */
  97238. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  97239. /**
  97240. * Add an anchor to a cloth impostor
  97241. * @param otherImpostor rigid impostor to anchor to
  97242. * @param width ratio across width from 0 to 1
  97243. * @param height ratio up height from 0 to 1
  97244. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  97245. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  97246. * @returns impostor the soft imposter
  97247. */
  97248. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97249. /**
  97250. * Add a hook to a rope impostor
  97251. * @param otherImpostor rigid impostor to anchor to
  97252. * @param length ratio across rope from 0 to 1
  97253. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  97254. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  97255. * @returns impostor the rope imposter
  97256. */
  97257. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97258. /**
  97259. * Will keep this body still, in a sleep mode.
  97260. * @returns the physics imposter
  97261. */
  97262. sleep(): PhysicsImpostor;
  97263. /**
  97264. * Wake the body up.
  97265. * @returns The physics imposter
  97266. */
  97267. wakeUp(): PhysicsImpostor;
  97268. /**
  97269. * Clones the physics imposter
  97270. * @param newObject The physics imposter clones to this physics-enabled object
  97271. * @returns A nullable physics imposter
  97272. */
  97273. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97274. /**
  97275. * Disposes the physics imposter
  97276. */
  97277. dispose(): void;
  97278. /**
  97279. * Sets the delta position
  97280. * @param position The delta position amount
  97281. */
  97282. setDeltaPosition(position: Vector3): void;
  97283. /**
  97284. * Sets the delta rotation
  97285. * @param rotation The delta rotation amount
  97286. */
  97287. setDeltaRotation(rotation: Quaternion): void;
  97288. /**
  97289. * Gets the box size of the physics imposter and stores the result in the input parameter
  97290. * @param result Stores the box size
  97291. * @returns The physics imposter
  97292. */
  97293. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  97294. /**
  97295. * Gets the radius of the physics imposter
  97296. * @returns Radius of the physics imposter
  97297. */
  97298. getRadius(): number;
  97299. /**
  97300. * Sync a bone with this impostor
  97301. * @param bone The bone to sync to the impostor.
  97302. * @param boneMesh The mesh that the bone is influencing.
  97303. * @param jointPivot The pivot of the joint / bone in local space.
  97304. * @param distToJoint Optional distance from the impostor to the joint.
  97305. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97306. */
  97307. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  97308. /**
  97309. * Sync impostor to a bone
  97310. * @param bone The bone that the impostor will be synced to.
  97311. * @param boneMesh The mesh that the bone is influencing.
  97312. * @param jointPivot The pivot of the joint / bone in local space.
  97313. * @param distToJoint Optional distance from the impostor to the joint.
  97314. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97315. * @param boneAxis Optional vector3 axis the bone is aligned with
  97316. */
  97317. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  97318. /**
  97319. * No-Imposter type
  97320. */
  97321. static NoImpostor: number;
  97322. /**
  97323. * Sphere-Imposter type
  97324. */
  97325. static SphereImpostor: number;
  97326. /**
  97327. * Box-Imposter type
  97328. */
  97329. static BoxImpostor: number;
  97330. /**
  97331. * Plane-Imposter type
  97332. */
  97333. static PlaneImpostor: number;
  97334. /**
  97335. * Mesh-imposter type
  97336. */
  97337. static MeshImpostor: number;
  97338. /**
  97339. * Capsule-Impostor type (Ammo.js plugin only)
  97340. */
  97341. static CapsuleImpostor: number;
  97342. /**
  97343. * Cylinder-Imposter type
  97344. */
  97345. static CylinderImpostor: number;
  97346. /**
  97347. * Particle-Imposter type
  97348. */
  97349. static ParticleImpostor: number;
  97350. /**
  97351. * Heightmap-Imposter type
  97352. */
  97353. static HeightmapImpostor: number;
  97354. /**
  97355. * ConvexHull-Impostor type (Ammo.js plugin only)
  97356. */
  97357. static ConvexHullImpostor: number;
  97358. /**
  97359. * Custom-Imposter type (Ammo.js plugin only)
  97360. */
  97361. static CustomImpostor: number;
  97362. /**
  97363. * Rope-Imposter type
  97364. */
  97365. static RopeImpostor: number;
  97366. /**
  97367. * Cloth-Imposter type
  97368. */
  97369. static ClothImpostor: number;
  97370. /**
  97371. * Softbody-Imposter type
  97372. */
  97373. static SoftbodyImpostor: number;
  97374. }
  97375. }
  97376. declare module BABYLON {
  97377. /**
  97378. * @hidden
  97379. **/
  97380. export class _CreationDataStorage {
  97381. closePath?: boolean;
  97382. closeArray?: boolean;
  97383. idx: number[];
  97384. dashSize: number;
  97385. gapSize: number;
  97386. path3D: Path3D;
  97387. pathArray: Vector3[][];
  97388. arc: number;
  97389. radius: number;
  97390. cap: number;
  97391. tessellation: number;
  97392. }
  97393. /**
  97394. * @hidden
  97395. **/
  97396. class _InstanceDataStorage {
  97397. visibleInstances: any;
  97398. batchCache: _InstancesBatch;
  97399. instancesBufferSize: number;
  97400. instancesBuffer: Nullable<Buffer>;
  97401. instancesData: Float32Array;
  97402. overridenInstanceCount: number;
  97403. isFrozen: boolean;
  97404. previousBatch: Nullable<_InstancesBatch>;
  97405. hardwareInstancedRendering: boolean;
  97406. sideOrientation: number;
  97407. manualUpdate: boolean;
  97408. }
  97409. /**
  97410. * @hidden
  97411. **/
  97412. export class _InstancesBatch {
  97413. mustReturn: boolean;
  97414. visibleInstances: Nullable<InstancedMesh[]>[];
  97415. renderSelf: boolean[];
  97416. hardwareInstancedRendering: boolean[];
  97417. }
  97418. /**
  97419. * Class used to represent renderable models
  97420. */
  97421. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  97422. /**
  97423. * Mesh side orientation : usually the external or front surface
  97424. */
  97425. static readonly FRONTSIDE: number;
  97426. /**
  97427. * Mesh side orientation : usually the internal or back surface
  97428. */
  97429. static readonly BACKSIDE: number;
  97430. /**
  97431. * Mesh side orientation : both internal and external or front and back surfaces
  97432. */
  97433. static readonly DOUBLESIDE: number;
  97434. /**
  97435. * Mesh side orientation : by default, `FRONTSIDE`
  97436. */
  97437. static readonly DEFAULTSIDE: number;
  97438. /**
  97439. * Mesh cap setting : no cap
  97440. */
  97441. static readonly NO_CAP: number;
  97442. /**
  97443. * Mesh cap setting : one cap at the beginning of the mesh
  97444. */
  97445. static readonly CAP_START: number;
  97446. /**
  97447. * Mesh cap setting : one cap at the end of the mesh
  97448. */
  97449. static readonly CAP_END: number;
  97450. /**
  97451. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  97452. */
  97453. static readonly CAP_ALL: number;
  97454. /**
  97455. * Mesh pattern setting : no flip or rotate
  97456. */
  97457. static readonly NO_FLIP: number;
  97458. /**
  97459. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  97460. */
  97461. static readonly FLIP_TILE: number;
  97462. /**
  97463. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  97464. */
  97465. static readonly ROTATE_TILE: number;
  97466. /**
  97467. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  97468. */
  97469. static readonly FLIP_ROW: number;
  97470. /**
  97471. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  97472. */
  97473. static readonly ROTATE_ROW: number;
  97474. /**
  97475. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  97476. */
  97477. static readonly FLIP_N_ROTATE_TILE: number;
  97478. /**
  97479. * Mesh pattern setting : rotate pattern and rotate
  97480. */
  97481. static readonly FLIP_N_ROTATE_ROW: number;
  97482. /**
  97483. * Mesh tile positioning : part tiles same on left/right or top/bottom
  97484. */
  97485. static readonly CENTER: number;
  97486. /**
  97487. * Mesh tile positioning : part tiles on left
  97488. */
  97489. static readonly LEFT: number;
  97490. /**
  97491. * Mesh tile positioning : part tiles on right
  97492. */
  97493. static readonly RIGHT: number;
  97494. /**
  97495. * Mesh tile positioning : part tiles on top
  97496. */
  97497. static readonly TOP: number;
  97498. /**
  97499. * Mesh tile positioning : part tiles on bottom
  97500. */
  97501. static readonly BOTTOM: number;
  97502. /**
  97503. * Gets the default side orientation.
  97504. * @param orientation the orientation to value to attempt to get
  97505. * @returns the default orientation
  97506. * @hidden
  97507. */
  97508. static _GetDefaultSideOrientation(orientation?: number): number;
  97509. private _internalMeshDataInfo;
  97510. /**
  97511. * An event triggered before rendering the mesh
  97512. */
  97513. get onBeforeRenderObservable(): Observable<Mesh>;
  97514. /**
  97515. * An event triggered before binding the mesh
  97516. */
  97517. get onBeforeBindObservable(): Observable<Mesh>;
  97518. /**
  97519. * An event triggered after rendering the mesh
  97520. */
  97521. get onAfterRenderObservable(): Observable<Mesh>;
  97522. /**
  97523. * An event triggered before drawing the mesh
  97524. */
  97525. get onBeforeDrawObservable(): Observable<Mesh>;
  97526. private _onBeforeDrawObserver;
  97527. /**
  97528. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  97529. */
  97530. set onBeforeDraw(callback: () => void);
  97531. get hasInstances(): boolean;
  97532. /**
  97533. * Gets the delay loading state of the mesh (when delay loading is turned on)
  97534. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  97535. */
  97536. delayLoadState: number;
  97537. /**
  97538. * Gets the list of instances created from this mesh
  97539. * it is not supposed to be modified manually.
  97540. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  97541. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97542. */
  97543. instances: InstancedMesh[];
  97544. /**
  97545. * Gets the file containing delay loading data for this mesh
  97546. */
  97547. delayLoadingFile: string;
  97548. /** @hidden */
  97549. _binaryInfo: any;
  97550. /**
  97551. * User defined function used to change how LOD level selection is done
  97552. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97553. */
  97554. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  97555. /**
  97556. * Gets or sets the morph target manager
  97557. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97558. */
  97559. get morphTargetManager(): Nullable<MorphTargetManager>;
  97560. set morphTargetManager(value: Nullable<MorphTargetManager>);
  97561. /** @hidden */
  97562. _creationDataStorage: Nullable<_CreationDataStorage>;
  97563. /** @hidden */
  97564. _geometry: Nullable<Geometry>;
  97565. /** @hidden */
  97566. _delayInfo: Array<string>;
  97567. /** @hidden */
  97568. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  97569. /** @hidden */
  97570. _instanceDataStorage: _InstanceDataStorage;
  97571. private _effectiveMaterial;
  97572. /** @hidden */
  97573. _shouldGenerateFlatShading: boolean;
  97574. /** @hidden */
  97575. _originalBuilderSideOrientation: number;
  97576. /**
  97577. * Use this property to change the original side orientation defined at construction time
  97578. */
  97579. overrideMaterialSideOrientation: Nullable<number>;
  97580. /**
  97581. * Gets the source mesh (the one used to clone this one from)
  97582. */
  97583. get source(): Nullable<Mesh>;
  97584. /**
  97585. * Gets or sets a boolean indicating that this mesh does not use index buffer
  97586. */
  97587. get isUnIndexed(): boolean;
  97588. set isUnIndexed(value: boolean);
  97589. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  97590. get worldMatrixInstancedBuffer(): Float32Array;
  97591. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  97592. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  97593. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  97594. /**
  97595. * @constructor
  97596. * @param name The value used by scene.getMeshByName() to do a lookup.
  97597. * @param scene The scene to add this mesh to.
  97598. * @param parent The parent of this mesh, if it has one
  97599. * @param source An optional Mesh from which geometry is shared, cloned.
  97600. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97601. * When false, achieved by calling a clone(), also passing False.
  97602. * This will make creation of children, recursive.
  97603. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  97604. */
  97605. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  97606. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  97607. doNotInstantiate: boolean;
  97608. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  97609. /**
  97610. * Gets the class name
  97611. * @returns the string "Mesh".
  97612. */
  97613. getClassName(): string;
  97614. /** @hidden */
  97615. get _isMesh(): boolean;
  97616. /**
  97617. * Returns a description of this mesh
  97618. * @param fullDetails define if full details about this mesh must be used
  97619. * @returns a descriptive string representing this mesh
  97620. */
  97621. toString(fullDetails?: boolean): string;
  97622. /** @hidden */
  97623. _unBindEffect(): void;
  97624. /**
  97625. * Gets a boolean indicating if this mesh has LOD
  97626. */
  97627. get hasLODLevels(): boolean;
  97628. /**
  97629. * Gets the list of MeshLODLevel associated with the current mesh
  97630. * @returns an array of MeshLODLevel
  97631. */
  97632. getLODLevels(): MeshLODLevel[];
  97633. private _sortLODLevels;
  97634. /**
  97635. * Add a mesh as LOD level triggered at the given distance.
  97636. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97637. * @param distance The distance from the center of the object to show this level
  97638. * @param mesh The mesh to be added as LOD level (can be null)
  97639. * @return This mesh (for chaining)
  97640. */
  97641. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  97642. /**
  97643. * Returns the LOD level mesh at the passed distance or null if not found.
  97644. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97645. * @param distance The distance from the center of the object to show this level
  97646. * @returns a Mesh or `null`
  97647. */
  97648. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  97649. /**
  97650. * Remove a mesh from the LOD array
  97651. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97652. * @param mesh defines the mesh to be removed
  97653. * @return This mesh (for chaining)
  97654. */
  97655. removeLODLevel(mesh: Mesh): Mesh;
  97656. /**
  97657. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  97658. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97659. * @param camera defines the camera to use to compute distance
  97660. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  97661. * @return This mesh (for chaining)
  97662. */
  97663. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  97664. /**
  97665. * Gets the mesh internal Geometry object
  97666. */
  97667. get geometry(): Nullable<Geometry>;
  97668. /**
  97669. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  97670. * @returns the total number of vertices
  97671. */
  97672. getTotalVertices(): number;
  97673. /**
  97674. * Returns the content of an associated vertex buffer
  97675. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97676. * - VertexBuffer.PositionKind
  97677. * - VertexBuffer.UVKind
  97678. * - VertexBuffer.UV2Kind
  97679. * - VertexBuffer.UV3Kind
  97680. * - VertexBuffer.UV4Kind
  97681. * - VertexBuffer.UV5Kind
  97682. * - VertexBuffer.UV6Kind
  97683. * - VertexBuffer.ColorKind
  97684. * - VertexBuffer.MatricesIndicesKind
  97685. * - VertexBuffer.MatricesIndicesExtraKind
  97686. * - VertexBuffer.MatricesWeightsKind
  97687. * - VertexBuffer.MatricesWeightsExtraKind
  97688. * @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
  97689. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  97690. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  97691. */
  97692. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  97693. /**
  97694. * Returns the mesh VertexBuffer object from the requested `kind`
  97695. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97696. * - VertexBuffer.PositionKind
  97697. * - VertexBuffer.NormalKind
  97698. * - VertexBuffer.UVKind
  97699. * - VertexBuffer.UV2Kind
  97700. * - VertexBuffer.UV3Kind
  97701. * - VertexBuffer.UV4Kind
  97702. * - VertexBuffer.UV5Kind
  97703. * - VertexBuffer.UV6Kind
  97704. * - VertexBuffer.ColorKind
  97705. * - VertexBuffer.MatricesIndicesKind
  97706. * - VertexBuffer.MatricesIndicesExtraKind
  97707. * - VertexBuffer.MatricesWeightsKind
  97708. * - VertexBuffer.MatricesWeightsExtraKind
  97709. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  97710. */
  97711. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  97712. /**
  97713. * Tests if a specific vertex buffer is associated with this mesh
  97714. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97715. * - VertexBuffer.PositionKind
  97716. * - VertexBuffer.NormalKind
  97717. * - VertexBuffer.UVKind
  97718. * - VertexBuffer.UV2Kind
  97719. * - VertexBuffer.UV3Kind
  97720. * - VertexBuffer.UV4Kind
  97721. * - VertexBuffer.UV5Kind
  97722. * - VertexBuffer.UV6Kind
  97723. * - VertexBuffer.ColorKind
  97724. * - VertexBuffer.MatricesIndicesKind
  97725. * - VertexBuffer.MatricesIndicesExtraKind
  97726. * - VertexBuffer.MatricesWeightsKind
  97727. * - VertexBuffer.MatricesWeightsExtraKind
  97728. * @returns a boolean
  97729. */
  97730. isVerticesDataPresent(kind: string): boolean;
  97731. /**
  97732. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  97733. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97734. * - VertexBuffer.PositionKind
  97735. * - VertexBuffer.UVKind
  97736. * - VertexBuffer.UV2Kind
  97737. * - VertexBuffer.UV3Kind
  97738. * - VertexBuffer.UV4Kind
  97739. * - VertexBuffer.UV5Kind
  97740. * - VertexBuffer.UV6Kind
  97741. * - VertexBuffer.ColorKind
  97742. * - VertexBuffer.MatricesIndicesKind
  97743. * - VertexBuffer.MatricesIndicesExtraKind
  97744. * - VertexBuffer.MatricesWeightsKind
  97745. * - VertexBuffer.MatricesWeightsExtraKind
  97746. * @returns a boolean
  97747. */
  97748. isVertexBufferUpdatable(kind: string): boolean;
  97749. /**
  97750. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  97751. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97752. * - VertexBuffer.PositionKind
  97753. * - VertexBuffer.NormalKind
  97754. * - VertexBuffer.UVKind
  97755. * - VertexBuffer.UV2Kind
  97756. * - VertexBuffer.UV3Kind
  97757. * - VertexBuffer.UV4Kind
  97758. * - VertexBuffer.UV5Kind
  97759. * - VertexBuffer.UV6Kind
  97760. * - VertexBuffer.ColorKind
  97761. * - VertexBuffer.MatricesIndicesKind
  97762. * - VertexBuffer.MatricesIndicesExtraKind
  97763. * - VertexBuffer.MatricesWeightsKind
  97764. * - VertexBuffer.MatricesWeightsExtraKind
  97765. * @returns an array of strings
  97766. */
  97767. getVerticesDataKinds(): string[];
  97768. /**
  97769. * Returns a positive integer : the total number of indices in this mesh geometry.
  97770. * @returns the numner of indices or zero if the mesh has no geometry.
  97771. */
  97772. getTotalIndices(): number;
  97773. /**
  97774. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97775. * @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.
  97776. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  97777. * @returns the indices array or an empty array if the mesh has no geometry
  97778. */
  97779. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  97780. get isBlocked(): boolean;
  97781. /**
  97782. * Determine if the current mesh is ready to be rendered
  97783. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97784. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  97785. * @returns true if all associated assets are ready (material, textures, shaders)
  97786. */
  97787. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  97788. /**
  97789. * 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.
  97790. */
  97791. get areNormalsFrozen(): boolean;
  97792. /**
  97793. * 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.
  97794. * @returns the current mesh
  97795. */
  97796. freezeNormals(): Mesh;
  97797. /**
  97798. * 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
  97799. * @returns the current mesh
  97800. */
  97801. unfreezeNormals(): Mesh;
  97802. /**
  97803. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  97804. */
  97805. set overridenInstanceCount(count: number);
  97806. /** @hidden */
  97807. _preActivate(): Mesh;
  97808. /** @hidden */
  97809. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97810. /** @hidden */
  97811. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  97812. /**
  97813. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97814. * This means the mesh underlying bounding box and sphere are recomputed.
  97815. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97816. * @returns the current mesh
  97817. */
  97818. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  97819. /** @hidden */
  97820. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  97821. /**
  97822. * This function will subdivide the mesh into multiple submeshes
  97823. * @param count defines the expected number of submeshes
  97824. */
  97825. subdivide(count: number): void;
  97826. /**
  97827. * Copy a FloatArray into a specific associated vertex buffer
  97828. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97829. * - VertexBuffer.PositionKind
  97830. * - VertexBuffer.UVKind
  97831. * - VertexBuffer.UV2Kind
  97832. * - VertexBuffer.UV3Kind
  97833. * - VertexBuffer.UV4Kind
  97834. * - VertexBuffer.UV5Kind
  97835. * - VertexBuffer.UV6Kind
  97836. * - VertexBuffer.ColorKind
  97837. * - VertexBuffer.MatricesIndicesKind
  97838. * - VertexBuffer.MatricesIndicesExtraKind
  97839. * - VertexBuffer.MatricesWeightsKind
  97840. * - VertexBuffer.MatricesWeightsExtraKind
  97841. * @param data defines the data source
  97842. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97843. * @param stride defines the data stride size (can be null)
  97844. * @returns the current mesh
  97845. */
  97846. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97847. /**
  97848. * Delete a vertex buffer associated with this mesh
  97849. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  97850. * - VertexBuffer.PositionKind
  97851. * - VertexBuffer.UVKind
  97852. * - VertexBuffer.UV2Kind
  97853. * - VertexBuffer.UV3Kind
  97854. * - VertexBuffer.UV4Kind
  97855. * - VertexBuffer.UV5Kind
  97856. * - VertexBuffer.UV6Kind
  97857. * - VertexBuffer.ColorKind
  97858. * - VertexBuffer.MatricesIndicesKind
  97859. * - VertexBuffer.MatricesIndicesExtraKind
  97860. * - VertexBuffer.MatricesWeightsKind
  97861. * - VertexBuffer.MatricesWeightsExtraKind
  97862. */
  97863. removeVerticesData(kind: string): void;
  97864. /**
  97865. * Flags an associated vertex buffer as updatable
  97866. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  97867. * - VertexBuffer.PositionKind
  97868. * - VertexBuffer.UVKind
  97869. * - VertexBuffer.UV2Kind
  97870. * - VertexBuffer.UV3Kind
  97871. * - VertexBuffer.UV4Kind
  97872. * - VertexBuffer.UV5Kind
  97873. * - VertexBuffer.UV6Kind
  97874. * - VertexBuffer.ColorKind
  97875. * - VertexBuffer.MatricesIndicesKind
  97876. * - VertexBuffer.MatricesIndicesExtraKind
  97877. * - VertexBuffer.MatricesWeightsKind
  97878. * - VertexBuffer.MatricesWeightsExtraKind
  97879. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97880. */
  97881. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  97882. /**
  97883. * Sets the mesh global Vertex Buffer
  97884. * @param buffer defines the buffer to use
  97885. * @returns the current mesh
  97886. */
  97887. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  97888. /**
  97889. * Update a specific associated vertex buffer
  97890. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97891. * - VertexBuffer.PositionKind
  97892. * - VertexBuffer.UVKind
  97893. * - VertexBuffer.UV2Kind
  97894. * - VertexBuffer.UV3Kind
  97895. * - VertexBuffer.UV4Kind
  97896. * - VertexBuffer.UV5Kind
  97897. * - VertexBuffer.UV6Kind
  97898. * - VertexBuffer.ColorKind
  97899. * - VertexBuffer.MatricesIndicesKind
  97900. * - VertexBuffer.MatricesIndicesExtraKind
  97901. * - VertexBuffer.MatricesWeightsKind
  97902. * - VertexBuffer.MatricesWeightsExtraKind
  97903. * @param data defines the data source
  97904. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  97905. * @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)
  97906. * @returns the current mesh
  97907. */
  97908. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  97909. /**
  97910. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  97911. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  97912. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  97913. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  97914. * @returns the current mesh
  97915. */
  97916. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  97917. /**
  97918. * Creates a un-shared specific occurence of the geometry for the mesh.
  97919. * @returns the current mesh
  97920. */
  97921. makeGeometryUnique(): Mesh;
  97922. /**
  97923. * Set the index buffer of this mesh
  97924. * @param indices defines the source data
  97925. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  97926. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  97927. * @returns the current mesh
  97928. */
  97929. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  97930. /**
  97931. * Update the current index buffer
  97932. * @param indices defines the source data
  97933. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  97934. * @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)
  97935. * @returns the current mesh
  97936. */
  97937. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  97938. /**
  97939. * Invert the geometry to move from a right handed system to a left handed one.
  97940. * @returns the current mesh
  97941. */
  97942. toLeftHanded(): Mesh;
  97943. /** @hidden */
  97944. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97945. /** @hidden */
  97946. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97947. /**
  97948. * Registers for this mesh a javascript function called just before the rendering process
  97949. * @param func defines the function to call before rendering this mesh
  97950. * @returns the current mesh
  97951. */
  97952. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  97953. /**
  97954. * Disposes a previously registered javascript function called before the rendering
  97955. * @param func defines the function to remove
  97956. * @returns the current mesh
  97957. */
  97958. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  97959. /**
  97960. * Registers for this mesh a javascript function called just after the rendering is complete
  97961. * @param func defines the function to call after rendering this mesh
  97962. * @returns the current mesh
  97963. */
  97964. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  97965. /**
  97966. * Disposes a previously registered javascript function called after the rendering.
  97967. * @param func defines the function to remove
  97968. * @returns the current mesh
  97969. */
  97970. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  97971. /** @hidden */
  97972. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  97973. /** @hidden */
  97974. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  97975. /** @hidden */
  97976. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  97977. /** @hidden */
  97978. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  97979. /** @hidden */
  97980. _rebuild(): void;
  97981. /** @hidden */
  97982. _freeze(): void;
  97983. /** @hidden */
  97984. _unFreeze(): void;
  97985. /**
  97986. * 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
  97987. * @param subMesh defines the subMesh to render
  97988. * @param enableAlphaMode defines if alpha mode can be changed
  97989. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  97990. * @returns the current mesh
  97991. */
  97992. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  97993. private _onBeforeDraw;
  97994. /**
  97995. * Renormalize the mesh and patch it up if there are no weights
  97996. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  97997. * However in the case of zero weights then we set just a single influence to 1.
  97998. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  97999. */
  98000. cleanMatrixWeights(): void;
  98001. private normalizeSkinFourWeights;
  98002. private normalizeSkinWeightsAndExtra;
  98003. /**
  98004. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  98005. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  98006. * the user know there was an issue with importing the mesh
  98007. * @returns a validation object with skinned, valid and report string
  98008. */
  98009. validateSkinning(): {
  98010. skinned: boolean;
  98011. valid: boolean;
  98012. report: string;
  98013. };
  98014. /** @hidden */
  98015. _checkDelayState(): Mesh;
  98016. private _queueLoad;
  98017. /**
  98018. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98019. * A mesh is in the frustum if its bounding box intersects the frustum
  98020. * @param frustumPlanes defines the frustum to test
  98021. * @returns true if the mesh is in the frustum planes
  98022. */
  98023. isInFrustum(frustumPlanes: Plane[]): boolean;
  98024. /**
  98025. * Sets the mesh material by the material or multiMaterial `id` property
  98026. * @param id is a string identifying the material or the multiMaterial
  98027. * @returns the current mesh
  98028. */
  98029. setMaterialByID(id: string): Mesh;
  98030. /**
  98031. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  98032. * @returns an array of IAnimatable
  98033. */
  98034. getAnimatables(): IAnimatable[];
  98035. /**
  98036. * Modifies the mesh geometry according to the passed transformation matrix.
  98037. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  98038. * The mesh normals are modified using the same transformation.
  98039. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98040. * @param transform defines the transform matrix to use
  98041. * @see http://doc.babylonjs.com/resources/baking_transformations
  98042. * @returns the current mesh
  98043. */
  98044. bakeTransformIntoVertices(transform: Matrix): Mesh;
  98045. /**
  98046. * Modifies the mesh geometry according to its own current World Matrix.
  98047. * The mesh World Matrix is then reset.
  98048. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  98049. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98050. * @see http://doc.babylonjs.com/resources/baking_transformations
  98051. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  98052. * @returns the current mesh
  98053. */
  98054. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  98055. /** @hidden */
  98056. get _positions(): Nullable<Vector3[]>;
  98057. /** @hidden */
  98058. _resetPointsArrayCache(): Mesh;
  98059. /** @hidden */
  98060. _generatePointsArray(): boolean;
  98061. /**
  98062. * Returns a new Mesh object generated from the current mesh properties.
  98063. * This method must not get confused with createInstance()
  98064. * @param name is a string, the name given to the new mesh
  98065. * @param newParent can be any Node object (default `null`)
  98066. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  98067. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  98068. * @returns a new mesh
  98069. */
  98070. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  98071. /**
  98072. * Releases resources associated with this mesh.
  98073. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98074. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98075. */
  98076. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98077. /** @hidden */
  98078. _disposeInstanceSpecificData(): void;
  98079. /**
  98080. * Modifies the mesh geometry according to a displacement map.
  98081. * 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.
  98082. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98083. * @param url is a string, the URL from the image file is to be downloaded.
  98084. * @param minHeight is the lower limit of the displacement.
  98085. * @param maxHeight is the upper limit of the displacement.
  98086. * @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.
  98087. * @param uvOffset is an optional vector2 used to offset UV.
  98088. * @param uvScale is an optional vector2 used to scale UV.
  98089. * @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.
  98090. * @returns the Mesh.
  98091. */
  98092. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98093. /**
  98094. * Modifies the mesh geometry according to a displacementMap buffer.
  98095. * 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.
  98096. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98097. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  98098. * @param heightMapWidth is the width of the buffer image.
  98099. * @param heightMapHeight is the height of the buffer image.
  98100. * @param minHeight is the lower limit of the displacement.
  98101. * @param maxHeight is the upper limit of the displacement.
  98102. * @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.
  98103. * @param uvOffset is an optional vector2 used to offset UV.
  98104. * @param uvScale is an optional vector2 used to scale UV.
  98105. * @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.
  98106. * @returns the Mesh.
  98107. */
  98108. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98109. /**
  98110. * Modify the mesh to get a flat shading rendering.
  98111. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  98112. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  98113. * @returns current mesh
  98114. */
  98115. convertToFlatShadedMesh(): Mesh;
  98116. /**
  98117. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  98118. * In other words, more vertices, no more indices and a single bigger VBO.
  98119. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  98120. * @returns current mesh
  98121. */
  98122. convertToUnIndexedMesh(): Mesh;
  98123. /**
  98124. * Inverses facet orientations.
  98125. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98126. * @param flipNormals will also inverts the normals
  98127. * @returns current mesh
  98128. */
  98129. flipFaces(flipNormals?: boolean): Mesh;
  98130. /**
  98131. * Increase the number of facets and hence vertices in a mesh
  98132. * Vertex normals are interpolated from existing vertex normals
  98133. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98134. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  98135. */
  98136. increaseVertices(numberPerEdge: number): void;
  98137. /**
  98138. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  98139. * This will undo any application of covertToFlatShadedMesh
  98140. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98141. */
  98142. forceSharedVertices(): void;
  98143. /** @hidden */
  98144. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  98145. /** @hidden */
  98146. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  98147. /**
  98148. * Creates a new InstancedMesh object from the mesh model.
  98149. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98150. * @param name defines the name of the new instance
  98151. * @returns a new InstancedMesh
  98152. */
  98153. createInstance(name: string): InstancedMesh;
  98154. /**
  98155. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  98156. * After this call, all the mesh instances have the same submeshes than the current mesh.
  98157. * @returns the current mesh
  98158. */
  98159. synchronizeInstances(): Mesh;
  98160. /**
  98161. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  98162. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  98163. * This should be used together with the simplification to avoid disappearing triangles.
  98164. * @param successCallback an optional success callback to be called after the optimization finished.
  98165. * @returns the current mesh
  98166. */
  98167. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  98168. /**
  98169. * Serialize current mesh
  98170. * @param serializationObject defines the object which will receive the serialization data
  98171. */
  98172. serialize(serializationObject: any): void;
  98173. /** @hidden */
  98174. _syncGeometryWithMorphTargetManager(): void;
  98175. /** @hidden */
  98176. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  98177. /**
  98178. * Returns a new Mesh object parsed from the source provided.
  98179. * @param parsedMesh is the source
  98180. * @param scene defines the hosting scene
  98181. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  98182. * @returns a new Mesh
  98183. */
  98184. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  98185. /**
  98186. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  98187. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98188. * @param name defines the name of the mesh to create
  98189. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  98190. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  98191. * @param closePath creates a seam between the first and the last points of each path of the path array
  98192. * @param offset is taken in account only if the `pathArray` is containing a single path
  98193. * @param scene defines the hosting scene
  98194. * @param updatable defines if the mesh must be flagged as updatable
  98195. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98196. * @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)
  98197. * @returns a new Mesh
  98198. */
  98199. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98200. /**
  98201. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  98202. * @param name defines the name of the mesh to create
  98203. * @param radius sets the radius size (float) of the polygon (default 0.5)
  98204. * @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
  98205. * @param scene defines the hosting scene
  98206. * @param updatable defines if the mesh must be flagged as updatable
  98207. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98208. * @returns a new Mesh
  98209. */
  98210. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98211. /**
  98212. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  98213. * @param name defines the name of the mesh to create
  98214. * @param size sets the size (float) of each box side (default 1)
  98215. * @param scene defines the hosting scene
  98216. * @param updatable defines if the mesh must be flagged as updatable
  98217. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98218. * @returns a new Mesh
  98219. */
  98220. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98221. /**
  98222. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  98223. * @param name defines the name of the mesh to create
  98224. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98225. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98226. * @param scene defines the hosting scene
  98227. * @param updatable defines if the mesh must be flagged as updatable
  98228. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98229. * @returns a new Mesh
  98230. */
  98231. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98232. /**
  98233. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  98234. * @param name defines the name of the mesh to create
  98235. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98236. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98237. * @param scene defines the hosting scene
  98238. * @returns a new Mesh
  98239. */
  98240. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  98241. /**
  98242. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  98243. * @param name defines the name of the mesh to create
  98244. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  98245. * @param diameterTop set the top cap diameter (floats, default 1)
  98246. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  98247. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  98248. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  98249. * @param scene defines the hosting scene
  98250. * @param updatable defines if the mesh must be flagged as updatable
  98251. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98252. * @returns a new Mesh
  98253. */
  98254. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  98255. /**
  98256. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  98257. * @param name defines the name of the mesh to create
  98258. * @param diameter sets the diameter size (float) of the torus (default 1)
  98259. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  98260. * @param tessellation sets the number of torus sides (postive integer, default 16)
  98261. * @param scene defines the hosting scene
  98262. * @param updatable defines if the mesh must be flagged as updatable
  98263. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98264. * @returns a new Mesh
  98265. */
  98266. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98267. /**
  98268. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  98269. * @param name defines the name of the mesh to create
  98270. * @param radius sets the global radius size (float) of the torus knot (default 2)
  98271. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  98272. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  98273. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  98274. * @param p the number of windings on X axis (positive integers, default 2)
  98275. * @param q the number of windings on Y axis (positive integers, default 3)
  98276. * @param scene defines the hosting scene
  98277. * @param updatable defines if the mesh must be flagged as updatable
  98278. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98279. * @returns a new Mesh
  98280. */
  98281. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98282. /**
  98283. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  98284. * @param name defines the name of the mesh to create
  98285. * @param points is an array successive Vector3
  98286. * @param scene defines the hosting scene
  98287. * @param updatable defines if the mesh must be flagged as updatable
  98288. * @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).
  98289. * @returns a new Mesh
  98290. */
  98291. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  98292. /**
  98293. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  98294. * @param name defines the name of the mesh to create
  98295. * @param points is an array successive Vector3
  98296. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  98297. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98298. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  98299. * @param scene defines the hosting scene
  98300. * @param updatable defines if the mesh must be flagged as updatable
  98301. * @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)
  98302. * @returns a new Mesh
  98303. */
  98304. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  98305. /**
  98306. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  98307. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  98308. * 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.
  98309. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98310. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98311. * Remember you can only change the shape positions, not their number when updating a polygon.
  98312. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  98313. * @param name defines the name of the mesh to create
  98314. * @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
  98315. * @param scene defines the hosting scene
  98316. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98317. * @param updatable defines if the mesh must be flagged as updatable
  98318. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98319. * @param earcutInjection can be used to inject your own earcut reference
  98320. * @returns a new Mesh
  98321. */
  98322. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98323. /**
  98324. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  98325. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  98326. * @param name defines the name of the mesh to create
  98327. * @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
  98328. * @param depth defines the height of extrusion
  98329. * @param scene defines the hosting scene
  98330. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98331. * @param updatable defines if the mesh must be flagged as updatable
  98332. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98333. * @param earcutInjection can be used to inject your own earcut reference
  98334. * @returns a new Mesh
  98335. */
  98336. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98337. /**
  98338. * Creates an extruded shape mesh.
  98339. * 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
  98340. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98341. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98342. * @param name defines the name of the mesh to create
  98343. * @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
  98344. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98345. * @param scale is the value to scale the shape
  98346. * @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
  98347. * @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
  98348. * @param scene defines the hosting scene
  98349. * @param updatable defines if the mesh must be flagged as updatable
  98350. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98351. * @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)
  98352. * @returns a new Mesh
  98353. */
  98354. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98355. /**
  98356. * Creates an custom extruded shape mesh.
  98357. * The custom extrusion is a parametric shape.
  98358. * It has no predefined shape. Its final shape will depend on the input parameters.
  98359. * Please consider using the same method from the MeshBuilder class instead
  98360. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98361. * @param name defines the name of the mesh to create
  98362. * @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
  98363. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98364. * @param scaleFunction is a custom Javascript function called on each path point
  98365. * @param rotationFunction is a custom Javascript function called on each path point
  98366. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  98367. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  98368. * @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
  98369. * @param scene defines the hosting scene
  98370. * @param updatable defines if the mesh must be flagged as updatable
  98371. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98372. * @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)
  98373. * @returns a new Mesh
  98374. */
  98375. 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;
  98376. /**
  98377. * Creates lathe mesh.
  98378. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  98379. * Please consider using the same method from the MeshBuilder class instead
  98380. * @param name defines the name of the mesh to create
  98381. * @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
  98382. * @param radius is the radius value of the lathe
  98383. * @param tessellation is the side number of the lathe.
  98384. * @param scene defines the hosting scene
  98385. * @param updatable defines if the mesh must be flagged as updatable
  98386. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98387. * @returns a new Mesh
  98388. */
  98389. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98390. /**
  98391. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  98392. * @param name defines the name of the mesh to create
  98393. * @param size sets the size (float) of both sides of the plane at once (default 1)
  98394. * @param scene defines the hosting scene
  98395. * @param updatable defines if the mesh must be flagged as updatable
  98396. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98397. * @returns a new Mesh
  98398. */
  98399. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98400. /**
  98401. * Creates a ground mesh.
  98402. * Please consider using the same method from the MeshBuilder class instead
  98403. * @param name defines the name of the mesh to create
  98404. * @param width set the width of the ground
  98405. * @param height set the height of the ground
  98406. * @param subdivisions sets the number of subdivisions per side
  98407. * @param scene defines the hosting scene
  98408. * @param updatable defines if the mesh must be flagged as updatable
  98409. * @returns a new Mesh
  98410. */
  98411. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  98412. /**
  98413. * Creates a tiled ground mesh.
  98414. * Please consider using the same method from the MeshBuilder class instead
  98415. * @param name defines the name of the mesh to create
  98416. * @param xmin set the ground minimum X coordinate
  98417. * @param zmin set the ground minimum Y coordinate
  98418. * @param xmax set the ground maximum X coordinate
  98419. * @param zmax set the ground maximum Z coordinate
  98420. * @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
  98421. * @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
  98422. * @param scene defines the hosting scene
  98423. * @param updatable defines if the mesh must be flagged as updatable
  98424. * @returns a new Mesh
  98425. */
  98426. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  98427. w: number;
  98428. h: number;
  98429. }, precision: {
  98430. w: number;
  98431. h: number;
  98432. }, scene: Scene, updatable?: boolean): Mesh;
  98433. /**
  98434. * Creates a ground mesh from a height map.
  98435. * Please consider using the same method from the MeshBuilder class instead
  98436. * @see http://doc.babylonjs.com/babylon101/height_map
  98437. * @param name defines the name of the mesh to create
  98438. * @param url sets the URL of the height map image resource
  98439. * @param width set the ground width size
  98440. * @param height set the ground height size
  98441. * @param subdivisions sets the number of subdivision per side
  98442. * @param minHeight is the minimum altitude on the ground
  98443. * @param maxHeight is the maximum altitude on the ground
  98444. * @param scene defines the hosting scene
  98445. * @param updatable defines if the mesh must be flagged as updatable
  98446. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  98447. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98448. * @returns a new Mesh
  98449. */
  98450. 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;
  98451. /**
  98452. * Creates a tube mesh.
  98453. * The tube is a parametric shape.
  98454. * It has no predefined shape. Its final shape will depend on the input parameters.
  98455. * Please consider using the same method from the MeshBuilder class instead
  98456. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98457. * @param name defines the name of the mesh to create
  98458. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  98459. * @param radius sets the tube radius size
  98460. * @param tessellation is the number of sides on the tubular surface
  98461. * @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
  98462. * @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
  98463. * @param scene defines the hosting scene
  98464. * @param updatable defines if the mesh must be flagged as updatable
  98465. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98466. * @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)
  98467. * @returns a new Mesh
  98468. */
  98469. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  98470. (i: number, distance: number): number;
  98471. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98472. /**
  98473. * Creates a polyhedron mesh.
  98474. * Please consider using the same method from the MeshBuilder class instead.
  98475. * * 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
  98476. * * The parameter `size` (positive float, default 1) sets the polygon size
  98477. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  98478. * * 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`
  98479. * * 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
  98480. * * 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)`)
  98481. * * 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
  98482. * * 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
  98483. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98484. * * If you create a double-sided mesh, you can choose what parts of 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
  98485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98486. * @param name defines the name of the mesh to create
  98487. * @param options defines the options used to create the mesh
  98488. * @param scene defines the hosting scene
  98489. * @returns a new Mesh
  98490. */
  98491. static CreatePolyhedron(name: string, options: {
  98492. type?: number;
  98493. size?: number;
  98494. sizeX?: number;
  98495. sizeY?: number;
  98496. sizeZ?: number;
  98497. custom?: any;
  98498. faceUV?: Vector4[];
  98499. faceColors?: Color4[];
  98500. updatable?: boolean;
  98501. sideOrientation?: number;
  98502. }, scene: Scene): Mesh;
  98503. /**
  98504. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  98505. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  98506. * * 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`)
  98507. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  98508. * * 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
  98509. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98510. * * If you create a double-sided mesh, you can choose what parts of 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
  98511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98512. * @param name defines the name of the mesh
  98513. * @param options defines the options used to create the mesh
  98514. * @param scene defines the hosting scene
  98515. * @returns a new Mesh
  98516. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  98517. */
  98518. static CreateIcoSphere(name: string, options: {
  98519. radius?: number;
  98520. flat?: boolean;
  98521. subdivisions?: number;
  98522. sideOrientation?: number;
  98523. updatable?: boolean;
  98524. }, scene: Scene): Mesh;
  98525. /**
  98526. * Creates a decal mesh.
  98527. * Please consider using the same method from the MeshBuilder class instead.
  98528. * A decal is a mesh usually applied as a model onto the surface of another mesh
  98529. * @param name defines the name of the mesh
  98530. * @param sourceMesh defines the mesh receiving the decal
  98531. * @param position sets the position of the decal in world coordinates
  98532. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  98533. * @param size sets the decal scaling
  98534. * @param angle sets the angle to rotate the decal
  98535. * @returns a new Mesh
  98536. */
  98537. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  98538. /**
  98539. * Prepare internal position array for software CPU skinning
  98540. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  98541. */
  98542. setPositionsForCPUSkinning(): Float32Array;
  98543. /**
  98544. * Prepare internal normal array for software CPU skinning
  98545. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  98546. */
  98547. setNormalsForCPUSkinning(): Float32Array;
  98548. /**
  98549. * Updates the vertex buffer by applying transformation from the bones
  98550. * @param skeleton defines the skeleton to apply to current mesh
  98551. * @returns the current mesh
  98552. */
  98553. applySkeleton(skeleton: Skeleton): Mesh;
  98554. /**
  98555. * 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
  98556. * @param meshes defines the list of meshes to scan
  98557. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  98558. */
  98559. static MinMax(meshes: AbstractMesh[]): {
  98560. min: Vector3;
  98561. max: Vector3;
  98562. };
  98563. /**
  98564. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  98565. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  98566. * @returns a vector3
  98567. */
  98568. static Center(meshesOrMinMaxVector: {
  98569. min: Vector3;
  98570. max: Vector3;
  98571. } | AbstractMesh[]): Vector3;
  98572. /**
  98573. * Merge the array of meshes into a single mesh for performance reasons.
  98574. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  98575. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  98576. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  98577. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  98578. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  98579. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  98580. * @returns a new mesh
  98581. */
  98582. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  98583. /** @hidden */
  98584. addInstance(instance: InstancedMesh): void;
  98585. /** @hidden */
  98586. removeInstance(instance: InstancedMesh): void;
  98587. }
  98588. }
  98589. declare module BABYLON {
  98590. /**
  98591. * This is the base class of all the camera used in the application.
  98592. * @see http://doc.babylonjs.com/features/cameras
  98593. */
  98594. export class Camera extends Node {
  98595. /** @hidden */
  98596. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  98597. /**
  98598. * This is the default projection mode used by the cameras.
  98599. * It helps recreating a feeling of perspective and better appreciate depth.
  98600. * This is the best way to simulate real life cameras.
  98601. */
  98602. static readonly PERSPECTIVE_CAMERA: number;
  98603. /**
  98604. * This helps creating camera with an orthographic mode.
  98605. * 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.
  98606. */
  98607. static readonly ORTHOGRAPHIC_CAMERA: number;
  98608. /**
  98609. * This is the default FOV mode for perspective cameras.
  98610. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  98611. */
  98612. static readonly FOVMODE_VERTICAL_FIXED: number;
  98613. /**
  98614. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  98615. */
  98616. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  98617. /**
  98618. * This specifies ther is no need for a camera rig.
  98619. * Basically only one eye is rendered corresponding to the camera.
  98620. */
  98621. static readonly RIG_MODE_NONE: number;
  98622. /**
  98623. * Simulates a camera Rig with one blue eye and one red eye.
  98624. * This can be use with 3d blue and red glasses.
  98625. */
  98626. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  98627. /**
  98628. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  98629. */
  98630. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  98631. /**
  98632. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  98633. */
  98634. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  98635. /**
  98636. * Defines that both eyes of the camera will be rendered over under each other.
  98637. */
  98638. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  98639. /**
  98640. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  98641. */
  98642. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  98643. /**
  98644. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  98645. */
  98646. static readonly RIG_MODE_VR: number;
  98647. /**
  98648. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  98649. */
  98650. static readonly RIG_MODE_WEBVR: number;
  98651. /**
  98652. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  98653. */
  98654. static readonly RIG_MODE_CUSTOM: number;
  98655. /**
  98656. * Defines if by default attaching controls should prevent the default javascript event to continue.
  98657. */
  98658. static ForceAttachControlToAlwaysPreventDefault: boolean;
  98659. /**
  98660. * Define the input manager associated with the camera.
  98661. */
  98662. inputs: CameraInputsManager<Camera>;
  98663. /** @hidden */
  98664. _position: Vector3;
  98665. /**
  98666. * Define the current local position of the camera in the scene
  98667. */
  98668. get position(): Vector3;
  98669. set position(newPosition: Vector3);
  98670. /**
  98671. * The vector the camera should consider as up.
  98672. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  98673. */
  98674. upVector: Vector3;
  98675. /**
  98676. * Define the current limit on the left side for an orthographic camera
  98677. * In scene unit
  98678. */
  98679. orthoLeft: Nullable<number>;
  98680. /**
  98681. * Define the current limit on the right side for an orthographic camera
  98682. * In scene unit
  98683. */
  98684. orthoRight: Nullable<number>;
  98685. /**
  98686. * Define the current limit on the bottom side for an orthographic camera
  98687. * In scene unit
  98688. */
  98689. orthoBottom: Nullable<number>;
  98690. /**
  98691. * Define the current limit on the top side for an orthographic camera
  98692. * In scene unit
  98693. */
  98694. orthoTop: Nullable<number>;
  98695. /**
  98696. * Field Of View is set in Radians. (default is 0.8)
  98697. */
  98698. fov: number;
  98699. /**
  98700. * Define the minimum distance the camera can see from.
  98701. * This is important to note that the depth buffer are not infinite and the closer it starts
  98702. * the more your scene might encounter depth fighting issue.
  98703. */
  98704. minZ: number;
  98705. /**
  98706. * Define the maximum distance the camera can see to.
  98707. * This is important to note that the depth buffer are not infinite and the further it end
  98708. * the more your scene might encounter depth fighting issue.
  98709. */
  98710. maxZ: number;
  98711. /**
  98712. * Define the default inertia of the camera.
  98713. * This helps giving a smooth feeling to the camera movement.
  98714. */
  98715. inertia: number;
  98716. /**
  98717. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  98718. */
  98719. mode: number;
  98720. /**
  98721. * Define whether the camera is intermediate.
  98722. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  98723. */
  98724. isIntermediate: boolean;
  98725. /**
  98726. * Define the viewport of the camera.
  98727. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  98728. */
  98729. viewport: Viewport;
  98730. /**
  98731. * Restricts the camera to viewing objects with the same layerMask.
  98732. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  98733. */
  98734. layerMask: number;
  98735. /**
  98736. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  98737. */
  98738. fovMode: number;
  98739. /**
  98740. * Rig mode of the camera.
  98741. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  98742. * This is normally controlled byt the camera themselves as internal use.
  98743. */
  98744. cameraRigMode: number;
  98745. /**
  98746. * Defines the distance between both "eyes" in case of a RIG
  98747. */
  98748. interaxialDistance: number;
  98749. /**
  98750. * Defines if stereoscopic rendering is done side by side or over under.
  98751. */
  98752. isStereoscopicSideBySide: boolean;
  98753. /**
  98754. * 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
  98755. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  98756. * else in the scene. (Eg. security camera)
  98757. *
  98758. * 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)
  98759. */
  98760. customRenderTargets: RenderTargetTexture[];
  98761. /**
  98762. * When set, the camera will render to this render target instead of the default canvas
  98763. *
  98764. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  98765. */
  98766. outputRenderTarget: Nullable<RenderTargetTexture>;
  98767. /**
  98768. * Observable triggered when the camera view matrix has changed.
  98769. */
  98770. onViewMatrixChangedObservable: Observable<Camera>;
  98771. /**
  98772. * Observable triggered when the camera Projection matrix has changed.
  98773. */
  98774. onProjectionMatrixChangedObservable: Observable<Camera>;
  98775. /**
  98776. * Observable triggered when the inputs have been processed.
  98777. */
  98778. onAfterCheckInputsObservable: Observable<Camera>;
  98779. /**
  98780. * Observable triggered when reset has been called and applied to the camera.
  98781. */
  98782. onRestoreStateObservable: Observable<Camera>;
  98783. /**
  98784. * Is this camera a part of a rig system?
  98785. */
  98786. isRigCamera: boolean;
  98787. /**
  98788. * If isRigCamera set to true this will be set with the parent camera.
  98789. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  98790. */
  98791. rigParent?: Camera;
  98792. /** @hidden */
  98793. _cameraRigParams: any;
  98794. /** @hidden */
  98795. _rigCameras: Camera[];
  98796. /** @hidden */
  98797. _rigPostProcess: Nullable<PostProcess>;
  98798. protected _webvrViewMatrix: Matrix;
  98799. /** @hidden */
  98800. _skipRendering: boolean;
  98801. /** @hidden */
  98802. _projectionMatrix: Matrix;
  98803. /** @hidden */
  98804. _postProcesses: Nullable<PostProcess>[];
  98805. /** @hidden */
  98806. _activeMeshes: SmartArray<AbstractMesh>;
  98807. protected _globalPosition: Vector3;
  98808. /** @hidden */
  98809. _computedViewMatrix: Matrix;
  98810. private _doNotComputeProjectionMatrix;
  98811. private _transformMatrix;
  98812. private _frustumPlanes;
  98813. private _refreshFrustumPlanes;
  98814. private _storedFov;
  98815. private _stateStored;
  98816. /**
  98817. * Instantiates a new camera object.
  98818. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  98819. * @see http://doc.babylonjs.com/features/cameras
  98820. * @param name Defines the name of the camera in the scene
  98821. * @param position Defines the position of the camera
  98822. * @param scene Defines the scene the camera belongs too
  98823. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  98824. */
  98825. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98826. /**
  98827. * Store current camera state (fov, position, etc..)
  98828. * @returns the camera
  98829. */
  98830. storeState(): Camera;
  98831. /**
  98832. * Restores the camera state values if it has been stored. You must call storeState() first
  98833. */
  98834. protected _restoreStateValues(): boolean;
  98835. /**
  98836. * Restored camera state. You must call storeState() first.
  98837. * @returns true if restored and false otherwise
  98838. */
  98839. restoreState(): boolean;
  98840. /**
  98841. * Gets the class name of the camera.
  98842. * @returns the class name
  98843. */
  98844. getClassName(): string;
  98845. /** @hidden */
  98846. readonly _isCamera: boolean;
  98847. /**
  98848. * Gets a string representation of the camera useful for debug purpose.
  98849. * @param fullDetails Defines that a more verboe level of logging is required
  98850. * @returns the string representation
  98851. */
  98852. toString(fullDetails?: boolean): string;
  98853. /**
  98854. * Gets the current world space position of the camera.
  98855. */
  98856. get globalPosition(): Vector3;
  98857. /**
  98858. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  98859. * @returns the active meshe list
  98860. */
  98861. getActiveMeshes(): SmartArray<AbstractMesh>;
  98862. /**
  98863. * Check whether a mesh is part of the current active mesh list of the camera
  98864. * @param mesh Defines the mesh to check
  98865. * @returns true if active, false otherwise
  98866. */
  98867. isActiveMesh(mesh: Mesh): boolean;
  98868. /**
  98869. * Is this camera ready to be used/rendered
  98870. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  98871. * @return true if the camera is ready
  98872. */
  98873. isReady(completeCheck?: boolean): boolean;
  98874. /** @hidden */
  98875. _initCache(): void;
  98876. /** @hidden */
  98877. _updateCache(ignoreParentClass?: boolean): void;
  98878. /** @hidden */
  98879. _isSynchronized(): boolean;
  98880. /** @hidden */
  98881. _isSynchronizedViewMatrix(): boolean;
  98882. /** @hidden */
  98883. _isSynchronizedProjectionMatrix(): boolean;
  98884. /**
  98885. * Attach the input controls to a specific dom element to get the input from.
  98886. * @param element Defines the element the controls should be listened from
  98887. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98888. */
  98889. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98890. /**
  98891. * Detach the current controls from the specified dom element.
  98892. * @param element Defines the element to stop listening the inputs from
  98893. */
  98894. detachControl(element: HTMLElement): void;
  98895. /**
  98896. * Update the camera state according to the different inputs gathered during the frame.
  98897. */
  98898. update(): void;
  98899. /** @hidden */
  98900. _checkInputs(): void;
  98901. /** @hidden */
  98902. get rigCameras(): Camera[];
  98903. /**
  98904. * Gets the post process used by the rig cameras
  98905. */
  98906. get rigPostProcess(): Nullable<PostProcess>;
  98907. /**
  98908. * Internal, gets the first post proces.
  98909. * @returns the first post process to be run on this camera.
  98910. */
  98911. _getFirstPostProcess(): Nullable<PostProcess>;
  98912. private _cascadePostProcessesToRigCams;
  98913. /**
  98914. * Attach a post process to the camera.
  98915. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98916. * @param postProcess The post process to attach to the camera
  98917. * @param insertAt The position of the post process in case several of them are in use in the scene
  98918. * @returns the position the post process has been inserted at
  98919. */
  98920. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  98921. /**
  98922. * Detach a post process to the camera.
  98923. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  98924. * @param postProcess The post process to detach from the camera
  98925. */
  98926. detachPostProcess(postProcess: PostProcess): void;
  98927. /**
  98928. * Gets the current world matrix of the camera
  98929. */
  98930. getWorldMatrix(): Matrix;
  98931. /** @hidden */
  98932. _getViewMatrix(): Matrix;
  98933. /**
  98934. * Gets the current view matrix of the camera.
  98935. * @param force forces the camera to recompute the matrix without looking at the cached state
  98936. * @returns the view matrix
  98937. */
  98938. getViewMatrix(force?: boolean): Matrix;
  98939. /**
  98940. * Freeze the projection matrix.
  98941. * It will prevent the cache check of the camera projection compute and can speed up perf
  98942. * if no parameter of the camera are meant to change
  98943. * @param projection Defines manually a projection if necessary
  98944. */
  98945. freezeProjectionMatrix(projection?: Matrix): void;
  98946. /**
  98947. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  98948. */
  98949. unfreezeProjectionMatrix(): void;
  98950. /**
  98951. * Gets the current projection matrix of the camera.
  98952. * @param force forces the camera to recompute the matrix without looking at the cached state
  98953. * @returns the projection matrix
  98954. */
  98955. getProjectionMatrix(force?: boolean): Matrix;
  98956. /**
  98957. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  98958. * @returns a Matrix
  98959. */
  98960. getTransformationMatrix(): Matrix;
  98961. private _updateFrustumPlanes;
  98962. /**
  98963. * Checks if a cullable object (mesh...) is in the camera frustum
  98964. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  98965. * @param target The object to check
  98966. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  98967. * @returns true if the object is in frustum otherwise false
  98968. */
  98969. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  98970. /**
  98971. * Checks if a cullable object (mesh...) is in the camera frustum
  98972. * Unlike isInFrustum this cheks the full bounding box
  98973. * @param target The object to check
  98974. * @returns true if the object is in frustum otherwise false
  98975. */
  98976. isCompletelyInFrustum(target: ICullable): boolean;
  98977. /**
  98978. * Gets a ray in the forward direction from the camera.
  98979. * @param length Defines the length of the ray to create
  98980. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  98981. * @param origin Defines the start point of the ray which defaults to the camera position
  98982. * @returns the forward ray
  98983. */
  98984. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  98985. /**
  98986. * Releases resources associated with this node.
  98987. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98988. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98989. */
  98990. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98991. /** @hidden */
  98992. _isLeftCamera: boolean;
  98993. /**
  98994. * Gets the left camera of a rig setup in case of Rigged Camera
  98995. */
  98996. get isLeftCamera(): boolean;
  98997. /** @hidden */
  98998. _isRightCamera: boolean;
  98999. /**
  99000. * Gets the right camera of a rig setup in case of Rigged Camera
  99001. */
  99002. get isRightCamera(): boolean;
  99003. /**
  99004. * Gets the left camera of a rig setup in case of Rigged Camera
  99005. */
  99006. get leftCamera(): Nullable<FreeCamera>;
  99007. /**
  99008. * Gets the right camera of a rig setup in case of Rigged Camera
  99009. */
  99010. get rightCamera(): Nullable<FreeCamera>;
  99011. /**
  99012. * Gets the left camera target of a rig setup in case of Rigged Camera
  99013. * @returns the target position
  99014. */
  99015. getLeftTarget(): Nullable<Vector3>;
  99016. /**
  99017. * Gets the right camera target of a rig setup in case of Rigged Camera
  99018. * @returns the target position
  99019. */
  99020. getRightTarget(): Nullable<Vector3>;
  99021. /**
  99022. * @hidden
  99023. */
  99024. setCameraRigMode(mode: number, rigParams: any): void;
  99025. /** @hidden */
  99026. static _setStereoscopicRigMode(camera: Camera): void;
  99027. /** @hidden */
  99028. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  99029. /** @hidden */
  99030. static _setVRRigMode(camera: Camera, rigParams: any): void;
  99031. /** @hidden */
  99032. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  99033. /** @hidden */
  99034. _getVRProjectionMatrix(): Matrix;
  99035. protected _updateCameraRotationMatrix(): void;
  99036. protected _updateWebVRCameraRotationMatrix(): void;
  99037. /**
  99038. * This function MUST be overwritten by the different WebVR cameras available.
  99039. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99040. * @hidden
  99041. */
  99042. _getWebVRProjectionMatrix(): Matrix;
  99043. /**
  99044. * This function MUST be overwritten by the different WebVR cameras available.
  99045. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99046. * @hidden
  99047. */
  99048. _getWebVRViewMatrix(): Matrix;
  99049. /** @hidden */
  99050. setCameraRigParameter(name: string, value: any): void;
  99051. /**
  99052. * needs to be overridden by children so sub has required properties to be copied
  99053. * @hidden
  99054. */
  99055. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99056. /**
  99057. * May need to be overridden by children
  99058. * @hidden
  99059. */
  99060. _updateRigCameras(): void;
  99061. /** @hidden */
  99062. _setupInputs(): void;
  99063. /**
  99064. * Serialiaze the camera setup to a json represention
  99065. * @returns the JSON representation
  99066. */
  99067. serialize(): any;
  99068. /**
  99069. * Clones the current camera.
  99070. * @param name The cloned camera name
  99071. * @returns the cloned camera
  99072. */
  99073. clone(name: string): Camera;
  99074. /**
  99075. * Gets the direction of the camera relative to a given local axis.
  99076. * @param localAxis Defines the reference axis to provide a relative direction.
  99077. * @return the direction
  99078. */
  99079. getDirection(localAxis: Vector3): Vector3;
  99080. /**
  99081. * Returns the current camera absolute rotation
  99082. */
  99083. get absoluteRotation(): Quaternion;
  99084. /**
  99085. * Gets the direction of the camera relative to a given local axis into a passed vector.
  99086. * @param localAxis Defines the reference axis to provide a relative direction.
  99087. * @param result Defines the vector to store the result in
  99088. */
  99089. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  99090. /**
  99091. * Gets a camera constructor for a given camera type
  99092. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  99093. * @param name The name of the camera the result will be able to instantiate
  99094. * @param scene The scene the result will construct the camera in
  99095. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  99096. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  99097. * @returns a factory method to construc the camera
  99098. */
  99099. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  99100. /**
  99101. * Compute the world matrix of the camera.
  99102. * @returns the camera world matrix
  99103. */
  99104. computeWorldMatrix(): Matrix;
  99105. /**
  99106. * Parse a JSON and creates the camera from the parsed information
  99107. * @param parsedCamera The JSON to parse
  99108. * @param scene The scene to instantiate the camera in
  99109. * @returns the newly constructed camera
  99110. */
  99111. static Parse(parsedCamera: any, scene: Scene): Camera;
  99112. }
  99113. }
  99114. declare module BABYLON {
  99115. /**
  99116. * Class containing static functions to help procedurally build meshes
  99117. */
  99118. export class DiscBuilder {
  99119. /**
  99120. * Creates a plane polygonal mesh. By default, this is a disc
  99121. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  99122. * * 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
  99123. * * 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
  99124. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99125. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99126. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99127. * @param name defines the name of the mesh
  99128. * @param options defines the options used to create the mesh
  99129. * @param scene defines the hosting scene
  99130. * @returns the plane polygonal mesh
  99131. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  99132. */
  99133. static CreateDisc(name: string, options: {
  99134. radius?: number;
  99135. tessellation?: number;
  99136. arc?: number;
  99137. updatable?: boolean;
  99138. sideOrientation?: number;
  99139. frontUVs?: Vector4;
  99140. backUVs?: Vector4;
  99141. }, scene?: Nullable<Scene>): Mesh;
  99142. }
  99143. }
  99144. declare module BABYLON {
  99145. /**
  99146. * This represents all the required information to add a fresnel effect on a material:
  99147. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99148. */
  99149. export class FresnelParameters {
  99150. private _isEnabled;
  99151. /**
  99152. * Define if the fresnel effect is enable or not.
  99153. */
  99154. get isEnabled(): boolean;
  99155. set isEnabled(value: boolean);
  99156. /**
  99157. * Define the color used on edges (grazing angle)
  99158. */
  99159. leftColor: Color3;
  99160. /**
  99161. * Define the color used on center
  99162. */
  99163. rightColor: Color3;
  99164. /**
  99165. * Define bias applied to computed fresnel term
  99166. */
  99167. bias: number;
  99168. /**
  99169. * Defined the power exponent applied to fresnel term
  99170. */
  99171. power: number;
  99172. /**
  99173. * Clones the current fresnel and its valuues
  99174. * @returns a clone fresnel configuration
  99175. */
  99176. clone(): FresnelParameters;
  99177. /**
  99178. * Serializes the current fresnel parameters to a JSON representation.
  99179. * @return the JSON serialization
  99180. */
  99181. serialize(): any;
  99182. /**
  99183. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99184. * @param parsedFresnelParameters Define the JSON representation
  99185. * @returns the parsed parameters
  99186. */
  99187. static Parse(parsedFresnelParameters: any): FresnelParameters;
  99188. }
  99189. }
  99190. declare module BABYLON {
  99191. /**
  99192. * Base class of materials working in push mode in babylon JS
  99193. * @hidden
  99194. */
  99195. export class PushMaterial extends Material {
  99196. protected _activeEffect: Effect;
  99197. protected _normalMatrix: Matrix;
  99198. /**
  99199. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  99200. * This means that the material can keep using a previous shader while a new one is being compiled.
  99201. * This is mostly used when shader parallel compilation is supported (true by default)
  99202. */
  99203. allowShaderHotSwapping: boolean;
  99204. constructor(name: string, scene: Scene);
  99205. getEffect(): Effect;
  99206. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99207. /**
  99208. * Binds the given world matrix to the active effect
  99209. *
  99210. * @param world the matrix to bind
  99211. */
  99212. bindOnlyWorldMatrix(world: Matrix): void;
  99213. /**
  99214. * Binds the given normal matrix to the active effect
  99215. *
  99216. * @param normalMatrix the matrix to bind
  99217. */
  99218. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99219. bind(world: Matrix, mesh?: Mesh): void;
  99220. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99221. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99222. }
  99223. }
  99224. declare module BABYLON {
  99225. /**
  99226. * This groups all the flags used to control the materials channel.
  99227. */
  99228. export class MaterialFlags {
  99229. private static _DiffuseTextureEnabled;
  99230. /**
  99231. * Are diffuse textures enabled in the application.
  99232. */
  99233. static get DiffuseTextureEnabled(): boolean;
  99234. static set DiffuseTextureEnabled(value: boolean);
  99235. private static _AmbientTextureEnabled;
  99236. /**
  99237. * Are ambient textures enabled in the application.
  99238. */
  99239. static get AmbientTextureEnabled(): boolean;
  99240. static set AmbientTextureEnabled(value: boolean);
  99241. private static _OpacityTextureEnabled;
  99242. /**
  99243. * Are opacity textures enabled in the application.
  99244. */
  99245. static get OpacityTextureEnabled(): boolean;
  99246. static set OpacityTextureEnabled(value: boolean);
  99247. private static _ReflectionTextureEnabled;
  99248. /**
  99249. * Are reflection textures enabled in the application.
  99250. */
  99251. static get ReflectionTextureEnabled(): boolean;
  99252. static set ReflectionTextureEnabled(value: boolean);
  99253. private static _EmissiveTextureEnabled;
  99254. /**
  99255. * Are emissive textures enabled in the application.
  99256. */
  99257. static get EmissiveTextureEnabled(): boolean;
  99258. static set EmissiveTextureEnabled(value: boolean);
  99259. private static _SpecularTextureEnabled;
  99260. /**
  99261. * Are specular textures enabled in the application.
  99262. */
  99263. static get SpecularTextureEnabled(): boolean;
  99264. static set SpecularTextureEnabled(value: boolean);
  99265. private static _BumpTextureEnabled;
  99266. /**
  99267. * Are bump textures enabled in the application.
  99268. */
  99269. static get BumpTextureEnabled(): boolean;
  99270. static set BumpTextureEnabled(value: boolean);
  99271. private static _LightmapTextureEnabled;
  99272. /**
  99273. * Are lightmap textures enabled in the application.
  99274. */
  99275. static get LightmapTextureEnabled(): boolean;
  99276. static set LightmapTextureEnabled(value: boolean);
  99277. private static _RefractionTextureEnabled;
  99278. /**
  99279. * Are refraction textures enabled in the application.
  99280. */
  99281. static get RefractionTextureEnabled(): boolean;
  99282. static set RefractionTextureEnabled(value: boolean);
  99283. private static _ColorGradingTextureEnabled;
  99284. /**
  99285. * Are color grading textures enabled in the application.
  99286. */
  99287. static get ColorGradingTextureEnabled(): boolean;
  99288. static set ColorGradingTextureEnabled(value: boolean);
  99289. private static _FresnelEnabled;
  99290. /**
  99291. * Are fresnels enabled in the application.
  99292. */
  99293. static get FresnelEnabled(): boolean;
  99294. static set FresnelEnabled(value: boolean);
  99295. private static _ClearCoatTextureEnabled;
  99296. /**
  99297. * Are clear coat textures enabled in the application.
  99298. */
  99299. static get ClearCoatTextureEnabled(): boolean;
  99300. static set ClearCoatTextureEnabled(value: boolean);
  99301. private static _ClearCoatBumpTextureEnabled;
  99302. /**
  99303. * Are clear coat bump textures enabled in the application.
  99304. */
  99305. static get ClearCoatBumpTextureEnabled(): boolean;
  99306. static set ClearCoatBumpTextureEnabled(value: boolean);
  99307. private static _ClearCoatTintTextureEnabled;
  99308. /**
  99309. * Are clear coat tint textures enabled in the application.
  99310. */
  99311. static get ClearCoatTintTextureEnabled(): boolean;
  99312. static set ClearCoatTintTextureEnabled(value: boolean);
  99313. private static _SheenTextureEnabled;
  99314. /**
  99315. * Are sheen textures enabled in the application.
  99316. */
  99317. static get SheenTextureEnabled(): boolean;
  99318. static set SheenTextureEnabled(value: boolean);
  99319. private static _AnisotropicTextureEnabled;
  99320. /**
  99321. * Are anisotropic textures enabled in the application.
  99322. */
  99323. static get AnisotropicTextureEnabled(): boolean;
  99324. static set AnisotropicTextureEnabled(value: boolean);
  99325. private static _ThicknessTextureEnabled;
  99326. /**
  99327. * Are thickness textures enabled in the application.
  99328. */
  99329. static get ThicknessTextureEnabled(): boolean;
  99330. static set ThicknessTextureEnabled(value: boolean);
  99331. }
  99332. }
  99333. declare module BABYLON {
  99334. /** @hidden */
  99335. export var defaultFragmentDeclaration: {
  99336. name: string;
  99337. shader: string;
  99338. };
  99339. }
  99340. declare module BABYLON {
  99341. /** @hidden */
  99342. export var defaultUboDeclaration: {
  99343. name: string;
  99344. shader: string;
  99345. };
  99346. }
  99347. declare module BABYLON {
  99348. /** @hidden */
  99349. export var lightFragmentDeclaration: {
  99350. name: string;
  99351. shader: string;
  99352. };
  99353. }
  99354. declare module BABYLON {
  99355. /** @hidden */
  99356. export var lightUboDeclaration: {
  99357. name: string;
  99358. shader: string;
  99359. };
  99360. }
  99361. declare module BABYLON {
  99362. /** @hidden */
  99363. export var lightsFragmentFunctions: {
  99364. name: string;
  99365. shader: string;
  99366. };
  99367. }
  99368. declare module BABYLON {
  99369. /** @hidden */
  99370. export var shadowsFragmentFunctions: {
  99371. name: string;
  99372. shader: string;
  99373. };
  99374. }
  99375. declare module BABYLON {
  99376. /** @hidden */
  99377. export var fresnelFunction: {
  99378. name: string;
  99379. shader: string;
  99380. };
  99381. }
  99382. declare module BABYLON {
  99383. /** @hidden */
  99384. export var reflectionFunction: {
  99385. name: string;
  99386. shader: string;
  99387. };
  99388. }
  99389. declare module BABYLON {
  99390. /** @hidden */
  99391. export var bumpFragmentFunctions: {
  99392. name: string;
  99393. shader: string;
  99394. };
  99395. }
  99396. declare module BABYLON {
  99397. /** @hidden */
  99398. export var logDepthDeclaration: {
  99399. name: string;
  99400. shader: string;
  99401. };
  99402. }
  99403. declare module BABYLON {
  99404. /** @hidden */
  99405. export var bumpFragment: {
  99406. name: string;
  99407. shader: string;
  99408. };
  99409. }
  99410. declare module BABYLON {
  99411. /** @hidden */
  99412. export var depthPrePass: {
  99413. name: string;
  99414. shader: string;
  99415. };
  99416. }
  99417. declare module BABYLON {
  99418. /** @hidden */
  99419. export var lightFragment: {
  99420. name: string;
  99421. shader: string;
  99422. };
  99423. }
  99424. declare module BABYLON {
  99425. /** @hidden */
  99426. export var logDepthFragment: {
  99427. name: string;
  99428. shader: string;
  99429. };
  99430. }
  99431. declare module BABYLON {
  99432. /** @hidden */
  99433. export var defaultPixelShader: {
  99434. name: string;
  99435. shader: string;
  99436. };
  99437. }
  99438. declare module BABYLON {
  99439. /** @hidden */
  99440. export var defaultVertexDeclaration: {
  99441. name: string;
  99442. shader: string;
  99443. };
  99444. }
  99445. declare module BABYLON {
  99446. /** @hidden */
  99447. export var bumpVertexDeclaration: {
  99448. name: string;
  99449. shader: string;
  99450. };
  99451. }
  99452. declare module BABYLON {
  99453. /** @hidden */
  99454. export var bumpVertex: {
  99455. name: string;
  99456. shader: string;
  99457. };
  99458. }
  99459. declare module BABYLON {
  99460. /** @hidden */
  99461. export var fogVertex: {
  99462. name: string;
  99463. shader: string;
  99464. };
  99465. }
  99466. declare module BABYLON {
  99467. /** @hidden */
  99468. export var shadowsVertex: {
  99469. name: string;
  99470. shader: string;
  99471. };
  99472. }
  99473. declare module BABYLON {
  99474. /** @hidden */
  99475. export var pointCloudVertex: {
  99476. name: string;
  99477. shader: string;
  99478. };
  99479. }
  99480. declare module BABYLON {
  99481. /** @hidden */
  99482. export var logDepthVertex: {
  99483. name: string;
  99484. shader: string;
  99485. };
  99486. }
  99487. declare module BABYLON {
  99488. /** @hidden */
  99489. export var defaultVertexShader: {
  99490. name: string;
  99491. shader: string;
  99492. };
  99493. }
  99494. declare module BABYLON {
  99495. /** @hidden */
  99496. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99497. MAINUV1: boolean;
  99498. MAINUV2: boolean;
  99499. DIFFUSE: boolean;
  99500. DIFFUSEDIRECTUV: number;
  99501. AMBIENT: boolean;
  99502. AMBIENTDIRECTUV: number;
  99503. OPACITY: boolean;
  99504. OPACITYDIRECTUV: number;
  99505. OPACITYRGB: boolean;
  99506. REFLECTION: boolean;
  99507. EMISSIVE: boolean;
  99508. EMISSIVEDIRECTUV: number;
  99509. SPECULAR: boolean;
  99510. SPECULARDIRECTUV: number;
  99511. BUMP: boolean;
  99512. BUMPDIRECTUV: number;
  99513. PARALLAX: boolean;
  99514. PARALLAXOCCLUSION: boolean;
  99515. SPECULAROVERALPHA: boolean;
  99516. CLIPPLANE: boolean;
  99517. CLIPPLANE2: boolean;
  99518. CLIPPLANE3: boolean;
  99519. CLIPPLANE4: boolean;
  99520. CLIPPLANE5: boolean;
  99521. CLIPPLANE6: boolean;
  99522. ALPHATEST: boolean;
  99523. DEPTHPREPASS: boolean;
  99524. ALPHAFROMDIFFUSE: boolean;
  99525. POINTSIZE: boolean;
  99526. FOG: boolean;
  99527. SPECULARTERM: boolean;
  99528. DIFFUSEFRESNEL: boolean;
  99529. OPACITYFRESNEL: boolean;
  99530. REFLECTIONFRESNEL: boolean;
  99531. REFRACTIONFRESNEL: boolean;
  99532. EMISSIVEFRESNEL: boolean;
  99533. FRESNEL: boolean;
  99534. NORMAL: boolean;
  99535. UV1: boolean;
  99536. UV2: boolean;
  99537. VERTEXCOLOR: boolean;
  99538. VERTEXALPHA: boolean;
  99539. NUM_BONE_INFLUENCERS: number;
  99540. BonesPerMesh: number;
  99541. BONETEXTURE: boolean;
  99542. INSTANCES: boolean;
  99543. GLOSSINESS: boolean;
  99544. ROUGHNESS: boolean;
  99545. EMISSIVEASILLUMINATION: boolean;
  99546. LINKEMISSIVEWITHDIFFUSE: boolean;
  99547. REFLECTIONFRESNELFROMSPECULAR: boolean;
  99548. LIGHTMAP: boolean;
  99549. LIGHTMAPDIRECTUV: number;
  99550. OBJECTSPACE_NORMALMAP: boolean;
  99551. USELIGHTMAPASSHADOWMAP: boolean;
  99552. REFLECTIONMAP_3D: boolean;
  99553. REFLECTIONMAP_SPHERICAL: boolean;
  99554. REFLECTIONMAP_PLANAR: boolean;
  99555. REFLECTIONMAP_CUBIC: boolean;
  99556. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  99557. REFLECTIONMAP_PROJECTION: boolean;
  99558. REFLECTIONMAP_SKYBOX: boolean;
  99559. REFLECTIONMAP_EXPLICIT: boolean;
  99560. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  99561. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  99562. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  99563. INVERTCUBICMAP: boolean;
  99564. LOGARITHMICDEPTH: boolean;
  99565. REFRACTION: boolean;
  99566. REFRACTIONMAP_3D: boolean;
  99567. REFLECTIONOVERALPHA: boolean;
  99568. TWOSIDEDLIGHTING: boolean;
  99569. SHADOWFLOAT: boolean;
  99570. MORPHTARGETS: boolean;
  99571. MORPHTARGETS_NORMAL: boolean;
  99572. MORPHTARGETS_TANGENT: boolean;
  99573. MORPHTARGETS_UV: boolean;
  99574. NUM_MORPH_INFLUENCERS: number;
  99575. NONUNIFORMSCALING: boolean;
  99576. PREMULTIPLYALPHA: boolean;
  99577. IMAGEPROCESSING: boolean;
  99578. VIGNETTE: boolean;
  99579. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99580. VIGNETTEBLENDMODEOPAQUE: boolean;
  99581. TONEMAPPING: boolean;
  99582. TONEMAPPING_ACES: boolean;
  99583. CONTRAST: boolean;
  99584. COLORCURVES: boolean;
  99585. COLORGRADING: boolean;
  99586. COLORGRADING3D: boolean;
  99587. SAMPLER3DGREENDEPTH: boolean;
  99588. SAMPLER3DBGRMAP: boolean;
  99589. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99590. MULTIVIEW: boolean;
  99591. /**
  99592. * If the reflection texture on this material is in linear color space
  99593. * @hidden
  99594. */
  99595. IS_REFLECTION_LINEAR: boolean;
  99596. /**
  99597. * If the refraction texture on this material is in linear color space
  99598. * @hidden
  99599. */
  99600. IS_REFRACTION_LINEAR: boolean;
  99601. EXPOSURE: boolean;
  99602. constructor();
  99603. setReflectionMode(modeToEnable: string): void;
  99604. }
  99605. /**
  99606. * This is the default material used in Babylon. It is the best trade off between quality
  99607. * and performances.
  99608. * @see http://doc.babylonjs.com/babylon101/materials
  99609. */
  99610. export class StandardMaterial extends PushMaterial {
  99611. private _diffuseTexture;
  99612. /**
  99613. * The basic texture of the material as viewed under a light.
  99614. */
  99615. diffuseTexture: Nullable<BaseTexture>;
  99616. private _ambientTexture;
  99617. /**
  99618. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  99619. */
  99620. ambientTexture: Nullable<BaseTexture>;
  99621. private _opacityTexture;
  99622. /**
  99623. * Define the transparency of the material from a texture.
  99624. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  99625. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  99626. */
  99627. opacityTexture: Nullable<BaseTexture>;
  99628. private _reflectionTexture;
  99629. /**
  99630. * Define the texture used to display the reflection.
  99631. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99632. */
  99633. reflectionTexture: Nullable<BaseTexture>;
  99634. private _emissiveTexture;
  99635. /**
  99636. * Define texture of the material as if self lit.
  99637. * This will be mixed in the final result even in the absence of light.
  99638. */
  99639. emissiveTexture: Nullable<BaseTexture>;
  99640. private _specularTexture;
  99641. /**
  99642. * Define how the color and intensity of the highlight given by the light in the material.
  99643. */
  99644. specularTexture: Nullable<BaseTexture>;
  99645. private _bumpTexture;
  99646. /**
  99647. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  99648. * 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.
  99649. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  99650. */
  99651. bumpTexture: Nullable<BaseTexture>;
  99652. private _lightmapTexture;
  99653. /**
  99654. * Complex lighting can be computationally expensive to compute at runtime.
  99655. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  99656. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  99657. */
  99658. lightmapTexture: Nullable<BaseTexture>;
  99659. private _refractionTexture;
  99660. /**
  99661. * Define the texture used to display the refraction.
  99662. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99663. */
  99664. refractionTexture: Nullable<BaseTexture>;
  99665. /**
  99666. * The color of the material lit by the environmental background lighting.
  99667. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  99668. */
  99669. ambientColor: Color3;
  99670. /**
  99671. * The basic color of the material as viewed under a light.
  99672. */
  99673. diffuseColor: Color3;
  99674. /**
  99675. * Define how the color and intensity of the highlight given by the light in the material.
  99676. */
  99677. specularColor: Color3;
  99678. /**
  99679. * Define the color of the material as if self lit.
  99680. * This will be mixed in the final result even in the absence of light.
  99681. */
  99682. emissiveColor: Color3;
  99683. /**
  99684. * Defines how sharp are the highlights in the material.
  99685. * The bigger the value the sharper giving a more glossy feeling to the result.
  99686. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  99687. */
  99688. specularPower: number;
  99689. private _useAlphaFromDiffuseTexture;
  99690. /**
  99691. * Does the transparency come from the diffuse texture alpha channel.
  99692. */
  99693. useAlphaFromDiffuseTexture: boolean;
  99694. private _useEmissiveAsIllumination;
  99695. /**
  99696. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  99697. */
  99698. useEmissiveAsIllumination: boolean;
  99699. private _linkEmissiveWithDiffuse;
  99700. /**
  99701. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  99702. * the emissive level when the final color is close to one.
  99703. */
  99704. linkEmissiveWithDiffuse: boolean;
  99705. private _useSpecularOverAlpha;
  99706. /**
  99707. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99708. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99709. */
  99710. useSpecularOverAlpha: boolean;
  99711. private _useReflectionOverAlpha;
  99712. /**
  99713. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99714. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99715. */
  99716. useReflectionOverAlpha: boolean;
  99717. private _disableLighting;
  99718. /**
  99719. * Does lights from the scene impacts this material.
  99720. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  99721. */
  99722. disableLighting: boolean;
  99723. private _useObjectSpaceNormalMap;
  99724. /**
  99725. * Allows using an object space normal map (instead of tangent space).
  99726. */
  99727. useObjectSpaceNormalMap: boolean;
  99728. private _useParallax;
  99729. /**
  99730. * Is parallax enabled or not.
  99731. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99732. */
  99733. useParallax: boolean;
  99734. private _useParallaxOcclusion;
  99735. /**
  99736. * Is parallax occlusion enabled or not.
  99737. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  99738. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99739. */
  99740. useParallaxOcclusion: boolean;
  99741. /**
  99742. * 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.
  99743. */
  99744. parallaxScaleBias: number;
  99745. private _roughness;
  99746. /**
  99747. * Helps to define how blurry the reflections should appears in the material.
  99748. */
  99749. roughness: number;
  99750. /**
  99751. * In case of refraction, define the value of the index of refraction.
  99752. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99753. */
  99754. indexOfRefraction: number;
  99755. /**
  99756. * Invert the refraction texture alongside the y axis.
  99757. * It can be useful with procedural textures or probe for instance.
  99758. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99759. */
  99760. invertRefractionY: boolean;
  99761. /**
  99762. * Defines the alpha limits in alpha test mode.
  99763. */
  99764. alphaCutOff: number;
  99765. private _useLightmapAsShadowmap;
  99766. /**
  99767. * In case of light mapping, define whether the map contains light or shadow informations.
  99768. */
  99769. useLightmapAsShadowmap: boolean;
  99770. private _diffuseFresnelParameters;
  99771. /**
  99772. * Define the diffuse fresnel parameters of the material.
  99773. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99774. */
  99775. diffuseFresnelParameters: FresnelParameters;
  99776. private _opacityFresnelParameters;
  99777. /**
  99778. * Define the opacity fresnel parameters of the material.
  99779. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99780. */
  99781. opacityFresnelParameters: FresnelParameters;
  99782. private _reflectionFresnelParameters;
  99783. /**
  99784. * Define the reflection fresnel parameters of the material.
  99785. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99786. */
  99787. reflectionFresnelParameters: FresnelParameters;
  99788. private _refractionFresnelParameters;
  99789. /**
  99790. * Define the refraction fresnel parameters of the material.
  99791. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99792. */
  99793. refractionFresnelParameters: FresnelParameters;
  99794. private _emissiveFresnelParameters;
  99795. /**
  99796. * Define the emissive fresnel parameters of the material.
  99797. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99798. */
  99799. emissiveFresnelParameters: FresnelParameters;
  99800. private _useReflectionFresnelFromSpecular;
  99801. /**
  99802. * If true automatically deducts the fresnels values from the material specularity.
  99803. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99804. */
  99805. useReflectionFresnelFromSpecular: boolean;
  99806. private _useGlossinessFromSpecularMapAlpha;
  99807. /**
  99808. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  99809. */
  99810. useGlossinessFromSpecularMapAlpha: boolean;
  99811. private _maxSimultaneousLights;
  99812. /**
  99813. * Defines the maximum number of lights that can be used in the material
  99814. */
  99815. maxSimultaneousLights: number;
  99816. private _invertNormalMapX;
  99817. /**
  99818. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99819. */
  99820. invertNormalMapX: boolean;
  99821. private _invertNormalMapY;
  99822. /**
  99823. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99824. */
  99825. invertNormalMapY: boolean;
  99826. private _twoSidedLighting;
  99827. /**
  99828. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99829. */
  99830. twoSidedLighting: boolean;
  99831. /**
  99832. * Default configuration related to image processing available in the standard Material.
  99833. */
  99834. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99835. /**
  99836. * Gets the image processing configuration used either in this material.
  99837. */
  99838. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99839. /**
  99840. * Sets the Default image processing configuration used either in the this material.
  99841. *
  99842. * If sets to null, the scene one is in use.
  99843. */
  99844. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99845. /**
  99846. * Keep track of the image processing observer to allow dispose and replace.
  99847. */
  99848. private _imageProcessingObserver;
  99849. /**
  99850. * Attaches a new image processing configuration to the Standard Material.
  99851. * @param configuration
  99852. */
  99853. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99854. /**
  99855. * Gets wether the color curves effect is enabled.
  99856. */
  99857. get cameraColorCurvesEnabled(): boolean;
  99858. /**
  99859. * Sets wether the color curves effect is enabled.
  99860. */
  99861. set cameraColorCurvesEnabled(value: boolean);
  99862. /**
  99863. * Gets wether the color grading effect is enabled.
  99864. */
  99865. get cameraColorGradingEnabled(): boolean;
  99866. /**
  99867. * Gets wether the color grading effect is enabled.
  99868. */
  99869. set cameraColorGradingEnabled(value: boolean);
  99870. /**
  99871. * Gets wether tonemapping is enabled or not.
  99872. */
  99873. get cameraToneMappingEnabled(): boolean;
  99874. /**
  99875. * Sets wether tonemapping is enabled or not
  99876. */
  99877. set cameraToneMappingEnabled(value: boolean);
  99878. /**
  99879. * The camera exposure used on this material.
  99880. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99881. * This corresponds to a photographic exposure.
  99882. */
  99883. get cameraExposure(): number;
  99884. /**
  99885. * The camera exposure used on this material.
  99886. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99887. * This corresponds to a photographic exposure.
  99888. */
  99889. set cameraExposure(value: number);
  99890. /**
  99891. * Gets The camera contrast used on this material.
  99892. */
  99893. get cameraContrast(): number;
  99894. /**
  99895. * Sets The camera contrast used on this material.
  99896. */
  99897. set cameraContrast(value: number);
  99898. /**
  99899. * Gets the Color Grading 2D Lookup Texture.
  99900. */
  99901. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  99902. /**
  99903. * Sets the Color Grading 2D Lookup Texture.
  99904. */
  99905. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  99906. /**
  99907. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99908. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99909. * 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;
  99910. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99911. */
  99912. get cameraColorCurves(): Nullable<ColorCurves>;
  99913. /**
  99914. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  99915. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  99916. * 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;
  99917. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  99918. */
  99919. set cameraColorCurves(value: Nullable<ColorCurves>);
  99920. /**
  99921. * Custom callback helping to override the default shader used in the material.
  99922. */
  99923. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  99924. protected _renderTargets: SmartArray<RenderTargetTexture>;
  99925. protected _worldViewProjectionMatrix: Matrix;
  99926. protected _globalAmbientColor: Color3;
  99927. protected _useLogarithmicDepth: boolean;
  99928. protected _rebuildInParallel: boolean;
  99929. /**
  99930. * Instantiates a new standard material.
  99931. * This is the default material used in Babylon. It is the best trade off between quality
  99932. * and performances.
  99933. * @see http://doc.babylonjs.com/babylon101/materials
  99934. * @param name Define the name of the material in the scene
  99935. * @param scene Define the scene the material belong to
  99936. */
  99937. constructor(name: string, scene: Scene);
  99938. /**
  99939. * Gets a boolean indicating that current material needs to register RTT
  99940. */
  99941. get hasRenderTargetTextures(): boolean;
  99942. /**
  99943. * Gets the current class name of the material e.g. "StandardMaterial"
  99944. * Mainly use in serialization.
  99945. * @returns the class name
  99946. */
  99947. getClassName(): string;
  99948. /**
  99949. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  99950. * You can try switching to logarithmic depth.
  99951. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  99952. */
  99953. get useLogarithmicDepth(): boolean;
  99954. set useLogarithmicDepth(value: boolean);
  99955. /**
  99956. * Specifies if the material will require alpha blending
  99957. * @returns a boolean specifying if alpha blending is needed
  99958. */
  99959. needAlphaBlending(): boolean;
  99960. /**
  99961. * Specifies if this material should be rendered in alpha test mode
  99962. * @returns a boolean specifying if an alpha test is needed.
  99963. */
  99964. needAlphaTesting(): boolean;
  99965. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  99966. /**
  99967. * Get the texture used for alpha test purpose.
  99968. * @returns the diffuse texture in case of the standard material.
  99969. */
  99970. getAlphaTestTexture(): Nullable<BaseTexture>;
  99971. /**
  99972. * Get if the submesh is ready to be used and all its information available.
  99973. * Child classes can use it to update shaders
  99974. * @param mesh defines the mesh to check
  99975. * @param subMesh defines which submesh to check
  99976. * @param useInstances specifies that instances should be used
  99977. * @returns a boolean indicating that the submesh is ready or not
  99978. */
  99979. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  99980. /**
  99981. * Builds the material UBO layouts.
  99982. * Used internally during the effect preparation.
  99983. */
  99984. buildUniformLayout(): void;
  99985. /**
  99986. * Unbinds the material from the mesh
  99987. */
  99988. unbind(): void;
  99989. /**
  99990. * Binds the submesh to this material by preparing the effect and shader to draw
  99991. * @param world defines the world transformation matrix
  99992. * @param mesh defines the mesh containing the submesh
  99993. * @param subMesh defines the submesh to bind the material to
  99994. */
  99995. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  99996. /**
  99997. * Get the list of animatables in the material.
  99998. * @returns the list of animatables object used in the material
  99999. */
  100000. getAnimatables(): IAnimatable[];
  100001. /**
  100002. * Gets the active textures from the material
  100003. * @returns an array of textures
  100004. */
  100005. getActiveTextures(): BaseTexture[];
  100006. /**
  100007. * Specifies if the material uses a texture
  100008. * @param texture defines the texture to check against the material
  100009. * @returns a boolean specifying if the material uses the texture
  100010. */
  100011. hasTexture(texture: BaseTexture): boolean;
  100012. /**
  100013. * Disposes the material
  100014. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100015. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100016. */
  100017. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100018. /**
  100019. * Makes a duplicate of the material, and gives it a new name
  100020. * @param name defines the new name for the duplicated material
  100021. * @returns the cloned material
  100022. */
  100023. clone(name: string): StandardMaterial;
  100024. /**
  100025. * Serializes this material in a JSON representation
  100026. * @returns the serialized material object
  100027. */
  100028. serialize(): any;
  100029. /**
  100030. * Creates a standard material from parsed material data
  100031. * @param source defines the JSON representation of the material
  100032. * @param scene defines the hosting scene
  100033. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100034. * @returns a new standard material
  100035. */
  100036. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100037. /**
  100038. * Are diffuse textures enabled in the application.
  100039. */
  100040. static get DiffuseTextureEnabled(): boolean;
  100041. static set DiffuseTextureEnabled(value: boolean);
  100042. /**
  100043. * Are ambient textures enabled in the application.
  100044. */
  100045. static get AmbientTextureEnabled(): boolean;
  100046. static set AmbientTextureEnabled(value: boolean);
  100047. /**
  100048. * Are opacity textures enabled in the application.
  100049. */
  100050. static get OpacityTextureEnabled(): boolean;
  100051. static set OpacityTextureEnabled(value: boolean);
  100052. /**
  100053. * Are reflection textures enabled in the application.
  100054. */
  100055. static get ReflectionTextureEnabled(): boolean;
  100056. static set ReflectionTextureEnabled(value: boolean);
  100057. /**
  100058. * Are emissive textures enabled in the application.
  100059. */
  100060. static get EmissiveTextureEnabled(): boolean;
  100061. static set EmissiveTextureEnabled(value: boolean);
  100062. /**
  100063. * Are specular textures enabled in the application.
  100064. */
  100065. static get SpecularTextureEnabled(): boolean;
  100066. static set SpecularTextureEnabled(value: boolean);
  100067. /**
  100068. * Are bump textures enabled in the application.
  100069. */
  100070. static get BumpTextureEnabled(): boolean;
  100071. static set BumpTextureEnabled(value: boolean);
  100072. /**
  100073. * Are lightmap textures enabled in the application.
  100074. */
  100075. static get LightmapTextureEnabled(): boolean;
  100076. static set LightmapTextureEnabled(value: boolean);
  100077. /**
  100078. * Are refraction textures enabled in the application.
  100079. */
  100080. static get RefractionTextureEnabled(): boolean;
  100081. static set RefractionTextureEnabled(value: boolean);
  100082. /**
  100083. * Are color grading textures enabled in the application.
  100084. */
  100085. static get ColorGradingTextureEnabled(): boolean;
  100086. static set ColorGradingTextureEnabled(value: boolean);
  100087. /**
  100088. * Are fresnels enabled in the application.
  100089. */
  100090. static get FresnelEnabled(): boolean;
  100091. static set FresnelEnabled(value: boolean);
  100092. }
  100093. }
  100094. declare module BABYLON {
  100095. /**
  100096. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  100097. *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.
  100098. * The SPS is also a particle system. It provides some methods to manage the particles.
  100099. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  100100. *
  100101. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  100102. */
  100103. export class SolidParticleSystem implements IDisposable {
  100104. /**
  100105. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  100106. * Example : var p = SPS.particles[i];
  100107. */
  100108. particles: SolidParticle[];
  100109. /**
  100110. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  100111. */
  100112. nbParticles: number;
  100113. /**
  100114. * If the particles must ever face the camera (default false). Useful for planar particles.
  100115. */
  100116. billboard: boolean;
  100117. /**
  100118. * Recompute normals when adding a shape
  100119. */
  100120. recomputeNormals: boolean;
  100121. /**
  100122. * This a counter ofr your own usage. It's not set by any SPS functions.
  100123. */
  100124. counter: number;
  100125. /**
  100126. * The SPS name. This name is also given to the underlying mesh.
  100127. */
  100128. name: string;
  100129. /**
  100130. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  100131. */
  100132. mesh: Mesh;
  100133. /**
  100134. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  100135. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  100136. */
  100137. vars: any;
  100138. /**
  100139. * This array is populated when the SPS is set as 'pickable'.
  100140. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  100141. * Each element of this array is an object `{idx: int, faceId: int}`.
  100142. * `idx` is the picked particle index in the `SPS.particles` array
  100143. * `faceId` is the picked face index counted within this particle.
  100144. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  100145. */
  100146. pickedParticles: {
  100147. idx: number;
  100148. faceId: number;
  100149. }[];
  100150. /**
  100151. * This array is populated when `enableDepthSort` is set to true.
  100152. * Each element of this array is an instance of the class DepthSortedParticle.
  100153. */
  100154. depthSortedParticles: DepthSortedParticle[];
  100155. /**
  100156. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  100157. * @hidden
  100158. */
  100159. _bSphereOnly: boolean;
  100160. /**
  100161. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  100162. * @hidden
  100163. */
  100164. _bSphereRadiusFactor: number;
  100165. private _scene;
  100166. private _positions;
  100167. private _indices;
  100168. private _normals;
  100169. private _colors;
  100170. private _uvs;
  100171. private _indices32;
  100172. private _positions32;
  100173. private _normals32;
  100174. private _fixedNormal32;
  100175. private _colors32;
  100176. private _uvs32;
  100177. private _index;
  100178. private _updatable;
  100179. private _pickable;
  100180. private _isVisibilityBoxLocked;
  100181. private _alwaysVisible;
  100182. private _depthSort;
  100183. private _expandable;
  100184. private _shapeCounter;
  100185. private _copy;
  100186. private _color;
  100187. private _computeParticleColor;
  100188. private _computeParticleTexture;
  100189. private _computeParticleRotation;
  100190. private _computeParticleVertex;
  100191. private _computeBoundingBox;
  100192. private _depthSortParticles;
  100193. private _camera;
  100194. private _mustUnrotateFixedNormals;
  100195. private _particlesIntersect;
  100196. private _needs32Bits;
  100197. private _isNotBuilt;
  100198. private _lastParticleId;
  100199. private _idxOfId;
  100200. private _multimaterialEnabled;
  100201. private _useModelMaterial;
  100202. private _indicesByMaterial;
  100203. private _materialIndexes;
  100204. private _depthSortFunction;
  100205. private _materialSortFunction;
  100206. private _materials;
  100207. private _multimaterial;
  100208. private _materialIndexesById;
  100209. private _defaultMaterial;
  100210. private _autoUpdateSubMeshes;
  100211. /**
  100212. * Creates a SPS (Solid Particle System) object.
  100213. * @param name (String) is the SPS name, this will be the underlying mesh name.
  100214. * @param scene (Scene) is the scene in which the SPS is added.
  100215. * @param options defines the options of the sps e.g.
  100216. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  100217. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  100218. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  100219. * * 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.
  100220. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  100221. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  100222. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  100223. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  100224. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  100225. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  100226. */
  100227. constructor(name: string, scene: Scene, options?: {
  100228. updatable?: boolean;
  100229. isPickable?: boolean;
  100230. enableDepthSort?: boolean;
  100231. particleIntersection?: boolean;
  100232. boundingSphereOnly?: boolean;
  100233. bSphereRadiusFactor?: number;
  100234. expandable?: boolean;
  100235. useModelMaterial?: boolean;
  100236. enableMultiMaterial?: boolean;
  100237. });
  100238. /**
  100239. * Builds the SPS underlying mesh. Returns a standard Mesh.
  100240. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  100241. * @returns the created mesh
  100242. */
  100243. buildMesh(): Mesh;
  100244. /**
  100245. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  100246. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  100247. * Thus the particles generated from `digest()` have their property `position` set yet.
  100248. * @param mesh ( Mesh ) is the mesh to be digested
  100249. * @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
  100250. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  100251. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  100252. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100253. * @returns the current SPS
  100254. */
  100255. digest(mesh: Mesh, options?: {
  100256. facetNb?: number;
  100257. number?: number;
  100258. delta?: number;
  100259. storage?: [];
  100260. }): SolidParticleSystem;
  100261. /**
  100262. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  100263. * @hidden
  100264. */
  100265. private _unrotateFixedNormals;
  100266. /**
  100267. * Resets the temporary working copy particle
  100268. * @hidden
  100269. */
  100270. private _resetCopy;
  100271. /**
  100272. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  100273. * @param p the current index in the positions array to be updated
  100274. * @param ind the current index in the indices array
  100275. * @param shape a Vector3 array, the shape geometry
  100276. * @param positions the positions array to be updated
  100277. * @param meshInd the shape indices array
  100278. * @param indices the indices array to be updated
  100279. * @param meshUV the shape uv array
  100280. * @param uvs the uv array to be updated
  100281. * @param meshCol the shape color array
  100282. * @param colors the color array to be updated
  100283. * @param meshNor the shape normals array
  100284. * @param normals the normals array to be updated
  100285. * @param idx the particle index
  100286. * @param idxInShape the particle index in its shape
  100287. * @param options the addShape() method passed options
  100288. * @model the particle model
  100289. * @hidden
  100290. */
  100291. private _meshBuilder;
  100292. /**
  100293. * Returns a shape Vector3 array from positions float array
  100294. * @param positions float array
  100295. * @returns a vector3 array
  100296. * @hidden
  100297. */
  100298. private _posToShape;
  100299. /**
  100300. * Returns a shapeUV array from a float uvs (array deep copy)
  100301. * @param uvs as a float array
  100302. * @returns a shapeUV array
  100303. * @hidden
  100304. */
  100305. private _uvsToShapeUV;
  100306. /**
  100307. * Adds a new particle object in the particles array
  100308. * @param idx particle index in particles array
  100309. * @param id particle id
  100310. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  100311. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  100312. * @param model particle ModelShape object
  100313. * @param shapeId model shape identifier
  100314. * @param idxInShape index of the particle in the current model
  100315. * @param bInfo model bounding info object
  100316. * @param storage target storage array, if any
  100317. * @hidden
  100318. */
  100319. private _addParticle;
  100320. /**
  100321. * Adds some particles to the SPS from the model shape. Returns the shape id.
  100322. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  100323. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  100324. * @param nb (positive integer) the number of particles to be created from this model
  100325. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  100326. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  100327. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100328. * @returns the number of shapes in the system
  100329. */
  100330. addShape(mesh: Mesh, nb: number, options?: {
  100331. positionFunction?: any;
  100332. vertexFunction?: any;
  100333. storage?: [];
  100334. }): number;
  100335. /**
  100336. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  100337. * @hidden
  100338. */
  100339. private _rebuildParticle;
  100340. /**
  100341. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  100342. * @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.
  100343. * @returns the SPS.
  100344. */
  100345. rebuildMesh(reset?: boolean): SolidParticleSystem;
  100346. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  100347. * Returns an array with the removed particles.
  100348. * 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.
  100349. * The SPS can't be empty so at least one particle needs to remain in place.
  100350. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  100351. * @param start index of the first particle to remove
  100352. * @param end index of the last particle to remove (included)
  100353. * @returns an array populated with the removed particles
  100354. */
  100355. removeParticles(start: number, end: number): SolidParticle[];
  100356. /**
  100357. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  100358. * @param solidParticleArray an array populated with Solid Particles objects
  100359. * @returns the SPS
  100360. */
  100361. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  100362. /**
  100363. * Creates a new particle and modifies the SPS mesh geometry :
  100364. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  100365. * - calls _addParticle() to populate the particle array
  100366. * factorized code from addShape() and insertParticlesFromArray()
  100367. * @param idx particle index in the particles array
  100368. * @param i particle index in its shape
  100369. * @param modelShape particle ModelShape object
  100370. * @param shape shape vertex array
  100371. * @param meshInd shape indices array
  100372. * @param meshUV shape uv array
  100373. * @param meshCol shape color array
  100374. * @param meshNor shape normals array
  100375. * @param bbInfo shape bounding info
  100376. * @param storage target particle storage
  100377. * @options addShape() passed options
  100378. * @hidden
  100379. */
  100380. private _insertNewParticle;
  100381. /**
  100382. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  100383. * This method calls `updateParticle()` for each particle of the SPS.
  100384. * For an animated SPS, it is usually called within the render loop.
  100385. * 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.
  100386. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  100387. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  100388. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  100389. * @returns the SPS.
  100390. */
  100391. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  100392. /**
  100393. * Disposes the SPS.
  100394. */
  100395. dispose(): void;
  100396. /**
  100397. * Returns a SolidParticle object from its identifier : particle.id
  100398. * @param id (integer) the particle Id
  100399. * @returns the searched particle or null if not found in the SPS.
  100400. */
  100401. getParticleById(id: number): Nullable<SolidParticle>;
  100402. /**
  100403. * Returns a new array populated with the particles having the passed shapeId.
  100404. * @param shapeId (integer) the shape identifier
  100405. * @returns a new solid particle array
  100406. */
  100407. getParticlesByShapeId(shapeId: number): SolidParticle[];
  100408. /**
  100409. * Populates the passed array "ref" with the particles having the passed shapeId.
  100410. * @param shapeId the shape identifier
  100411. * @returns the SPS
  100412. * @param ref
  100413. */
  100414. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  100415. /**
  100416. * Computes the required SubMeshes according the materials assigned to the particles.
  100417. * @returns the solid particle system.
  100418. * Does nothing if called before the SPS mesh is built.
  100419. */
  100420. computeSubMeshes(): SolidParticleSystem;
  100421. /**
  100422. * Sorts the solid particles by material when MultiMaterial is enabled.
  100423. * Updates the indices32 array.
  100424. * Updates the indicesByMaterial array.
  100425. * Updates the mesh indices array.
  100426. * @returns the SPS
  100427. * @hidden
  100428. */
  100429. private _sortParticlesByMaterial;
  100430. /**
  100431. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  100432. * @hidden
  100433. */
  100434. private _setMaterialIndexesById;
  100435. /**
  100436. * Returns an array with unique values of Materials from the passed array
  100437. * @param array the material array to be checked and filtered
  100438. * @hidden
  100439. */
  100440. private _filterUniqueMaterialId;
  100441. /**
  100442. * Sets a new Standard Material as _defaultMaterial if not already set.
  100443. * @hidden
  100444. */
  100445. private _setDefaultMaterial;
  100446. /**
  100447. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  100448. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100449. * @returns the SPS.
  100450. */
  100451. refreshVisibleSize(): SolidParticleSystem;
  100452. /**
  100453. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  100454. * @param size the size (float) of the visibility box
  100455. * note : this doesn't lock the SPS mesh bounding box.
  100456. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100457. */
  100458. setVisibilityBox(size: number): void;
  100459. /**
  100460. * Gets whether the SPS as always visible or not
  100461. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100462. */
  100463. get isAlwaysVisible(): boolean;
  100464. /**
  100465. * Sets the SPS as always visible or not
  100466. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100467. */
  100468. set isAlwaysVisible(val: boolean);
  100469. /**
  100470. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100471. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100472. */
  100473. set isVisibilityBoxLocked(val: boolean);
  100474. /**
  100475. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100476. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100477. */
  100478. get isVisibilityBoxLocked(): boolean;
  100479. /**
  100480. * Tells to `setParticles()` to compute the particle rotations or not.
  100481. * Default value : true. The SPS is faster when it's set to false.
  100482. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100483. */
  100484. set computeParticleRotation(val: boolean);
  100485. /**
  100486. * Tells to `setParticles()` to compute the particle colors or not.
  100487. * Default value : true. The SPS is faster when it's set to false.
  100488. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100489. */
  100490. set computeParticleColor(val: boolean);
  100491. set computeParticleTexture(val: boolean);
  100492. /**
  100493. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  100494. * Default value : false. The SPS is faster when it's set to false.
  100495. * Note : the particle custom vertex positions aren't stored values.
  100496. */
  100497. set computeParticleVertex(val: boolean);
  100498. /**
  100499. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  100500. */
  100501. set computeBoundingBox(val: boolean);
  100502. /**
  100503. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  100504. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100505. * Default : `true`
  100506. */
  100507. set depthSortParticles(val: boolean);
  100508. /**
  100509. * Gets if `setParticles()` computes the particle rotations or not.
  100510. * Default value : true. The SPS is faster when it's set to false.
  100511. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100512. */
  100513. get computeParticleRotation(): boolean;
  100514. /**
  100515. * Gets if `setParticles()` computes the particle colors or not.
  100516. * Default value : true. The SPS is faster when it's set to false.
  100517. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100518. */
  100519. get computeParticleColor(): boolean;
  100520. /**
  100521. * Gets if `setParticles()` computes the particle textures or not.
  100522. * Default value : true. The SPS is faster when it's set to false.
  100523. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  100524. */
  100525. get computeParticleTexture(): boolean;
  100526. /**
  100527. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  100528. * Default value : false. The SPS is faster when it's set to false.
  100529. * Note : the particle custom vertex positions aren't stored values.
  100530. */
  100531. get computeParticleVertex(): boolean;
  100532. /**
  100533. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  100534. */
  100535. get computeBoundingBox(): boolean;
  100536. /**
  100537. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  100538. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100539. * Default : `true`
  100540. */
  100541. get depthSortParticles(): boolean;
  100542. /**
  100543. * Gets if the SPS is created as expandable at construction time.
  100544. * Default : `false`
  100545. */
  100546. get expandable(): boolean;
  100547. /**
  100548. * Gets if the SPS supports the Multi Materials
  100549. */
  100550. get multimaterialEnabled(): boolean;
  100551. /**
  100552. * Gets if the SPS uses the model materials for its own multimaterial.
  100553. */
  100554. get useModelMaterial(): boolean;
  100555. /**
  100556. * The SPS used material array.
  100557. */
  100558. get materials(): Material[];
  100559. /**
  100560. * Sets the SPS MultiMaterial from the passed materials.
  100561. * Note : the passed array is internally copied and not used then by reference.
  100562. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  100563. */
  100564. setMultiMaterial(materials: Material[]): void;
  100565. /**
  100566. * The SPS computed multimaterial object
  100567. */
  100568. get multimaterial(): MultiMaterial;
  100569. set multimaterial(mm: MultiMaterial);
  100570. /**
  100571. * If the subMeshes must be updated on the next call to setParticles()
  100572. */
  100573. get autoUpdateSubMeshes(): boolean;
  100574. set autoUpdateSubMeshes(val: boolean);
  100575. /**
  100576. * This function does nothing. It may be overwritten to set all the particle first values.
  100577. * The SPS doesn't call this function, you may have to call it by your own.
  100578. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100579. */
  100580. initParticles(): void;
  100581. /**
  100582. * This function does nothing. It may be overwritten to recycle a particle.
  100583. * The SPS doesn't call this function, you may have to call it by your own.
  100584. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100585. * @param particle The particle to recycle
  100586. * @returns the recycled particle
  100587. */
  100588. recycleParticle(particle: SolidParticle): SolidParticle;
  100589. /**
  100590. * Updates a particle : this function should be overwritten by the user.
  100591. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  100592. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100593. * @example : just set a particle position or velocity and recycle conditions
  100594. * @param particle The particle to update
  100595. * @returns the updated particle
  100596. */
  100597. updateParticle(particle: SolidParticle): SolidParticle;
  100598. /**
  100599. * Updates a vertex of a particle : it can be overwritten by the user.
  100600. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  100601. * @param particle the current particle
  100602. * @param vertex the current index of the current particle
  100603. * @param pt the index of the current vertex in the particle shape
  100604. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  100605. * @example : just set a vertex particle position
  100606. * @returns the updated vertex
  100607. */
  100608. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  100609. /**
  100610. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  100611. * This does nothing and may be overwritten by the user.
  100612. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100613. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100614. * @param update the boolean update value actually passed to setParticles()
  100615. */
  100616. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100617. /**
  100618. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  100619. * This will be passed three parameters.
  100620. * This does nothing and may be overwritten by the user.
  100621. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100622. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100623. * @param update the boolean update value actually passed to setParticles()
  100624. */
  100625. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100626. }
  100627. }
  100628. declare module BABYLON {
  100629. /**
  100630. * Represents one particle of a solid particle system.
  100631. */
  100632. export class SolidParticle {
  100633. /**
  100634. * particle global index
  100635. */
  100636. idx: number;
  100637. /**
  100638. * particle identifier
  100639. */
  100640. id: number;
  100641. /**
  100642. * The color of the particle
  100643. */
  100644. color: Nullable<Color4>;
  100645. /**
  100646. * The world space position of the particle.
  100647. */
  100648. position: Vector3;
  100649. /**
  100650. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  100651. */
  100652. rotation: Vector3;
  100653. /**
  100654. * The world space rotation quaternion of the particle.
  100655. */
  100656. rotationQuaternion: Nullable<Quaternion>;
  100657. /**
  100658. * The scaling of the particle.
  100659. */
  100660. scaling: Vector3;
  100661. /**
  100662. * The uvs of the particle.
  100663. */
  100664. uvs: Vector4;
  100665. /**
  100666. * The current speed of the particle.
  100667. */
  100668. velocity: Vector3;
  100669. /**
  100670. * The pivot point in the particle local space.
  100671. */
  100672. pivot: Vector3;
  100673. /**
  100674. * Must the particle be translated from its pivot point in its local space ?
  100675. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  100676. * Default : false
  100677. */
  100678. translateFromPivot: boolean;
  100679. /**
  100680. * Is the particle active or not ?
  100681. */
  100682. alive: boolean;
  100683. /**
  100684. * Is the particle visible or not ?
  100685. */
  100686. isVisible: boolean;
  100687. /**
  100688. * Index of this particle in the global "positions" array (Internal use)
  100689. * @hidden
  100690. */
  100691. _pos: number;
  100692. /**
  100693. * @hidden Index of this particle in the global "indices" array (Internal use)
  100694. */
  100695. _ind: number;
  100696. /**
  100697. * @hidden ModelShape of this particle (Internal use)
  100698. */
  100699. _model: ModelShape;
  100700. /**
  100701. * ModelShape id of this particle
  100702. */
  100703. shapeId: number;
  100704. /**
  100705. * Index of the particle in its shape id
  100706. */
  100707. idxInShape: number;
  100708. /**
  100709. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  100710. */
  100711. _modelBoundingInfo: BoundingInfo;
  100712. /**
  100713. * @hidden Particle BoundingInfo object (Internal use)
  100714. */
  100715. _boundingInfo: BoundingInfo;
  100716. /**
  100717. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  100718. */
  100719. _sps: SolidParticleSystem;
  100720. /**
  100721. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  100722. */
  100723. _stillInvisible: boolean;
  100724. /**
  100725. * @hidden Last computed particle rotation matrix
  100726. */
  100727. _rotationMatrix: number[];
  100728. /**
  100729. * Parent particle Id, if any.
  100730. * Default null.
  100731. */
  100732. parentId: Nullable<number>;
  100733. /**
  100734. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  100735. */
  100736. materialIndex: Nullable<number>;
  100737. /**
  100738. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  100739. * The possible values are :
  100740. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  100741. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100742. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  100743. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  100744. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100745. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  100746. * */
  100747. cullingStrategy: number;
  100748. /**
  100749. * @hidden Internal global position in the SPS.
  100750. */
  100751. _globalPosition: Vector3;
  100752. /**
  100753. * Creates a Solid Particle object.
  100754. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  100755. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  100756. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  100757. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  100758. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  100759. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  100760. * @param shapeId (integer) is the model shape identifier in the SPS.
  100761. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  100762. * @param sps defines the sps it is associated to
  100763. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  100764. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  100765. */
  100766. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  100767. /**
  100768. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  100769. * @param target the particle target
  100770. * @returns the current particle
  100771. */
  100772. copyToRef(target: SolidParticle): SolidParticle;
  100773. /**
  100774. * Legacy support, changed scale to scaling
  100775. */
  100776. get scale(): Vector3;
  100777. /**
  100778. * Legacy support, changed scale to scaling
  100779. */
  100780. set scale(scale: Vector3);
  100781. /**
  100782. * Legacy support, changed quaternion to rotationQuaternion
  100783. */
  100784. get quaternion(): Nullable<Quaternion>;
  100785. /**
  100786. * Legacy support, changed quaternion to rotationQuaternion
  100787. */
  100788. set quaternion(q: Nullable<Quaternion>);
  100789. /**
  100790. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  100791. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  100792. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  100793. * @returns true if it intersects
  100794. */
  100795. intersectsMesh(target: Mesh | SolidParticle): boolean;
  100796. /**
  100797. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  100798. * A particle is in the frustum if its bounding box intersects the frustum
  100799. * @param frustumPlanes defines the frustum to test
  100800. * @returns true if the particle is in the frustum planes
  100801. */
  100802. isInFrustum(frustumPlanes: Plane[]): boolean;
  100803. /**
  100804. * get the rotation matrix of the particle
  100805. * @hidden
  100806. */
  100807. getRotationMatrix(m: Matrix): void;
  100808. }
  100809. /**
  100810. * Represents the shape of the model used by one particle of a solid particle system.
  100811. * SPS internal tool, don't use it manually.
  100812. */
  100813. export class ModelShape {
  100814. /**
  100815. * The shape id
  100816. * @hidden
  100817. */
  100818. shapeID: number;
  100819. /**
  100820. * flat array of model positions (internal use)
  100821. * @hidden
  100822. */
  100823. _shape: Vector3[];
  100824. /**
  100825. * flat array of model UVs (internal use)
  100826. * @hidden
  100827. */
  100828. _shapeUV: number[];
  100829. /**
  100830. * color array of the model
  100831. * @hidden
  100832. */
  100833. _shapeColors: number[];
  100834. /**
  100835. * indices array of the model
  100836. * @hidden
  100837. */
  100838. _indices: number[];
  100839. /**
  100840. * normals array of the model
  100841. * @hidden
  100842. */
  100843. _normals: number[];
  100844. /**
  100845. * length of the shape in the model indices array (internal use)
  100846. * @hidden
  100847. */
  100848. _indicesLength: number;
  100849. /**
  100850. * Custom position function (internal use)
  100851. * @hidden
  100852. */
  100853. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  100854. /**
  100855. * Custom vertex function (internal use)
  100856. * @hidden
  100857. */
  100858. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  100859. /**
  100860. * Model material (internal use)
  100861. * @hidden
  100862. */
  100863. _material: Nullable<Material>;
  100864. /**
  100865. * 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.
  100866. * SPS internal tool, don't use it manually.
  100867. * @hidden
  100868. */
  100869. 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>);
  100870. }
  100871. /**
  100872. * Represents a Depth Sorted Particle in the solid particle system.
  100873. * @hidden
  100874. */
  100875. export class DepthSortedParticle {
  100876. /**
  100877. * Index of the particle in the "indices" array
  100878. */
  100879. ind: number;
  100880. /**
  100881. * Length of the particle shape in the "indices" array
  100882. */
  100883. indicesLength: number;
  100884. /**
  100885. * Squared distance from the particle to the camera
  100886. */
  100887. sqDistance: number;
  100888. /**
  100889. * Material index when used with MultiMaterials
  100890. */
  100891. materialIndex: number;
  100892. /**
  100893. * Creates a new sorted particle
  100894. * @param materialIndex
  100895. */
  100896. constructor(ind: number, indLength: number, materialIndex: number);
  100897. }
  100898. }
  100899. declare module BABYLON {
  100900. /**
  100901. * @hidden
  100902. */
  100903. export class _MeshCollisionData {
  100904. _checkCollisions: boolean;
  100905. _collisionMask: number;
  100906. _collisionGroup: number;
  100907. _collider: Nullable<Collider>;
  100908. _oldPositionForCollisions: Vector3;
  100909. _diffPositionForCollisions: Vector3;
  100910. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  100911. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  100912. }
  100913. }
  100914. declare module BABYLON {
  100915. /** @hidden */
  100916. class _FacetDataStorage {
  100917. facetPositions: Vector3[];
  100918. facetNormals: Vector3[];
  100919. facetPartitioning: number[][];
  100920. facetNb: number;
  100921. partitioningSubdivisions: number;
  100922. partitioningBBoxRatio: number;
  100923. facetDataEnabled: boolean;
  100924. facetParameters: any;
  100925. bbSize: Vector3;
  100926. subDiv: {
  100927. max: number;
  100928. X: number;
  100929. Y: number;
  100930. Z: number;
  100931. };
  100932. facetDepthSort: boolean;
  100933. facetDepthSortEnabled: boolean;
  100934. depthSortedIndices: IndicesArray;
  100935. depthSortedFacets: {
  100936. ind: number;
  100937. sqDistance: number;
  100938. }[];
  100939. facetDepthSortFunction: (f1: {
  100940. ind: number;
  100941. sqDistance: number;
  100942. }, f2: {
  100943. ind: number;
  100944. sqDistance: number;
  100945. }) => number;
  100946. facetDepthSortFrom: Vector3;
  100947. facetDepthSortOrigin: Vector3;
  100948. invertedMatrix: Matrix;
  100949. }
  100950. /**
  100951. * @hidden
  100952. **/
  100953. class _InternalAbstractMeshDataInfo {
  100954. _hasVertexAlpha: boolean;
  100955. _useVertexColors: boolean;
  100956. _numBoneInfluencers: number;
  100957. _applyFog: boolean;
  100958. _receiveShadows: boolean;
  100959. _facetData: _FacetDataStorage;
  100960. _visibility: number;
  100961. _skeleton: Nullable<Skeleton>;
  100962. _layerMask: number;
  100963. _computeBonesUsingShaders: boolean;
  100964. _isActive: boolean;
  100965. _onlyForInstances: boolean;
  100966. _isActiveIntermediate: boolean;
  100967. _onlyForInstancesIntermediate: boolean;
  100968. _actAsRegularMesh: boolean;
  100969. }
  100970. /**
  100971. * Class used to store all common mesh properties
  100972. */
  100973. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  100974. /** No occlusion */
  100975. static OCCLUSION_TYPE_NONE: number;
  100976. /** Occlusion set to optimisitic */
  100977. static OCCLUSION_TYPE_OPTIMISTIC: number;
  100978. /** Occlusion set to strict */
  100979. static OCCLUSION_TYPE_STRICT: number;
  100980. /** Use an accurante occlusion algorithm */
  100981. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  100982. /** Use a conservative occlusion algorithm */
  100983. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  100984. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  100985. * Test order :
  100986. * Is the bounding sphere outside the frustum ?
  100987. * If not, are the bounding box vertices outside the frustum ?
  100988. * It not, then the cullable object is in the frustum.
  100989. */
  100990. static readonly CULLINGSTRATEGY_STANDARD: number;
  100991. /** Culling strategy : Bounding Sphere Only.
  100992. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  100993. * It's also less accurate than the standard because some not visible objects can still be selected.
  100994. * Test : is the bounding sphere outside the frustum ?
  100995. * If not, then the cullable object is in the frustum.
  100996. */
  100997. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  100998. /** Culling strategy : Optimistic Inclusion.
  100999. * This in an inclusion test first, then the standard exclusion test.
  101000. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  101001. * 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.
  101002. * Anyway, it's as accurate as the standard strategy.
  101003. * Test :
  101004. * Is the cullable object bounding sphere center in the frustum ?
  101005. * If not, apply the default culling strategy.
  101006. */
  101007. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  101008. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  101009. * This in an inclusion test first, then the bounding sphere only exclusion test.
  101010. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  101011. * 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.
  101012. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  101013. * Test :
  101014. * Is the cullable object bounding sphere center in the frustum ?
  101015. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  101016. */
  101017. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  101018. /**
  101019. * No billboard
  101020. */
  101021. static get BILLBOARDMODE_NONE(): number;
  101022. /** Billboard on X axis */
  101023. static get BILLBOARDMODE_X(): number;
  101024. /** Billboard on Y axis */
  101025. static get BILLBOARDMODE_Y(): number;
  101026. /** Billboard on Z axis */
  101027. static get BILLBOARDMODE_Z(): number;
  101028. /** Billboard on all axes */
  101029. static get BILLBOARDMODE_ALL(): number;
  101030. /** Billboard on using position instead of orientation */
  101031. static get BILLBOARDMODE_USE_POSITION(): number;
  101032. /** @hidden */
  101033. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  101034. /**
  101035. * The culling strategy to use to check whether the mesh must be rendered or not.
  101036. * This value can be changed at any time and will be used on the next render mesh selection.
  101037. * The possible values are :
  101038. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101039. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101040. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101041. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101042. * Please read each static variable documentation to get details about the culling process.
  101043. * */
  101044. cullingStrategy: number;
  101045. /**
  101046. * Gets the number of facets in the mesh
  101047. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101048. */
  101049. get facetNb(): number;
  101050. /**
  101051. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  101052. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101053. */
  101054. get partitioningSubdivisions(): number;
  101055. set partitioningSubdivisions(nb: number);
  101056. /**
  101057. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  101058. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  101059. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101060. */
  101061. get partitioningBBoxRatio(): number;
  101062. set partitioningBBoxRatio(ratio: number);
  101063. /**
  101064. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  101065. * Works only for updatable meshes.
  101066. * Doesn't work with multi-materials
  101067. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101068. */
  101069. get mustDepthSortFacets(): boolean;
  101070. set mustDepthSortFacets(sort: boolean);
  101071. /**
  101072. * The location (Vector3) where the facet depth sort must be computed from.
  101073. * By default, the active camera position.
  101074. * Used only when facet depth sort is enabled
  101075. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101076. */
  101077. get facetDepthSortFrom(): Vector3;
  101078. set facetDepthSortFrom(location: Vector3);
  101079. /**
  101080. * gets a boolean indicating if facetData is enabled
  101081. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101082. */
  101083. get isFacetDataEnabled(): boolean;
  101084. /** @hidden */
  101085. _updateNonUniformScalingState(value: boolean): boolean;
  101086. /**
  101087. * An event triggered when this mesh collides with another one
  101088. */
  101089. onCollideObservable: Observable<AbstractMesh>;
  101090. /** Set a function to call when this mesh collides with another one */
  101091. set onCollide(callback: () => void);
  101092. /**
  101093. * An event triggered when the collision's position changes
  101094. */
  101095. onCollisionPositionChangeObservable: Observable<Vector3>;
  101096. /** Set a function to call when the collision's position changes */
  101097. set onCollisionPositionChange(callback: () => void);
  101098. /**
  101099. * An event triggered when material is changed
  101100. */
  101101. onMaterialChangedObservable: Observable<AbstractMesh>;
  101102. /**
  101103. * Gets or sets the orientation for POV movement & rotation
  101104. */
  101105. definedFacingForward: boolean;
  101106. /** @hidden */
  101107. _occlusionQuery: Nullable<WebGLQuery>;
  101108. /** @hidden */
  101109. _renderingGroup: Nullable<RenderingGroup>;
  101110. /**
  101111. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101112. */
  101113. get visibility(): number;
  101114. /**
  101115. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101116. */
  101117. set visibility(value: number);
  101118. /** Gets or sets the alpha index used to sort transparent meshes
  101119. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  101120. */
  101121. alphaIndex: number;
  101122. /**
  101123. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  101124. */
  101125. isVisible: boolean;
  101126. /**
  101127. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  101128. */
  101129. isPickable: boolean;
  101130. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  101131. showSubMeshesBoundingBox: boolean;
  101132. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  101133. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101134. */
  101135. isBlocker: boolean;
  101136. /**
  101137. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  101138. */
  101139. enablePointerMoveEvents: boolean;
  101140. /**
  101141. * Specifies the rendering group id for this mesh (0 by default)
  101142. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  101143. */
  101144. renderingGroupId: number;
  101145. private _material;
  101146. /** Gets or sets current material */
  101147. get material(): Nullable<Material>;
  101148. set material(value: Nullable<Material>);
  101149. /**
  101150. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  101151. * @see http://doc.babylonjs.com/babylon101/shadows
  101152. */
  101153. get receiveShadows(): boolean;
  101154. set receiveShadows(value: boolean);
  101155. /** Defines color to use when rendering outline */
  101156. outlineColor: Color3;
  101157. /** Define width to use when rendering outline */
  101158. outlineWidth: number;
  101159. /** Defines color to use when rendering overlay */
  101160. overlayColor: Color3;
  101161. /** Defines alpha to use when rendering overlay */
  101162. overlayAlpha: number;
  101163. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  101164. get hasVertexAlpha(): boolean;
  101165. set hasVertexAlpha(value: boolean);
  101166. /** 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) */
  101167. get useVertexColors(): boolean;
  101168. set useVertexColors(value: boolean);
  101169. /**
  101170. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  101171. */
  101172. get computeBonesUsingShaders(): boolean;
  101173. set computeBonesUsingShaders(value: boolean);
  101174. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  101175. get numBoneInfluencers(): number;
  101176. set numBoneInfluencers(value: number);
  101177. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  101178. get applyFog(): boolean;
  101179. set applyFog(value: boolean);
  101180. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  101181. useOctreeForRenderingSelection: boolean;
  101182. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  101183. useOctreeForPicking: boolean;
  101184. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  101185. useOctreeForCollisions: boolean;
  101186. /**
  101187. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  101188. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  101189. */
  101190. get layerMask(): number;
  101191. set layerMask(value: number);
  101192. /**
  101193. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  101194. */
  101195. alwaysSelectAsActiveMesh: boolean;
  101196. /**
  101197. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  101198. */
  101199. doNotSyncBoundingInfo: boolean;
  101200. /**
  101201. * Gets or sets the current action manager
  101202. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101203. */
  101204. actionManager: Nullable<AbstractActionManager>;
  101205. private _meshCollisionData;
  101206. /**
  101207. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  101208. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101209. */
  101210. ellipsoid: Vector3;
  101211. /**
  101212. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  101213. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101214. */
  101215. ellipsoidOffset: Vector3;
  101216. /**
  101217. * Gets or sets a collision mask used to mask collisions (default is -1).
  101218. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101219. */
  101220. get collisionMask(): number;
  101221. set collisionMask(mask: number);
  101222. /**
  101223. * Gets or sets the current collision group mask (-1 by default).
  101224. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101225. */
  101226. get collisionGroup(): number;
  101227. set collisionGroup(mask: number);
  101228. /**
  101229. * Defines edge width used when edgesRenderer is enabled
  101230. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101231. */
  101232. edgesWidth: number;
  101233. /**
  101234. * Defines edge color used when edgesRenderer is enabled
  101235. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101236. */
  101237. edgesColor: Color4;
  101238. /** @hidden */
  101239. _edgesRenderer: Nullable<IEdgesRenderer>;
  101240. /** @hidden */
  101241. _masterMesh: Nullable<AbstractMesh>;
  101242. /** @hidden */
  101243. _boundingInfo: Nullable<BoundingInfo>;
  101244. /** @hidden */
  101245. _renderId: number;
  101246. /**
  101247. * Gets or sets the list of subMeshes
  101248. * @see http://doc.babylonjs.com/how_to/multi_materials
  101249. */
  101250. subMeshes: SubMesh[];
  101251. /** @hidden */
  101252. _intersectionsInProgress: AbstractMesh[];
  101253. /** @hidden */
  101254. _unIndexed: boolean;
  101255. /** @hidden */
  101256. _lightSources: Light[];
  101257. /** Gets the list of lights affecting that mesh */
  101258. get lightSources(): Light[];
  101259. /** @hidden */
  101260. get _positions(): Nullable<Vector3[]>;
  101261. /** @hidden */
  101262. _waitingData: {
  101263. lods: Nullable<any>;
  101264. actions: Nullable<any>;
  101265. freezeWorldMatrix: Nullable<boolean>;
  101266. };
  101267. /** @hidden */
  101268. _bonesTransformMatrices: Nullable<Float32Array>;
  101269. /** @hidden */
  101270. _transformMatrixTexture: Nullable<RawTexture>;
  101271. /**
  101272. * Gets or sets a skeleton to apply skining transformations
  101273. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101274. */
  101275. set skeleton(value: Nullable<Skeleton>);
  101276. get skeleton(): Nullable<Skeleton>;
  101277. /**
  101278. * An event triggered when the mesh is rebuilt.
  101279. */
  101280. onRebuildObservable: Observable<AbstractMesh>;
  101281. /**
  101282. * Creates a new AbstractMesh
  101283. * @param name defines the name of the mesh
  101284. * @param scene defines the hosting scene
  101285. */
  101286. constructor(name: string, scene?: Nullable<Scene>);
  101287. /**
  101288. * Returns the string "AbstractMesh"
  101289. * @returns "AbstractMesh"
  101290. */
  101291. getClassName(): string;
  101292. /**
  101293. * Gets a string representation of the current mesh
  101294. * @param fullDetails defines a boolean indicating if full details must be included
  101295. * @returns a string representation of the current mesh
  101296. */
  101297. toString(fullDetails?: boolean): string;
  101298. /**
  101299. * @hidden
  101300. */
  101301. protected _getEffectiveParent(): Nullable<Node>;
  101302. /** @hidden */
  101303. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101304. /** @hidden */
  101305. _rebuild(): void;
  101306. /** @hidden */
  101307. _resyncLightSources(): void;
  101308. /** @hidden */
  101309. _resyncLightSource(light: Light): void;
  101310. /** @hidden */
  101311. _unBindEffect(): void;
  101312. /** @hidden */
  101313. _removeLightSource(light: Light, dispose: boolean): void;
  101314. private _markSubMeshesAsDirty;
  101315. /** @hidden */
  101316. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  101317. /** @hidden */
  101318. _markSubMeshesAsAttributesDirty(): void;
  101319. /** @hidden */
  101320. _markSubMeshesAsMiscDirty(): void;
  101321. /**
  101322. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  101323. */
  101324. get scaling(): Vector3;
  101325. set scaling(newScaling: Vector3);
  101326. /**
  101327. * Returns true if the mesh is blocked. Implemented by child classes
  101328. */
  101329. get isBlocked(): boolean;
  101330. /**
  101331. * Returns the mesh itself by default. Implemented by child classes
  101332. * @param camera defines the camera to use to pick the right LOD level
  101333. * @returns the currentAbstractMesh
  101334. */
  101335. getLOD(camera: Camera): Nullable<AbstractMesh>;
  101336. /**
  101337. * Returns 0 by default. Implemented by child classes
  101338. * @returns an integer
  101339. */
  101340. getTotalVertices(): number;
  101341. /**
  101342. * Returns a positive integer : the total number of indices in this mesh geometry.
  101343. * @returns the numner of indices or zero if the mesh has no geometry.
  101344. */
  101345. getTotalIndices(): number;
  101346. /**
  101347. * Returns null by default. Implemented by child classes
  101348. * @returns null
  101349. */
  101350. getIndices(): Nullable<IndicesArray>;
  101351. /**
  101352. * Returns the array of the requested vertex data kind. Implemented by child classes
  101353. * @param kind defines the vertex data kind to use
  101354. * @returns null
  101355. */
  101356. getVerticesData(kind: string): Nullable<FloatArray>;
  101357. /**
  101358. * Sets the vertex data of the mesh geometry for the requested `kind`.
  101359. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  101360. * Note that a new underlying VertexBuffer object is created each call.
  101361. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  101362. * @param kind defines vertex data kind:
  101363. * * VertexBuffer.PositionKind
  101364. * * VertexBuffer.UVKind
  101365. * * VertexBuffer.UV2Kind
  101366. * * VertexBuffer.UV3Kind
  101367. * * VertexBuffer.UV4Kind
  101368. * * VertexBuffer.UV5Kind
  101369. * * VertexBuffer.UV6Kind
  101370. * * VertexBuffer.ColorKind
  101371. * * VertexBuffer.MatricesIndicesKind
  101372. * * VertexBuffer.MatricesIndicesExtraKind
  101373. * * VertexBuffer.MatricesWeightsKind
  101374. * * VertexBuffer.MatricesWeightsExtraKind
  101375. * @param data defines the data source
  101376. * @param updatable defines if the data must be flagged as updatable (or static)
  101377. * @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
  101378. * @returns the current mesh
  101379. */
  101380. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  101381. /**
  101382. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  101383. * If the mesh has no geometry, it is simply returned as it is.
  101384. * @param kind defines vertex data kind:
  101385. * * VertexBuffer.PositionKind
  101386. * * VertexBuffer.UVKind
  101387. * * VertexBuffer.UV2Kind
  101388. * * VertexBuffer.UV3Kind
  101389. * * VertexBuffer.UV4Kind
  101390. * * VertexBuffer.UV5Kind
  101391. * * VertexBuffer.UV6Kind
  101392. * * VertexBuffer.ColorKind
  101393. * * VertexBuffer.MatricesIndicesKind
  101394. * * VertexBuffer.MatricesIndicesExtraKind
  101395. * * VertexBuffer.MatricesWeightsKind
  101396. * * VertexBuffer.MatricesWeightsExtraKind
  101397. * @param data defines the data source
  101398. * @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
  101399. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  101400. * @returns the current mesh
  101401. */
  101402. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  101403. /**
  101404. * Sets the mesh indices,
  101405. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  101406. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  101407. * @param totalVertices Defines the total number of vertices
  101408. * @returns the current mesh
  101409. */
  101410. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  101411. /**
  101412. * Gets a boolean indicating if specific vertex data is present
  101413. * @param kind defines the vertex data kind to use
  101414. * @returns true is data kind is present
  101415. */
  101416. isVerticesDataPresent(kind: string): boolean;
  101417. /**
  101418. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  101419. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  101420. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  101421. * @returns a BoundingInfo
  101422. */
  101423. getBoundingInfo(): BoundingInfo;
  101424. /**
  101425. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  101426. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  101427. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  101428. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  101429. * @returns the current mesh
  101430. */
  101431. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  101432. /**
  101433. * Overwrite the current bounding info
  101434. * @param boundingInfo defines the new bounding info
  101435. * @returns the current mesh
  101436. */
  101437. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  101438. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  101439. get useBones(): boolean;
  101440. /** @hidden */
  101441. _preActivate(): void;
  101442. /** @hidden */
  101443. _preActivateForIntermediateRendering(renderId: number): void;
  101444. /** @hidden */
  101445. _activate(renderId: number, intermediateRendering: boolean): boolean;
  101446. /** @hidden */
  101447. _postActivate(): void;
  101448. /** @hidden */
  101449. _freeze(): void;
  101450. /** @hidden */
  101451. _unFreeze(): void;
  101452. /**
  101453. * Gets the current world matrix
  101454. * @returns a Matrix
  101455. */
  101456. getWorldMatrix(): Matrix;
  101457. /** @hidden */
  101458. _getWorldMatrixDeterminant(): number;
  101459. /**
  101460. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  101461. */
  101462. get isAnInstance(): boolean;
  101463. /**
  101464. * Gets a boolean indicating if this mesh has instances
  101465. */
  101466. get hasInstances(): boolean;
  101467. /**
  101468. * Perform relative position change from the point of view of behind the front of the mesh.
  101469. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101470. * Supports definition of mesh facing forward or backward
  101471. * @param amountRight defines the distance on the right axis
  101472. * @param amountUp defines the distance on the up axis
  101473. * @param amountForward defines the distance on the forward axis
  101474. * @returns the current mesh
  101475. */
  101476. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  101477. /**
  101478. * Calculate relative position change from the point of view of behind the front of the mesh.
  101479. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101480. * Supports definition of mesh facing forward or backward
  101481. * @param amountRight defines the distance on the right axis
  101482. * @param amountUp defines the distance on the up axis
  101483. * @param amountForward defines the distance on the forward axis
  101484. * @returns the new displacement vector
  101485. */
  101486. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  101487. /**
  101488. * Perform relative rotation change from the point of view of behind the front of the mesh.
  101489. * Supports definition of mesh facing forward or backward
  101490. * @param flipBack defines the flip
  101491. * @param twirlClockwise defines the twirl
  101492. * @param tiltRight defines the tilt
  101493. * @returns the current mesh
  101494. */
  101495. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  101496. /**
  101497. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  101498. * Supports definition of mesh facing forward or backward.
  101499. * @param flipBack defines the flip
  101500. * @param twirlClockwise defines the twirl
  101501. * @param tiltRight defines the tilt
  101502. * @returns the new rotation vector
  101503. */
  101504. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  101505. /**
  101506. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  101507. * This means the mesh underlying bounding box and sphere are recomputed.
  101508. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  101509. * @returns the current mesh
  101510. */
  101511. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  101512. /** @hidden */
  101513. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  101514. /** @hidden */
  101515. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  101516. /** @hidden */
  101517. _updateBoundingInfo(): AbstractMesh;
  101518. /** @hidden */
  101519. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  101520. /** @hidden */
  101521. protected _afterComputeWorldMatrix(): void;
  101522. /** @hidden */
  101523. get _effectiveMesh(): AbstractMesh;
  101524. /**
  101525. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101526. * A mesh is in the frustum if its bounding box intersects the frustum
  101527. * @param frustumPlanes defines the frustum to test
  101528. * @returns true if the mesh is in the frustum planes
  101529. */
  101530. isInFrustum(frustumPlanes: Plane[]): boolean;
  101531. /**
  101532. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  101533. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  101534. * @param frustumPlanes defines the frustum to test
  101535. * @returns true if the mesh is completely in the frustum planes
  101536. */
  101537. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101538. /**
  101539. * True if the mesh intersects another mesh or a SolidParticle object
  101540. * @param mesh defines a target mesh or SolidParticle to test
  101541. * @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)
  101542. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  101543. * @returns true if there is an intersection
  101544. */
  101545. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  101546. /**
  101547. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  101548. * @param point defines the point to test
  101549. * @returns true if there is an intersection
  101550. */
  101551. intersectsPoint(point: Vector3): boolean;
  101552. /**
  101553. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  101554. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101555. */
  101556. get checkCollisions(): boolean;
  101557. set checkCollisions(collisionEnabled: boolean);
  101558. /**
  101559. * Gets Collider object used to compute collisions (not physics)
  101560. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101561. */
  101562. get collider(): Nullable<Collider>;
  101563. /**
  101564. * Move the mesh using collision engine
  101565. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101566. * @param displacement defines the requested displacement vector
  101567. * @returns the current mesh
  101568. */
  101569. moveWithCollisions(displacement: Vector3): AbstractMesh;
  101570. private _onCollisionPositionChange;
  101571. /** @hidden */
  101572. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  101573. /** @hidden */
  101574. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  101575. /** @hidden */
  101576. _checkCollision(collider: Collider): AbstractMesh;
  101577. /** @hidden */
  101578. _generatePointsArray(): boolean;
  101579. /**
  101580. * Checks if the passed Ray intersects with the mesh
  101581. * @param ray defines the ray to use
  101582. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  101583. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101584. * @returns the picking info
  101585. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  101586. */
  101587. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  101588. /**
  101589. * Clones the current mesh
  101590. * @param name defines the mesh name
  101591. * @param newParent defines the new mesh parent
  101592. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  101593. * @returns the new mesh
  101594. */
  101595. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  101596. /**
  101597. * Disposes all the submeshes of the current meshnp
  101598. * @returns the current mesh
  101599. */
  101600. releaseSubMeshes(): AbstractMesh;
  101601. /**
  101602. * Releases resources associated with this abstract mesh.
  101603. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101604. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101605. */
  101606. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101607. /**
  101608. * Adds the passed mesh as a child to the current mesh
  101609. * @param mesh defines the child mesh
  101610. * @returns the current mesh
  101611. */
  101612. addChild(mesh: AbstractMesh): AbstractMesh;
  101613. /**
  101614. * Removes the passed mesh from the current mesh children list
  101615. * @param mesh defines the child mesh
  101616. * @returns the current mesh
  101617. */
  101618. removeChild(mesh: AbstractMesh): AbstractMesh;
  101619. /** @hidden */
  101620. private _initFacetData;
  101621. /**
  101622. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  101623. * This method can be called within the render loop.
  101624. * 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
  101625. * @returns the current mesh
  101626. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101627. */
  101628. updateFacetData(): AbstractMesh;
  101629. /**
  101630. * Returns the facetLocalNormals array.
  101631. * The normals are expressed in the mesh local spac
  101632. * @returns an array of Vector3
  101633. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101634. */
  101635. getFacetLocalNormals(): Vector3[];
  101636. /**
  101637. * Returns the facetLocalPositions array.
  101638. * The facet positions are expressed in the mesh local space
  101639. * @returns an array of Vector3
  101640. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101641. */
  101642. getFacetLocalPositions(): Vector3[];
  101643. /**
  101644. * Returns the facetLocalPartioning array
  101645. * @returns an array of array of numbers
  101646. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101647. */
  101648. getFacetLocalPartitioning(): number[][];
  101649. /**
  101650. * Returns the i-th facet position in the world system.
  101651. * This method allocates a new Vector3 per call
  101652. * @param i defines the facet index
  101653. * @returns a new Vector3
  101654. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101655. */
  101656. getFacetPosition(i: number): Vector3;
  101657. /**
  101658. * Sets the reference Vector3 with the i-th facet position in the world system
  101659. * @param i defines the facet index
  101660. * @param ref defines the target vector
  101661. * @returns the current mesh
  101662. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101663. */
  101664. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  101665. /**
  101666. * Returns the i-th facet normal in the world system.
  101667. * This method allocates a new Vector3 per call
  101668. * @param i defines the facet index
  101669. * @returns a new Vector3
  101670. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101671. */
  101672. getFacetNormal(i: number): Vector3;
  101673. /**
  101674. * Sets the reference Vector3 with the i-th facet normal in the world system
  101675. * @param i defines the facet index
  101676. * @param ref defines the target vector
  101677. * @returns the current mesh
  101678. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101679. */
  101680. getFacetNormalToRef(i: number, ref: Vector3): this;
  101681. /**
  101682. * 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)
  101683. * @param x defines x coordinate
  101684. * @param y defines y coordinate
  101685. * @param z defines z coordinate
  101686. * @returns the array of facet indexes
  101687. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101688. */
  101689. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  101690. /**
  101691. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  101692. * @param projected sets as the (x,y,z) world projection on the facet
  101693. * @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
  101694. * @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
  101695. * @param x defines x coordinate
  101696. * @param y defines y coordinate
  101697. * @param z defines z coordinate
  101698. * @returns the face index if found (or null instead)
  101699. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101700. */
  101701. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101702. /**
  101703. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  101704. * @param projected sets as the (x,y,z) local projection on the facet
  101705. * @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
  101706. * @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
  101707. * @param x defines x coordinate
  101708. * @param y defines y coordinate
  101709. * @param z defines z coordinate
  101710. * @returns the face index if found (or null instead)
  101711. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101712. */
  101713. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101714. /**
  101715. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  101716. * @returns the parameters
  101717. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101718. */
  101719. getFacetDataParameters(): any;
  101720. /**
  101721. * Disables the feature FacetData and frees the related memory
  101722. * @returns the current mesh
  101723. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101724. */
  101725. disableFacetData(): AbstractMesh;
  101726. /**
  101727. * Updates the AbstractMesh indices array
  101728. * @param indices defines the data source
  101729. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  101730. * @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)
  101731. * @returns the current mesh
  101732. */
  101733. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  101734. /**
  101735. * Creates new normals data for the mesh
  101736. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  101737. * @returns the current mesh
  101738. */
  101739. createNormals(updatable: boolean): AbstractMesh;
  101740. /**
  101741. * Align the mesh with a normal
  101742. * @param normal defines the normal to use
  101743. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  101744. * @returns the current mesh
  101745. */
  101746. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  101747. /** @hidden */
  101748. _checkOcclusionQuery(): boolean;
  101749. /**
  101750. * Disables the mesh edge rendering mode
  101751. * @returns the currentAbstractMesh
  101752. */
  101753. disableEdgesRendering(): AbstractMesh;
  101754. /**
  101755. * Enables the edge rendering mode on the mesh.
  101756. * This mode makes the mesh edges visible
  101757. * @param epsilon defines the maximal distance between two angles to detect a face
  101758. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  101759. * @returns the currentAbstractMesh
  101760. * @see https://www.babylonjs-playground.com/#19O9TU#0
  101761. */
  101762. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  101763. }
  101764. }
  101765. declare module BABYLON {
  101766. /**
  101767. * Interface used to define ActionEvent
  101768. */
  101769. export interface IActionEvent {
  101770. /** The mesh or sprite that triggered the action */
  101771. source: any;
  101772. /** The X mouse cursor position at the time of the event */
  101773. pointerX: number;
  101774. /** The Y mouse cursor position at the time of the event */
  101775. pointerY: number;
  101776. /** The mesh that is currently pointed at (can be null) */
  101777. meshUnderPointer: Nullable<AbstractMesh>;
  101778. /** the original (browser) event that triggered the ActionEvent */
  101779. sourceEvent?: any;
  101780. /** additional data for the event */
  101781. additionalData?: any;
  101782. }
  101783. /**
  101784. * ActionEvent is the event being sent when an action is triggered.
  101785. */
  101786. export class ActionEvent implements IActionEvent {
  101787. /** The mesh or sprite that triggered the action */
  101788. source: any;
  101789. /** The X mouse cursor position at the time of the event */
  101790. pointerX: number;
  101791. /** The Y mouse cursor position at the time of the event */
  101792. pointerY: number;
  101793. /** The mesh that is currently pointed at (can be null) */
  101794. meshUnderPointer: Nullable<AbstractMesh>;
  101795. /** the original (browser) event that triggered the ActionEvent */
  101796. sourceEvent?: any;
  101797. /** additional data for the event */
  101798. additionalData?: any;
  101799. /**
  101800. * Creates a new ActionEvent
  101801. * @param source The mesh or sprite that triggered the action
  101802. * @param pointerX The X mouse cursor position at the time of the event
  101803. * @param pointerY The Y mouse cursor position at the time of the event
  101804. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  101805. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  101806. * @param additionalData additional data for the event
  101807. */
  101808. constructor(
  101809. /** The mesh or sprite that triggered the action */
  101810. source: any,
  101811. /** The X mouse cursor position at the time of the event */
  101812. pointerX: number,
  101813. /** The Y mouse cursor position at the time of the event */
  101814. pointerY: number,
  101815. /** The mesh that is currently pointed at (can be null) */
  101816. meshUnderPointer: Nullable<AbstractMesh>,
  101817. /** the original (browser) event that triggered the ActionEvent */
  101818. sourceEvent?: any,
  101819. /** additional data for the event */
  101820. additionalData?: any);
  101821. /**
  101822. * Helper function to auto-create an ActionEvent from a source mesh.
  101823. * @param source The source mesh that triggered the event
  101824. * @param evt The original (browser) event
  101825. * @param additionalData additional data for the event
  101826. * @returns the new ActionEvent
  101827. */
  101828. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  101829. /**
  101830. * Helper function to auto-create an ActionEvent from a source sprite
  101831. * @param source The source sprite that triggered the event
  101832. * @param scene Scene associated with the sprite
  101833. * @param evt The original (browser) event
  101834. * @param additionalData additional data for the event
  101835. * @returns the new ActionEvent
  101836. */
  101837. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  101838. /**
  101839. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  101840. * @param scene the scene where the event occurred
  101841. * @param evt The original (browser) event
  101842. * @returns the new ActionEvent
  101843. */
  101844. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  101845. /**
  101846. * Helper function to auto-create an ActionEvent from a primitive
  101847. * @param prim defines the target primitive
  101848. * @param pointerPos defines the pointer position
  101849. * @param evt The original (browser) event
  101850. * @param additionalData additional data for the event
  101851. * @returns the new ActionEvent
  101852. */
  101853. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  101854. }
  101855. }
  101856. declare module BABYLON {
  101857. /**
  101858. * Abstract class used to decouple action Manager from scene and meshes.
  101859. * Do not instantiate.
  101860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101861. */
  101862. export abstract class AbstractActionManager implements IDisposable {
  101863. /** Gets the list of active triggers */
  101864. static Triggers: {
  101865. [key: string]: number;
  101866. };
  101867. /** Gets the cursor to use when hovering items */
  101868. hoverCursor: string;
  101869. /** Gets the list of actions */
  101870. actions: IAction[];
  101871. /**
  101872. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  101873. */
  101874. isRecursive: boolean;
  101875. /**
  101876. * Releases all associated resources
  101877. */
  101878. abstract dispose(): void;
  101879. /**
  101880. * Does this action manager has pointer triggers
  101881. */
  101882. abstract get hasPointerTriggers(): boolean;
  101883. /**
  101884. * Does this action manager has pick triggers
  101885. */
  101886. abstract get hasPickTriggers(): boolean;
  101887. /**
  101888. * Process a specific trigger
  101889. * @param trigger defines the trigger to process
  101890. * @param evt defines the event details to be processed
  101891. */
  101892. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  101893. /**
  101894. * Does this action manager handles actions of any of the given triggers
  101895. * @param triggers defines the triggers to be tested
  101896. * @return a boolean indicating whether one (or more) of the triggers is handled
  101897. */
  101898. abstract hasSpecificTriggers(triggers: number[]): boolean;
  101899. /**
  101900. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  101901. * speed.
  101902. * @param triggerA defines the trigger to be tested
  101903. * @param triggerB defines the trigger to be tested
  101904. * @return a boolean indicating whether one (or more) of the triggers is handled
  101905. */
  101906. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  101907. /**
  101908. * Does this action manager handles actions of a given trigger
  101909. * @param trigger defines the trigger to be tested
  101910. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  101911. * @return whether the trigger is handled
  101912. */
  101913. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  101914. /**
  101915. * Serialize this manager to a JSON object
  101916. * @param name defines the property name to store this manager
  101917. * @returns a JSON representation of this manager
  101918. */
  101919. abstract serialize(name: string): any;
  101920. /**
  101921. * Registers an action to this action manager
  101922. * @param action defines the action to be registered
  101923. * @return the action amended (prepared) after registration
  101924. */
  101925. abstract registerAction(action: IAction): Nullable<IAction>;
  101926. /**
  101927. * Unregisters an action to this action manager
  101928. * @param action defines the action to be unregistered
  101929. * @return a boolean indicating whether the action has been unregistered
  101930. */
  101931. abstract unregisterAction(action: IAction): Boolean;
  101932. /**
  101933. * Does exist one action manager with at least one trigger
  101934. **/
  101935. static get HasTriggers(): boolean;
  101936. /**
  101937. * Does exist one action manager with at least one pick trigger
  101938. **/
  101939. static get HasPickTriggers(): boolean;
  101940. /**
  101941. * Does exist one action manager that handles actions of a given trigger
  101942. * @param trigger defines the trigger to be tested
  101943. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  101944. **/
  101945. static HasSpecificTrigger(trigger: number): boolean;
  101946. }
  101947. }
  101948. declare module BABYLON {
  101949. /**
  101950. * Defines how a node can be built from a string name.
  101951. */
  101952. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  101953. /**
  101954. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  101955. */
  101956. export class Node implements IBehaviorAware<Node> {
  101957. /** @hidden */
  101958. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  101959. private static _NodeConstructors;
  101960. /**
  101961. * Add a new node constructor
  101962. * @param type defines the type name of the node to construct
  101963. * @param constructorFunc defines the constructor function
  101964. */
  101965. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  101966. /**
  101967. * Returns a node constructor based on type name
  101968. * @param type defines the type name
  101969. * @param name defines the new node name
  101970. * @param scene defines the hosting scene
  101971. * @param options defines optional options to transmit to constructors
  101972. * @returns the new constructor or null
  101973. */
  101974. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  101975. /**
  101976. * Gets or sets the name of the node
  101977. */
  101978. name: string;
  101979. /**
  101980. * Gets or sets the id of the node
  101981. */
  101982. id: string;
  101983. /**
  101984. * Gets or sets the unique id of the node
  101985. */
  101986. uniqueId: number;
  101987. /**
  101988. * Gets or sets a string used to store user defined state for the node
  101989. */
  101990. state: string;
  101991. /**
  101992. * Gets or sets an object used to store user defined information for the node
  101993. */
  101994. metadata: any;
  101995. /**
  101996. * For internal use only. Please do not use.
  101997. */
  101998. reservedDataStore: any;
  101999. /**
  102000. * List of inspectable custom properties (used by the Inspector)
  102001. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102002. */
  102003. inspectableCustomProperties: IInspectable[];
  102004. private _doNotSerialize;
  102005. /**
  102006. * Gets or sets a boolean used to define if the node must be serialized
  102007. */
  102008. get doNotSerialize(): boolean;
  102009. set doNotSerialize(value: boolean);
  102010. /** @hidden */
  102011. _isDisposed: boolean;
  102012. /**
  102013. * Gets a list of Animations associated with the node
  102014. */
  102015. animations: Animation[];
  102016. protected _ranges: {
  102017. [name: string]: Nullable<AnimationRange>;
  102018. };
  102019. /**
  102020. * Callback raised when the node is ready to be used
  102021. */
  102022. onReady: Nullable<(node: Node) => void>;
  102023. private _isEnabled;
  102024. private _isParentEnabled;
  102025. private _isReady;
  102026. /** @hidden */
  102027. _currentRenderId: number;
  102028. private _parentUpdateId;
  102029. /** @hidden */
  102030. _childUpdateId: number;
  102031. /** @hidden */
  102032. _waitingParentId: Nullable<string>;
  102033. /** @hidden */
  102034. _scene: Scene;
  102035. /** @hidden */
  102036. _cache: any;
  102037. private _parentNode;
  102038. private _children;
  102039. /** @hidden */
  102040. _worldMatrix: Matrix;
  102041. /** @hidden */
  102042. _worldMatrixDeterminant: number;
  102043. /** @hidden */
  102044. _worldMatrixDeterminantIsDirty: boolean;
  102045. /** @hidden */
  102046. private _sceneRootNodesIndex;
  102047. /**
  102048. * Gets a boolean indicating if the node has been disposed
  102049. * @returns true if the node was disposed
  102050. */
  102051. isDisposed(): boolean;
  102052. /**
  102053. * Gets or sets the parent of the node (without keeping the current position in the scene)
  102054. * @see https://doc.babylonjs.com/how_to/parenting
  102055. */
  102056. set parent(parent: Nullable<Node>);
  102057. get parent(): Nullable<Node>;
  102058. /** @hidden */
  102059. _addToSceneRootNodes(): void;
  102060. /** @hidden */
  102061. _removeFromSceneRootNodes(): void;
  102062. private _animationPropertiesOverride;
  102063. /**
  102064. * Gets or sets the animation properties override
  102065. */
  102066. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102067. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102068. /**
  102069. * Gets a string idenfifying the name of the class
  102070. * @returns "Node" string
  102071. */
  102072. getClassName(): string;
  102073. /** @hidden */
  102074. readonly _isNode: boolean;
  102075. /**
  102076. * An event triggered when the mesh is disposed
  102077. */
  102078. onDisposeObservable: Observable<Node>;
  102079. private _onDisposeObserver;
  102080. /**
  102081. * Sets a callback that will be raised when the node will be disposed
  102082. */
  102083. set onDispose(callback: () => void);
  102084. /**
  102085. * Creates a new Node
  102086. * @param name the name and id to be given to this node
  102087. * @param scene the scene this node will be added to
  102088. */
  102089. constructor(name: string, scene?: Nullable<Scene>);
  102090. /**
  102091. * Gets the scene of the node
  102092. * @returns a scene
  102093. */
  102094. getScene(): Scene;
  102095. /**
  102096. * Gets the engine of the node
  102097. * @returns a Engine
  102098. */
  102099. getEngine(): Engine;
  102100. private _behaviors;
  102101. /**
  102102. * Attach a behavior to the node
  102103. * @see http://doc.babylonjs.com/features/behaviour
  102104. * @param behavior defines the behavior to attach
  102105. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  102106. * @returns the current Node
  102107. */
  102108. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  102109. /**
  102110. * Remove an attached behavior
  102111. * @see http://doc.babylonjs.com/features/behaviour
  102112. * @param behavior defines the behavior to attach
  102113. * @returns the current Node
  102114. */
  102115. removeBehavior(behavior: Behavior<Node>): Node;
  102116. /**
  102117. * Gets the list of attached behaviors
  102118. * @see http://doc.babylonjs.com/features/behaviour
  102119. */
  102120. get behaviors(): Behavior<Node>[];
  102121. /**
  102122. * Gets an attached behavior by name
  102123. * @param name defines the name of the behavior to look for
  102124. * @see http://doc.babylonjs.com/features/behaviour
  102125. * @returns null if behavior was not found else the requested behavior
  102126. */
  102127. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  102128. /**
  102129. * Returns the latest update of the World matrix
  102130. * @returns a Matrix
  102131. */
  102132. getWorldMatrix(): Matrix;
  102133. /** @hidden */
  102134. _getWorldMatrixDeterminant(): number;
  102135. /**
  102136. * Returns directly the latest state of the mesh World matrix.
  102137. * A Matrix is returned.
  102138. */
  102139. get worldMatrixFromCache(): Matrix;
  102140. /** @hidden */
  102141. _initCache(): void;
  102142. /** @hidden */
  102143. updateCache(force?: boolean): void;
  102144. /** @hidden */
  102145. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102146. /** @hidden */
  102147. _updateCache(ignoreParentClass?: boolean): void;
  102148. /** @hidden */
  102149. _isSynchronized(): boolean;
  102150. /** @hidden */
  102151. _markSyncedWithParent(): void;
  102152. /** @hidden */
  102153. isSynchronizedWithParent(): boolean;
  102154. /** @hidden */
  102155. isSynchronized(): boolean;
  102156. /**
  102157. * Is this node ready to be used/rendered
  102158. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  102159. * @return true if the node is ready
  102160. */
  102161. isReady(completeCheck?: boolean): boolean;
  102162. /**
  102163. * Is this node enabled?
  102164. * 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
  102165. * @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
  102166. * @return whether this node (and its parent) is enabled
  102167. */
  102168. isEnabled(checkAncestors?: boolean): boolean;
  102169. /** @hidden */
  102170. protected _syncParentEnabledState(): void;
  102171. /**
  102172. * Set the enabled state of this node
  102173. * @param value defines the new enabled state
  102174. */
  102175. setEnabled(value: boolean): void;
  102176. /**
  102177. * Is this node a descendant of the given node?
  102178. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  102179. * @param ancestor defines the parent node to inspect
  102180. * @returns a boolean indicating if this node is a descendant of the given node
  102181. */
  102182. isDescendantOf(ancestor: Node): boolean;
  102183. /** @hidden */
  102184. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  102185. /**
  102186. * Will return all nodes that have this node as ascendant
  102187. * @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
  102188. * @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
  102189. * @return all children nodes of all types
  102190. */
  102191. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  102192. /**
  102193. * Get all child-meshes of this node
  102194. * @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)
  102195. * @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
  102196. * @returns an array of AbstractMesh
  102197. */
  102198. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  102199. /**
  102200. * Get all direct children of this node
  102201. * @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
  102202. * @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)
  102203. * @returns an array of Node
  102204. */
  102205. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  102206. /** @hidden */
  102207. _setReady(state: boolean): void;
  102208. /**
  102209. * Get an animation by name
  102210. * @param name defines the name of the animation to look for
  102211. * @returns null if not found else the requested animation
  102212. */
  102213. getAnimationByName(name: string): Nullable<Animation>;
  102214. /**
  102215. * Creates an animation range for this node
  102216. * @param name defines the name of the range
  102217. * @param from defines the starting key
  102218. * @param to defines the end key
  102219. */
  102220. createAnimationRange(name: string, from: number, to: number): void;
  102221. /**
  102222. * Delete a specific animation range
  102223. * @param name defines the name of the range to delete
  102224. * @param deleteFrames defines if animation frames from the range must be deleted as well
  102225. */
  102226. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  102227. /**
  102228. * Get an animation range by name
  102229. * @param name defines the name of the animation range to look for
  102230. * @returns null if not found else the requested animation range
  102231. */
  102232. getAnimationRange(name: string): Nullable<AnimationRange>;
  102233. /**
  102234. * Gets the list of all animation ranges defined on this node
  102235. * @returns an array
  102236. */
  102237. getAnimationRanges(): Nullable<AnimationRange>[];
  102238. /**
  102239. * Will start the animation sequence
  102240. * @param name defines the range frames for animation sequence
  102241. * @param loop defines if the animation should loop (false by default)
  102242. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  102243. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  102244. * @returns the object created for this animation. If range does not exist, it will return null
  102245. */
  102246. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  102247. /**
  102248. * Serialize animation ranges into a JSON compatible object
  102249. * @returns serialization object
  102250. */
  102251. serializeAnimationRanges(): any;
  102252. /**
  102253. * Computes the world matrix of the node
  102254. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  102255. * @returns the world matrix
  102256. */
  102257. computeWorldMatrix(force?: boolean): Matrix;
  102258. /**
  102259. * Releases resources associated with this node.
  102260. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102261. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102262. */
  102263. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102264. /**
  102265. * Parse animation range data from a serialization object and store them into a given node
  102266. * @param node defines where to store the animation ranges
  102267. * @param parsedNode defines the serialization object to read data from
  102268. * @param scene defines the hosting scene
  102269. */
  102270. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  102271. /**
  102272. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  102273. * @param includeDescendants Include bounding info from descendants as well (true by default)
  102274. * @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
  102275. * @returns the new bounding vectors
  102276. */
  102277. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  102278. min: Vector3;
  102279. max: Vector3;
  102280. };
  102281. }
  102282. }
  102283. declare module BABYLON {
  102284. /**
  102285. * @hidden
  102286. */
  102287. export class _IAnimationState {
  102288. key: number;
  102289. repeatCount: number;
  102290. workValue?: any;
  102291. loopMode?: number;
  102292. offsetValue?: any;
  102293. highLimitValue?: any;
  102294. }
  102295. /**
  102296. * Class used to store any kind of animation
  102297. */
  102298. export class Animation {
  102299. /**Name of the animation */
  102300. name: string;
  102301. /**Property to animate */
  102302. targetProperty: string;
  102303. /**The frames per second of the animation */
  102304. framePerSecond: number;
  102305. /**The data type of the animation */
  102306. dataType: number;
  102307. /**The loop mode of the animation */
  102308. loopMode?: number | undefined;
  102309. /**Specifies if blending should be enabled */
  102310. enableBlending?: boolean | undefined;
  102311. /**
  102312. * Use matrix interpolation instead of using direct key value when animating matrices
  102313. */
  102314. static AllowMatricesInterpolation: boolean;
  102315. /**
  102316. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  102317. */
  102318. static AllowMatrixDecomposeForInterpolation: boolean;
  102319. /**
  102320. * Stores the key frames of the animation
  102321. */
  102322. private _keys;
  102323. /**
  102324. * Stores the easing function of the animation
  102325. */
  102326. private _easingFunction;
  102327. /**
  102328. * @hidden Internal use only
  102329. */
  102330. _runtimeAnimations: RuntimeAnimation[];
  102331. /**
  102332. * The set of event that will be linked to this animation
  102333. */
  102334. private _events;
  102335. /**
  102336. * Stores an array of target property paths
  102337. */
  102338. targetPropertyPath: string[];
  102339. /**
  102340. * Stores the blending speed of the animation
  102341. */
  102342. blendingSpeed: number;
  102343. /**
  102344. * Stores the animation ranges for the animation
  102345. */
  102346. private _ranges;
  102347. /**
  102348. * @hidden Internal use
  102349. */
  102350. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  102351. /**
  102352. * Sets up an animation
  102353. * @param property The property to animate
  102354. * @param animationType The animation type to apply
  102355. * @param framePerSecond The frames per second of the animation
  102356. * @param easingFunction The easing function used in the animation
  102357. * @returns The created animation
  102358. */
  102359. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  102360. /**
  102361. * Create and start an animation on a node
  102362. * @param name defines the name of the global animation that will be run on all nodes
  102363. * @param node defines the root node where the animation will take place
  102364. * @param targetProperty defines property to animate
  102365. * @param framePerSecond defines the number of frame per second yo use
  102366. * @param totalFrame defines the number of frames in total
  102367. * @param from defines the initial value
  102368. * @param to defines the final value
  102369. * @param loopMode defines which loop mode you want to use (off by default)
  102370. * @param easingFunction defines the easing function to use (linear by default)
  102371. * @param onAnimationEnd defines the callback to call when animation end
  102372. * @returns the animatable created for this animation
  102373. */
  102374. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102375. /**
  102376. * Create and start an animation on a node and its descendants
  102377. * @param name defines the name of the global animation that will be run on all nodes
  102378. * @param node defines the root node where the animation will take place
  102379. * @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
  102380. * @param targetProperty defines property to animate
  102381. * @param framePerSecond defines the number of frame per second to use
  102382. * @param totalFrame defines the number of frames in total
  102383. * @param from defines the initial value
  102384. * @param to defines the final value
  102385. * @param loopMode defines which loop mode you want to use (off by default)
  102386. * @param easingFunction defines the easing function to use (linear by default)
  102387. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  102388. * @returns the list of animatables created for all nodes
  102389. * @example https://www.babylonjs-playground.com/#MH0VLI
  102390. */
  102391. 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[]>;
  102392. /**
  102393. * Creates a new animation, merges it with the existing animations and starts it
  102394. * @param name Name of the animation
  102395. * @param node Node which contains the scene that begins the animations
  102396. * @param targetProperty Specifies which property to animate
  102397. * @param framePerSecond The frames per second of the animation
  102398. * @param totalFrame The total number of frames
  102399. * @param from The frame at the beginning of the animation
  102400. * @param to The frame at the end of the animation
  102401. * @param loopMode Specifies the loop mode of the animation
  102402. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  102403. * @param onAnimationEnd Callback to run once the animation is complete
  102404. * @returns Nullable animation
  102405. */
  102406. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102407. /**
  102408. * Transition property of an host to the target Value
  102409. * @param property The property to transition
  102410. * @param targetValue The target Value of the property
  102411. * @param host The object where the property to animate belongs
  102412. * @param scene Scene used to run the animation
  102413. * @param frameRate Framerate (in frame/s) to use
  102414. * @param transition The transition type we want to use
  102415. * @param duration The duration of the animation, in milliseconds
  102416. * @param onAnimationEnd Callback trigger at the end of the animation
  102417. * @returns Nullable animation
  102418. */
  102419. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  102420. /**
  102421. * Return the array of runtime animations currently using this animation
  102422. */
  102423. get runtimeAnimations(): RuntimeAnimation[];
  102424. /**
  102425. * Specifies if any of the runtime animations are currently running
  102426. */
  102427. get hasRunningRuntimeAnimations(): boolean;
  102428. /**
  102429. * Initializes the animation
  102430. * @param name Name of the animation
  102431. * @param targetProperty Property to animate
  102432. * @param framePerSecond The frames per second of the animation
  102433. * @param dataType The data type of the animation
  102434. * @param loopMode The loop mode of the animation
  102435. * @param enableBlending Specifies if blending should be enabled
  102436. */
  102437. constructor(
  102438. /**Name of the animation */
  102439. name: string,
  102440. /**Property to animate */
  102441. targetProperty: string,
  102442. /**The frames per second of the animation */
  102443. framePerSecond: number,
  102444. /**The data type of the animation */
  102445. dataType: number,
  102446. /**The loop mode of the animation */
  102447. loopMode?: number | undefined,
  102448. /**Specifies if blending should be enabled */
  102449. enableBlending?: boolean | undefined);
  102450. /**
  102451. * Converts the animation to a string
  102452. * @param fullDetails support for multiple levels of logging within scene loading
  102453. * @returns String form of the animation
  102454. */
  102455. toString(fullDetails?: boolean): string;
  102456. /**
  102457. * Add an event to this animation
  102458. * @param event Event to add
  102459. */
  102460. addEvent(event: AnimationEvent): void;
  102461. /**
  102462. * Remove all events found at the given frame
  102463. * @param frame The frame to remove events from
  102464. */
  102465. removeEvents(frame: number): void;
  102466. /**
  102467. * Retrieves all the events from the animation
  102468. * @returns Events from the animation
  102469. */
  102470. getEvents(): AnimationEvent[];
  102471. /**
  102472. * Creates an animation range
  102473. * @param name Name of the animation range
  102474. * @param from Starting frame of the animation range
  102475. * @param to Ending frame of the animation
  102476. */
  102477. createRange(name: string, from: number, to: number): void;
  102478. /**
  102479. * Deletes an animation range by name
  102480. * @param name Name of the animation range to delete
  102481. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  102482. */
  102483. deleteRange(name: string, deleteFrames?: boolean): void;
  102484. /**
  102485. * Gets the animation range by name, or null if not defined
  102486. * @param name Name of the animation range
  102487. * @returns Nullable animation range
  102488. */
  102489. getRange(name: string): Nullable<AnimationRange>;
  102490. /**
  102491. * Gets the key frames from the animation
  102492. * @returns The key frames of the animation
  102493. */
  102494. getKeys(): Array<IAnimationKey>;
  102495. /**
  102496. * Gets the highest frame rate of the animation
  102497. * @returns Highest frame rate of the animation
  102498. */
  102499. getHighestFrame(): number;
  102500. /**
  102501. * Gets the easing function of the animation
  102502. * @returns Easing function of the animation
  102503. */
  102504. getEasingFunction(): IEasingFunction;
  102505. /**
  102506. * Sets the easing function of the animation
  102507. * @param easingFunction A custom mathematical formula for animation
  102508. */
  102509. setEasingFunction(easingFunction: EasingFunction): void;
  102510. /**
  102511. * Interpolates a scalar linearly
  102512. * @param startValue Start value of the animation curve
  102513. * @param endValue End value of the animation curve
  102514. * @param gradient Scalar amount to interpolate
  102515. * @returns Interpolated scalar value
  102516. */
  102517. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  102518. /**
  102519. * Interpolates a scalar cubically
  102520. * @param startValue Start value of the animation curve
  102521. * @param outTangent End tangent of the animation
  102522. * @param endValue End value of the animation curve
  102523. * @param inTangent Start tangent of the animation curve
  102524. * @param gradient Scalar amount to interpolate
  102525. * @returns Interpolated scalar value
  102526. */
  102527. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  102528. /**
  102529. * Interpolates a quaternion using a spherical linear interpolation
  102530. * @param startValue Start value of the animation curve
  102531. * @param endValue End value of the animation curve
  102532. * @param gradient Scalar amount to interpolate
  102533. * @returns Interpolated quaternion value
  102534. */
  102535. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  102536. /**
  102537. * Interpolates a quaternion cubically
  102538. * @param startValue Start value of the animation curve
  102539. * @param outTangent End tangent of the animation curve
  102540. * @param endValue End value of the animation curve
  102541. * @param inTangent Start tangent of the animation curve
  102542. * @param gradient Scalar amount to interpolate
  102543. * @returns Interpolated quaternion value
  102544. */
  102545. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  102546. /**
  102547. * Interpolates a Vector3 linearl
  102548. * @param startValue Start value of the animation curve
  102549. * @param endValue End value of the animation curve
  102550. * @param gradient Scalar amount to interpolate
  102551. * @returns Interpolated scalar value
  102552. */
  102553. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  102554. /**
  102555. * Interpolates a Vector3 cubically
  102556. * @param startValue Start value of the animation curve
  102557. * @param outTangent End tangent of the animation
  102558. * @param endValue End value of the animation curve
  102559. * @param inTangent Start tangent of the animation curve
  102560. * @param gradient Scalar amount to interpolate
  102561. * @returns InterpolatedVector3 value
  102562. */
  102563. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  102564. /**
  102565. * Interpolates a Vector2 linearly
  102566. * @param startValue Start value of the animation curve
  102567. * @param endValue End value of the animation curve
  102568. * @param gradient Scalar amount to interpolate
  102569. * @returns Interpolated Vector2 value
  102570. */
  102571. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  102572. /**
  102573. * Interpolates a Vector2 cubically
  102574. * @param startValue Start value of the animation curve
  102575. * @param outTangent End tangent of the animation
  102576. * @param endValue End value of the animation curve
  102577. * @param inTangent Start tangent of the animation curve
  102578. * @param gradient Scalar amount to interpolate
  102579. * @returns Interpolated Vector2 value
  102580. */
  102581. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  102582. /**
  102583. * Interpolates a size linearly
  102584. * @param startValue Start value of the animation curve
  102585. * @param endValue End value of the animation curve
  102586. * @param gradient Scalar amount to interpolate
  102587. * @returns Interpolated Size value
  102588. */
  102589. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  102590. /**
  102591. * Interpolates a Color3 linearly
  102592. * @param startValue Start value of the animation curve
  102593. * @param endValue End value of the animation curve
  102594. * @param gradient Scalar amount to interpolate
  102595. * @returns Interpolated Color3 value
  102596. */
  102597. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  102598. /**
  102599. * Interpolates a Color4 linearly
  102600. * @param startValue Start value of the animation curve
  102601. * @param endValue End value of the animation curve
  102602. * @param gradient Scalar amount to interpolate
  102603. * @returns Interpolated Color3 value
  102604. */
  102605. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  102606. /**
  102607. * @hidden Internal use only
  102608. */
  102609. _getKeyValue(value: any): any;
  102610. /**
  102611. * @hidden Internal use only
  102612. */
  102613. _interpolate(currentFrame: number, state: _IAnimationState): any;
  102614. /**
  102615. * Defines the function to use to interpolate matrices
  102616. * @param startValue defines the start matrix
  102617. * @param endValue defines the end matrix
  102618. * @param gradient defines the gradient between both matrices
  102619. * @param result defines an optional target matrix where to store the interpolation
  102620. * @returns the interpolated matrix
  102621. */
  102622. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  102623. /**
  102624. * Makes a copy of the animation
  102625. * @returns Cloned animation
  102626. */
  102627. clone(): Animation;
  102628. /**
  102629. * Sets the key frames of the animation
  102630. * @param values The animation key frames to set
  102631. */
  102632. setKeys(values: Array<IAnimationKey>): void;
  102633. /**
  102634. * Serializes the animation to an object
  102635. * @returns Serialized object
  102636. */
  102637. serialize(): any;
  102638. /**
  102639. * Float animation type
  102640. */
  102641. static readonly ANIMATIONTYPE_FLOAT: number;
  102642. /**
  102643. * Vector3 animation type
  102644. */
  102645. static readonly ANIMATIONTYPE_VECTOR3: number;
  102646. /**
  102647. * Quaternion animation type
  102648. */
  102649. static readonly ANIMATIONTYPE_QUATERNION: number;
  102650. /**
  102651. * Matrix animation type
  102652. */
  102653. static readonly ANIMATIONTYPE_MATRIX: number;
  102654. /**
  102655. * Color3 animation type
  102656. */
  102657. static readonly ANIMATIONTYPE_COLOR3: number;
  102658. /**
  102659. * Color3 animation type
  102660. */
  102661. static readonly ANIMATIONTYPE_COLOR4: number;
  102662. /**
  102663. * Vector2 animation type
  102664. */
  102665. static readonly ANIMATIONTYPE_VECTOR2: number;
  102666. /**
  102667. * Size animation type
  102668. */
  102669. static readonly ANIMATIONTYPE_SIZE: number;
  102670. /**
  102671. * Relative Loop Mode
  102672. */
  102673. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  102674. /**
  102675. * Cycle Loop Mode
  102676. */
  102677. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  102678. /**
  102679. * Constant Loop Mode
  102680. */
  102681. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  102682. /** @hidden */
  102683. static _UniversalLerp(left: any, right: any, amount: number): any;
  102684. /**
  102685. * Parses an animation object and creates an animation
  102686. * @param parsedAnimation Parsed animation object
  102687. * @returns Animation object
  102688. */
  102689. static Parse(parsedAnimation: any): Animation;
  102690. /**
  102691. * Appends the serialized animations from the source animations
  102692. * @param source Source containing the animations
  102693. * @param destination Target to store the animations
  102694. */
  102695. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102696. }
  102697. }
  102698. declare module BABYLON {
  102699. /**
  102700. * Interface containing an array of animations
  102701. */
  102702. export interface IAnimatable {
  102703. /**
  102704. * Array of animations
  102705. */
  102706. animations: Nullable<Array<Animation>>;
  102707. }
  102708. }
  102709. declare module BABYLON {
  102710. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  102711. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102712. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102713. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102714. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102715. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102716. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102717. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102718. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102719. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102720. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102721. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102722. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102723. /**
  102724. * Decorator used to define property that can be serialized as reference to a camera
  102725. * @param sourceName defines the name of the property to decorate
  102726. */
  102727. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102728. /**
  102729. * Class used to help serialization objects
  102730. */
  102731. export class SerializationHelper {
  102732. /** @hidden */
  102733. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  102734. /** @hidden */
  102735. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  102736. /** @hidden */
  102737. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  102738. /** @hidden */
  102739. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  102740. /**
  102741. * Appends the serialized animations from the source animations
  102742. * @param source Source containing the animations
  102743. * @param destination Target to store the animations
  102744. */
  102745. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102746. /**
  102747. * Static function used to serialized a specific entity
  102748. * @param entity defines the entity to serialize
  102749. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  102750. * @returns a JSON compatible object representing the serialization of the entity
  102751. */
  102752. static Serialize<T>(entity: T, serializationObject?: any): any;
  102753. /**
  102754. * Creates a new entity from a serialization data object
  102755. * @param creationFunction defines a function used to instanciated the new entity
  102756. * @param source defines the source serialization data
  102757. * @param scene defines the hosting scene
  102758. * @param rootUrl defines the root url for resources
  102759. * @returns a new entity
  102760. */
  102761. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  102762. /**
  102763. * Clones an object
  102764. * @param creationFunction defines the function used to instanciate the new object
  102765. * @param source defines the source object
  102766. * @returns the cloned object
  102767. */
  102768. static Clone<T>(creationFunction: () => T, source: T): T;
  102769. /**
  102770. * Instanciates a new object based on a source one (some data will be shared between both object)
  102771. * @param creationFunction defines the function used to instanciate the new object
  102772. * @param source defines the source object
  102773. * @returns the new object
  102774. */
  102775. static Instanciate<T>(creationFunction: () => T, source: T): T;
  102776. }
  102777. }
  102778. declare module BABYLON {
  102779. /**
  102780. * Class used to manipulate GUIDs
  102781. */
  102782. export class GUID {
  102783. /**
  102784. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102785. * Be aware Math.random() could cause collisions, but:
  102786. * "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"
  102787. * @returns a pseudo random id
  102788. */
  102789. static RandomId(): string;
  102790. }
  102791. }
  102792. declare module BABYLON {
  102793. /**
  102794. * Base class of all the textures in babylon.
  102795. * It groups all the common properties the materials, post process, lights... might need
  102796. * in order to make a correct use of the texture.
  102797. */
  102798. export class BaseTexture implements IAnimatable {
  102799. /**
  102800. * Default anisotropic filtering level for the application.
  102801. * It is set to 4 as a good tradeoff between perf and quality.
  102802. */
  102803. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  102804. /**
  102805. * Gets or sets the unique id of the texture
  102806. */
  102807. uniqueId: number;
  102808. /**
  102809. * Define the name of the texture.
  102810. */
  102811. name: string;
  102812. /**
  102813. * Gets or sets an object used to store user defined information.
  102814. */
  102815. metadata: any;
  102816. /**
  102817. * For internal use only. Please do not use.
  102818. */
  102819. reservedDataStore: any;
  102820. private _hasAlpha;
  102821. /**
  102822. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  102823. */
  102824. set hasAlpha(value: boolean);
  102825. get hasAlpha(): boolean;
  102826. /**
  102827. * Defines if the alpha value should be determined via the rgb values.
  102828. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  102829. */
  102830. getAlphaFromRGB: boolean;
  102831. /**
  102832. * Intensity or strength of the texture.
  102833. * It is commonly used by materials to fine tune the intensity of the texture
  102834. */
  102835. level: number;
  102836. /**
  102837. * Define the UV chanel to use starting from 0 and defaulting to 0.
  102838. * This is part of the texture as textures usually maps to one uv set.
  102839. */
  102840. coordinatesIndex: number;
  102841. private _coordinatesMode;
  102842. /**
  102843. * How a texture is mapped.
  102844. *
  102845. * | Value | Type | Description |
  102846. * | ----- | ----------------------------------- | ----------- |
  102847. * | 0 | EXPLICIT_MODE | |
  102848. * | 1 | SPHERICAL_MODE | |
  102849. * | 2 | PLANAR_MODE | |
  102850. * | 3 | CUBIC_MODE | |
  102851. * | 4 | PROJECTION_MODE | |
  102852. * | 5 | SKYBOX_MODE | |
  102853. * | 6 | INVCUBIC_MODE | |
  102854. * | 7 | EQUIRECTANGULAR_MODE | |
  102855. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  102856. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  102857. */
  102858. set coordinatesMode(value: number);
  102859. get coordinatesMode(): number;
  102860. /**
  102861. * | Value | Type | Description |
  102862. * | ----- | ------------------ | ----------- |
  102863. * | 0 | CLAMP_ADDRESSMODE | |
  102864. * | 1 | WRAP_ADDRESSMODE | |
  102865. * | 2 | MIRROR_ADDRESSMODE | |
  102866. */
  102867. wrapU: number;
  102868. /**
  102869. * | Value | Type | Description |
  102870. * | ----- | ------------------ | ----------- |
  102871. * | 0 | CLAMP_ADDRESSMODE | |
  102872. * | 1 | WRAP_ADDRESSMODE | |
  102873. * | 2 | MIRROR_ADDRESSMODE | |
  102874. */
  102875. wrapV: number;
  102876. /**
  102877. * | Value | Type | Description |
  102878. * | ----- | ------------------ | ----------- |
  102879. * | 0 | CLAMP_ADDRESSMODE | |
  102880. * | 1 | WRAP_ADDRESSMODE | |
  102881. * | 2 | MIRROR_ADDRESSMODE | |
  102882. */
  102883. wrapR: number;
  102884. /**
  102885. * With compliant hardware and browser (supporting anisotropic filtering)
  102886. * this defines the level of anisotropic filtering in the texture.
  102887. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  102888. */
  102889. anisotropicFilteringLevel: number;
  102890. /**
  102891. * Define if the texture is a cube texture or if false a 2d texture.
  102892. */
  102893. get isCube(): boolean;
  102894. set isCube(value: boolean);
  102895. /**
  102896. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  102897. */
  102898. get is3D(): boolean;
  102899. set is3D(value: boolean);
  102900. /**
  102901. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  102902. */
  102903. get is2DArray(): boolean;
  102904. set is2DArray(value: boolean);
  102905. /**
  102906. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  102907. * HDR texture are usually stored in linear space.
  102908. * This only impacts the PBR and Background materials
  102909. */
  102910. gammaSpace: boolean;
  102911. /**
  102912. * Gets or sets whether or not the texture contains RGBD data.
  102913. */
  102914. get isRGBD(): boolean;
  102915. set isRGBD(value: boolean);
  102916. /**
  102917. * Is Z inverted in the texture (useful in a cube texture).
  102918. */
  102919. invertZ: boolean;
  102920. /**
  102921. * Are mip maps generated for this texture or not.
  102922. */
  102923. get noMipmap(): boolean;
  102924. /**
  102925. * @hidden
  102926. */
  102927. lodLevelInAlpha: boolean;
  102928. /**
  102929. * With prefiltered texture, defined the offset used during the prefiltering steps.
  102930. */
  102931. get lodGenerationOffset(): number;
  102932. set lodGenerationOffset(value: number);
  102933. /**
  102934. * With prefiltered texture, defined the scale used during the prefiltering steps.
  102935. */
  102936. get lodGenerationScale(): number;
  102937. set lodGenerationScale(value: number);
  102938. /**
  102939. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  102940. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  102941. * average roughness values.
  102942. */
  102943. get linearSpecularLOD(): boolean;
  102944. set linearSpecularLOD(value: boolean);
  102945. /**
  102946. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  102947. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  102948. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  102949. */
  102950. get irradianceTexture(): Nullable<BaseTexture>;
  102951. set irradianceTexture(value: Nullable<BaseTexture>);
  102952. /**
  102953. * Define if the texture is a render target.
  102954. */
  102955. isRenderTarget: boolean;
  102956. /**
  102957. * Define the unique id of the texture in the scene.
  102958. */
  102959. get uid(): string;
  102960. /**
  102961. * Return a string representation of the texture.
  102962. * @returns the texture as a string
  102963. */
  102964. toString(): string;
  102965. /**
  102966. * Get the class name of the texture.
  102967. * @returns "BaseTexture"
  102968. */
  102969. getClassName(): string;
  102970. /**
  102971. * Define the list of animation attached to the texture.
  102972. */
  102973. animations: Animation[];
  102974. /**
  102975. * An event triggered when the texture is disposed.
  102976. */
  102977. onDisposeObservable: Observable<BaseTexture>;
  102978. private _onDisposeObserver;
  102979. /**
  102980. * Callback triggered when the texture has been disposed.
  102981. * Kept for back compatibility, you can use the onDisposeObservable instead.
  102982. */
  102983. set onDispose(callback: () => void);
  102984. /**
  102985. * Define the current state of the loading sequence when in delayed load mode.
  102986. */
  102987. delayLoadState: number;
  102988. private _scene;
  102989. /** @hidden */
  102990. _texture: Nullable<InternalTexture>;
  102991. private _uid;
  102992. /**
  102993. * Define if the texture is preventinga material to render or not.
  102994. * If not and the texture is not ready, the engine will use a default black texture instead.
  102995. */
  102996. get isBlocking(): boolean;
  102997. /**
  102998. * Instantiates a new BaseTexture.
  102999. * Base class of all the textures in babylon.
  103000. * It groups all the common properties the materials, post process, lights... might need
  103001. * in order to make a correct use of the texture.
  103002. * @param scene Define the scene the texture blongs to
  103003. */
  103004. constructor(scene: Nullable<Scene>);
  103005. /**
  103006. * Get the scene the texture belongs to.
  103007. * @returns the scene or null if undefined
  103008. */
  103009. getScene(): Nullable<Scene>;
  103010. /**
  103011. * Get the texture transform matrix used to offset tile the texture for istance.
  103012. * @returns the transformation matrix
  103013. */
  103014. getTextureMatrix(): Matrix;
  103015. /**
  103016. * Get the texture reflection matrix used to rotate/transform the reflection.
  103017. * @returns the reflection matrix
  103018. */
  103019. getReflectionTextureMatrix(): Matrix;
  103020. /**
  103021. * Get the underlying lower level texture from Babylon.
  103022. * @returns the insternal texture
  103023. */
  103024. getInternalTexture(): Nullable<InternalTexture>;
  103025. /**
  103026. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  103027. * @returns true if ready or not blocking
  103028. */
  103029. isReadyOrNotBlocking(): boolean;
  103030. /**
  103031. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  103032. * @returns true if fully ready
  103033. */
  103034. isReady(): boolean;
  103035. private _cachedSize;
  103036. /**
  103037. * Get the size of the texture.
  103038. * @returns the texture size.
  103039. */
  103040. getSize(): ISize;
  103041. /**
  103042. * Get the base size of the texture.
  103043. * It can be different from the size if the texture has been resized for POT for instance
  103044. * @returns the base size
  103045. */
  103046. getBaseSize(): ISize;
  103047. /**
  103048. * Update the sampling mode of the texture.
  103049. * Default is Trilinear mode.
  103050. *
  103051. * | Value | Type | Description |
  103052. * | ----- | ------------------ | ----------- |
  103053. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  103054. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  103055. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  103056. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  103057. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  103058. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  103059. * | 7 | NEAREST_LINEAR | |
  103060. * | 8 | NEAREST_NEAREST | |
  103061. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  103062. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  103063. * | 11 | LINEAR_LINEAR | |
  103064. * | 12 | LINEAR_NEAREST | |
  103065. *
  103066. * > _mag_: magnification filter (close to the viewer)
  103067. * > _min_: minification filter (far from the viewer)
  103068. * > _mip_: filter used between mip map levels
  103069. *@param samplingMode Define the new sampling mode of the texture
  103070. */
  103071. updateSamplingMode(samplingMode: number): void;
  103072. /**
  103073. * Scales the texture if is `canRescale()`
  103074. * @param ratio the resize factor we want to use to rescale
  103075. */
  103076. scale(ratio: number): void;
  103077. /**
  103078. * Get if the texture can rescale.
  103079. */
  103080. get canRescale(): boolean;
  103081. /** @hidden */
  103082. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  103083. /** @hidden */
  103084. _rebuild(): void;
  103085. /**
  103086. * Triggers the load sequence in delayed load mode.
  103087. */
  103088. delayLoad(): void;
  103089. /**
  103090. * Clones the texture.
  103091. * @returns the cloned texture
  103092. */
  103093. clone(): Nullable<BaseTexture>;
  103094. /**
  103095. * Get the texture underlying type (INT, FLOAT...)
  103096. */
  103097. get textureType(): number;
  103098. /**
  103099. * Get the texture underlying format (RGB, RGBA...)
  103100. */
  103101. get textureFormat(): number;
  103102. /**
  103103. * Indicates that textures need to be re-calculated for all materials
  103104. */
  103105. protected _markAllSubMeshesAsTexturesDirty(): void;
  103106. /**
  103107. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  103108. * This will returns an RGBA array buffer containing either in values (0-255) or
  103109. * float values (0-1) depending of the underlying buffer type.
  103110. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  103111. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  103112. * @param buffer defines a user defined buffer to fill with data (can be null)
  103113. * @returns The Array buffer containing the pixels data.
  103114. */
  103115. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  103116. /**
  103117. * Release and destroy the underlying lower level texture aka internalTexture.
  103118. */
  103119. releaseInternalTexture(): void;
  103120. /** @hidden */
  103121. get _lodTextureHigh(): Nullable<BaseTexture>;
  103122. /** @hidden */
  103123. get _lodTextureMid(): Nullable<BaseTexture>;
  103124. /** @hidden */
  103125. get _lodTextureLow(): Nullable<BaseTexture>;
  103126. /**
  103127. * Dispose the texture and release its associated resources.
  103128. */
  103129. dispose(): void;
  103130. /**
  103131. * Serialize the texture into a JSON representation that can be parsed later on.
  103132. * @returns the JSON representation of the texture
  103133. */
  103134. serialize(): any;
  103135. /**
  103136. * Helper function to be called back once a list of texture contains only ready textures.
  103137. * @param textures Define the list of textures to wait for
  103138. * @param callback Define the callback triggered once the entire list will be ready
  103139. */
  103140. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  103141. }
  103142. }
  103143. declare module BABYLON {
  103144. /**
  103145. * Options to be used when creating an effect.
  103146. */
  103147. export interface IEffectCreationOptions {
  103148. /**
  103149. * Atrributes that will be used in the shader.
  103150. */
  103151. attributes: string[];
  103152. /**
  103153. * Uniform varible names that will be set in the shader.
  103154. */
  103155. uniformsNames: string[];
  103156. /**
  103157. * Uniform buffer variable names that will be set in the shader.
  103158. */
  103159. uniformBuffersNames: string[];
  103160. /**
  103161. * Sampler texture variable names that will be set in the shader.
  103162. */
  103163. samplers: string[];
  103164. /**
  103165. * Define statements that will be set in the shader.
  103166. */
  103167. defines: any;
  103168. /**
  103169. * Possible fallbacks for this effect to improve performance when needed.
  103170. */
  103171. fallbacks: Nullable<IEffectFallbacks>;
  103172. /**
  103173. * Callback that will be called when the shader is compiled.
  103174. */
  103175. onCompiled: Nullable<(effect: Effect) => void>;
  103176. /**
  103177. * Callback that will be called if an error occurs during shader compilation.
  103178. */
  103179. onError: Nullable<(effect: Effect, errors: string) => void>;
  103180. /**
  103181. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103182. */
  103183. indexParameters?: any;
  103184. /**
  103185. * Max number of lights that can be used in the shader.
  103186. */
  103187. maxSimultaneousLights?: number;
  103188. /**
  103189. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  103190. */
  103191. transformFeedbackVaryings?: Nullable<string[]>;
  103192. }
  103193. /**
  103194. * Effect containing vertex and fragment shader that can be executed on an object.
  103195. */
  103196. export class Effect implements IDisposable {
  103197. /**
  103198. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103199. */
  103200. static ShadersRepository: string;
  103201. /**
  103202. * Name of the effect.
  103203. */
  103204. name: any;
  103205. /**
  103206. * String container all the define statements that should be set on the shader.
  103207. */
  103208. defines: string;
  103209. /**
  103210. * Callback that will be called when the shader is compiled.
  103211. */
  103212. onCompiled: Nullable<(effect: Effect) => void>;
  103213. /**
  103214. * Callback that will be called if an error occurs during shader compilation.
  103215. */
  103216. onError: Nullable<(effect: Effect, errors: string) => void>;
  103217. /**
  103218. * Callback that will be called when effect is bound.
  103219. */
  103220. onBind: Nullable<(effect: Effect) => void>;
  103221. /**
  103222. * Unique ID of the effect.
  103223. */
  103224. uniqueId: number;
  103225. /**
  103226. * Observable that will be called when the shader is compiled.
  103227. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  103228. */
  103229. onCompileObservable: Observable<Effect>;
  103230. /**
  103231. * Observable that will be called if an error occurs during shader compilation.
  103232. */
  103233. onErrorObservable: Observable<Effect>;
  103234. /** @hidden */
  103235. _onBindObservable: Nullable<Observable<Effect>>;
  103236. /**
  103237. * @hidden
  103238. * Specifies if the effect was previously ready
  103239. */
  103240. _wasPreviouslyReady: boolean;
  103241. /**
  103242. * Observable that will be called when effect is bound.
  103243. */
  103244. get onBindObservable(): Observable<Effect>;
  103245. /** @hidden */
  103246. _bonesComputationForcedToCPU: boolean;
  103247. private static _uniqueIdSeed;
  103248. private _engine;
  103249. private _uniformBuffersNames;
  103250. private _uniformsNames;
  103251. private _samplerList;
  103252. private _samplers;
  103253. private _isReady;
  103254. private _compilationError;
  103255. private _allFallbacksProcessed;
  103256. private _attributesNames;
  103257. private _attributes;
  103258. private _attributeLocationByName;
  103259. private _uniforms;
  103260. /**
  103261. * Key for the effect.
  103262. * @hidden
  103263. */
  103264. _key: string;
  103265. private _indexParameters;
  103266. private _fallbacks;
  103267. private _vertexSourceCode;
  103268. private _fragmentSourceCode;
  103269. private _vertexSourceCodeOverride;
  103270. private _fragmentSourceCodeOverride;
  103271. private _transformFeedbackVaryings;
  103272. /**
  103273. * Compiled shader to webGL program.
  103274. * @hidden
  103275. */
  103276. _pipelineContext: Nullable<IPipelineContext>;
  103277. private _valueCache;
  103278. private static _baseCache;
  103279. /**
  103280. * Instantiates an effect.
  103281. * An effect can be used to create/manage/execute vertex and fragment shaders.
  103282. * @param baseName Name of the effect.
  103283. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  103284. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  103285. * @param samplers List of sampler variables that will be passed to the shader.
  103286. * @param engine Engine to be used to render the effect
  103287. * @param defines Define statements to be added to the shader.
  103288. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  103289. * @param onCompiled Callback that will be called when the shader is compiled.
  103290. * @param onError Callback that will be called if an error occurs during shader compilation.
  103291. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103292. */
  103293. 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);
  103294. private _useFinalCode;
  103295. /**
  103296. * Unique key for this effect
  103297. */
  103298. get key(): string;
  103299. /**
  103300. * If the effect has been compiled and prepared.
  103301. * @returns if the effect is compiled and prepared.
  103302. */
  103303. isReady(): boolean;
  103304. private _isReadyInternal;
  103305. /**
  103306. * The engine the effect was initialized with.
  103307. * @returns the engine.
  103308. */
  103309. getEngine(): Engine;
  103310. /**
  103311. * The pipeline context for this effect
  103312. * @returns the associated pipeline context
  103313. */
  103314. getPipelineContext(): Nullable<IPipelineContext>;
  103315. /**
  103316. * The set of names of attribute variables for the shader.
  103317. * @returns An array of attribute names.
  103318. */
  103319. getAttributesNames(): string[];
  103320. /**
  103321. * Returns the attribute at the given index.
  103322. * @param index The index of the attribute.
  103323. * @returns The location of the attribute.
  103324. */
  103325. getAttributeLocation(index: number): number;
  103326. /**
  103327. * Returns the attribute based on the name of the variable.
  103328. * @param name of the attribute to look up.
  103329. * @returns the attribute location.
  103330. */
  103331. getAttributeLocationByName(name: string): number;
  103332. /**
  103333. * The number of attributes.
  103334. * @returns the numnber of attributes.
  103335. */
  103336. getAttributesCount(): number;
  103337. /**
  103338. * Gets the index of a uniform variable.
  103339. * @param uniformName of the uniform to look up.
  103340. * @returns the index.
  103341. */
  103342. getUniformIndex(uniformName: string): number;
  103343. /**
  103344. * Returns the attribute based on the name of the variable.
  103345. * @param uniformName of the uniform to look up.
  103346. * @returns the location of the uniform.
  103347. */
  103348. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  103349. /**
  103350. * Returns an array of sampler variable names
  103351. * @returns The array of sampler variable neames.
  103352. */
  103353. getSamplers(): string[];
  103354. /**
  103355. * The error from the last compilation.
  103356. * @returns the error string.
  103357. */
  103358. getCompilationError(): string;
  103359. /**
  103360. * Gets a boolean indicating that all fallbacks were used during compilation
  103361. * @returns true if all fallbacks were used
  103362. */
  103363. allFallbacksProcessed(): boolean;
  103364. /**
  103365. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  103366. * @param func The callback to be used.
  103367. */
  103368. executeWhenCompiled(func: (effect: Effect) => void): void;
  103369. private _checkIsReady;
  103370. private _loadShader;
  103371. /**
  103372. * Recompiles the webGL program
  103373. * @param vertexSourceCode The source code for the vertex shader.
  103374. * @param fragmentSourceCode The source code for the fragment shader.
  103375. * @param onCompiled Callback called when completed.
  103376. * @param onError Callback called on error.
  103377. * @hidden
  103378. */
  103379. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  103380. /**
  103381. * Prepares the effect
  103382. * @hidden
  103383. */
  103384. _prepareEffect(): void;
  103385. private _processCompilationErrors;
  103386. /**
  103387. * Checks if the effect is supported. (Must be called after compilation)
  103388. */
  103389. get isSupported(): boolean;
  103390. /**
  103391. * Binds a texture to the engine to be used as output of the shader.
  103392. * @param channel Name of the output variable.
  103393. * @param texture Texture to bind.
  103394. * @hidden
  103395. */
  103396. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  103397. /**
  103398. * Sets a texture on the engine to be used in the shader.
  103399. * @param channel Name of the sampler variable.
  103400. * @param texture Texture to set.
  103401. */
  103402. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  103403. /**
  103404. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  103405. * @param channel Name of the sampler variable.
  103406. * @param texture Texture to set.
  103407. */
  103408. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  103409. /**
  103410. * Sets an array of textures on the engine to be used in the shader.
  103411. * @param channel Name of the variable.
  103412. * @param textures Textures to set.
  103413. */
  103414. setTextureArray(channel: string, textures: BaseTexture[]): void;
  103415. /**
  103416. * 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)
  103417. * @param channel Name of the sampler variable.
  103418. * @param postProcess Post process to get the input texture from.
  103419. */
  103420. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  103421. /**
  103422. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  103423. * 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)
  103424. * @param channel Name of the sampler variable.
  103425. * @param postProcess Post process to get the output texture from.
  103426. */
  103427. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  103428. /** @hidden */
  103429. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  103430. /** @hidden */
  103431. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  103432. /** @hidden */
  103433. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  103434. /** @hidden */
  103435. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  103436. /**
  103437. * Binds a buffer to a uniform.
  103438. * @param buffer Buffer to bind.
  103439. * @param name Name of the uniform variable to bind to.
  103440. */
  103441. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  103442. /**
  103443. * Binds block to a uniform.
  103444. * @param blockName Name of the block to bind.
  103445. * @param index Index to bind.
  103446. */
  103447. bindUniformBlock(blockName: string, index: number): void;
  103448. /**
  103449. * Sets an interger value on a uniform variable.
  103450. * @param uniformName Name of the variable.
  103451. * @param value Value to be set.
  103452. * @returns this effect.
  103453. */
  103454. setInt(uniformName: string, value: number): Effect;
  103455. /**
  103456. * Sets an int array on a uniform variable.
  103457. * @param uniformName Name of the variable.
  103458. * @param array array to be set.
  103459. * @returns this effect.
  103460. */
  103461. setIntArray(uniformName: string, array: Int32Array): Effect;
  103462. /**
  103463. * 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)
  103464. * @param uniformName Name of the variable.
  103465. * @param array array to be set.
  103466. * @returns this effect.
  103467. */
  103468. setIntArray2(uniformName: string, array: Int32Array): Effect;
  103469. /**
  103470. * 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)
  103471. * @param uniformName Name of the variable.
  103472. * @param array array to be set.
  103473. * @returns this effect.
  103474. */
  103475. setIntArray3(uniformName: string, array: Int32Array): Effect;
  103476. /**
  103477. * 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)
  103478. * @param uniformName Name of the variable.
  103479. * @param array array to be set.
  103480. * @returns this effect.
  103481. */
  103482. setIntArray4(uniformName: string, array: Int32Array): Effect;
  103483. /**
  103484. * Sets an float array on a uniform variable.
  103485. * @param uniformName Name of the variable.
  103486. * @param array array to be set.
  103487. * @returns this effect.
  103488. */
  103489. setFloatArray(uniformName: string, array: Float32Array): Effect;
  103490. /**
  103491. * 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)
  103492. * @param uniformName Name of the variable.
  103493. * @param array array to be set.
  103494. * @returns this effect.
  103495. */
  103496. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  103497. /**
  103498. * 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)
  103499. * @param uniformName Name of the variable.
  103500. * @param array array to be set.
  103501. * @returns this effect.
  103502. */
  103503. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  103504. /**
  103505. * 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)
  103506. * @param uniformName Name of the variable.
  103507. * @param array array to be set.
  103508. * @returns this effect.
  103509. */
  103510. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  103511. /**
  103512. * Sets an array on a uniform variable.
  103513. * @param uniformName Name of the variable.
  103514. * @param array array to be set.
  103515. * @returns this effect.
  103516. */
  103517. setArray(uniformName: string, array: number[]): Effect;
  103518. /**
  103519. * 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)
  103520. * @param uniformName Name of the variable.
  103521. * @param array array to be set.
  103522. * @returns this effect.
  103523. */
  103524. setArray2(uniformName: string, array: number[]): Effect;
  103525. /**
  103526. * 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)
  103527. * @param uniformName Name of the variable.
  103528. * @param array array to be set.
  103529. * @returns this effect.
  103530. */
  103531. setArray3(uniformName: string, array: number[]): Effect;
  103532. /**
  103533. * 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)
  103534. * @param uniformName Name of the variable.
  103535. * @param array array to be set.
  103536. * @returns this effect.
  103537. */
  103538. setArray4(uniformName: string, array: number[]): Effect;
  103539. /**
  103540. * Sets matrices on a uniform variable.
  103541. * @param uniformName Name of the variable.
  103542. * @param matrices matrices to be set.
  103543. * @returns this effect.
  103544. */
  103545. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  103546. /**
  103547. * Sets matrix on a uniform variable.
  103548. * @param uniformName Name of the variable.
  103549. * @param matrix matrix to be set.
  103550. * @returns this effect.
  103551. */
  103552. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  103553. /**
  103554. * 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)
  103555. * @param uniformName Name of the variable.
  103556. * @param matrix matrix to be set.
  103557. * @returns this effect.
  103558. */
  103559. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  103560. /**
  103561. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  103562. * @param uniformName Name of the variable.
  103563. * @param matrix matrix to be set.
  103564. * @returns this effect.
  103565. */
  103566. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  103567. /**
  103568. * Sets a float on a uniform variable.
  103569. * @param uniformName Name of the variable.
  103570. * @param value value to be set.
  103571. * @returns this effect.
  103572. */
  103573. setFloat(uniformName: string, value: number): Effect;
  103574. /**
  103575. * Sets a boolean on a uniform variable.
  103576. * @param uniformName Name of the variable.
  103577. * @param bool value to be set.
  103578. * @returns this effect.
  103579. */
  103580. setBool(uniformName: string, bool: boolean): Effect;
  103581. /**
  103582. * Sets a Vector2 on a uniform variable.
  103583. * @param uniformName Name of the variable.
  103584. * @param vector2 vector2 to be set.
  103585. * @returns this effect.
  103586. */
  103587. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  103588. /**
  103589. * Sets a float2 on a uniform variable.
  103590. * @param uniformName Name of the variable.
  103591. * @param x First float in float2.
  103592. * @param y Second float in float2.
  103593. * @returns this effect.
  103594. */
  103595. setFloat2(uniformName: string, x: number, y: number): Effect;
  103596. /**
  103597. * Sets a Vector3 on a uniform variable.
  103598. * @param uniformName Name of the variable.
  103599. * @param vector3 Value to be set.
  103600. * @returns this effect.
  103601. */
  103602. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  103603. /**
  103604. * Sets a float3 on a uniform variable.
  103605. * @param uniformName Name of the variable.
  103606. * @param x First float in float3.
  103607. * @param y Second float in float3.
  103608. * @param z Third float in float3.
  103609. * @returns this effect.
  103610. */
  103611. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  103612. /**
  103613. * Sets a Vector4 on a uniform variable.
  103614. * @param uniformName Name of the variable.
  103615. * @param vector4 Value to be set.
  103616. * @returns this effect.
  103617. */
  103618. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  103619. /**
  103620. * Sets a float4 on a uniform variable.
  103621. * @param uniformName Name of the variable.
  103622. * @param x First float in float4.
  103623. * @param y Second float in float4.
  103624. * @param z Third float in float4.
  103625. * @param w Fourth float in float4.
  103626. * @returns this effect.
  103627. */
  103628. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  103629. /**
  103630. * Sets a Color3 on a uniform variable.
  103631. * @param uniformName Name of the variable.
  103632. * @param color3 Value to be set.
  103633. * @returns this effect.
  103634. */
  103635. setColor3(uniformName: string, color3: IColor3Like): Effect;
  103636. /**
  103637. * Sets a Color4 on a uniform variable.
  103638. * @param uniformName Name of the variable.
  103639. * @param color3 Value to be set.
  103640. * @param alpha Alpha value to be set.
  103641. * @returns this effect.
  103642. */
  103643. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  103644. /**
  103645. * Sets a Color4 on a uniform variable
  103646. * @param uniformName defines the name of the variable
  103647. * @param color4 defines the value to be set
  103648. * @returns this effect.
  103649. */
  103650. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  103651. /** Release all associated resources */
  103652. dispose(): void;
  103653. /**
  103654. * This function will add a new shader to the shader store
  103655. * @param name the name of the shader
  103656. * @param pixelShader optional pixel shader content
  103657. * @param vertexShader optional vertex shader content
  103658. */
  103659. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  103660. /**
  103661. * Store of each shader (The can be looked up using effect.key)
  103662. */
  103663. static ShadersStore: {
  103664. [key: string]: string;
  103665. };
  103666. /**
  103667. * Store of each included file for a shader (The can be looked up using effect.key)
  103668. */
  103669. static IncludesShadersStore: {
  103670. [key: string]: string;
  103671. };
  103672. /**
  103673. * Resets the cache of effects.
  103674. */
  103675. static ResetCache(): void;
  103676. }
  103677. }
  103678. declare module BABYLON {
  103679. /**
  103680. * Interface used to describe the capabilities of the engine relatively to the current browser
  103681. */
  103682. export interface EngineCapabilities {
  103683. /** Maximum textures units per fragment shader */
  103684. maxTexturesImageUnits: number;
  103685. /** Maximum texture units per vertex shader */
  103686. maxVertexTextureImageUnits: number;
  103687. /** Maximum textures units in the entire pipeline */
  103688. maxCombinedTexturesImageUnits: number;
  103689. /** Maximum texture size */
  103690. maxTextureSize: number;
  103691. /** Maximum texture samples */
  103692. maxSamples?: number;
  103693. /** Maximum cube texture size */
  103694. maxCubemapTextureSize: number;
  103695. /** Maximum render texture size */
  103696. maxRenderTextureSize: number;
  103697. /** Maximum number of vertex attributes */
  103698. maxVertexAttribs: number;
  103699. /** Maximum number of varyings */
  103700. maxVaryingVectors: number;
  103701. /** Maximum number of uniforms per vertex shader */
  103702. maxVertexUniformVectors: number;
  103703. /** Maximum number of uniforms per fragment shader */
  103704. maxFragmentUniformVectors: number;
  103705. /** Defines if standard derivates (dx/dy) are supported */
  103706. standardDerivatives: boolean;
  103707. /** Defines if s3tc texture compression is supported */
  103708. s3tc?: WEBGL_compressed_texture_s3tc;
  103709. /** Defines if pvrtc texture compression is supported */
  103710. pvrtc: any;
  103711. /** Defines if etc1 texture compression is supported */
  103712. etc1: any;
  103713. /** Defines if etc2 texture compression is supported */
  103714. etc2: any;
  103715. /** Defines if astc texture compression is supported */
  103716. astc: any;
  103717. /** Defines if float textures are supported */
  103718. textureFloat: boolean;
  103719. /** Defines if vertex array objects are supported */
  103720. vertexArrayObject: boolean;
  103721. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  103722. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  103723. /** Gets the maximum level of anisotropy supported */
  103724. maxAnisotropy: number;
  103725. /** Defines if instancing is supported */
  103726. instancedArrays: boolean;
  103727. /** Defines if 32 bits indices are supported */
  103728. uintIndices: boolean;
  103729. /** Defines if high precision shaders are supported */
  103730. highPrecisionShaderSupported: boolean;
  103731. /** Defines if depth reading in the fragment shader is supported */
  103732. fragmentDepthSupported: boolean;
  103733. /** Defines if float texture linear filtering is supported*/
  103734. textureFloatLinearFiltering: boolean;
  103735. /** Defines if rendering to float textures is supported */
  103736. textureFloatRender: boolean;
  103737. /** Defines if half float textures are supported*/
  103738. textureHalfFloat: boolean;
  103739. /** Defines if half float texture linear filtering is supported*/
  103740. textureHalfFloatLinearFiltering: boolean;
  103741. /** Defines if rendering to half float textures is supported */
  103742. textureHalfFloatRender: boolean;
  103743. /** Defines if textureLOD shader command is supported */
  103744. textureLOD: boolean;
  103745. /** Defines if draw buffers extension is supported */
  103746. drawBuffersExtension: boolean;
  103747. /** Defines if depth textures are supported */
  103748. depthTextureExtension: boolean;
  103749. /** Defines if float color buffer are supported */
  103750. colorBufferFloat: boolean;
  103751. /** Gets disjoint timer query extension (null if not supported) */
  103752. timerQuery?: EXT_disjoint_timer_query;
  103753. /** Defines if timestamp can be used with timer query */
  103754. canUseTimestampForTimerQuery: boolean;
  103755. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  103756. multiview?: any;
  103757. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  103758. oculusMultiview?: any;
  103759. /** Function used to let the system compiles shaders in background */
  103760. parallelShaderCompile?: {
  103761. COMPLETION_STATUS_KHR: number;
  103762. };
  103763. /** Max number of texture samples for MSAA */
  103764. maxMSAASamples: number;
  103765. /** Defines if the blend min max extension is supported */
  103766. blendMinMax: boolean;
  103767. }
  103768. }
  103769. declare module BABYLON {
  103770. /**
  103771. * @hidden
  103772. **/
  103773. export class DepthCullingState {
  103774. private _isDepthTestDirty;
  103775. private _isDepthMaskDirty;
  103776. private _isDepthFuncDirty;
  103777. private _isCullFaceDirty;
  103778. private _isCullDirty;
  103779. private _isZOffsetDirty;
  103780. private _isFrontFaceDirty;
  103781. private _depthTest;
  103782. private _depthMask;
  103783. private _depthFunc;
  103784. private _cull;
  103785. private _cullFace;
  103786. private _zOffset;
  103787. private _frontFace;
  103788. /**
  103789. * Initializes the state.
  103790. */
  103791. constructor();
  103792. get isDirty(): boolean;
  103793. get zOffset(): number;
  103794. set zOffset(value: number);
  103795. get cullFace(): Nullable<number>;
  103796. set cullFace(value: Nullable<number>);
  103797. get cull(): Nullable<boolean>;
  103798. set cull(value: Nullable<boolean>);
  103799. get depthFunc(): Nullable<number>;
  103800. set depthFunc(value: Nullable<number>);
  103801. get depthMask(): boolean;
  103802. set depthMask(value: boolean);
  103803. get depthTest(): boolean;
  103804. set depthTest(value: boolean);
  103805. get frontFace(): Nullable<number>;
  103806. set frontFace(value: Nullable<number>);
  103807. reset(): void;
  103808. apply(gl: WebGLRenderingContext): void;
  103809. }
  103810. }
  103811. declare module BABYLON {
  103812. /**
  103813. * @hidden
  103814. **/
  103815. export class StencilState {
  103816. /** 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 */
  103817. static readonly ALWAYS: number;
  103818. /** Passed to stencilOperation to specify that stencil value must be kept */
  103819. static readonly KEEP: number;
  103820. /** Passed to stencilOperation to specify that stencil value must be replaced */
  103821. static readonly REPLACE: number;
  103822. private _isStencilTestDirty;
  103823. private _isStencilMaskDirty;
  103824. private _isStencilFuncDirty;
  103825. private _isStencilOpDirty;
  103826. private _stencilTest;
  103827. private _stencilMask;
  103828. private _stencilFunc;
  103829. private _stencilFuncRef;
  103830. private _stencilFuncMask;
  103831. private _stencilOpStencilFail;
  103832. private _stencilOpDepthFail;
  103833. private _stencilOpStencilDepthPass;
  103834. get isDirty(): boolean;
  103835. get stencilFunc(): number;
  103836. set stencilFunc(value: number);
  103837. get stencilFuncRef(): number;
  103838. set stencilFuncRef(value: number);
  103839. get stencilFuncMask(): number;
  103840. set stencilFuncMask(value: number);
  103841. get stencilOpStencilFail(): number;
  103842. set stencilOpStencilFail(value: number);
  103843. get stencilOpDepthFail(): number;
  103844. set stencilOpDepthFail(value: number);
  103845. get stencilOpStencilDepthPass(): number;
  103846. set stencilOpStencilDepthPass(value: number);
  103847. get stencilMask(): number;
  103848. set stencilMask(value: number);
  103849. get stencilTest(): boolean;
  103850. set stencilTest(value: boolean);
  103851. constructor();
  103852. reset(): void;
  103853. apply(gl: WebGLRenderingContext): void;
  103854. }
  103855. }
  103856. declare module BABYLON {
  103857. /**
  103858. * @hidden
  103859. **/
  103860. export class AlphaState {
  103861. private _isAlphaBlendDirty;
  103862. private _isBlendFunctionParametersDirty;
  103863. private _isBlendEquationParametersDirty;
  103864. private _isBlendConstantsDirty;
  103865. private _alphaBlend;
  103866. private _blendFunctionParameters;
  103867. private _blendEquationParameters;
  103868. private _blendConstants;
  103869. /**
  103870. * Initializes the state.
  103871. */
  103872. constructor();
  103873. get isDirty(): boolean;
  103874. get alphaBlend(): boolean;
  103875. set alphaBlend(value: boolean);
  103876. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  103877. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  103878. setAlphaEquationParameters(rgb: number, alpha: number): void;
  103879. reset(): void;
  103880. apply(gl: WebGLRenderingContext): void;
  103881. }
  103882. }
  103883. declare module BABYLON {
  103884. /** @hidden */
  103885. export class WebGL2ShaderProcessor implements IShaderProcessor {
  103886. attributeProcessor(attribute: string): string;
  103887. varyingProcessor(varying: string, isFragment: boolean): string;
  103888. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  103889. }
  103890. }
  103891. declare module BABYLON {
  103892. /**
  103893. * Interface for attribute information associated with buffer instanciation
  103894. */
  103895. export interface InstancingAttributeInfo {
  103896. /**
  103897. * Name of the GLSL attribute
  103898. * if attribute index is not specified, this is used to retrieve the index from the effect
  103899. */
  103900. attributeName: string;
  103901. /**
  103902. * Index/offset of the attribute in the vertex shader
  103903. * if not specified, this will be computes from the name.
  103904. */
  103905. index?: number;
  103906. /**
  103907. * size of the attribute, 1, 2, 3 or 4
  103908. */
  103909. attributeSize: number;
  103910. /**
  103911. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  103912. */
  103913. offset: number;
  103914. /**
  103915. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  103916. * default to 1
  103917. */
  103918. divisor?: number;
  103919. /**
  103920. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  103921. * default is FLOAT
  103922. */
  103923. attributeType?: number;
  103924. /**
  103925. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  103926. */
  103927. normalized?: boolean;
  103928. }
  103929. }
  103930. declare module BABYLON {
  103931. interface ThinEngine {
  103932. /**
  103933. * Update a video texture
  103934. * @param texture defines the texture to update
  103935. * @param video defines the video element to use
  103936. * @param invertY defines if data must be stored with Y axis inverted
  103937. */
  103938. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  103939. }
  103940. }
  103941. declare module BABYLON {
  103942. /**
  103943. * Settings for finer control over video usage
  103944. */
  103945. export interface VideoTextureSettings {
  103946. /**
  103947. * Applies `autoplay` to video, if specified
  103948. */
  103949. autoPlay?: boolean;
  103950. /**
  103951. * Applies `loop` to video, if specified
  103952. */
  103953. loop?: boolean;
  103954. /**
  103955. * Automatically updates internal texture from video at every frame in the render loop
  103956. */
  103957. autoUpdateTexture: boolean;
  103958. /**
  103959. * Image src displayed during the video loading or until the user interacts with the video.
  103960. */
  103961. poster?: string;
  103962. }
  103963. /**
  103964. * If you want to display a video in your scene, this is the special texture for that.
  103965. * This special texture works similar to other textures, with the exception of a few parameters.
  103966. * @see https://doc.babylonjs.com/how_to/video_texture
  103967. */
  103968. export class VideoTexture extends Texture {
  103969. /**
  103970. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  103971. */
  103972. readonly autoUpdateTexture: boolean;
  103973. /**
  103974. * The video instance used by the texture internally
  103975. */
  103976. readonly video: HTMLVideoElement;
  103977. private _onUserActionRequestedObservable;
  103978. /**
  103979. * Event triggerd when a dom action is required by the user to play the video.
  103980. * This happens due to recent changes in browser policies preventing video to auto start.
  103981. */
  103982. get onUserActionRequestedObservable(): Observable<Texture>;
  103983. private _generateMipMaps;
  103984. private _engine;
  103985. private _stillImageCaptured;
  103986. private _displayingPosterTexture;
  103987. private _settings;
  103988. private _createInternalTextureOnEvent;
  103989. private _frameId;
  103990. private _currentSrc;
  103991. /**
  103992. * Creates a video texture.
  103993. * If you want to display a video in your scene, this is the special texture for that.
  103994. * This special texture works similar to other textures, with the exception of a few parameters.
  103995. * @see https://doc.babylonjs.com/how_to/video_texture
  103996. * @param name optional name, will detect from video source, if not defined
  103997. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  103998. * @param scene is obviously the current scene.
  103999. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  104000. * @param invertY is false by default but can be used to invert video on Y axis
  104001. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  104002. * @param settings allows finer control over video usage
  104003. */
  104004. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  104005. private _getName;
  104006. private _getVideo;
  104007. private _createInternalTexture;
  104008. private reset;
  104009. /**
  104010. * @hidden Internal method to initiate `update`.
  104011. */
  104012. _rebuild(): void;
  104013. /**
  104014. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  104015. */
  104016. update(): void;
  104017. /**
  104018. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  104019. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  104020. */
  104021. updateTexture(isVisible: boolean): void;
  104022. protected _updateInternalTexture: () => void;
  104023. /**
  104024. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  104025. * @param url New url.
  104026. */
  104027. updateURL(url: string): void;
  104028. /**
  104029. * Clones the texture.
  104030. * @returns the cloned texture
  104031. */
  104032. clone(): VideoTexture;
  104033. /**
  104034. * Dispose the texture and release its associated resources.
  104035. */
  104036. dispose(): void;
  104037. /**
  104038. * Creates a video texture straight from a stream.
  104039. * @param scene Define the scene the texture should be created in
  104040. * @param stream Define the stream the texture should be created from
  104041. * @returns The created video texture as a promise
  104042. */
  104043. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  104044. /**
  104045. * Creates a video texture straight from your WebCam video feed.
  104046. * @param scene Define the scene the texture should be created in
  104047. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104048. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104049. * @returns The created video texture as a promise
  104050. */
  104051. static CreateFromWebCamAsync(scene: Scene, constraints: {
  104052. minWidth: number;
  104053. maxWidth: number;
  104054. minHeight: number;
  104055. maxHeight: number;
  104056. deviceId: string;
  104057. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  104058. /**
  104059. * Creates a video texture straight from your WebCam video feed.
  104060. * @param scene Define the scene the texture should be created in
  104061. * @param onReady Define a callback to triggered once the texture will be ready
  104062. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104063. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104064. */
  104065. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  104066. minWidth: number;
  104067. maxWidth: number;
  104068. minHeight: number;
  104069. maxHeight: number;
  104070. deviceId: string;
  104071. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  104072. }
  104073. }
  104074. declare module BABYLON {
  104075. /**
  104076. * Defines the interface used by objects working like Scene
  104077. * @hidden
  104078. */
  104079. export interface ISceneLike {
  104080. _addPendingData(data: any): void;
  104081. _removePendingData(data: any): void;
  104082. offlineProvider: IOfflineProvider;
  104083. }
  104084. /** Interface defining initialization parameters for Engine class */
  104085. export interface EngineOptions extends WebGLContextAttributes {
  104086. /**
  104087. * Defines if the engine should no exceed a specified device ratio
  104088. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  104089. */
  104090. limitDeviceRatio?: number;
  104091. /**
  104092. * Defines if webvr should be enabled automatically
  104093. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104094. */
  104095. autoEnableWebVR?: boolean;
  104096. /**
  104097. * Defines if webgl2 should be turned off even if supported
  104098. * @see http://doc.babylonjs.com/features/webgl2
  104099. */
  104100. disableWebGL2Support?: boolean;
  104101. /**
  104102. * Defines if webaudio should be initialized as well
  104103. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104104. */
  104105. audioEngine?: boolean;
  104106. /**
  104107. * Defines if animations should run using a deterministic lock step
  104108. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104109. */
  104110. deterministicLockstep?: boolean;
  104111. /** Defines the maximum steps to use with deterministic lock step mode */
  104112. lockstepMaxSteps?: number;
  104113. /** Defines the seconds between each deterministic lock step */
  104114. timeStep?: number;
  104115. /**
  104116. * Defines that engine should ignore context lost events
  104117. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  104118. */
  104119. doNotHandleContextLost?: boolean;
  104120. /**
  104121. * Defines that engine should ignore modifying touch action attribute and style
  104122. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  104123. */
  104124. doNotHandleTouchAction?: boolean;
  104125. /**
  104126. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  104127. */
  104128. useHighPrecisionFloats?: boolean;
  104129. }
  104130. /**
  104131. * The base engine class (root of all engines)
  104132. */
  104133. export class ThinEngine {
  104134. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  104135. static ExceptionList: ({
  104136. key: string;
  104137. capture: string;
  104138. captureConstraint: number;
  104139. targets: string[];
  104140. } | {
  104141. key: string;
  104142. capture: null;
  104143. captureConstraint: null;
  104144. targets: string[];
  104145. })[];
  104146. /** @hidden */
  104147. static _TextureLoaders: IInternalTextureLoader[];
  104148. /**
  104149. * Returns the current npm package of the sdk
  104150. */
  104151. static get NpmPackage(): string;
  104152. /**
  104153. * Returns the current version of the framework
  104154. */
  104155. static get Version(): string;
  104156. /**
  104157. * Returns a string describing the current engine
  104158. */
  104159. get description(): string;
  104160. /**
  104161. * Gets or sets the epsilon value used by collision engine
  104162. */
  104163. static CollisionsEpsilon: number;
  104164. /**
  104165. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104166. */
  104167. static get ShadersRepository(): string;
  104168. static set ShadersRepository(value: string);
  104169. /** @hidden */
  104170. _shaderProcessor: IShaderProcessor;
  104171. /**
  104172. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  104173. */
  104174. forcePOTTextures: boolean;
  104175. /**
  104176. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  104177. */
  104178. isFullscreen: boolean;
  104179. /**
  104180. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  104181. */
  104182. cullBackFaces: boolean;
  104183. /**
  104184. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  104185. */
  104186. renderEvenInBackground: boolean;
  104187. /**
  104188. * Gets or sets a boolean indicating that cache can be kept between frames
  104189. */
  104190. preventCacheWipeBetweenFrames: boolean;
  104191. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  104192. validateShaderPrograms: boolean;
  104193. /**
  104194. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  104195. * This can provide greater z depth for distant objects.
  104196. */
  104197. useReverseDepthBuffer: boolean;
  104198. /**
  104199. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  104200. */
  104201. disableUniformBuffers: boolean;
  104202. /** @hidden */
  104203. _uniformBuffers: UniformBuffer[];
  104204. /**
  104205. * Gets a boolean indicating that the engine supports uniform buffers
  104206. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  104207. */
  104208. get supportsUniformBuffers(): boolean;
  104209. /** @hidden */
  104210. _gl: WebGLRenderingContext;
  104211. /** @hidden */
  104212. _webGLVersion: number;
  104213. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  104214. protected _windowIsBackground: boolean;
  104215. protected _creationOptions: EngineOptions;
  104216. protected _highPrecisionShadersAllowed: boolean;
  104217. /** @hidden */
  104218. get _shouldUseHighPrecisionShader(): boolean;
  104219. /**
  104220. * Gets a boolean indicating that only power of 2 textures are supported
  104221. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  104222. */
  104223. get needPOTTextures(): boolean;
  104224. /** @hidden */
  104225. _badOS: boolean;
  104226. /** @hidden */
  104227. _badDesktopOS: boolean;
  104228. private _hardwareScalingLevel;
  104229. /** @hidden */
  104230. _caps: EngineCapabilities;
  104231. private _isStencilEnable;
  104232. private _glVersion;
  104233. private _glRenderer;
  104234. private _glVendor;
  104235. /** @hidden */
  104236. _videoTextureSupported: boolean;
  104237. protected _renderingQueueLaunched: boolean;
  104238. protected _activeRenderLoops: (() => void)[];
  104239. /**
  104240. * Observable signaled when a context lost event is raised
  104241. */
  104242. onContextLostObservable: Observable<ThinEngine>;
  104243. /**
  104244. * Observable signaled when a context restored event is raised
  104245. */
  104246. onContextRestoredObservable: Observable<ThinEngine>;
  104247. private _onContextLost;
  104248. private _onContextRestored;
  104249. protected _contextWasLost: boolean;
  104250. /** @hidden */
  104251. _doNotHandleContextLost: boolean;
  104252. /**
  104253. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  104254. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  104255. */
  104256. get doNotHandleContextLost(): boolean;
  104257. set doNotHandleContextLost(value: boolean);
  104258. /**
  104259. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  104260. */
  104261. disableVertexArrayObjects: boolean;
  104262. /** @hidden */
  104263. protected _colorWrite: boolean;
  104264. /** @hidden */
  104265. protected _colorWriteChanged: boolean;
  104266. /** @hidden */
  104267. protected _depthCullingState: DepthCullingState;
  104268. /** @hidden */
  104269. protected _stencilState: StencilState;
  104270. /** @hidden */
  104271. _alphaState: AlphaState;
  104272. /** @hidden */
  104273. _alphaMode: number;
  104274. /** @hidden */
  104275. _alphaEquation: number;
  104276. /** @hidden */
  104277. _internalTexturesCache: InternalTexture[];
  104278. /** @hidden */
  104279. protected _activeChannel: number;
  104280. private _currentTextureChannel;
  104281. /** @hidden */
  104282. protected _boundTexturesCache: {
  104283. [key: string]: Nullable<InternalTexture>;
  104284. };
  104285. /** @hidden */
  104286. protected _currentEffect: Nullable<Effect>;
  104287. /** @hidden */
  104288. protected _currentProgram: Nullable<WebGLProgram>;
  104289. private _compiledEffects;
  104290. private _vertexAttribArraysEnabled;
  104291. /** @hidden */
  104292. protected _cachedViewport: Nullable<IViewportLike>;
  104293. private _cachedVertexArrayObject;
  104294. /** @hidden */
  104295. protected _cachedVertexBuffers: any;
  104296. /** @hidden */
  104297. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  104298. /** @hidden */
  104299. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  104300. /** @hidden */
  104301. _currentRenderTarget: Nullable<InternalTexture>;
  104302. private _uintIndicesCurrentlySet;
  104303. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  104304. /** @hidden */
  104305. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  104306. private _currentBufferPointers;
  104307. private _currentInstanceLocations;
  104308. private _currentInstanceBuffers;
  104309. private _textureUnits;
  104310. /** @hidden */
  104311. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  104312. /** @hidden */
  104313. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  104314. /** @hidden */
  104315. _boundRenderFunction: any;
  104316. private _vaoRecordInProgress;
  104317. private _mustWipeVertexAttributes;
  104318. private _emptyTexture;
  104319. private _emptyCubeTexture;
  104320. private _emptyTexture3D;
  104321. private _emptyTexture2DArray;
  104322. /** @hidden */
  104323. _frameHandler: number;
  104324. private _nextFreeTextureSlots;
  104325. private _maxSimultaneousTextures;
  104326. private _activeRequests;
  104327. protected _texturesSupported: string[];
  104328. /** @hidden */
  104329. _textureFormatInUse: Nullable<string>;
  104330. protected get _supportsHardwareTextureRescaling(): boolean;
  104331. /**
  104332. * Gets the list of texture formats supported
  104333. */
  104334. get texturesSupported(): Array<string>;
  104335. /**
  104336. * Gets the list of texture formats in use
  104337. */
  104338. get textureFormatInUse(): Nullable<string>;
  104339. /**
  104340. * Gets the current viewport
  104341. */
  104342. get currentViewport(): Nullable<IViewportLike>;
  104343. /**
  104344. * Gets the default empty texture
  104345. */
  104346. get emptyTexture(): InternalTexture;
  104347. /**
  104348. * Gets the default empty 3D texture
  104349. */
  104350. get emptyTexture3D(): InternalTexture;
  104351. /**
  104352. * Gets the default empty 2D array texture
  104353. */
  104354. get emptyTexture2DArray(): InternalTexture;
  104355. /**
  104356. * Gets the default empty cube texture
  104357. */
  104358. get emptyCubeTexture(): InternalTexture;
  104359. /**
  104360. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  104361. */
  104362. readonly premultipliedAlpha: boolean;
  104363. /**
  104364. * Observable event triggered before each texture is initialized
  104365. */
  104366. onBeforeTextureInitObservable: Observable<Texture>;
  104367. /**
  104368. * Creates a new engine
  104369. * @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
  104370. * @param antialias defines enable antialiasing (default: false)
  104371. * @param options defines further options to be sent to the getContext() function
  104372. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  104373. */
  104374. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  104375. private _rebuildInternalTextures;
  104376. private _rebuildEffects;
  104377. /**
  104378. * Gets a boolean indicating if all created effects are ready
  104379. * @returns true if all effects are ready
  104380. */
  104381. areAllEffectsReady(): boolean;
  104382. protected _rebuildBuffers(): void;
  104383. private _initGLContext;
  104384. /**
  104385. * Gets version of the current webGL context
  104386. */
  104387. get webGLVersion(): number;
  104388. /**
  104389. * Gets a string idenfifying the name of the class
  104390. * @returns "Engine" string
  104391. */
  104392. getClassName(): string;
  104393. /**
  104394. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  104395. */
  104396. get isStencilEnable(): boolean;
  104397. /** @hidden */
  104398. _prepareWorkingCanvas(): void;
  104399. /**
  104400. * Reset the texture cache to empty state
  104401. */
  104402. resetTextureCache(): void;
  104403. /**
  104404. * Gets an object containing information about the current webGL context
  104405. * @returns an object containing the vender, the renderer and the version of the current webGL context
  104406. */
  104407. getGlInfo(): {
  104408. vendor: string;
  104409. renderer: string;
  104410. version: string;
  104411. };
  104412. /**
  104413. * Defines the hardware scaling level.
  104414. * By default the hardware scaling level is computed from the window device ratio.
  104415. * 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.
  104416. * @param level defines the level to use
  104417. */
  104418. setHardwareScalingLevel(level: number): void;
  104419. /**
  104420. * Gets the current hardware scaling level.
  104421. * By default the hardware scaling level is computed from the window device ratio.
  104422. * 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.
  104423. * @returns a number indicating the current hardware scaling level
  104424. */
  104425. getHardwareScalingLevel(): number;
  104426. /**
  104427. * Gets the list of loaded textures
  104428. * @returns an array containing all loaded textures
  104429. */
  104430. getLoadedTexturesCache(): InternalTexture[];
  104431. /**
  104432. * Gets the object containing all engine capabilities
  104433. * @returns the EngineCapabilities object
  104434. */
  104435. getCaps(): EngineCapabilities;
  104436. /**
  104437. * stop executing a render loop function and remove it from the execution array
  104438. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  104439. */
  104440. stopRenderLoop(renderFunction?: () => void): void;
  104441. /** @hidden */
  104442. _renderLoop(): void;
  104443. /**
  104444. * Gets the HTML canvas attached with the current webGL context
  104445. * @returns a HTML canvas
  104446. */
  104447. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  104448. /**
  104449. * Gets host window
  104450. * @returns the host window object
  104451. */
  104452. getHostWindow(): Nullable<Window>;
  104453. /**
  104454. * Gets the current render width
  104455. * @param useScreen defines if screen size must be used (or the current render target if any)
  104456. * @returns a number defining the current render width
  104457. */
  104458. getRenderWidth(useScreen?: boolean): number;
  104459. /**
  104460. * Gets the current render height
  104461. * @param useScreen defines if screen size must be used (or the current render target if any)
  104462. * @returns a number defining the current render height
  104463. */
  104464. getRenderHeight(useScreen?: boolean): number;
  104465. /**
  104466. * Can be used to override the current requestAnimationFrame requester.
  104467. * @hidden
  104468. */
  104469. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  104470. /**
  104471. * Register and execute a render loop. The engine can have more than one render function
  104472. * @param renderFunction defines the function to continuously execute
  104473. */
  104474. runRenderLoop(renderFunction: () => void): void;
  104475. /**
  104476. * Clear the current render buffer or the current render target (if any is set up)
  104477. * @param color defines the color to use
  104478. * @param backBuffer defines if the back buffer must be cleared
  104479. * @param depth defines if the depth buffer must be cleared
  104480. * @param stencil defines if the stencil buffer must be cleared
  104481. */
  104482. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104483. private _viewportCached;
  104484. /** @hidden */
  104485. _viewport(x: number, y: number, width: number, height: number): void;
  104486. /**
  104487. * Set the WebGL's viewport
  104488. * @param viewport defines the viewport element to be used
  104489. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  104490. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  104491. */
  104492. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  104493. /**
  104494. * Begin a new frame
  104495. */
  104496. beginFrame(): void;
  104497. /**
  104498. * Enf the current frame
  104499. */
  104500. endFrame(): void;
  104501. /**
  104502. * Resize the view according to the canvas' size
  104503. */
  104504. resize(): void;
  104505. /**
  104506. * Force a specific size of the canvas
  104507. * @param width defines the new canvas' width
  104508. * @param height defines the new canvas' height
  104509. */
  104510. setSize(width: number, height: number): void;
  104511. /**
  104512. * Binds the frame buffer to the specified texture.
  104513. * @param texture The texture to render to or null for the default canvas
  104514. * @param faceIndex The face of the texture to render to in case of cube texture
  104515. * @param requiredWidth The width of the target to render to
  104516. * @param requiredHeight The height of the target to render to
  104517. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  104518. * @param lodLevel defines the lod level to bind to the frame buffer
  104519. * @param layer defines the 2d array index to bind to frame buffer to
  104520. */
  104521. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  104522. /** @hidden */
  104523. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  104524. /**
  104525. * Unbind the current render target texture from the webGL context
  104526. * @param texture defines the render target texture to unbind
  104527. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104528. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104529. */
  104530. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104531. /**
  104532. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  104533. */
  104534. flushFramebuffer(): void;
  104535. /**
  104536. * Unbind the current render target and bind the default framebuffer
  104537. */
  104538. restoreDefaultFramebuffer(): void;
  104539. /** @hidden */
  104540. protected _resetVertexBufferBinding(): void;
  104541. /**
  104542. * Creates a vertex buffer
  104543. * @param data the data for the vertex buffer
  104544. * @returns the new WebGL static buffer
  104545. */
  104546. createVertexBuffer(data: DataArray): DataBuffer;
  104547. private _createVertexBuffer;
  104548. /**
  104549. * Creates a dynamic vertex buffer
  104550. * @param data the data for the dynamic vertex buffer
  104551. * @returns the new WebGL dynamic buffer
  104552. */
  104553. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  104554. protected _resetIndexBufferBinding(): void;
  104555. /**
  104556. * Creates a new index buffer
  104557. * @param indices defines the content of the index buffer
  104558. * @param updatable defines if the index buffer must be updatable
  104559. * @returns a new webGL buffer
  104560. */
  104561. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  104562. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  104563. /**
  104564. * Bind a webGL buffer to the webGL context
  104565. * @param buffer defines the buffer to bind
  104566. */
  104567. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  104568. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  104569. private bindBuffer;
  104570. /**
  104571. * update the bound buffer with the given data
  104572. * @param data defines the data to update
  104573. */
  104574. updateArrayBuffer(data: Float32Array): void;
  104575. private _vertexAttribPointer;
  104576. /** @hidden */
  104577. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  104578. private _bindVertexBuffersAttributes;
  104579. /**
  104580. * Records a vertex array object
  104581. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104582. * @param vertexBuffers defines the list of vertex buffers to store
  104583. * @param indexBuffer defines the index buffer to store
  104584. * @param effect defines the effect to store
  104585. * @returns the new vertex array object
  104586. */
  104587. recordVertexArrayObject(vertexBuffers: {
  104588. [key: string]: VertexBuffer;
  104589. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  104590. /**
  104591. * Bind a specific vertex array object
  104592. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104593. * @param vertexArrayObject defines the vertex array object to bind
  104594. * @param indexBuffer defines the index buffer to bind
  104595. */
  104596. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  104597. /**
  104598. * Bind webGl buffers directly to the webGL context
  104599. * @param vertexBuffer defines the vertex buffer to bind
  104600. * @param indexBuffer defines the index buffer to bind
  104601. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  104602. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  104603. * @param effect defines the effect associated with the vertex buffer
  104604. */
  104605. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  104606. private _unbindVertexArrayObject;
  104607. /**
  104608. * Bind a list of vertex buffers to the webGL context
  104609. * @param vertexBuffers defines the list of vertex buffers to bind
  104610. * @param indexBuffer defines the index buffer to bind
  104611. * @param effect defines the effect associated with the vertex buffers
  104612. */
  104613. bindBuffers(vertexBuffers: {
  104614. [key: string]: Nullable<VertexBuffer>;
  104615. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  104616. /**
  104617. * Unbind all instance attributes
  104618. */
  104619. unbindInstanceAttributes(): void;
  104620. /**
  104621. * Release and free the memory of a vertex array object
  104622. * @param vao defines the vertex array object to delete
  104623. */
  104624. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  104625. /** @hidden */
  104626. _releaseBuffer(buffer: DataBuffer): boolean;
  104627. protected _deleteBuffer(buffer: DataBuffer): void;
  104628. /**
  104629. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  104630. * @param instancesBuffer defines the webGL buffer to update and bind
  104631. * @param data defines the data to store in the buffer
  104632. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  104633. */
  104634. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  104635. /**
  104636. * Bind the content of a webGL buffer used with instantiation
  104637. * @param instancesBuffer defines the webGL buffer to bind
  104638. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  104639. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  104640. */
  104641. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  104642. /**
  104643. * Disable the instance attribute corresponding to the name in parameter
  104644. * @param name defines the name of the attribute to disable
  104645. */
  104646. disableInstanceAttributeByName(name: string): void;
  104647. /**
  104648. * Disable the instance attribute corresponding to the location in parameter
  104649. * @param attributeLocation defines the attribute location of the attribute to disable
  104650. */
  104651. disableInstanceAttribute(attributeLocation: number): void;
  104652. /**
  104653. * Disable the attribute corresponding to the location in parameter
  104654. * @param attributeLocation defines the attribute location of the attribute to disable
  104655. */
  104656. disableAttributeByIndex(attributeLocation: number): void;
  104657. /**
  104658. * Send a draw order
  104659. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104660. * @param indexStart defines the starting index
  104661. * @param indexCount defines the number of index to draw
  104662. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104663. */
  104664. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104665. /**
  104666. * Draw a list of points
  104667. * @param verticesStart defines the index of first vertex to draw
  104668. * @param verticesCount defines the count of vertices to draw
  104669. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104670. */
  104671. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104672. /**
  104673. * Draw a list of unindexed primitives
  104674. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104675. * @param verticesStart defines the index of first vertex to draw
  104676. * @param verticesCount defines the count of vertices to draw
  104677. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104678. */
  104679. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104680. /**
  104681. * Draw a list of indexed primitives
  104682. * @param fillMode defines the primitive to use
  104683. * @param indexStart defines the starting index
  104684. * @param indexCount defines the number of index to draw
  104685. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104686. */
  104687. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104688. /**
  104689. * Draw a list of unindexed primitives
  104690. * @param fillMode defines the primitive to use
  104691. * @param verticesStart defines the index of first vertex to draw
  104692. * @param verticesCount defines the count of vertices to draw
  104693. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104694. */
  104695. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104696. private _drawMode;
  104697. /** @hidden */
  104698. protected _reportDrawCall(): void;
  104699. /** @hidden */
  104700. _releaseEffect(effect: Effect): void;
  104701. /** @hidden */
  104702. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104703. /**
  104704. * Create a new effect (used to store vertex/fragment shaders)
  104705. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  104706. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  104707. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  104708. * @param samplers defines an array of string used to represent textures
  104709. * @param defines defines the string containing the defines to use to compile the shaders
  104710. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  104711. * @param onCompiled defines a function to call when the effect creation is successful
  104712. * @param onError defines a function to call when the effect creation has failed
  104713. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  104714. * @returns the new Effect
  104715. */
  104716. 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;
  104717. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  104718. private _compileShader;
  104719. private _compileRawShader;
  104720. /**
  104721. * Directly creates a webGL program
  104722. * @param pipelineContext defines the pipeline context to attach to
  104723. * @param vertexCode defines the vertex shader code to use
  104724. * @param fragmentCode defines the fragment shader code to use
  104725. * @param context defines the webGL context to use (if not set, the current one will be used)
  104726. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104727. * @returns the new webGL program
  104728. */
  104729. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104730. /**
  104731. * Creates a webGL program
  104732. * @param pipelineContext defines the pipeline context to attach to
  104733. * @param vertexCode defines the vertex shader code to use
  104734. * @param fragmentCode defines the fragment shader code to use
  104735. * @param defines defines the string containing the defines to use to compile the shaders
  104736. * @param context defines the webGL context to use (if not set, the current one will be used)
  104737. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104738. * @returns the new webGL program
  104739. */
  104740. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104741. /**
  104742. * Creates a new pipeline context
  104743. * @returns the new pipeline
  104744. */
  104745. createPipelineContext(): IPipelineContext;
  104746. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104747. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  104748. /** @hidden */
  104749. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  104750. /** @hidden */
  104751. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  104752. /** @hidden */
  104753. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  104754. /**
  104755. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  104756. * @param pipelineContext defines the pipeline context to use
  104757. * @param uniformsNames defines the list of uniform names
  104758. * @returns an array of webGL uniform locations
  104759. */
  104760. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104761. /**
  104762. * Gets the lsit of active attributes for a given webGL program
  104763. * @param pipelineContext defines the pipeline context to use
  104764. * @param attributesNames defines the list of attribute names to get
  104765. * @returns an array of indices indicating the offset of each attribute
  104766. */
  104767. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104768. /**
  104769. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  104770. * @param effect defines the effect to activate
  104771. */
  104772. enableEffect(effect: Nullable<Effect>): void;
  104773. /**
  104774. * Set the value of an uniform to a number (int)
  104775. * @param uniform defines the webGL uniform location where to store the value
  104776. * @param value defines the int number to store
  104777. */
  104778. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104779. /**
  104780. * Set the value of an uniform to an array of int32
  104781. * @param uniform defines the webGL uniform location where to store the value
  104782. * @param array defines the array of int32 to store
  104783. */
  104784. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104785. /**
  104786. * Set the value of an uniform to an array of int32 (stored as vec2)
  104787. * @param uniform defines the webGL uniform location where to store the value
  104788. * @param array defines the array of int32 to store
  104789. */
  104790. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104791. /**
  104792. * Set the value of an uniform to an array of int32 (stored as vec3)
  104793. * @param uniform defines the webGL uniform location where to store the value
  104794. * @param array defines the array of int32 to store
  104795. */
  104796. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104797. /**
  104798. * Set the value of an uniform to an array of int32 (stored as vec4)
  104799. * @param uniform defines the webGL uniform location where to store the value
  104800. * @param array defines the array of int32 to store
  104801. */
  104802. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104803. /**
  104804. * Set the value of an uniform to an array of number
  104805. * @param uniform defines the webGL uniform location where to store the value
  104806. * @param array defines the array of number to store
  104807. */
  104808. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104809. /**
  104810. * Set the value of an uniform to an array of number (stored as vec2)
  104811. * @param uniform defines the webGL uniform location where to store the value
  104812. * @param array defines the array of number to store
  104813. */
  104814. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104815. /**
  104816. * Set the value of an uniform to an array of number (stored as vec3)
  104817. * @param uniform defines the webGL uniform location where to store the value
  104818. * @param array defines the array of number to store
  104819. */
  104820. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104821. /**
  104822. * Set the value of an uniform to an array of number (stored as vec4)
  104823. * @param uniform defines the webGL uniform location where to store the value
  104824. * @param array defines the array of number to store
  104825. */
  104826. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104827. /**
  104828. * Set the value of an uniform to an array of float32 (stored as matrices)
  104829. * @param uniform defines the webGL uniform location where to store the value
  104830. * @param matrices defines the array of float32 to store
  104831. */
  104832. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  104833. /**
  104834. * Set the value of an uniform to a matrix (3x3)
  104835. * @param uniform defines the webGL uniform location where to store the value
  104836. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  104837. */
  104838. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104839. /**
  104840. * Set the value of an uniform to a matrix (2x2)
  104841. * @param uniform defines the webGL uniform location where to store the value
  104842. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  104843. */
  104844. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104845. /**
  104846. * Set the value of an uniform to a number (float)
  104847. * @param uniform defines the webGL uniform location where to store the value
  104848. * @param value defines the float number to store
  104849. */
  104850. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104851. /**
  104852. * Set the value of an uniform to a vec2
  104853. * @param uniform defines the webGL uniform location where to store the value
  104854. * @param x defines the 1st component of the value
  104855. * @param y defines the 2nd component of the value
  104856. */
  104857. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  104858. /**
  104859. * Set the value of an uniform to a vec3
  104860. * @param uniform defines the webGL uniform location where to store the value
  104861. * @param x defines the 1st component of the value
  104862. * @param y defines the 2nd component of the value
  104863. * @param z defines the 3rd component of the value
  104864. */
  104865. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  104866. /**
  104867. * Set the value of an uniform to a vec4
  104868. * @param uniform defines the webGL uniform location where to store the value
  104869. * @param x defines the 1st component of the value
  104870. * @param y defines the 2nd component of the value
  104871. * @param z defines the 3rd component of the value
  104872. * @param w defines the 4th component of the value
  104873. */
  104874. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  104875. /**
  104876. * Apply all cached states (depth, culling, stencil and alpha)
  104877. */
  104878. applyStates(): void;
  104879. /**
  104880. * Enable or disable color writing
  104881. * @param enable defines the state to set
  104882. */
  104883. setColorWrite(enable: boolean): void;
  104884. /**
  104885. * Gets a boolean indicating if color writing is enabled
  104886. * @returns the current color writing state
  104887. */
  104888. getColorWrite(): boolean;
  104889. /**
  104890. * Gets the depth culling state manager
  104891. */
  104892. get depthCullingState(): DepthCullingState;
  104893. /**
  104894. * Gets the alpha state manager
  104895. */
  104896. get alphaState(): AlphaState;
  104897. /**
  104898. * Gets the stencil state manager
  104899. */
  104900. get stencilState(): StencilState;
  104901. /**
  104902. * Clears the list of texture accessible through engine.
  104903. * This can help preventing texture load conflict due to name collision.
  104904. */
  104905. clearInternalTexturesCache(): void;
  104906. /**
  104907. * Force the entire cache to be cleared
  104908. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  104909. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  104910. */
  104911. wipeCaches(bruteForce?: boolean): void;
  104912. /** @hidden */
  104913. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  104914. min: number;
  104915. mag: number;
  104916. };
  104917. /** @hidden */
  104918. _createTexture(): WebGLTexture;
  104919. /**
  104920. * Usually called from Texture.ts.
  104921. * Passed information to create a WebGLTexture
  104922. * @param urlArg defines a value which contains one of the following:
  104923. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  104924. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  104925. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  104926. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  104927. * @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)
  104928. * @param scene needed for loading to the correct scene
  104929. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  104930. * @param onLoad optional callback to be called upon successful completion
  104931. * @param onError optional callback to be called upon failure
  104932. * @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
  104933. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  104934. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  104935. * @param forcedExtension defines the extension to use to pick the right loader
  104936. * @param mimeType defines an optional mime type
  104937. * @returns a InternalTexture for assignment back into BABYLON.Texture
  104938. */
  104939. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  104940. /**
  104941. * Loads an image as an HTMLImageElement.
  104942. * @param input url string, ArrayBuffer, or Blob to load
  104943. * @param onLoad callback called when the image successfully loads
  104944. * @param onError callback called when the image fails to load
  104945. * @param offlineProvider offline provider for caching
  104946. * @param mimeType optional mime type
  104947. * @returns the HTMLImageElement of the loaded image
  104948. * @hidden
  104949. */
  104950. 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>;
  104951. /**
  104952. * @hidden
  104953. */
  104954. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  104955. /**
  104956. * Creates a raw texture
  104957. * @param data defines the data to store in the texture
  104958. * @param width defines the width of the texture
  104959. * @param height defines the height of the texture
  104960. * @param format defines the format of the data
  104961. * @param generateMipMaps defines if the engine should generate the mip levels
  104962. * @param invertY defines if data must be stored with Y axis inverted
  104963. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  104964. * @param compression defines the compression used (null by default)
  104965. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  104966. * @returns the raw texture inside an InternalTexture
  104967. */
  104968. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  104969. /**
  104970. * Creates a new raw cube texture
  104971. * @param data defines the array of data to use to create each face
  104972. * @param size defines the size of the textures
  104973. * @param format defines the format of the data
  104974. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  104975. * @param generateMipMaps defines if the engine should generate the mip levels
  104976. * @param invertY defines if data must be stored with Y axis inverted
  104977. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104978. * @param compression defines the compression used (null by default)
  104979. * @returns the cube texture as an InternalTexture
  104980. */
  104981. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  104982. /**
  104983. * Creates a new raw 3D texture
  104984. * @param data defines the data used to create the texture
  104985. * @param width defines the width of the texture
  104986. * @param height defines the height of the texture
  104987. * @param depth defines the depth of the texture
  104988. * @param format defines the format of the texture
  104989. * @param generateMipMaps defines if the engine must generate mip levels
  104990. * @param invertY defines if data must be stored with Y axis inverted
  104991. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  104992. * @param compression defines the compressed used (can be null)
  104993. * @param textureType defines the compressed used (can be null)
  104994. * @returns a new raw 3D texture (stored in an InternalTexture)
  104995. */
  104996. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  104997. /**
  104998. * Creates a new raw 2D array texture
  104999. * @param data defines the data used to create the texture
  105000. * @param width defines the width of the texture
  105001. * @param height defines the height of the texture
  105002. * @param depth defines the number of layers of the texture
  105003. * @param format defines the format of the texture
  105004. * @param generateMipMaps defines if the engine must generate mip levels
  105005. * @param invertY defines if data must be stored with Y axis inverted
  105006. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105007. * @param compression defines the compressed used (can be null)
  105008. * @param textureType defines the compressed used (can be null)
  105009. * @returns a new raw 2D array texture (stored in an InternalTexture)
  105010. */
  105011. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105012. private _unpackFlipYCached;
  105013. /**
  105014. * In case you are sharing the context with other applications, it might
  105015. * be interested to not cache the unpack flip y state to ensure a consistent
  105016. * value would be set.
  105017. */
  105018. enableUnpackFlipYCached: boolean;
  105019. /** @hidden */
  105020. _unpackFlipY(value: boolean): void;
  105021. /** @hidden */
  105022. _getUnpackAlignement(): number;
  105023. private _getTextureTarget;
  105024. /**
  105025. * Update the sampling mode of a given texture
  105026. * @param samplingMode defines the required sampling mode
  105027. * @param texture defines the texture to update
  105028. * @param generateMipMaps defines whether to generate mipmaps for the texture
  105029. */
  105030. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  105031. /**
  105032. * Update the sampling mode of a given texture
  105033. * @param texture defines the texture to update
  105034. * @param wrapU defines the texture wrap mode of the u coordinates
  105035. * @param wrapV defines the texture wrap mode of the v coordinates
  105036. * @param wrapR defines the texture wrap mode of the r coordinates
  105037. */
  105038. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  105039. /** @hidden */
  105040. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  105041. width: number;
  105042. height: number;
  105043. layers?: number;
  105044. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  105045. /** @hidden */
  105046. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105047. /** @hidden */
  105048. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  105049. /**
  105050. * Update a portion of an internal texture
  105051. * @param texture defines the texture to update
  105052. * @param imageData defines the data to store into the texture
  105053. * @param xOffset defines the x coordinates of the update rectangle
  105054. * @param yOffset defines the y coordinates of the update rectangle
  105055. * @param width defines the width of the update rectangle
  105056. * @param height defines the height of the update rectangle
  105057. * @param faceIndex defines the face index if texture is a cube (0 by default)
  105058. * @param lod defines the lod level to update (0 by default)
  105059. */
  105060. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  105061. /** @hidden */
  105062. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105063. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  105064. private _prepareWebGLTexture;
  105065. /** @hidden */
  105066. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  105067. private _getDepthStencilBuffer;
  105068. /** @hidden */
  105069. _releaseFramebufferObjects(texture: InternalTexture): void;
  105070. /** @hidden */
  105071. _releaseTexture(texture: InternalTexture): void;
  105072. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  105073. protected _setProgram(program: WebGLProgram): void;
  105074. protected _boundUniforms: {
  105075. [key: number]: WebGLUniformLocation;
  105076. };
  105077. /**
  105078. * Binds an effect to the webGL context
  105079. * @param effect defines the effect to bind
  105080. */
  105081. bindSamplers(effect: Effect): void;
  105082. private _activateCurrentTexture;
  105083. /** @hidden */
  105084. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  105085. /** @hidden */
  105086. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  105087. /**
  105088. * Unbind all textures from the webGL context
  105089. */
  105090. unbindAllTextures(): void;
  105091. /**
  105092. * Sets a texture to the according uniform.
  105093. * @param channel The texture channel
  105094. * @param uniform The uniform to set
  105095. * @param texture The texture to apply
  105096. */
  105097. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  105098. private _bindSamplerUniformToChannel;
  105099. private _getTextureWrapMode;
  105100. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  105101. /**
  105102. * Sets an array of texture to the webGL context
  105103. * @param channel defines the channel where the texture array must be set
  105104. * @param uniform defines the associated uniform location
  105105. * @param textures defines the array of textures to bind
  105106. */
  105107. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  105108. /** @hidden */
  105109. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  105110. private _setTextureParameterFloat;
  105111. private _setTextureParameterInteger;
  105112. /**
  105113. * Unbind all vertex attributes from the webGL context
  105114. */
  105115. unbindAllAttributes(): void;
  105116. /**
  105117. * 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
  105118. */
  105119. releaseEffects(): void;
  105120. /**
  105121. * Dispose and release all associated resources
  105122. */
  105123. dispose(): void;
  105124. /**
  105125. * Attach a new callback raised when context lost event is fired
  105126. * @param callback defines the callback to call
  105127. */
  105128. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105129. /**
  105130. * Attach a new callback raised when context restored event is fired
  105131. * @param callback defines the callback to call
  105132. */
  105133. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105134. /**
  105135. * Get the current error code of the webGL context
  105136. * @returns the error code
  105137. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  105138. */
  105139. getError(): number;
  105140. private _canRenderToFloatFramebuffer;
  105141. private _canRenderToHalfFloatFramebuffer;
  105142. private _canRenderToFramebuffer;
  105143. /** @hidden */
  105144. _getWebGLTextureType(type: number): number;
  105145. /** @hidden */
  105146. _getInternalFormat(format: number): number;
  105147. /** @hidden */
  105148. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  105149. /** @hidden */
  105150. _getRGBAMultiSampleBufferFormat(type: number): number;
  105151. /** @hidden */
  105152. _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;
  105153. /**
  105154. * Loads a file from a url
  105155. * @param url url to load
  105156. * @param onSuccess callback called when the file successfully loads
  105157. * @param onProgress callback called while file is loading (if the server supports this mode)
  105158. * @param offlineProvider defines the offline provider for caching
  105159. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  105160. * @param onError callback called when the file fails to load
  105161. * @returns a file request object
  105162. * @hidden
  105163. */
  105164. 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;
  105165. /**
  105166. * Reads pixels from the current frame buffer. Please note that this function can be slow
  105167. * @param x defines the x coordinate of the rectangle where pixels must be read
  105168. * @param y defines the y coordinate of the rectangle where pixels must be read
  105169. * @param width defines the width of the rectangle where pixels must be read
  105170. * @param height defines the height of the rectangle where pixels must be read
  105171. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  105172. * @returns a Uint8Array containing RGBA colors
  105173. */
  105174. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  105175. private static _isSupported;
  105176. /**
  105177. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  105178. * @returns true if the engine can be created
  105179. * @ignorenaming
  105180. */
  105181. static isSupported(): boolean;
  105182. /**
  105183. * Find the next highest power of two.
  105184. * @param x Number to start search from.
  105185. * @return Next highest power of two.
  105186. */
  105187. static CeilingPOT(x: number): number;
  105188. /**
  105189. * Find the next lowest power of two.
  105190. * @param x Number to start search from.
  105191. * @return Next lowest power of two.
  105192. */
  105193. static FloorPOT(x: number): number;
  105194. /**
  105195. * Find the nearest power of two.
  105196. * @param x Number to start search from.
  105197. * @return Next nearest power of two.
  105198. */
  105199. static NearestPOT(x: number): number;
  105200. /**
  105201. * Get the closest exponent of two
  105202. * @param value defines the value to approximate
  105203. * @param max defines the maximum value to return
  105204. * @param mode defines how to define the closest value
  105205. * @returns closest exponent of two of the given value
  105206. */
  105207. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  105208. /**
  105209. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  105210. * @param func - the function to be called
  105211. * @param requester - the object that will request the next frame. Falls back to window.
  105212. * @returns frame number
  105213. */
  105214. static QueueNewFrame(func: () => void, requester?: any): number;
  105215. /**
  105216. * Gets host document
  105217. * @returns the host document object
  105218. */
  105219. getHostDocument(): Nullable<Document>;
  105220. }
  105221. }
  105222. declare module BABYLON {
  105223. /**
  105224. * Class representing spherical harmonics coefficients to the 3rd degree
  105225. */
  105226. export class SphericalHarmonics {
  105227. /**
  105228. * Defines whether or not the harmonics have been prescaled for rendering.
  105229. */
  105230. preScaled: boolean;
  105231. /**
  105232. * The l0,0 coefficients of the spherical harmonics
  105233. */
  105234. l00: Vector3;
  105235. /**
  105236. * The l1,-1 coefficients of the spherical harmonics
  105237. */
  105238. l1_1: Vector3;
  105239. /**
  105240. * The l1,0 coefficients of the spherical harmonics
  105241. */
  105242. l10: Vector3;
  105243. /**
  105244. * The l1,1 coefficients of the spherical harmonics
  105245. */
  105246. l11: Vector3;
  105247. /**
  105248. * The l2,-2 coefficients of the spherical harmonics
  105249. */
  105250. l2_2: Vector3;
  105251. /**
  105252. * The l2,-1 coefficients of the spherical harmonics
  105253. */
  105254. l2_1: Vector3;
  105255. /**
  105256. * The l2,0 coefficients of the spherical harmonics
  105257. */
  105258. l20: Vector3;
  105259. /**
  105260. * The l2,1 coefficients of the spherical harmonics
  105261. */
  105262. l21: Vector3;
  105263. /**
  105264. * The l2,2 coefficients of the spherical harmonics
  105265. */
  105266. l22: Vector3;
  105267. /**
  105268. * Adds a light to the spherical harmonics
  105269. * @param direction the direction of the light
  105270. * @param color the color of the light
  105271. * @param deltaSolidAngle the delta solid angle of the light
  105272. */
  105273. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  105274. /**
  105275. * Scales the spherical harmonics by the given amount
  105276. * @param scale the amount to scale
  105277. */
  105278. scaleInPlace(scale: number): void;
  105279. /**
  105280. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  105281. *
  105282. * ```
  105283. * E_lm = A_l * L_lm
  105284. * ```
  105285. *
  105286. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  105287. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  105288. * the scaling factors are given in equation 9.
  105289. */
  105290. convertIncidentRadianceToIrradiance(): void;
  105291. /**
  105292. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  105293. *
  105294. * ```
  105295. * L = (1/pi) * E * rho
  105296. * ```
  105297. *
  105298. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  105299. */
  105300. convertIrradianceToLambertianRadiance(): void;
  105301. /**
  105302. * Integrates the reconstruction coefficients directly in to the SH preventing further
  105303. * required operations at run time.
  105304. *
  105305. * This is simply done by scaling back the SH with Ylm constants parameter.
  105306. * The trigonometric part being applied by the shader at run time.
  105307. */
  105308. preScaleForRendering(): void;
  105309. /**
  105310. * Constructs a spherical harmonics from an array.
  105311. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  105312. * @returns the spherical harmonics
  105313. */
  105314. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  105315. /**
  105316. * Gets the spherical harmonics from polynomial
  105317. * @param polynomial the spherical polynomial
  105318. * @returns the spherical harmonics
  105319. */
  105320. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  105321. }
  105322. /**
  105323. * Class representing spherical polynomial coefficients to the 3rd degree
  105324. */
  105325. export class SphericalPolynomial {
  105326. private _harmonics;
  105327. /**
  105328. * The spherical harmonics used to create the polynomials.
  105329. */
  105330. get preScaledHarmonics(): SphericalHarmonics;
  105331. /**
  105332. * The x coefficients of the spherical polynomial
  105333. */
  105334. x: Vector3;
  105335. /**
  105336. * The y coefficients of the spherical polynomial
  105337. */
  105338. y: Vector3;
  105339. /**
  105340. * The z coefficients of the spherical polynomial
  105341. */
  105342. z: Vector3;
  105343. /**
  105344. * The xx coefficients of the spherical polynomial
  105345. */
  105346. xx: Vector3;
  105347. /**
  105348. * The yy coefficients of the spherical polynomial
  105349. */
  105350. yy: Vector3;
  105351. /**
  105352. * The zz coefficients of the spherical polynomial
  105353. */
  105354. zz: Vector3;
  105355. /**
  105356. * The xy coefficients of the spherical polynomial
  105357. */
  105358. xy: Vector3;
  105359. /**
  105360. * The yz coefficients of the spherical polynomial
  105361. */
  105362. yz: Vector3;
  105363. /**
  105364. * The zx coefficients of the spherical polynomial
  105365. */
  105366. zx: Vector3;
  105367. /**
  105368. * Adds an ambient color to the spherical polynomial
  105369. * @param color the color to add
  105370. */
  105371. addAmbient(color: Color3): void;
  105372. /**
  105373. * Scales the spherical polynomial by the given amount
  105374. * @param scale the amount to scale
  105375. */
  105376. scaleInPlace(scale: number): void;
  105377. /**
  105378. * Gets the spherical polynomial from harmonics
  105379. * @param harmonics the spherical harmonics
  105380. * @returns the spherical polynomial
  105381. */
  105382. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  105383. /**
  105384. * Constructs a spherical polynomial from an array.
  105385. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  105386. * @returns the spherical polynomial
  105387. */
  105388. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  105389. }
  105390. }
  105391. declare module BABYLON {
  105392. /**
  105393. * Defines the source of the internal texture
  105394. */
  105395. export enum InternalTextureSource {
  105396. /**
  105397. * The source of the texture data is unknown
  105398. */
  105399. Unknown = 0,
  105400. /**
  105401. * Texture data comes from an URL
  105402. */
  105403. Url = 1,
  105404. /**
  105405. * Texture data is only used for temporary storage
  105406. */
  105407. Temp = 2,
  105408. /**
  105409. * Texture data comes from raw data (ArrayBuffer)
  105410. */
  105411. Raw = 3,
  105412. /**
  105413. * Texture content is dynamic (video or dynamic texture)
  105414. */
  105415. Dynamic = 4,
  105416. /**
  105417. * Texture content is generated by rendering to it
  105418. */
  105419. RenderTarget = 5,
  105420. /**
  105421. * Texture content is part of a multi render target process
  105422. */
  105423. MultiRenderTarget = 6,
  105424. /**
  105425. * Texture data comes from a cube data file
  105426. */
  105427. Cube = 7,
  105428. /**
  105429. * Texture data comes from a raw cube data
  105430. */
  105431. CubeRaw = 8,
  105432. /**
  105433. * Texture data come from a prefiltered cube data file
  105434. */
  105435. CubePrefiltered = 9,
  105436. /**
  105437. * Texture content is raw 3D data
  105438. */
  105439. Raw3D = 10,
  105440. /**
  105441. * Texture content is raw 2D array data
  105442. */
  105443. Raw2DArray = 11,
  105444. /**
  105445. * Texture content is a depth texture
  105446. */
  105447. Depth = 12,
  105448. /**
  105449. * Texture data comes from a raw cube data encoded with RGBD
  105450. */
  105451. CubeRawRGBD = 13
  105452. }
  105453. /**
  105454. * Class used to store data associated with WebGL texture data for the engine
  105455. * This class should not be used directly
  105456. */
  105457. export class InternalTexture {
  105458. /** @hidden */
  105459. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  105460. /**
  105461. * Defines if the texture is ready
  105462. */
  105463. isReady: boolean;
  105464. /**
  105465. * Defines if the texture is a cube texture
  105466. */
  105467. isCube: boolean;
  105468. /**
  105469. * Defines if the texture contains 3D data
  105470. */
  105471. is3D: boolean;
  105472. /**
  105473. * Defines if the texture contains 2D array data
  105474. */
  105475. is2DArray: boolean;
  105476. /**
  105477. * Defines if the texture contains multiview data
  105478. */
  105479. isMultiview: boolean;
  105480. /**
  105481. * Gets the URL used to load this texture
  105482. */
  105483. url: string;
  105484. /**
  105485. * Gets the sampling mode of the texture
  105486. */
  105487. samplingMode: number;
  105488. /**
  105489. * Gets a boolean indicating if the texture needs mipmaps generation
  105490. */
  105491. generateMipMaps: boolean;
  105492. /**
  105493. * Gets the number of samples used by the texture (WebGL2+ only)
  105494. */
  105495. samples: number;
  105496. /**
  105497. * Gets the type of the texture (int, float...)
  105498. */
  105499. type: number;
  105500. /**
  105501. * Gets the format of the texture (RGB, RGBA...)
  105502. */
  105503. format: number;
  105504. /**
  105505. * Observable called when the texture is loaded
  105506. */
  105507. onLoadedObservable: Observable<InternalTexture>;
  105508. /**
  105509. * Gets the width of the texture
  105510. */
  105511. width: number;
  105512. /**
  105513. * Gets the height of the texture
  105514. */
  105515. height: number;
  105516. /**
  105517. * Gets the depth of the texture
  105518. */
  105519. depth: number;
  105520. /**
  105521. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  105522. */
  105523. baseWidth: number;
  105524. /**
  105525. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  105526. */
  105527. baseHeight: number;
  105528. /**
  105529. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  105530. */
  105531. baseDepth: number;
  105532. /**
  105533. * Gets a boolean indicating if the texture is inverted on Y axis
  105534. */
  105535. invertY: boolean;
  105536. /** @hidden */
  105537. _invertVScale: boolean;
  105538. /** @hidden */
  105539. _associatedChannel: number;
  105540. /** @hidden */
  105541. _source: InternalTextureSource;
  105542. /** @hidden */
  105543. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  105544. /** @hidden */
  105545. _bufferView: Nullable<ArrayBufferView>;
  105546. /** @hidden */
  105547. _bufferViewArray: Nullable<ArrayBufferView[]>;
  105548. /** @hidden */
  105549. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  105550. /** @hidden */
  105551. _size: number;
  105552. /** @hidden */
  105553. _extension: string;
  105554. /** @hidden */
  105555. _files: Nullable<string[]>;
  105556. /** @hidden */
  105557. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105558. /** @hidden */
  105559. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105560. /** @hidden */
  105561. _framebuffer: Nullable<WebGLFramebuffer>;
  105562. /** @hidden */
  105563. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  105564. /** @hidden */
  105565. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  105566. /** @hidden */
  105567. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  105568. /** @hidden */
  105569. _attachments: Nullable<number[]>;
  105570. /** @hidden */
  105571. _cachedCoordinatesMode: Nullable<number>;
  105572. /** @hidden */
  105573. _cachedWrapU: Nullable<number>;
  105574. /** @hidden */
  105575. _cachedWrapV: Nullable<number>;
  105576. /** @hidden */
  105577. _cachedWrapR: Nullable<number>;
  105578. /** @hidden */
  105579. _cachedAnisotropicFilteringLevel: Nullable<number>;
  105580. /** @hidden */
  105581. _isDisabled: boolean;
  105582. /** @hidden */
  105583. _compression: Nullable<string>;
  105584. /** @hidden */
  105585. _generateStencilBuffer: boolean;
  105586. /** @hidden */
  105587. _generateDepthBuffer: boolean;
  105588. /** @hidden */
  105589. _comparisonFunction: number;
  105590. /** @hidden */
  105591. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  105592. /** @hidden */
  105593. _lodGenerationScale: number;
  105594. /** @hidden */
  105595. _lodGenerationOffset: number;
  105596. /** @hidden */
  105597. _depthStencilTexture: Nullable<InternalTexture>;
  105598. /** @hidden */
  105599. _colorTextureArray: Nullable<WebGLTexture>;
  105600. /** @hidden */
  105601. _depthStencilTextureArray: Nullable<WebGLTexture>;
  105602. /** @hidden */
  105603. _lodTextureHigh: Nullable<BaseTexture>;
  105604. /** @hidden */
  105605. _lodTextureMid: Nullable<BaseTexture>;
  105606. /** @hidden */
  105607. _lodTextureLow: Nullable<BaseTexture>;
  105608. /** @hidden */
  105609. _isRGBD: boolean;
  105610. /** @hidden */
  105611. _linearSpecularLOD: boolean;
  105612. /** @hidden */
  105613. _irradianceTexture: Nullable<BaseTexture>;
  105614. /** @hidden */
  105615. _webGLTexture: Nullable<WebGLTexture>;
  105616. /** @hidden */
  105617. _references: number;
  105618. private _engine;
  105619. /**
  105620. * Gets the Engine the texture belongs to.
  105621. * @returns The babylon engine
  105622. */
  105623. getEngine(): ThinEngine;
  105624. /**
  105625. * Gets the data source type of the texture
  105626. */
  105627. get source(): InternalTextureSource;
  105628. /**
  105629. * Creates a new InternalTexture
  105630. * @param engine defines the engine to use
  105631. * @param source defines the type of data that will be used
  105632. * @param delayAllocation if the texture allocation should be delayed (default: false)
  105633. */
  105634. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  105635. /**
  105636. * Increments the number of references (ie. the number of Texture that point to it)
  105637. */
  105638. incrementReferences(): void;
  105639. /**
  105640. * Change the size of the texture (not the size of the content)
  105641. * @param width defines the new width
  105642. * @param height defines the new height
  105643. * @param depth defines the new depth (1 by default)
  105644. */
  105645. updateSize(width: int, height: int, depth?: int): void;
  105646. /** @hidden */
  105647. _rebuild(): void;
  105648. /** @hidden */
  105649. _swapAndDie(target: InternalTexture): void;
  105650. /**
  105651. * Dispose the current allocated resources
  105652. */
  105653. dispose(): void;
  105654. }
  105655. }
  105656. declare module BABYLON {
  105657. /**
  105658. * Class used to work with sound analyzer using fast fourier transform (FFT)
  105659. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105660. */
  105661. export class Analyser {
  105662. /**
  105663. * Gets or sets the smoothing
  105664. * @ignorenaming
  105665. */
  105666. SMOOTHING: number;
  105667. /**
  105668. * Gets or sets the FFT table size
  105669. * @ignorenaming
  105670. */
  105671. FFT_SIZE: number;
  105672. /**
  105673. * Gets or sets the bar graph amplitude
  105674. * @ignorenaming
  105675. */
  105676. BARGRAPHAMPLITUDE: number;
  105677. /**
  105678. * Gets or sets the position of the debug canvas
  105679. * @ignorenaming
  105680. */
  105681. DEBUGCANVASPOS: {
  105682. x: number;
  105683. y: number;
  105684. };
  105685. /**
  105686. * Gets or sets the debug canvas size
  105687. * @ignorenaming
  105688. */
  105689. DEBUGCANVASSIZE: {
  105690. width: number;
  105691. height: number;
  105692. };
  105693. private _byteFreqs;
  105694. private _byteTime;
  105695. private _floatFreqs;
  105696. private _webAudioAnalyser;
  105697. private _debugCanvas;
  105698. private _debugCanvasContext;
  105699. private _scene;
  105700. private _registerFunc;
  105701. private _audioEngine;
  105702. /**
  105703. * Creates a new analyser
  105704. * @param scene defines hosting scene
  105705. */
  105706. constructor(scene: Scene);
  105707. /**
  105708. * Get the number of data values you will have to play with for the visualization
  105709. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  105710. * @returns a number
  105711. */
  105712. getFrequencyBinCount(): number;
  105713. /**
  105714. * Gets the current frequency data as a byte array
  105715. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105716. * @returns a Uint8Array
  105717. */
  105718. getByteFrequencyData(): Uint8Array;
  105719. /**
  105720. * Gets the current waveform as a byte array
  105721. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  105722. * @returns a Uint8Array
  105723. */
  105724. getByteTimeDomainData(): Uint8Array;
  105725. /**
  105726. * Gets the current frequency data as a float array
  105727. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105728. * @returns a Float32Array
  105729. */
  105730. getFloatFrequencyData(): Float32Array;
  105731. /**
  105732. * Renders the debug canvas
  105733. */
  105734. drawDebugCanvas(): void;
  105735. /**
  105736. * Stops rendering the debug canvas and removes it
  105737. */
  105738. stopDebugCanvas(): void;
  105739. /**
  105740. * Connects two audio nodes
  105741. * @param inputAudioNode defines first node to connect
  105742. * @param outputAudioNode defines second node to connect
  105743. */
  105744. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  105745. /**
  105746. * Releases all associated resources
  105747. */
  105748. dispose(): void;
  105749. }
  105750. }
  105751. declare module BABYLON {
  105752. /**
  105753. * This represents an audio engine and it is responsible
  105754. * to play, synchronize and analyse sounds throughout the application.
  105755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105756. */
  105757. export interface IAudioEngine extends IDisposable {
  105758. /**
  105759. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105760. */
  105761. readonly canUseWebAudio: boolean;
  105762. /**
  105763. * Gets the current AudioContext if available.
  105764. */
  105765. readonly audioContext: Nullable<AudioContext>;
  105766. /**
  105767. * The master gain node defines the global audio volume of your audio engine.
  105768. */
  105769. readonly masterGain: GainNode;
  105770. /**
  105771. * Gets whether or not mp3 are supported by your browser.
  105772. */
  105773. readonly isMP3supported: boolean;
  105774. /**
  105775. * Gets whether or not ogg are supported by your browser.
  105776. */
  105777. readonly isOGGsupported: boolean;
  105778. /**
  105779. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105780. * @ignoreNaming
  105781. */
  105782. WarnedWebAudioUnsupported: boolean;
  105783. /**
  105784. * Defines if the audio engine relies on a custom unlocked button.
  105785. * In this case, the embedded button will not be displayed.
  105786. */
  105787. useCustomUnlockedButton: boolean;
  105788. /**
  105789. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  105790. */
  105791. readonly unlocked: boolean;
  105792. /**
  105793. * Event raised when audio has been unlocked on the browser.
  105794. */
  105795. onAudioUnlockedObservable: Observable<AudioEngine>;
  105796. /**
  105797. * Event raised when audio has been locked on the browser.
  105798. */
  105799. onAudioLockedObservable: Observable<AudioEngine>;
  105800. /**
  105801. * Flags the audio engine in Locked state.
  105802. * This happens due to new browser policies preventing audio to autoplay.
  105803. */
  105804. lock(): void;
  105805. /**
  105806. * Unlocks the audio engine once a user action has been done on the dom.
  105807. * This is helpful to resume play once browser policies have been satisfied.
  105808. */
  105809. unlock(): void;
  105810. }
  105811. /**
  105812. * This represents the default audio engine used in babylon.
  105813. * It is responsible to play, synchronize and analyse sounds throughout the application.
  105814. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105815. */
  105816. export class AudioEngine implements IAudioEngine {
  105817. private _audioContext;
  105818. private _audioContextInitialized;
  105819. private _muteButton;
  105820. private _hostElement;
  105821. /**
  105822. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105823. */
  105824. canUseWebAudio: boolean;
  105825. /**
  105826. * The master gain node defines the global audio volume of your audio engine.
  105827. */
  105828. masterGain: GainNode;
  105829. /**
  105830. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105831. * @ignoreNaming
  105832. */
  105833. WarnedWebAudioUnsupported: boolean;
  105834. /**
  105835. * Gets whether or not mp3 are supported by your browser.
  105836. */
  105837. isMP3supported: boolean;
  105838. /**
  105839. * Gets whether or not ogg are supported by your browser.
  105840. */
  105841. isOGGsupported: boolean;
  105842. /**
  105843. * Gets whether audio has been unlocked on the device.
  105844. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  105845. * a user interaction has happened.
  105846. */
  105847. unlocked: boolean;
  105848. /**
  105849. * Defines if the audio engine relies on a custom unlocked button.
  105850. * In this case, the embedded button will not be displayed.
  105851. */
  105852. useCustomUnlockedButton: boolean;
  105853. /**
  105854. * Event raised when audio has been unlocked on the browser.
  105855. */
  105856. onAudioUnlockedObservable: Observable<AudioEngine>;
  105857. /**
  105858. * Event raised when audio has been locked on the browser.
  105859. */
  105860. onAudioLockedObservable: Observable<AudioEngine>;
  105861. /**
  105862. * Gets the current AudioContext if available.
  105863. */
  105864. get audioContext(): Nullable<AudioContext>;
  105865. private _connectedAnalyser;
  105866. /**
  105867. * Instantiates a new audio engine.
  105868. *
  105869. * There should be only one per page as some browsers restrict the number
  105870. * of audio contexts you can create.
  105871. * @param hostElement defines the host element where to display the mute icon if necessary
  105872. */
  105873. constructor(hostElement?: Nullable<HTMLElement>);
  105874. /**
  105875. * Flags the audio engine in Locked state.
  105876. * This happens due to new browser policies preventing audio to autoplay.
  105877. */
  105878. lock(): void;
  105879. /**
  105880. * Unlocks the audio engine once a user action has been done on the dom.
  105881. * This is helpful to resume play once browser policies have been satisfied.
  105882. */
  105883. unlock(): void;
  105884. private _resumeAudioContext;
  105885. private _initializeAudioContext;
  105886. private _tryToRun;
  105887. private _triggerRunningState;
  105888. private _triggerSuspendedState;
  105889. private _displayMuteButton;
  105890. private _moveButtonToTopLeft;
  105891. private _onResize;
  105892. private _hideMuteButton;
  105893. /**
  105894. * Destroy and release the resources associated with the audio ccontext.
  105895. */
  105896. dispose(): void;
  105897. /**
  105898. * Gets the global volume sets on the master gain.
  105899. * @returns the global volume if set or -1 otherwise
  105900. */
  105901. getGlobalVolume(): number;
  105902. /**
  105903. * Sets the global volume of your experience (sets on the master gain).
  105904. * @param newVolume Defines the new global volume of the application
  105905. */
  105906. setGlobalVolume(newVolume: number): void;
  105907. /**
  105908. * Connect the audio engine to an audio analyser allowing some amazing
  105909. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  105910. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  105911. * @param analyser The analyser to connect to the engine
  105912. */
  105913. connectToAnalyser(analyser: Analyser): void;
  105914. }
  105915. }
  105916. declare module BABYLON {
  105917. /**
  105918. * Interface used to present a loading screen while loading a scene
  105919. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105920. */
  105921. export interface ILoadingScreen {
  105922. /**
  105923. * Function called to display the loading screen
  105924. */
  105925. displayLoadingUI: () => void;
  105926. /**
  105927. * Function called to hide the loading screen
  105928. */
  105929. hideLoadingUI: () => void;
  105930. /**
  105931. * Gets or sets the color to use for the background
  105932. */
  105933. loadingUIBackgroundColor: string;
  105934. /**
  105935. * Gets or sets the text to display while loading
  105936. */
  105937. loadingUIText: string;
  105938. }
  105939. /**
  105940. * Class used for the default loading screen
  105941. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  105942. */
  105943. export class DefaultLoadingScreen implements ILoadingScreen {
  105944. private _renderingCanvas;
  105945. private _loadingText;
  105946. private _loadingDivBackgroundColor;
  105947. private _loadingDiv;
  105948. private _loadingTextDiv;
  105949. /** Gets or sets the logo url to use for the default loading screen */
  105950. static DefaultLogoUrl: string;
  105951. /** Gets or sets the spinner url to use for the default loading screen */
  105952. static DefaultSpinnerUrl: string;
  105953. /**
  105954. * Creates a new default loading screen
  105955. * @param _renderingCanvas defines the canvas used to render the scene
  105956. * @param _loadingText defines the default text to display
  105957. * @param _loadingDivBackgroundColor defines the default background color
  105958. */
  105959. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  105960. /**
  105961. * Function called to display the loading screen
  105962. */
  105963. displayLoadingUI(): void;
  105964. /**
  105965. * Function called to hide the loading screen
  105966. */
  105967. hideLoadingUI(): void;
  105968. /**
  105969. * Gets or sets the text to display while loading
  105970. */
  105971. set loadingUIText(text: string);
  105972. get loadingUIText(): string;
  105973. /**
  105974. * Gets or sets the color to use for the background
  105975. */
  105976. get loadingUIBackgroundColor(): string;
  105977. set loadingUIBackgroundColor(color: string);
  105978. private _resizeLoadingUI;
  105979. }
  105980. }
  105981. declare module BABYLON {
  105982. /**
  105983. * Interface for any object that can request an animation frame
  105984. */
  105985. export interface ICustomAnimationFrameRequester {
  105986. /**
  105987. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  105988. */
  105989. renderFunction?: Function;
  105990. /**
  105991. * Called to request the next frame to render to
  105992. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  105993. */
  105994. requestAnimationFrame: Function;
  105995. /**
  105996. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  105997. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  105998. */
  105999. requestID?: number;
  106000. }
  106001. }
  106002. declare module BABYLON {
  106003. /**
  106004. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  106005. */
  106006. export class PerformanceMonitor {
  106007. private _enabled;
  106008. private _rollingFrameTime;
  106009. private _lastFrameTimeMs;
  106010. /**
  106011. * constructor
  106012. * @param frameSampleSize The number of samples required to saturate the sliding window
  106013. */
  106014. constructor(frameSampleSize?: number);
  106015. /**
  106016. * Samples current frame
  106017. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  106018. */
  106019. sampleFrame(timeMs?: number): void;
  106020. /**
  106021. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106022. */
  106023. get averageFrameTime(): number;
  106024. /**
  106025. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106026. */
  106027. get averageFrameTimeVariance(): number;
  106028. /**
  106029. * Returns the frame time of the most recent frame
  106030. */
  106031. get instantaneousFrameTime(): number;
  106032. /**
  106033. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  106034. */
  106035. get averageFPS(): number;
  106036. /**
  106037. * Returns the average framerate in frames per second using the most recent frame time
  106038. */
  106039. get instantaneousFPS(): number;
  106040. /**
  106041. * Returns true if enough samples have been taken to completely fill the sliding window
  106042. */
  106043. get isSaturated(): boolean;
  106044. /**
  106045. * Enables contributions to the sliding window sample set
  106046. */
  106047. enable(): void;
  106048. /**
  106049. * Disables contributions to the sliding window sample set
  106050. * Samples will not be interpolated over the disabled period
  106051. */
  106052. disable(): void;
  106053. /**
  106054. * Returns true if sampling is enabled
  106055. */
  106056. get isEnabled(): boolean;
  106057. /**
  106058. * Resets performance monitor
  106059. */
  106060. reset(): void;
  106061. }
  106062. /**
  106063. * RollingAverage
  106064. *
  106065. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  106066. */
  106067. export class RollingAverage {
  106068. /**
  106069. * Current average
  106070. */
  106071. average: number;
  106072. /**
  106073. * Current variance
  106074. */
  106075. variance: number;
  106076. protected _samples: Array<number>;
  106077. protected _sampleCount: number;
  106078. protected _pos: number;
  106079. protected _m2: number;
  106080. /**
  106081. * constructor
  106082. * @param length The number of samples required to saturate the sliding window
  106083. */
  106084. constructor(length: number);
  106085. /**
  106086. * Adds a sample to the sample set
  106087. * @param v The sample value
  106088. */
  106089. add(v: number): void;
  106090. /**
  106091. * Returns previously added values or null if outside of history or outside the sliding window domain
  106092. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  106093. * @return Value previously recorded with add() or null if outside of range
  106094. */
  106095. history(i: number): number;
  106096. /**
  106097. * Returns true if enough samples have been taken to completely fill the sliding window
  106098. * @return true if sample-set saturated
  106099. */
  106100. isSaturated(): boolean;
  106101. /**
  106102. * Resets the rolling average (equivalent to 0 samples taken so far)
  106103. */
  106104. reset(): void;
  106105. /**
  106106. * Wraps a value around the sample range boundaries
  106107. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  106108. * @return Wrapped position in sample range
  106109. */
  106110. protected _wrapPosition(i: number): number;
  106111. }
  106112. }
  106113. declare module BABYLON {
  106114. /**
  106115. * This class is used to track a performance counter which is number based.
  106116. * The user has access to many properties which give statistics of different nature.
  106117. *
  106118. * The implementer can track two kinds of Performance Counter: time and count.
  106119. * 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.
  106120. * 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.
  106121. */
  106122. export class PerfCounter {
  106123. /**
  106124. * Gets or sets a global boolean to turn on and off all the counters
  106125. */
  106126. static Enabled: boolean;
  106127. /**
  106128. * Returns the smallest value ever
  106129. */
  106130. get min(): number;
  106131. /**
  106132. * Returns the biggest value ever
  106133. */
  106134. get max(): number;
  106135. /**
  106136. * Returns the average value since the performance counter is running
  106137. */
  106138. get average(): number;
  106139. /**
  106140. * Returns the average value of the last second the counter was monitored
  106141. */
  106142. get lastSecAverage(): number;
  106143. /**
  106144. * Returns the current value
  106145. */
  106146. get current(): number;
  106147. /**
  106148. * Gets the accumulated total
  106149. */
  106150. get total(): number;
  106151. /**
  106152. * Gets the total value count
  106153. */
  106154. get count(): number;
  106155. /**
  106156. * Creates a new counter
  106157. */
  106158. constructor();
  106159. /**
  106160. * Call this method to start monitoring a new frame.
  106161. * 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.
  106162. */
  106163. fetchNewFrame(): void;
  106164. /**
  106165. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  106166. * @param newCount the count value to add to the monitored count
  106167. * @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.
  106168. */
  106169. addCount(newCount: number, fetchResult: boolean): void;
  106170. /**
  106171. * Start monitoring this performance counter
  106172. */
  106173. beginMonitoring(): void;
  106174. /**
  106175. * Compute the time lapsed since the previous beginMonitoring() call.
  106176. * @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
  106177. */
  106178. endMonitoring(newFrame?: boolean): void;
  106179. private _fetchResult;
  106180. private _startMonitoringTime;
  106181. private _min;
  106182. private _max;
  106183. private _average;
  106184. private _current;
  106185. private _totalValueCount;
  106186. private _totalAccumulated;
  106187. private _lastSecAverage;
  106188. private _lastSecAccumulated;
  106189. private _lastSecTime;
  106190. private _lastSecValueCount;
  106191. }
  106192. }
  106193. declare module BABYLON {
  106194. interface ThinEngine {
  106195. /**
  106196. * Sets alpha constants used by some alpha blending modes
  106197. * @param r defines the red component
  106198. * @param g defines the green component
  106199. * @param b defines the blue component
  106200. * @param a defines the alpha component
  106201. */
  106202. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  106203. /**
  106204. * Sets the current alpha mode
  106205. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  106206. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  106207. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106208. */
  106209. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106210. /**
  106211. * Gets the current alpha mode
  106212. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106213. * @returns the current alpha mode
  106214. */
  106215. getAlphaMode(): number;
  106216. /**
  106217. * Sets the current alpha equation
  106218. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  106219. */
  106220. setAlphaEquation(equation: number): void;
  106221. /**
  106222. * Gets the current alpha equation.
  106223. * @returns the current alpha equation
  106224. */
  106225. getAlphaEquation(): number;
  106226. }
  106227. }
  106228. declare module BABYLON {
  106229. /**
  106230. * Defines the interface used by display changed events
  106231. */
  106232. export interface IDisplayChangedEventArgs {
  106233. /** Gets the vrDisplay object (if any) */
  106234. vrDisplay: Nullable<any>;
  106235. /** Gets a boolean indicating if webVR is supported */
  106236. vrSupported: boolean;
  106237. }
  106238. /**
  106239. * Defines the interface used by objects containing a viewport (like a camera)
  106240. */
  106241. interface IViewportOwnerLike {
  106242. /**
  106243. * Gets or sets the viewport
  106244. */
  106245. viewport: IViewportLike;
  106246. }
  106247. /**
  106248. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  106249. */
  106250. export class Engine extends ThinEngine {
  106251. /** Defines that alpha blending is disabled */
  106252. static readonly ALPHA_DISABLE: number;
  106253. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  106254. static readonly ALPHA_ADD: number;
  106255. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  106256. static readonly ALPHA_COMBINE: number;
  106257. /** Defines that alpha blending to DEST - SRC * DEST */
  106258. static readonly ALPHA_SUBTRACT: number;
  106259. /** Defines that alpha blending to SRC * DEST */
  106260. static readonly ALPHA_MULTIPLY: number;
  106261. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  106262. static readonly ALPHA_MAXIMIZED: number;
  106263. /** Defines that alpha blending to SRC + DEST */
  106264. static readonly ALPHA_ONEONE: number;
  106265. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  106266. static readonly ALPHA_PREMULTIPLIED: number;
  106267. /**
  106268. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  106269. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  106270. */
  106271. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  106272. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  106273. static readonly ALPHA_INTERPOLATE: number;
  106274. /**
  106275. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  106276. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  106277. */
  106278. static readonly ALPHA_SCREENMODE: number;
  106279. /** Defines that the ressource is not delayed*/
  106280. static readonly DELAYLOADSTATE_NONE: number;
  106281. /** Defines that the ressource was successfully delay loaded */
  106282. static readonly DELAYLOADSTATE_LOADED: number;
  106283. /** Defines that the ressource is currently delay loading */
  106284. static readonly DELAYLOADSTATE_LOADING: number;
  106285. /** Defines that the ressource is delayed and has not started loading */
  106286. static readonly DELAYLOADSTATE_NOTLOADED: number;
  106287. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  106288. static readonly NEVER: number;
  106289. /** 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 */
  106290. static readonly ALWAYS: number;
  106291. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  106292. static readonly LESS: number;
  106293. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  106294. static readonly EQUAL: number;
  106295. /** 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 */
  106296. static readonly LEQUAL: number;
  106297. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  106298. static readonly GREATER: number;
  106299. /** 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 */
  106300. static readonly GEQUAL: number;
  106301. /** 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 */
  106302. static readonly NOTEQUAL: number;
  106303. /** Passed to stencilOperation to specify that stencil value must be kept */
  106304. static readonly KEEP: number;
  106305. /** Passed to stencilOperation to specify that stencil value must be replaced */
  106306. static readonly REPLACE: number;
  106307. /** Passed to stencilOperation to specify that stencil value must be incremented */
  106308. static readonly INCR: number;
  106309. /** Passed to stencilOperation to specify that stencil value must be decremented */
  106310. static readonly DECR: number;
  106311. /** Passed to stencilOperation to specify that stencil value must be inverted */
  106312. static readonly INVERT: number;
  106313. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  106314. static readonly INCR_WRAP: number;
  106315. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  106316. static readonly DECR_WRAP: number;
  106317. /** Texture is not repeating outside of 0..1 UVs */
  106318. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  106319. /** Texture is repeating outside of 0..1 UVs */
  106320. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  106321. /** Texture is repeating and mirrored */
  106322. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  106323. /** ALPHA */
  106324. static readonly TEXTUREFORMAT_ALPHA: number;
  106325. /** LUMINANCE */
  106326. static readonly TEXTUREFORMAT_LUMINANCE: number;
  106327. /** LUMINANCE_ALPHA */
  106328. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  106329. /** RGB */
  106330. static readonly TEXTUREFORMAT_RGB: number;
  106331. /** RGBA */
  106332. static readonly TEXTUREFORMAT_RGBA: number;
  106333. /** RED */
  106334. static readonly TEXTUREFORMAT_RED: number;
  106335. /** RED (2nd reference) */
  106336. static readonly TEXTUREFORMAT_R: number;
  106337. /** RG */
  106338. static readonly TEXTUREFORMAT_RG: number;
  106339. /** RED_INTEGER */
  106340. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  106341. /** RED_INTEGER (2nd reference) */
  106342. static readonly TEXTUREFORMAT_R_INTEGER: number;
  106343. /** RG_INTEGER */
  106344. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  106345. /** RGB_INTEGER */
  106346. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  106347. /** RGBA_INTEGER */
  106348. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  106349. /** UNSIGNED_BYTE */
  106350. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  106351. /** UNSIGNED_BYTE (2nd reference) */
  106352. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  106353. /** FLOAT */
  106354. static readonly TEXTURETYPE_FLOAT: number;
  106355. /** HALF_FLOAT */
  106356. static readonly TEXTURETYPE_HALF_FLOAT: number;
  106357. /** BYTE */
  106358. static readonly TEXTURETYPE_BYTE: number;
  106359. /** SHORT */
  106360. static readonly TEXTURETYPE_SHORT: number;
  106361. /** UNSIGNED_SHORT */
  106362. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  106363. /** INT */
  106364. static readonly TEXTURETYPE_INT: number;
  106365. /** UNSIGNED_INT */
  106366. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  106367. /** UNSIGNED_SHORT_4_4_4_4 */
  106368. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  106369. /** UNSIGNED_SHORT_5_5_5_1 */
  106370. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  106371. /** UNSIGNED_SHORT_5_6_5 */
  106372. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  106373. /** UNSIGNED_INT_2_10_10_10_REV */
  106374. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  106375. /** UNSIGNED_INT_24_8 */
  106376. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  106377. /** UNSIGNED_INT_10F_11F_11F_REV */
  106378. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  106379. /** UNSIGNED_INT_5_9_9_9_REV */
  106380. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  106381. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  106382. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  106383. /** nearest is mag = nearest and min = nearest and mip = linear */
  106384. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  106385. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106386. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  106387. /** Trilinear is mag = linear and min = linear and mip = linear */
  106388. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  106389. /** nearest is mag = nearest and min = nearest and mip = linear */
  106390. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  106391. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106392. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  106393. /** Trilinear is mag = linear and min = linear and mip = linear */
  106394. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  106395. /** mag = nearest and min = nearest and mip = nearest */
  106396. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  106397. /** mag = nearest and min = linear and mip = nearest */
  106398. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  106399. /** mag = nearest and min = linear and mip = linear */
  106400. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  106401. /** mag = nearest and min = linear and mip = none */
  106402. static readonly TEXTURE_NEAREST_LINEAR: number;
  106403. /** mag = nearest and min = nearest and mip = none */
  106404. static readonly TEXTURE_NEAREST_NEAREST: number;
  106405. /** mag = linear and min = nearest and mip = nearest */
  106406. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  106407. /** mag = linear and min = nearest and mip = linear */
  106408. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  106409. /** mag = linear and min = linear and mip = none */
  106410. static readonly TEXTURE_LINEAR_LINEAR: number;
  106411. /** mag = linear and min = nearest and mip = none */
  106412. static readonly TEXTURE_LINEAR_NEAREST: number;
  106413. /** Explicit coordinates mode */
  106414. static readonly TEXTURE_EXPLICIT_MODE: number;
  106415. /** Spherical coordinates mode */
  106416. static readonly TEXTURE_SPHERICAL_MODE: number;
  106417. /** Planar coordinates mode */
  106418. static readonly TEXTURE_PLANAR_MODE: number;
  106419. /** Cubic coordinates mode */
  106420. static readonly TEXTURE_CUBIC_MODE: number;
  106421. /** Projection coordinates mode */
  106422. static readonly TEXTURE_PROJECTION_MODE: number;
  106423. /** Skybox coordinates mode */
  106424. static readonly TEXTURE_SKYBOX_MODE: number;
  106425. /** Inverse Cubic coordinates mode */
  106426. static readonly TEXTURE_INVCUBIC_MODE: number;
  106427. /** Equirectangular coordinates mode */
  106428. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  106429. /** Equirectangular Fixed coordinates mode */
  106430. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  106431. /** Equirectangular Fixed Mirrored coordinates mode */
  106432. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  106433. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  106434. static readonly SCALEMODE_FLOOR: number;
  106435. /** Defines that texture rescaling will look for the nearest power of 2 size */
  106436. static readonly SCALEMODE_NEAREST: number;
  106437. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  106438. static readonly SCALEMODE_CEILING: number;
  106439. /**
  106440. * Returns the current npm package of the sdk
  106441. */
  106442. static get NpmPackage(): string;
  106443. /**
  106444. * Returns the current version of the framework
  106445. */
  106446. static get Version(): string;
  106447. /** Gets the list of created engines */
  106448. static get Instances(): Engine[];
  106449. /**
  106450. * Gets the latest created engine
  106451. */
  106452. static get LastCreatedEngine(): Nullable<Engine>;
  106453. /**
  106454. * Gets the latest created scene
  106455. */
  106456. static get LastCreatedScene(): Nullable<Scene>;
  106457. /**
  106458. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  106459. * @param flag defines which part of the materials must be marked as dirty
  106460. * @param predicate defines a predicate used to filter which materials should be affected
  106461. */
  106462. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  106463. /**
  106464. * Method called to create the default loading screen.
  106465. * This can be overriden in your own app.
  106466. * @param canvas The rendering canvas element
  106467. * @returns The loading screen
  106468. */
  106469. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  106470. /**
  106471. * Method called to create the default rescale post process on each engine.
  106472. */
  106473. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  106474. /**
  106475. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  106476. **/
  106477. enableOfflineSupport: boolean;
  106478. /**
  106479. * 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)
  106480. **/
  106481. disableManifestCheck: boolean;
  106482. /**
  106483. * Gets the list of created scenes
  106484. */
  106485. scenes: Scene[];
  106486. /**
  106487. * Event raised when a new scene is created
  106488. */
  106489. onNewSceneAddedObservable: Observable<Scene>;
  106490. /**
  106491. * Gets the list of created postprocesses
  106492. */
  106493. postProcesses: PostProcess[];
  106494. /**
  106495. * Gets a boolean indicating if the pointer is currently locked
  106496. */
  106497. isPointerLock: boolean;
  106498. /**
  106499. * Observable event triggered each time the rendering canvas is resized
  106500. */
  106501. onResizeObservable: Observable<Engine>;
  106502. /**
  106503. * Observable event triggered each time the canvas loses focus
  106504. */
  106505. onCanvasBlurObservable: Observable<Engine>;
  106506. /**
  106507. * Observable event triggered each time the canvas gains focus
  106508. */
  106509. onCanvasFocusObservable: Observable<Engine>;
  106510. /**
  106511. * Observable event triggered each time the canvas receives pointerout event
  106512. */
  106513. onCanvasPointerOutObservable: Observable<PointerEvent>;
  106514. /**
  106515. * Observable raised when the engine begins a new frame
  106516. */
  106517. onBeginFrameObservable: Observable<Engine>;
  106518. /**
  106519. * If set, will be used to request the next animation frame for the render loop
  106520. */
  106521. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  106522. /**
  106523. * Observable raised when the engine ends the current frame
  106524. */
  106525. onEndFrameObservable: Observable<Engine>;
  106526. /**
  106527. * Observable raised when the engine is about to compile a shader
  106528. */
  106529. onBeforeShaderCompilationObservable: Observable<Engine>;
  106530. /**
  106531. * Observable raised when the engine has jsut compiled a shader
  106532. */
  106533. onAfterShaderCompilationObservable: Observable<Engine>;
  106534. /**
  106535. * Gets the audio engine
  106536. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106537. * @ignorenaming
  106538. */
  106539. static audioEngine: IAudioEngine;
  106540. /**
  106541. * Default AudioEngine factory responsible of creating the Audio Engine.
  106542. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  106543. */
  106544. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  106545. /**
  106546. * Default offline support factory responsible of creating a tool used to store data locally.
  106547. * By default, this will create a Database object if the workload has been embedded.
  106548. */
  106549. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  106550. private _loadingScreen;
  106551. private _pointerLockRequested;
  106552. private _dummyFramebuffer;
  106553. private _rescalePostProcess;
  106554. private _deterministicLockstep;
  106555. private _lockstepMaxSteps;
  106556. private _timeStep;
  106557. protected get _supportsHardwareTextureRescaling(): boolean;
  106558. private _fps;
  106559. private _deltaTime;
  106560. /** @hidden */
  106561. _drawCalls: PerfCounter;
  106562. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  106563. canvasTabIndex: number;
  106564. /**
  106565. * Turn this value on if you want to pause FPS computation when in background
  106566. */
  106567. disablePerformanceMonitorInBackground: boolean;
  106568. private _performanceMonitor;
  106569. /**
  106570. * Gets the performance monitor attached to this engine
  106571. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106572. */
  106573. get performanceMonitor(): PerformanceMonitor;
  106574. private _onFocus;
  106575. private _onBlur;
  106576. private _onCanvasPointerOut;
  106577. private _onCanvasBlur;
  106578. private _onCanvasFocus;
  106579. private _onFullscreenChange;
  106580. private _onPointerLockChange;
  106581. /**
  106582. * Gets the HTML element used to attach event listeners
  106583. * @returns a HTML element
  106584. */
  106585. getInputElement(): Nullable<HTMLElement>;
  106586. /**
  106587. * Creates a new engine
  106588. * @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
  106589. * @param antialias defines enable antialiasing (default: false)
  106590. * @param options defines further options to be sent to the getContext() function
  106591. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  106592. */
  106593. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  106594. /**
  106595. * Gets current aspect ratio
  106596. * @param viewportOwner defines the camera to use to get the aspect ratio
  106597. * @param useScreen defines if screen size must be used (or the current render target if any)
  106598. * @returns a number defining the aspect ratio
  106599. */
  106600. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  106601. /**
  106602. * Gets current screen aspect ratio
  106603. * @returns a number defining the aspect ratio
  106604. */
  106605. getScreenAspectRatio(): number;
  106606. /**
  106607. * Gets the client rect of the HTML canvas attached with the current webGL context
  106608. * @returns a client rectanglee
  106609. */
  106610. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  106611. /**
  106612. * Gets the client rect of the HTML element used for events
  106613. * @returns a client rectanglee
  106614. */
  106615. getInputElementClientRect(): Nullable<ClientRect>;
  106616. /**
  106617. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  106618. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106619. * @returns true if engine is in deterministic lock step mode
  106620. */
  106621. isDeterministicLockStep(): boolean;
  106622. /**
  106623. * Gets the max steps when engine is running in deterministic lock step
  106624. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106625. * @returns the max steps
  106626. */
  106627. getLockstepMaxSteps(): number;
  106628. /**
  106629. * Returns the time in ms between steps when using deterministic lock step.
  106630. * @returns time step in (ms)
  106631. */
  106632. getTimeStep(): number;
  106633. /**
  106634. * Force the mipmap generation for the given render target texture
  106635. * @param texture defines the render target texture to use
  106636. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  106637. */
  106638. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  106639. /** States */
  106640. /**
  106641. * Set various states to the webGL context
  106642. * @param culling defines backface culling state
  106643. * @param zOffset defines the value to apply to zOffset (0 by default)
  106644. * @param force defines if states must be applied even if cache is up to date
  106645. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  106646. */
  106647. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106648. /**
  106649. * Set the z offset to apply to current rendering
  106650. * @param value defines the offset to apply
  106651. */
  106652. setZOffset(value: number): void;
  106653. /**
  106654. * Gets the current value of the zOffset
  106655. * @returns the current zOffset state
  106656. */
  106657. getZOffset(): number;
  106658. /**
  106659. * Enable or disable depth buffering
  106660. * @param enable defines the state to set
  106661. */
  106662. setDepthBuffer(enable: boolean): void;
  106663. /**
  106664. * Gets a boolean indicating if depth writing is enabled
  106665. * @returns the current depth writing state
  106666. */
  106667. getDepthWrite(): boolean;
  106668. /**
  106669. * Enable or disable depth writing
  106670. * @param enable defines the state to set
  106671. */
  106672. setDepthWrite(enable: boolean): void;
  106673. /**
  106674. * Gets a boolean indicating if stencil buffer is enabled
  106675. * @returns the current stencil buffer state
  106676. */
  106677. getStencilBuffer(): boolean;
  106678. /**
  106679. * Enable or disable the stencil buffer
  106680. * @param enable defines if the stencil buffer must be enabled or disabled
  106681. */
  106682. setStencilBuffer(enable: boolean): void;
  106683. /**
  106684. * Gets the current stencil mask
  106685. * @returns a number defining the new stencil mask to use
  106686. */
  106687. getStencilMask(): number;
  106688. /**
  106689. * Sets the current stencil mask
  106690. * @param mask defines the new stencil mask to use
  106691. */
  106692. setStencilMask(mask: number): void;
  106693. /**
  106694. * Gets the current stencil function
  106695. * @returns a number defining the stencil function to use
  106696. */
  106697. getStencilFunction(): number;
  106698. /**
  106699. * Gets the current stencil reference value
  106700. * @returns a number defining the stencil reference value to use
  106701. */
  106702. getStencilFunctionReference(): number;
  106703. /**
  106704. * Gets the current stencil mask
  106705. * @returns a number defining the stencil mask to use
  106706. */
  106707. getStencilFunctionMask(): number;
  106708. /**
  106709. * Sets the current stencil function
  106710. * @param stencilFunc defines the new stencil function to use
  106711. */
  106712. setStencilFunction(stencilFunc: number): void;
  106713. /**
  106714. * Sets the current stencil reference
  106715. * @param reference defines the new stencil reference to use
  106716. */
  106717. setStencilFunctionReference(reference: number): void;
  106718. /**
  106719. * Sets the current stencil mask
  106720. * @param mask defines the new stencil mask to use
  106721. */
  106722. setStencilFunctionMask(mask: number): void;
  106723. /**
  106724. * Gets the current stencil operation when stencil fails
  106725. * @returns a number defining stencil operation to use when stencil fails
  106726. */
  106727. getStencilOperationFail(): number;
  106728. /**
  106729. * Gets the current stencil operation when depth fails
  106730. * @returns a number defining stencil operation to use when depth fails
  106731. */
  106732. getStencilOperationDepthFail(): number;
  106733. /**
  106734. * Gets the current stencil operation when stencil passes
  106735. * @returns a number defining stencil operation to use when stencil passes
  106736. */
  106737. getStencilOperationPass(): number;
  106738. /**
  106739. * Sets the stencil operation to use when stencil fails
  106740. * @param operation defines the stencil operation to use when stencil fails
  106741. */
  106742. setStencilOperationFail(operation: number): void;
  106743. /**
  106744. * Sets the stencil operation to use when depth fails
  106745. * @param operation defines the stencil operation to use when depth fails
  106746. */
  106747. setStencilOperationDepthFail(operation: number): void;
  106748. /**
  106749. * Sets the stencil operation to use when stencil passes
  106750. * @param operation defines the stencil operation to use when stencil passes
  106751. */
  106752. setStencilOperationPass(operation: number): void;
  106753. /**
  106754. * Sets a boolean indicating if the dithering state is enabled or disabled
  106755. * @param value defines the dithering state
  106756. */
  106757. setDitheringState(value: boolean): void;
  106758. /**
  106759. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  106760. * @param value defines the rasterizer state
  106761. */
  106762. setRasterizerState(value: boolean): void;
  106763. /**
  106764. * Gets the current depth function
  106765. * @returns a number defining the depth function
  106766. */
  106767. getDepthFunction(): Nullable<number>;
  106768. /**
  106769. * Sets the current depth function
  106770. * @param depthFunc defines the function to use
  106771. */
  106772. setDepthFunction(depthFunc: number): void;
  106773. /**
  106774. * Sets the current depth function to GREATER
  106775. */
  106776. setDepthFunctionToGreater(): void;
  106777. /**
  106778. * Sets the current depth function to GEQUAL
  106779. */
  106780. setDepthFunctionToGreaterOrEqual(): void;
  106781. /**
  106782. * Sets the current depth function to LESS
  106783. */
  106784. setDepthFunctionToLess(): void;
  106785. /**
  106786. * Sets the current depth function to LEQUAL
  106787. */
  106788. setDepthFunctionToLessOrEqual(): void;
  106789. private _cachedStencilBuffer;
  106790. private _cachedStencilFunction;
  106791. private _cachedStencilMask;
  106792. private _cachedStencilOperationPass;
  106793. private _cachedStencilOperationFail;
  106794. private _cachedStencilOperationDepthFail;
  106795. private _cachedStencilReference;
  106796. /**
  106797. * Caches the the state of the stencil buffer
  106798. */
  106799. cacheStencilState(): void;
  106800. /**
  106801. * Restores the state of the stencil buffer
  106802. */
  106803. restoreStencilState(): void;
  106804. /**
  106805. * Directly set the WebGL Viewport
  106806. * @param x defines the x coordinate of the viewport (in screen space)
  106807. * @param y defines the y coordinate of the viewport (in screen space)
  106808. * @param width defines the width of the viewport (in screen space)
  106809. * @param height defines the height of the viewport (in screen space)
  106810. * @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
  106811. */
  106812. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  106813. /**
  106814. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  106815. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106816. * @param y defines the y-coordinate of the corner of the clear rectangle
  106817. * @param width defines the width of the clear rectangle
  106818. * @param height defines the height of the clear rectangle
  106819. * @param clearColor defines the clear color
  106820. */
  106821. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  106822. /**
  106823. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  106824. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106825. * @param y defines the y-coordinate of the corner of the clear rectangle
  106826. * @param width defines the width of the clear rectangle
  106827. * @param height defines the height of the clear rectangle
  106828. */
  106829. enableScissor(x: number, y: number, width: number, height: number): void;
  106830. /**
  106831. * Disable previously set scissor test rectangle
  106832. */
  106833. disableScissor(): void;
  106834. protected _reportDrawCall(): void;
  106835. /**
  106836. * Initializes a webVR display and starts listening to display change events
  106837. * The onVRDisplayChangedObservable will be notified upon these changes
  106838. * @returns The onVRDisplayChangedObservable
  106839. */
  106840. initWebVR(): Observable<IDisplayChangedEventArgs>;
  106841. /** @hidden */
  106842. _prepareVRComponent(): void;
  106843. /** @hidden */
  106844. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  106845. /** @hidden */
  106846. _submitVRFrame(): void;
  106847. /**
  106848. * Call this function to leave webVR mode
  106849. * Will do nothing if webVR is not supported or if there is no webVR device
  106850. * @see http://doc.babylonjs.com/how_to/webvr_camera
  106851. */
  106852. disableVR(): void;
  106853. /**
  106854. * Gets a boolean indicating that the system is in VR mode and is presenting
  106855. * @returns true if VR mode is engaged
  106856. */
  106857. isVRPresenting(): boolean;
  106858. /** @hidden */
  106859. _requestVRFrame(): void;
  106860. /** @hidden */
  106861. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  106862. /**
  106863. * Gets the source code of the vertex shader associated with a specific webGL program
  106864. * @param program defines the program to use
  106865. * @returns a string containing the source code of the vertex shader associated with the program
  106866. */
  106867. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  106868. /**
  106869. * Gets the source code of the fragment shader associated with a specific webGL program
  106870. * @param program defines the program to use
  106871. * @returns a string containing the source code of the fragment shader associated with the program
  106872. */
  106873. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  106874. /**
  106875. * Sets a depth stencil texture from a render target to the according uniform.
  106876. * @param channel The texture channel
  106877. * @param uniform The uniform to set
  106878. * @param texture The render target texture containing the depth stencil texture to apply
  106879. */
  106880. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  106881. /**
  106882. * Sets a texture to the webGL context from a postprocess
  106883. * @param channel defines the channel to use
  106884. * @param postProcess defines the source postprocess
  106885. */
  106886. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  106887. /**
  106888. * Binds the output of the passed in post process to the texture channel specified
  106889. * @param channel The channel the texture should be bound to
  106890. * @param postProcess The post process which's output should be bound
  106891. */
  106892. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  106893. /** @hidden */
  106894. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  106895. protected _rebuildBuffers(): void;
  106896. /** @hidden */
  106897. _renderFrame(): void;
  106898. _renderLoop(): void;
  106899. /** @hidden */
  106900. _renderViews(): boolean;
  106901. /**
  106902. * Toggle full screen mode
  106903. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106904. */
  106905. switchFullscreen(requestPointerLock: boolean): void;
  106906. /**
  106907. * Enters full screen mode
  106908. * @param requestPointerLock defines if a pointer lock should be requested from the user
  106909. */
  106910. enterFullscreen(requestPointerLock: boolean): void;
  106911. /**
  106912. * Exits full screen mode
  106913. */
  106914. exitFullscreen(): void;
  106915. /**
  106916. * Enters Pointerlock mode
  106917. */
  106918. enterPointerlock(): void;
  106919. /**
  106920. * Exits Pointerlock mode
  106921. */
  106922. exitPointerlock(): void;
  106923. /**
  106924. * Begin a new frame
  106925. */
  106926. beginFrame(): void;
  106927. /**
  106928. * Enf the current frame
  106929. */
  106930. endFrame(): void;
  106931. resize(): void;
  106932. /**
  106933. * Force a specific size of the canvas
  106934. * @param width defines the new canvas' width
  106935. * @param height defines the new canvas' height
  106936. */
  106937. setSize(width: number, height: number): void;
  106938. /**
  106939. * Updates a dynamic vertex buffer.
  106940. * @param vertexBuffer the vertex buffer to update
  106941. * @param data the data used to update the vertex buffer
  106942. * @param byteOffset the byte offset of the data
  106943. * @param byteLength the byte length of the data
  106944. */
  106945. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  106946. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  106947. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106948. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106949. _releaseTexture(texture: InternalTexture): void;
  106950. /**
  106951. * @hidden
  106952. * Rescales a texture
  106953. * @param source input texutre
  106954. * @param destination destination texture
  106955. * @param scene scene to use to render the resize
  106956. * @param internalFormat format to use when resizing
  106957. * @param onComplete callback to be called when resize has completed
  106958. */
  106959. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  106960. /**
  106961. * Gets the current framerate
  106962. * @returns a number representing the framerate
  106963. */
  106964. getFps(): number;
  106965. /**
  106966. * Gets the time spent between current and previous frame
  106967. * @returns a number representing the delta time in ms
  106968. */
  106969. getDeltaTime(): number;
  106970. private _measureFps;
  106971. /** @hidden */
  106972. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  106973. /**
  106974. * Update a dynamic index buffer
  106975. * @param indexBuffer defines the target index buffer
  106976. * @param indices defines the data to update
  106977. * @param offset defines the offset in the target index buffer where update should start
  106978. */
  106979. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  106980. /**
  106981. * Updates the sample count of a render target texture
  106982. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  106983. * @param texture defines the texture to update
  106984. * @param samples defines the sample count to set
  106985. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  106986. */
  106987. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  106988. /**
  106989. * Updates a depth texture Comparison Mode and Function.
  106990. * If the comparison Function is equal to 0, the mode will be set to none.
  106991. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  106992. * @param texture The texture to set the comparison function for
  106993. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  106994. */
  106995. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  106996. /**
  106997. * Creates a webGL buffer to use with instanciation
  106998. * @param capacity defines the size of the buffer
  106999. * @returns the webGL buffer
  107000. */
  107001. createInstancesBuffer(capacity: number): DataBuffer;
  107002. /**
  107003. * Delete a webGL buffer used with instanciation
  107004. * @param buffer defines the webGL buffer to delete
  107005. */
  107006. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  107007. private _clientWaitAsync;
  107008. /** @hidden */
  107009. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  107010. /** @hidden */
  107011. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  107012. dispose(): void;
  107013. private _disableTouchAction;
  107014. /**
  107015. * Display the loading screen
  107016. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107017. */
  107018. displayLoadingUI(): void;
  107019. /**
  107020. * Hide the loading screen
  107021. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107022. */
  107023. hideLoadingUI(): void;
  107024. /**
  107025. * Gets the current loading screen object
  107026. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107027. */
  107028. get loadingScreen(): ILoadingScreen;
  107029. /**
  107030. * Sets the current loading screen object
  107031. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107032. */
  107033. set loadingScreen(loadingScreen: ILoadingScreen);
  107034. /**
  107035. * Sets the current loading screen text
  107036. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107037. */
  107038. set loadingUIText(text: string);
  107039. /**
  107040. * Sets the current loading screen background color
  107041. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107042. */
  107043. set loadingUIBackgroundColor(color: string);
  107044. /** Pointerlock and fullscreen */
  107045. /**
  107046. * Ask the browser to promote the current element to pointerlock mode
  107047. * @param element defines the DOM element to promote
  107048. */
  107049. static _RequestPointerlock(element: HTMLElement): void;
  107050. /**
  107051. * Asks the browser to exit pointerlock mode
  107052. */
  107053. static _ExitPointerlock(): void;
  107054. /**
  107055. * Ask the browser to promote the current element to fullscreen rendering mode
  107056. * @param element defines the DOM element to promote
  107057. */
  107058. static _RequestFullscreen(element: HTMLElement): void;
  107059. /**
  107060. * Asks the browser to exit fullscreen mode
  107061. */
  107062. static _ExitFullscreen(): void;
  107063. }
  107064. }
  107065. declare module BABYLON {
  107066. /**
  107067. * The engine store class is responsible to hold all the instances of Engine and Scene created
  107068. * during the life time of the application.
  107069. */
  107070. export class EngineStore {
  107071. /** Gets the list of created engines */
  107072. static Instances: Engine[];
  107073. /** @hidden */
  107074. static _LastCreatedScene: Nullable<Scene>;
  107075. /**
  107076. * Gets the latest created engine
  107077. */
  107078. static get LastCreatedEngine(): Nullable<Engine>;
  107079. /**
  107080. * Gets the latest created scene
  107081. */
  107082. static get LastCreatedScene(): Nullable<Scene>;
  107083. /**
  107084. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107085. * @ignorenaming
  107086. */
  107087. static UseFallbackTexture: boolean;
  107088. /**
  107089. * Texture content used if a texture cannot loaded
  107090. * @ignorenaming
  107091. */
  107092. static FallbackTexture: string;
  107093. }
  107094. }
  107095. declare module BABYLON {
  107096. /**
  107097. * Helper class that provides a small promise polyfill
  107098. */
  107099. export class PromisePolyfill {
  107100. /**
  107101. * Static function used to check if the polyfill is required
  107102. * If this is the case then the function will inject the polyfill to window.Promise
  107103. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  107104. */
  107105. static Apply(force?: boolean): void;
  107106. }
  107107. }
  107108. declare module BABYLON {
  107109. /**
  107110. * Interface for screenshot methods with describe argument called `size` as object with options
  107111. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  107112. */
  107113. export interface IScreenshotSize {
  107114. /**
  107115. * number in pixels for canvas height
  107116. */
  107117. height?: number;
  107118. /**
  107119. * multiplier allowing render at a higher or lower resolution
  107120. * If value is defined then height and width will be ignored and taken from camera
  107121. */
  107122. precision?: number;
  107123. /**
  107124. * number in pixels for canvas width
  107125. */
  107126. width?: number;
  107127. }
  107128. }
  107129. declare module BABYLON {
  107130. interface IColor4Like {
  107131. r: float;
  107132. g: float;
  107133. b: float;
  107134. a: float;
  107135. }
  107136. /**
  107137. * Class containing a set of static utilities functions
  107138. */
  107139. export class Tools {
  107140. /**
  107141. * Gets or sets the base URL to use to load assets
  107142. */
  107143. static get BaseUrl(): string;
  107144. static set BaseUrl(value: string);
  107145. /**
  107146. * Enable/Disable Custom HTTP Request Headers globally.
  107147. * default = false
  107148. * @see CustomRequestHeaders
  107149. */
  107150. static UseCustomRequestHeaders: boolean;
  107151. /**
  107152. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  107153. * i.e. when loading files, where the server/service expects an Authorization header
  107154. */
  107155. static CustomRequestHeaders: {
  107156. [key: string]: string;
  107157. };
  107158. /**
  107159. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  107160. */
  107161. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  107162. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  107163. /**
  107164. * Default behaviour for cors in the application.
  107165. * It can be a string if the expected behavior is identical in the entire app.
  107166. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  107167. */
  107168. static CorsBehavior: string | ((url: string | string[]) => string);
  107169. /**
  107170. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107171. * @ignorenaming
  107172. */
  107173. static get UseFallbackTexture(): boolean;
  107174. static set UseFallbackTexture(value: boolean);
  107175. /**
  107176. * Use this object to register external classes like custom textures or material
  107177. * to allow the laoders to instantiate them
  107178. */
  107179. static get RegisteredExternalClasses(): {
  107180. [key: string]: Object;
  107181. };
  107182. static set RegisteredExternalClasses(classes: {
  107183. [key: string]: Object;
  107184. });
  107185. /**
  107186. * Texture content used if a texture cannot loaded
  107187. * @ignorenaming
  107188. */
  107189. static get fallbackTexture(): string;
  107190. static set fallbackTexture(value: string);
  107191. /**
  107192. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  107193. * @param u defines the coordinate on X axis
  107194. * @param v defines the coordinate on Y axis
  107195. * @param width defines the width of the source data
  107196. * @param height defines the height of the source data
  107197. * @param pixels defines the source byte array
  107198. * @param color defines the output color
  107199. */
  107200. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  107201. /**
  107202. * Interpolates between a and b via alpha
  107203. * @param a The lower value (returned when alpha = 0)
  107204. * @param b The upper value (returned when alpha = 1)
  107205. * @param alpha The interpolation-factor
  107206. * @return The mixed value
  107207. */
  107208. static Mix(a: number, b: number, alpha: number): number;
  107209. /**
  107210. * Tries to instantiate a new object from a given class name
  107211. * @param className defines the class name to instantiate
  107212. * @returns the new object or null if the system was not able to do the instantiation
  107213. */
  107214. static Instantiate(className: string): any;
  107215. /**
  107216. * Provides a slice function that will work even on IE
  107217. * @param data defines the array to slice
  107218. * @param start defines the start of the data (optional)
  107219. * @param end defines the end of the data (optional)
  107220. * @returns the new sliced array
  107221. */
  107222. static Slice<T>(data: T, start?: number, end?: number): T;
  107223. /**
  107224. * Polyfill for setImmediate
  107225. * @param action defines the action to execute after the current execution block
  107226. */
  107227. static SetImmediate(action: () => void): void;
  107228. /**
  107229. * Function indicating if a number is an exponent of 2
  107230. * @param value defines the value to test
  107231. * @returns true if the value is an exponent of 2
  107232. */
  107233. static IsExponentOfTwo(value: number): boolean;
  107234. private static _tmpFloatArray;
  107235. /**
  107236. * Returns the nearest 32-bit single precision float representation of a Number
  107237. * @param value A Number. If the parameter is of a different type, it will get converted
  107238. * to a number or to NaN if it cannot be converted
  107239. * @returns number
  107240. */
  107241. static FloatRound(value: number): number;
  107242. /**
  107243. * Extracts the filename from a path
  107244. * @param path defines the path to use
  107245. * @returns the filename
  107246. */
  107247. static GetFilename(path: string): string;
  107248. /**
  107249. * Extracts the "folder" part of a path (everything before the filename).
  107250. * @param uri The URI to extract the info from
  107251. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  107252. * @returns The "folder" part of the path
  107253. */
  107254. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  107255. /**
  107256. * Extracts text content from a DOM element hierarchy
  107257. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  107258. */
  107259. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  107260. /**
  107261. * Convert an angle in radians to degrees
  107262. * @param angle defines the angle to convert
  107263. * @returns the angle in degrees
  107264. */
  107265. static ToDegrees(angle: number): number;
  107266. /**
  107267. * Convert an angle in degrees to radians
  107268. * @param angle defines the angle to convert
  107269. * @returns the angle in radians
  107270. */
  107271. static ToRadians(angle: number): number;
  107272. /**
  107273. * Returns an array if obj is not an array
  107274. * @param obj defines the object to evaluate as an array
  107275. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  107276. * @returns either obj directly if obj is an array or a new array containing obj
  107277. */
  107278. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  107279. /**
  107280. * Gets the pointer prefix to use
  107281. * @returns "pointer" if touch is enabled. Else returns "mouse"
  107282. */
  107283. static GetPointerPrefix(): string;
  107284. /**
  107285. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  107286. * @param url define the url we are trying
  107287. * @param element define the dom element where to configure the cors policy
  107288. */
  107289. static SetCorsBehavior(url: string | string[], element: {
  107290. crossOrigin: string | null;
  107291. }): void;
  107292. /**
  107293. * Removes unwanted characters from an url
  107294. * @param url defines the url to clean
  107295. * @returns the cleaned url
  107296. */
  107297. static CleanUrl(url: string): string;
  107298. /**
  107299. * Gets or sets a function used to pre-process url before using them to load assets
  107300. */
  107301. static get PreprocessUrl(): (url: string) => string;
  107302. static set PreprocessUrl(processor: (url: string) => string);
  107303. /**
  107304. * Loads an image as an HTMLImageElement.
  107305. * @param input url string, ArrayBuffer, or Blob to load
  107306. * @param onLoad callback called when the image successfully loads
  107307. * @param onError callback called when the image fails to load
  107308. * @param offlineProvider offline provider for caching
  107309. * @param mimeType optional mime type
  107310. * @returns the HTMLImageElement of the loaded image
  107311. */
  107312. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  107313. /**
  107314. * Loads a file from a url
  107315. * @param url url string, ArrayBuffer, or Blob to load
  107316. * @param onSuccess callback called when the file successfully loads
  107317. * @param onProgress callback called while file is loading (if the server supports this mode)
  107318. * @param offlineProvider defines the offline provider for caching
  107319. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107320. * @param onError callback called when the file fails to load
  107321. * @returns a file request object
  107322. */
  107323. 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;
  107324. /**
  107325. * Loads a file from a url
  107326. * @param url the file url to load
  107327. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107328. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  107329. */
  107330. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  107331. /**
  107332. * Load a script (identified by an url). When the url returns, the
  107333. * content of this file is added into a new script element, attached to the DOM (body element)
  107334. * @param scriptUrl defines the url of the script to laod
  107335. * @param onSuccess defines the callback called when the script is loaded
  107336. * @param onError defines the callback to call if an error occurs
  107337. * @param scriptId defines the id of the script element
  107338. */
  107339. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  107340. /**
  107341. * Load an asynchronous script (identified by an url). When the url returns, the
  107342. * content of this file is added into a new script element, attached to the DOM (body element)
  107343. * @param scriptUrl defines the url of the script to laod
  107344. * @param scriptId defines the id of the script element
  107345. * @returns a promise request object
  107346. */
  107347. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  107348. /**
  107349. * Loads a file from a blob
  107350. * @param fileToLoad defines the blob to use
  107351. * @param callback defines the callback to call when data is loaded
  107352. * @param progressCallback defines the callback to call during loading process
  107353. * @returns a file request object
  107354. */
  107355. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  107356. /**
  107357. * Reads a file from a File object
  107358. * @param file defines the file to load
  107359. * @param onSuccess defines the callback to call when data is loaded
  107360. * @param onProgress defines the callback to call during loading process
  107361. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  107362. * @param onError defines the callback to call when an error occurs
  107363. * @returns a file request object
  107364. */
  107365. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107366. /**
  107367. * Creates a data url from a given string content
  107368. * @param content defines the content to convert
  107369. * @returns the new data url link
  107370. */
  107371. static FileAsURL(content: string): string;
  107372. /**
  107373. * Format the given number to a specific decimal format
  107374. * @param value defines the number to format
  107375. * @param decimals defines the number of decimals to use
  107376. * @returns the formatted string
  107377. */
  107378. static Format(value: number, decimals?: number): string;
  107379. /**
  107380. * Tries to copy an object by duplicating every property
  107381. * @param source defines the source object
  107382. * @param destination defines the target object
  107383. * @param doNotCopyList defines a list of properties to avoid
  107384. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  107385. */
  107386. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  107387. /**
  107388. * Gets a boolean indicating if the given object has no own property
  107389. * @param obj defines the object to test
  107390. * @returns true if object has no own property
  107391. */
  107392. static IsEmpty(obj: any): boolean;
  107393. /**
  107394. * Function used to register events at window level
  107395. * @param windowElement defines the Window object to use
  107396. * @param events defines the events to register
  107397. */
  107398. static RegisterTopRootEvents(windowElement: Window, events: {
  107399. name: string;
  107400. handler: Nullable<(e: FocusEvent) => any>;
  107401. }[]): void;
  107402. /**
  107403. * Function used to unregister events from window level
  107404. * @param windowElement defines the Window object to use
  107405. * @param events defines the events to unregister
  107406. */
  107407. static UnregisterTopRootEvents(windowElement: Window, events: {
  107408. name: string;
  107409. handler: Nullable<(e: FocusEvent) => any>;
  107410. }[]): void;
  107411. /**
  107412. * @ignore
  107413. */
  107414. static _ScreenshotCanvas: HTMLCanvasElement;
  107415. /**
  107416. * Dumps the current bound framebuffer
  107417. * @param width defines the rendering width
  107418. * @param height defines the rendering height
  107419. * @param engine defines the hosting engine
  107420. * @param successCallback defines the callback triggered once the data are available
  107421. * @param mimeType defines the mime type of the result
  107422. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  107423. */
  107424. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107425. /**
  107426. * Converts the canvas data to blob.
  107427. * This acts as a polyfill for browsers not supporting the to blob function.
  107428. * @param canvas Defines the canvas to extract the data from
  107429. * @param successCallback Defines the callback triggered once the data are available
  107430. * @param mimeType Defines the mime type of the result
  107431. */
  107432. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  107433. /**
  107434. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  107435. * @param successCallback defines the callback triggered once the data are available
  107436. * @param mimeType defines the mime type of the result
  107437. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  107438. */
  107439. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107440. /**
  107441. * Downloads a blob in the browser
  107442. * @param blob defines the blob to download
  107443. * @param fileName defines the name of the downloaded file
  107444. */
  107445. static Download(blob: Blob, fileName: string): void;
  107446. /**
  107447. * Captures a screenshot of the current rendering
  107448. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107449. * @param engine defines the rendering engine
  107450. * @param camera defines the source camera
  107451. * @param size This parameter can be set to a single number or to an object with the
  107452. * following (optional) properties: precision, width, height. If a single number is passed,
  107453. * it will be used for both width and height. If an object is passed, the screenshot size
  107454. * will be derived from the parameters. The precision property is a multiplier allowing
  107455. * rendering at a higher or lower resolution
  107456. * @param successCallback defines the callback receives a single parameter which contains the
  107457. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107458. * src parameter of an <img> to display it
  107459. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107460. * Check your browser for supported MIME types
  107461. */
  107462. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  107463. /**
  107464. * Captures a screenshot of the current rendering
  107465. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107466. * @param engine defines the rendering engine
  107467. * @param camera defines the source camera
  107468. * @param size This parameter can be set to a single number or to an object with the
  107469. * following (optional) properties: precision, width, height. If a single number is passed,
  107470. * it will be used for both width and height. If an object is passed, the screenshot size
  107471. * will be derived from the parameters. The precision property is a multiplier allowing
  107472. * rendering at a higher or lower resolution
  107473. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107474. * Check your browser for supported MIME types
  107475. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107476. * to the src parameter of an <img> to display it
  107477. */
  107478. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  107479. /**
  107480. * Generates an image screenshot from the specified camera.
  107481. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107482. * @param engine The engine to use for rendering
  107483. * @param camera The camera to use for rendering
  107484. * @param size This parameter can be set to a single number or to an object with the
  107485. * following (optional) properties: precision, width, height. If a single number is passed,
  107486. * it will be used for both width and height. If an object is passed, the screenshot size
  107487. * will be derived from the parameters. The precision property is a multiplier allowing
  107488. * rendering at a higher or lower resolution
  107489. * @param successCallback The callback receives a single parameter which contains the
  107490. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107491. * src parameter of an <img> to display it
  107492. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107493. * Check your browser for supported MIME types
  107494. * @param samples Texture samples (default: 1)
  107495. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107496. * @param fileName A name for for the downloaded file.
  107497. */
  107498. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  107499. /**
  107500. * Generates an image screenshot from the specified camera.
  107501. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107502. * @param engine The engine to use for rendering
  107503. * @param camera The camera to use for rendering
  107504. * @param size This parameter can be set to a single number or to an object with the
  107505. * following (optional) properties: precision, width, height. If a single number is passed,
  107506. * it will be used for both width and height. If an object is passed, the screenshot size
  107507. * will be derived from the parameters. The precision property is a multiplier allowing
  107508. * rendering at a higher or lower resolution
  107509. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107510. * Check your browser for supported MIME types
  107511. * @param samples Texture samples (default: 1)
  107512. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107513. * @param fileName A name for for the downloaded file.
  107514. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107515. * to the src parameter of an <img> to display it
  107516. */
  107517. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  107518. /**
  107519. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  107520. * Be aware Math.random() could cause collisions, but:
  107521. * "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"
  107522. * @returns a pseudo random id
  107523. */
  107524. static RandomId(): string;
  107525. /**
  107526. * Test if the given uri is a base64 string
  107527. * @param uri The uri to test
  107528. * @return True if the uri is a base64 string or false otherwise
  107529. */
  107530. static IsBase64(uri: string): boolean;
  107531. /**
  107532. * Decode the given base64 uri.
  107533. * @param uri The uri to decode
  107534. * @return The decoded base64 data.
  107535. */
  107536. static DecodeBase64(uri: string): ArrayBuffer;
  107537. /**
  107538. * Gets the absolute url.
  107539. * @param url the input url
  107540. * @return the absolute url
  107541. */
  107542. static GetAbsoluteUrl(url: string): string;
  107543. /**
  107544. * No log
  107545. */
  107546. static readonly NoneLogLevel: number;
  107547. /**
  107548. * Only message logs
  107549. */
  107550. static readonly MessageLogLevel: number;
  107551. /**
  107552. * Only warning logs
  107553. */
  107554. static readonly WarningLogLevel: number;
  107555. /**
  107556. * Only error logs
  107557. */
  107558. static readonly ErrorLogLevel: number;
  107559. /**
  107560. * All logs
  107561. */
  107562. static readonly AllLogLevel: number;
  107563. /**
  107564. * Gets a value indicating the number of loading errors
  107565. * @ignorenaming
  107566. */
  107567. static get errorsCount(): number;
  107568. /**
  107569. * Callback called when a new log is added
  107570. */
  107571. static OnNewCacheEntry: (entry: string) => void;
  107572. /**
  107573. * Log a message to the console
  107574. * @param message defines the message to log
  107575. */
  107576. static Log(message: string): void;
  107577. /**
  107578. * Write a warning message to the console
  107579. * @param message defines the message to log
  107580. */
  107581. static Warn(message: string): void;
  107582. /**
  107583. * Write an error message to the console
  107584. * @param message defines the message to log
  107585. */
  107586. static Error(message: string): void;
  107587. /**
  107588. * Gets current log cache (list of logs)
  107589. */
  107590. static get LogCache(): string;
  107591. /**
  107592. * Clears the log cache
  107593. */
  107594. static ClearLogCache(): void;
  107595. /**
  107596. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  107597. */
  107598. static set LogLevels(level: number);
  107599. /**
  107600. * Checks if the window object exists
  107601. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  107602. */
  107603. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  107604. /**
  107605. * No performance log
  107606. */
  107607. static readonly PerformanceNoneLogLevel: number;
  107608. /**
  107609. * Use user marks to log performance
  107610. */
  107611. static readonly PerformanceUserMarkLogLevel: number;
  107612. /**
  107613. * Log performance to the console
  107614. */
  107615. static readonly PerformanceConsoleLogLevel: number;
  107616. private static _performance;
  107617. /**
  107618. * Sets the current performance log level
  107619. */
  107620. static set PerformanceLogLevel(level: number);
  107621. private static _StartPerformanceCounterDisabled;
  107622. private static _EndPerformanceCounterDisabled;
  107623. private static _StartUserMark;
  107624. private static _EndUserMark;
  107625. private static _StartPerformanceConsole;
  107626. private static _EndPerformanceConsole;
  107627. /**
  107628. * Starts a performance counter
  107629. */
  107630. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107631. /**
  107632. * Ends a specific performance coutner
  107633. */
  107634. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107635. /**
  107636. * Gets either window.performance.now() if supported or Date.now() else
  107637. */
  107638. static get Now(): number;
  107639. /**
  107640. * This method will return the name of the class used to create the instance of the given object.
  107641. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  107642. * @param object the object to get the class name from
  107643. * @param isType defines if the object is actually a type
  107644. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  107645. */
  107646. static GetClassName(object: any, isType?: boolean): string;
  107647. /**
  107648. * Gets the first element of an array satisfying a given predicate
  107649. * @param array defines the array to browse
  107650. * @param predicate defines the predicate to use
  107651. * @returns null if not found or the element
  107652. */
  107653. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  107654. /**
  107655. * This method will return the name of the full name of the class, including its owning module (if any).
  107656. * 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).
  107657. * @param object the object to get the class name from
  107658. * @param isType defines if the object is actually a type
  107659. * @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.
  107660. * @ignorenaming
  107661. */
  107662. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  107663. /**
  107664. * Returns a promise that resolves after the given amount of time.
  107665. * @param delay Number of milliseconds to delay
  107666. * @returns Promise that resolves after the given amount of time
  107667. */
  107668. static DelayAsync(delay: number): Promise<void>;
  107669. /**
  107670. * Utility function to detect if the current user agent is Safari
  107671. * @returns whether or not the current user agent is safari
  107672. */
  107673. static IsSafari(): boolean;
  107674. }
  107675. /**
  107676. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  107677. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  107678. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  107679. * @param name The name of the class, case should be preserved
  107680. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  107681. */
  107682. export function className(name: string, module?: string): (target: Object) => void;
  107683. /**
  107684. * An implementation of a loop for asynchronous functions.
  107685. */
  107686. export class AsyncLoop {
  107687. /**
  107688. * Defines the number of iterations for the loop
  107689. */
  107690. iterations: number;
  107691. /**
  107692. * Defines the current index of the loop.
  107693. */
  107694. index: number;
  107695. private _done;
  107696. private _fn;
  107697. private _successCallback;
  107698. /**
  107699. * Constructor.
  107700. * @param iterations the number of iterations.
  107701. * @param func the function to run each iteration
  107702. * @param successCallback the callback that will be called upon succesful execution
  107703. * @param offset starting offset.
  107704. */
  107705. constructor(
  107706. /**
  107707. * Defines the number of iterations for the loop
  107708. */
  107709. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  107710. /**
  107711. * Execute the next iteration. Must be called after the last iteration was finished.
  107712. */
  107713. executeNext(): void;
  107714. /**
  107715. * Break the loop and run the success callback.
  107716. */
  107717. breakLoop(): void;
  107718. /**
  107719. * Create and run an async loop.
  107720. * @param iterations the number of iterations.
  107721. * @param fn the function to run each iteration
  107722. * @param successCallback the callback that will be called upon succesful execution
  107723. * @param offset starting offset.
  107724. * @returns the created async loop object
  107725. */
  107726. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  107727. /**
  107728. * A for-loop that will run a given number of iterations synchronous and the rest async.
  107729. * @param iterations total number of iterations
  107730. * @param syncedIterations number of synchronous iterations in each async iteration.
  107731. * @param fn the function to call each iteration.
  107732. * @param callback a success call back that will be called when iterating stops.
  107733. * @param breakFunction a break condition (optional)
  107734. * @param timeout timeout settings for the setTimeout function. default - 0.
  107735. * @returns the created async loop object
  107736. */
  107737. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  107738. }
  107739. }
  107740. declare module BABYLON {
  107741. /**
  107742. * This class implement a typical dictionary using a string as key and the generic type T as value.
  107743. * The underlying implementation relies on an associative array to ensure the best performances.
  107744. * The value can be anything including 'null' but except 'undefined'
  107745. */
  107746. export class StringDictionary<T> {
  107747. /**
  107748. * This will clear this dictionary and copy the content from the 'source' one.
  107749. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  107750. * @param source the dictionary to take the content from and copy to this dictionary
  107751. */
  107752. copyFrom(source: StringDictionary<T>): void;
  107753. /**
  107754. * Get a value based from its key
  107755. * @param key the given key to get the matching value from
  107756. * @return the value if found, otherwise undefined is returned
  107757. */
  107758. get(key: string): T | undefined;
  107759. /**
  107760. * Get a value from its key or add it if it doesn't exist.
  107761. * This method will ensure you that a given key/data will be present in the dictionary.
  107762. * @param key the given key to get the matching value from
  107763. * @param factory the factory that will create the value if the key is not present in the dictionary.
  107764. * The factory will only be invoked if there's no data for the given key.
  107765. * @return the value corresponding to the key.
  107766. */
  107767. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  107768. /**
  107769. * Get a value from its key if present in the dictionary otherwise add it
  107770. * @param key the key to get the value from
  107771. * @param val if there's no such key/value pair in the dictionary add it with this value
  107772. * @return the value corresponding to the key
  107773. */
  107774. getOrAdd(key: string, val: T): T;
  107775. /**
  107776. * Check if there's a given key in the dictionary
  107777. * @param key the key to check for
  107778. * @return true if the key is present, false otherwise
  107779. */
  107780. contains(key: string): boolean;
  107781. /**
  107782. * Add a new key and its corresponding value
  107783. * @param key the key to add
  107784. * @param value the value corresponding to the key
  107785. * @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
  107786. */
  107787. add(key: string, value: T): boolean;
  107788. /**
  107789. * Update a specific value associated to a key
  107790. * @param key defines the key to use
  107791. * @param value defines the value to store
  107792. * @returns true if the value was updated (or false if the key was not found)
  107793. */
  107794. set(key: string, value: T): boolean;
  107795. /**
  107796. * Get the element of the given key and remove it from the dictionary
  107797. * @param key defines the key to search
  107798. * @returns the value associated with the key or null if not found
  107799. */
  107800. getAndRemove(key: string): Nullable<T>;
  107801. /**
  107802. * Remove a key/value from the dictionary.
  107803. * @param key the key to remove
  107804. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  107805. */
  107806. remove(key: string): boolean;
  107807. /**
  107808. * Clear the whole content of the dictionary
  107809. */
  107810. clear(): void;
  107811. /**
  107812. * Gets the current count
  107813. */
  107814. get count(): number;
  107815. /**
  107816. * Execute a callback on each key/val of the dictionary.
  107817. * Note that you can remove any element in this dictionary in the callback implementation
  107818. * @param callback the callback to execute on a given key/value pair
  107819. */
  107820. forEach(callback: (key: string, val: T) => void): void;
  107821. /**
  107822. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  107823. * If the callback returns null or undefined the method will iterate to the next key/value pair
  107824. * Note that you can remove any element in this dictionary in the callback implementation
  107825. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  107826. * @returns the first item
  107827. */
  107828. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  107829. private _count;
  107830. private _data;
  107831. }
  107832. }
  107833. declare module BABYLON {
  107834. /** @hidden */
  107835. export interface ICollisionCoordinator {
  107836. createCollider(): Collider;
  107837. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107838. init(scene: Scene): void;
  107839. }
  107840. /** @hidden */
  107841. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  107842. private _scene;
  107843. private _scaledPosition;
  107844. private _scaledVelocity;
  107845. private _finalPosition;
  107846. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107847. createCollider(): Collider;
  107848. init(scene: Scene): void;
  107849. private _collideWithWorld;
  107850. }
  107851. }
  107852. declare module BABYLON {
  107853. /**
  107854. * Class used to manage all inputs for the scene.
  107855. */
  107856. export class InputManager {
  107857. /** The distance in pixel that you have to move to prevent some events */
  107858. static DragMovementThreshold: number;
  107859. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  107860. static LongPressDelay: number;
  107861. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  107862. static DoubleClickDelay: number;
  107863. /** If you need to check double click without raising a single click at first click, enable this flag */
  107864. static ExclusiveDoubleClickMode: boolean;
  107865. private _wheelEventName;
  107866. private _onPointerMove;
  107867. private _onPointerDown;
  107868. private _onPointerUp;
  107869. private _initClickEvent;
  107870. private _initActionManager;
  107871. private _delayedSimpleClick;
  107872. private _delayedSimpleClickTimeout;
  107873. private _previousDelayedSimpleClickTimeout;
  107874. private _meshPickProceed;
  107875. private _previousButtonPressed;
  107876. private _currentPickResult;
  107877. private _previousPickResult;
  107878. private _totalPointersPressed;
  107879. private _doubleClickOccured;
  107880. private _pointerOverMesh;
  107881. private _pickedDownMesh;
  107882. private _pickedUpMesh;
  107883. private _pointerX;
  107884. private _pointerY;
  107885. private _unTranslatedPointerX;
  107886. private _unTranslatedPointerY;
  107887. private _startingPointerPosition;
  107888. private _previousStartingPointerPosition;
  107889. private _startingPointerTime;
  107890. private _previousStartingPointerTime;
  107891. private _pointerCaptures;
  107892. private _onKeyDown;
  107893. private _onKeyUp;
  107894. private _onCanvasFocusObserver;
  107895. private _onCanvasBlurObserver;
  107896. private _scene;
  107897. /**
  107898. * Creates a new InputManager
  107899. * @param scene defines the hosting scene
  107900. */
  107901. constructor(scene: Scene);
  107902. /**
  107903. * Gets the mesh that is currently under the pointer
  107904. */
  107905. get meshUnderPointer(): Nullable<AbstractMesh>;
  107906. /**
  107907. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  107908. */
  107909. get unTranslatedPointer(): Vector2;
  107910. /**
  107911. * Gets or sets the current on-screen X position of the pointer
  107912. */
  107913. get pointerX(): number;
  107914. set pointerX(value: number);
  107915. /**
  107916. * Gets or sets the current on-screen Y position of the pointer
  107917. */
  107918. get pointerY(): number;
  107919. set pointerY(value: number);
  107920. private _updatePointerPosition;
  107921. private _processPointerMove;
  107922. private _setRayOnPointerInfo;
  107923. private _checkPrePointerObservable;
  107924. /**
  107925. * Use this method to simulate a pointer move on a mesh
  107926. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107927. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107928. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107929. */
  107930. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  107931. /**
  107932. * Use this method to simulate a pointer down on a mesh
  107933. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107934. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107935. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107936. */
  107937. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  107938. private _processPointerDown;
  107939. /** @hidden */
  107940. _isPointerSwiping(): boolean;
  107941. /**
  107942. * Use this method to simulate a pointer up on a mesh
  107943. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  107944. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  107945. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  107946. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  107947. */
  107948. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  107949. private _processPointerUp;
  107950. /**
  107951. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  107952. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  107953. * @returns true if the pointer was captured
  107954. */
  107955. isPointerCaptured(pointerId?: number): boolean;
  107956. /**
  107957. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  107958. * @param attachUp defines if you want to attach events to pointerup
  107959. * @param attachDown defines if you want to attach events to pointerdown
  107960. * @param attachMove defines if you want to attach events to pointermove
  107961. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  107962. */
  107963. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  107964. /**
  107965. * Detaches all event handlers
  107966. */
  107967. detachControl(): void;
  107968. /**
  107969. * Force the value of meshUnderPointer
  107970. * @param mesh defines the mesh to use
  107971. */
  107972. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  107973. /**
  107974. * Gets the mesh under the pointer
  107975. * @returns a Mesh or null if no mesh is under the pointer
  107976. */
  107977. getPointerOverMesh(): Nullable<AbstractMesh>;
  107978. }
  107979. }
  107980. declare module BABYLON {
  107981. /**
  107982. * Helper class used to generate session unique ID
  107983. */
  107984. export class UniqueIdGenerator {
  107985. private static _UniqueIdCounter;
  107986. /**
  107987. * Gets an unique (relatively to the current scene) Id
  107988. */
  107989. static get UniqueId(): number;
  107990. }
  107991. }
  107992. declare module BABYLON {
  107993. /**
  107994. * This class defines the direct association between an animation and a target
  107995. */
  107996. export class TargetedAnimation {
  107997. /**
  107998. * Animation to perform
  107999. */
  108000. animation: Animation;
  108001. /**
  108002. * Target to animate
  108003. */
  108004. target: any;
  108005. /**
  108006. * Serialize the object
  108007. * @returns the JSON object representing the current entity
  108008. */
  108009. serialize(): any;
  108010. }
  108011. /**
  108012. * Use this class to create coordinated animations on multiple targets
  108013. */
  108014. export class AnimationGroup implements IDisposable {
  108015. /** The name of the animation group */
  108016. name: string;
  108017. private _scene;
  108018. private _targetedAnimations;
  108019. private _animatables;
  108020. private _from;
  108021. private _to;
  108022. private _isStarted;
  108023. private _isPaused;
  108024. private _speedRatio;
  108025. private _loopAnimation;
  108026. /**
  108027. * Gets or sets the unique id of the node
  108028. */
  108029. uniqueId: number;
  108030. /**
  108031. * This observable will notify when one animation have ended
  108032. */
  108033. onAnimationEndObservable: Observable<TargetedAnimation>;
  108034. /**
  108035. * Observer raised when one animation loops
  108036. */
  108037. onAnimationLoopObservable: Observable<TargetedAnimation>;
  108038. /**
  108039. * Observer raised when all animations have looped
  108040. */
  108041. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  108042. /**
  108043. * This observable will notify when all animations have ended.
  108044. */
  108045. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  108046. /**
  108047. * This observable will notify when all animations have paused.
  108048. */
  108049. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  108050. /**
  108051. * This observable will notify when all animations are playing.
  108052. */
  108053. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  108054. /**
  108055. * Gets the first frame
  108056. */
  108057. get from(): number;
  108058. /**
  108059. * Gets the last frame
  108060. */
  108061. get to(): number;
  108062. /**
  108063. * Define if the animations are started
  108064. */
  108065. get isStarted(): boolean;
  108066. /**
  108067. * Gets a value indicating that the current group is playing
  108068. */
  108069. get isPlaying(): boolean;
  108070. /**
  108071. * Gets or sets the speed ratio to use for all animations
  108072. */
  108073. get speedRatio(): number;
  108074. /**
  108075. * Gets or sets the speed ratio to use for all animations
  108076. */
  108077. set speedRatio(value: number);
  108078. /**
  108079. * Gets or sets if all animations should loop or not
  108080. */
  108081. get loopAnimation(): boolean;
  108082. set loopAnimation(value: boolean);
  108083. /**
  108084. * Gets the targeted animations for this animation group
  108085. */
  108086. get targetedAnimations(): Array<TargetedAnimation>;
  108087. /**
  108088. * returning the list of animatables controlled by this animation group.
  108089. */
  108090. get animatables(): Array<Animatable>;
  108091. /**
  108092. * Instantiates a new Animation Group.
  108093. * This helps managing several animations at once.
  108094. * @see http://doc.babylonjs.com/how_to/group
  108095. * @param name Defines the name of the group
  108096. * @param scene Defines the scene the group belongs to
  108097. */
  108098. constructor(
  108099. /** The name of the animation group */
  108100. name: string, scene?: Nullable<Scene>);
  108101. /**
  108102. * Add an animation (with its target) in the group
  108103. * @param animation defines the animation we want to add
  108104. * @param target defines the target of the animation
  108105. * @returns the TargetedAnimation object
  108106. */
  108107. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  108108. /**
  108109. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  108110. * It can add constant keys at begin or end
  108111. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  108112. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  108113. * @returns the animation group
  108114. */
  108115. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  108116. private _animationLoopCount;
  108117. private _animationLoopFlags;
  108118. private _processLoop;
  108119. /**
  108120. * Start all animations on given targets
  108121. * @param loop defines if animations must loop
  108122. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  108123. * @param from defines the from key (optional)
  108124. * @param to defines the to key (optional)
  108125. * @returns the current animation group
  108126. */
  108127. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  108128. /**
  108129. * Pause all animations
  108130. * @returns the animation group
  108131. */
  108132. pause(): AnimationGroup;
  108133. /**
  108134. * Play all animations to initial state
  108135. * This function will start() the animations if they were not started or will restart() them if they were paused
  108136. * @param loop defines if animations must loop
  108137. * @returns the animation group
  108138. */
  108139. play(loop?: boolean): AnimationGroup;
  108140. /**
  108141. * Reset all animations to initial state
  108142. * @returns the animation group
  108143. */
  108144. reset(): AnimationGroup;
  108145. /**
  108146. * Restart animations from key 0
  108147. * @returns the animation group
  108148. */
  108149. restart(): AnimationGroup;
  108150. /**
  108151. * Stop all animations
  108152. * @returns the animation group
  108153. */
  108154. stop(): AnimationGroup;
  108155. /**
  108156. * Set animation weight for all animatables
  108157. * @param weight defines the weight to use
  108158. * @return the animationGroup
  108159. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108160. */
  108161. setWeightForAllAnimatables(weight: number): AnimationGroup;
  108162. /**
  108163. * Synchronize and normalize all animatables with a source animatable
  108164. * @param root defines the root animatable to synchronize with
  108165. * @return the animationGroup
  108166. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108167. */
  108168. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  108169. /**
  108170. * Goes to a specific frame in this animation group
  108171. * @param frame the frame number to go to
  108172. * @return the animationGroup
  108173. */
  108174. goToFrame(frame: number): AnimationGroup;
  108175. /**
  108176. * Dispose all associated resources
  108177. */
  108178. dispose(): void;
  108179. private _checkAnimationGroupEnded;
  108180. /**
  108181. * Clone the current animation group and returns a copy
  108182. * @param newName defines the name of the new group
  108183. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  108184. * @returns the new aniamtion group
  108185. */
  108186. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  108187. /**
  108188. * Serializes the animationGroup to an object
  108189. * @returns Serialized object
  108190. */
  108191. serialize(): any;
  108192. /**
  108193. * Returns a new AnimationGroup object parsed from the source provided.
  108194. * @param parsedAnimationGroup defines the source
  108195. * @param scene defines the scene that will receive the animationGroup
  108196. * @returns a new AnimationGroup
  108197. */
  108198. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  108199. /**
  108200. * Returns the string "AnimationGroup"
  108201. * @returns "AnimationGroup"
  108202. */
  108203. getClassName(): string;
  108204. /**
  108205. * Creates a detailled string about the object
  108206. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  108207. * @returns a string representing the object
  108208. */
  108209. toString(fullDetails?: boolean): string;
  108210. }
  108211. }
  108212. declare module BABYLON {
  108213. /**
  108214. * Define an interface for all classes that will hold resources
  108215. */
  108216. export interface IDisposable {
  108217. /**
  108218. * Releases all held resources
  108219. */
  108220. dispose(): void;
  108221. }
  108222. /** Interface defining initialization parameters for Scene class */
  108223. export interface SceneOptions {
  108224. /**
  108225. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  108226. * It will improve performance when the number of geometries becomes important.
  108227. */
  108228. useGeometryUniqueIdsMap?: boolean;
  108229. /**
  108230. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  108231. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108232. */
  108233. useMaterialMeshMap?: boolean;
  108234. /**
  108235. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  108236. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108237. */
  108238. useClonedMeshMap?: boolean;
  108239. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  108240. virtual?: boolean;
  108241. }
  108242. /**
  108243. * Represents a scene to be rendered by the engine.
  108244. * @see http://doc.babylonjs.com/features/scene
  108245. */
  108246. export class Scene extends AbstractScene implements IAnimatable {
  108247. /** The fog is deactivated */
  108248. static readonly FOGMODE_NONE: number;
  108249. /** The fog density is following an exponential function */
  108250. static readonly FOGMODE_EXP: number;
  108251. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  108252. static readonly FOGMODE_EXP2: number;
  108253. /** The fog density is following a linear function. */
  108254. static readonly FOGMODE_LINEAR: number;
  108255. /**
  108256. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  108257. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108258. */
  108259. static MinDeltaTime: number;
  108260. /**
  108261. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  108262. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108263. */
  108264. static MaxDeltaTime: number;
  108265. /**
  108266. * Factory used to create the default material.
  108267. * @param name The name of the material to create
  108268. * @param scene The scene to create the material for
  108269. * @returns The default material
  108270. */
  108271. static DefaultMaterialFactory(scene: Scene): Material;
  108272. /**
  108273. * Factory used to create the a collision coordinator.
  108274. * @returns The collision coordinator
  108275. */
  108276. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  108277. /** @hidden */
  108278. _inputManager: InputManager;
  108279. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  108280. cameraToUseForPointers: Nullable<Camera>;
  108281. /** @hidden */
  108282. readonly _isScene: boolean;
  108283. /** @hidden */
  108284. _blockEntityCollection: boolean;
  108285. /**
  108286. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  108287. */
  108288. autoClear: boolean;
  108289. /**
  108290. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  108291. */
  108292. autoClearDepthAndStencil: boolean;
  108293. /**
  108294. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  108295. */
  108296. clearColor: Color4;
  108297. /**
  108298. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  108299. */
  108300. ambientColor: Color3;
  108301. /**
  108302. * This is use to store the default BRDF lookup for PBR materials in your scene.
  108303. * It should only be one of the following (if not the default embedded one):
  108304. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108305. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  108306. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108307. * The material properties need to be setup according to the type of texture in use.
  108308. */
  108309. environmentBRDFTexture: BaseTexture;
  108310. /** @hidden */
  108311. protected _environmentTexture: Nullable<BaseTexture>;
  108312. /**
  108313. * Texture used in all pbr material as the reflection texture.
  108314. * As in the majority of the scene they are the same (exception for multi room and so on),
  108315. * this is easier to reference from here than from all the materials.
  108316. */
  108317. get environmentTexture(): Nullable<BaseTexture>;
  108318. /**
  108319. * Texture used in all pbr material as the reflection texture.
  108320. * As in the majority of the scene they are the same (exception for multi room and so on),
  108321. * this is easier to set here than in all the materials.
  108322. */
  108323. set environmentTexture(value: Nullable<BaseTexture>);
  108324. /** @hidden */
  108325. protected _environmentIntensity: number;
  108326. /**
  108327. * Intensity of the environment in all pbr material.
  108328. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108329. * As in the majority of the scene they are the same (exception for multi room and so on),
  108330. * this is easier to reference from here than from all the materials.
  108331. */
  108332. get environmentIntensity(): number;
  108333. /**
  108334. * Intensity of the environment in all pbr material.
  108335. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108336. * As in the majority of the scene they are the same (exception for multi room and so on),
  108337. * this is easier to set here than in all the materials.
  108338. */
  108339. set environmentIntensity(value: number);
  108340. /** @hidden */
  108341. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108342. /**
  108343. * Default image processing configuration used either in the rendering
  108344. * Forward main pass or through the imageProcessingPostProcess if present.
  108345. * As in the majority of the scene they are the same (exception for multi camera),
  108346. * this is easier to reference from here than from all the materials and post process.
  108347. *
  108348. * No setter as we it is a shared configuration, you can set the values instead.
  108349. */
  108350. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108351. private _forceWireframe;
  108352. /**
  108353. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  108354. */
  108355. set forceWireframe(value: boolean);
  108356. get forceWireframe(): boolean;
  108357. private _skipFrustumClipping;
  108358. /**
  108359. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  108360. */
  108361. set skipFrustumClipping(value: boolean);
  108362. get skipFrustumClipping(): boolean;
  108363. private _forcePointsCloud;
  108364. /**
  108365. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  108366. */
  108367. set forcePointsCloud(value: boolean);
  108368. get forcePointsCloud(): boolean;
  108369. /**
  108370. * Gets or sets the active clipplane 1
  108371. */
  108372. clipPlane: Nullable<Plane>;
  108373. /**
  108374. * Gets or sets the active clipplane 2
  108375. */
  108376. clipPlane2: Nullable<Plane>;
  108377. /**
  108378. * Gets or sets the active clipplane 3
  108379. */
  108380. clipPlane3: Nullable<Plane>;
  108381. /**
  108382. * Gets or sets the active clipplane 4
  108383. */
  108384. clipPlane4: Nullable<Plane>;
  108385. /**
  108386. * Gets or sets the active clipplane 5
  108387. */
  108388. clipPlane5: Nullable<Plane>;
  108389. /**
  108390. * Gets or sets the active clipplane 6
  108391. */
  108392. clipPlane6: Nullable<Plane>;
  108393. /**
  108394. * Gets or sets a boolean indicating if animations are enabled
  108395. */
  108396. animationsEnabled: boolean;
  108397. private _animationPropertiesOverride;
  108398. /**
  108399. * Gets or sets the animation properties override
  108400. */
  108401. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  108402. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  108403. /**
  108404. * Gets or sets a boolean indicating if a constant deltatime has to be used
  108405. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  108406. */
  108407. useConstantAnimationDeltaTime: boolean;
  108408. /**
  108409. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  108410. * Please note that it requires to run a ray cast through the scene on every frame
  108411. */
  108412. constantlyUpdateMeshUnderPointer: boolean;
  108413. /**
  108414. * Defines the HTML cursor to use when hovering over interactive elements
  108415. */
  108416. hoverCursor: string;
  108417. /**
  108418. * Defines the HTML default cursor to use (empty by default)
  108419. */
  108420. defaultCursor: string;
  108421. /**
  108422. * Defines whether cursors are handled by the scene.
  108423. */
  108424. doNotHandleCursors: boolean;
  108425. /**
  108426. * This is used to call preventDefault() on pointer down
  108427. * in order to block unwanted artifacts like system double clicks
  108428. */
  108429. preventDefaultOnPointerDown: boolean;
  108430. /**
  108431. * This is used to call preventDefault() on pointer up
  108432. * in order to block unwanted artifacts like system double clicks
  108433. */
  108434. preventDefaultOnPointerUp: boolean;
  108435. /**
  108436. * Gets or sets user defined metadata
  108437. */
  108438. metadata: any;
  108439. /**
  108440. * For internal use only. Please do not use.
  108441. */
  108442. reservedDataStore: any;
  108443. /**
  108444. * Gets the name of the plugin used to load this scene (null by default)
  108445. */
  108446. loadingPluginName: string;
  108447. /**
  108448. * Use this array to add regular expressions used to disable offline support for specific urls
  108449. */
  108450. disableOfflineSupportExceptionRules: RegExp[];
  108451. /**
  108452. * An event triggered when the scene is disposed.
  108453. */
  108454. onDisposeObservable: Observable<Scene>;
  108455. private _onDisposeObserver;
  108456. /** Sets a function to be executed when this scene is disposed. */
  108457. set onDispose(callback: () => void);
  108458. /**
  108459. * An event triggered before rendering the scene (right after animations and physics)
  108460. */
  108461. onBeforeRenderObservable: Observable<Scene>;
  108462. private _onBeforeRenderObserver;
  108463. /** Sets a function to be executed before rendering this scene */
  108464. set beforeRender(callback: Nullable<() => void>);
  108465. /**
  108466. * An event triggered after rendering the scene
  108467. */
  108468. onAfterRenderObservable: Observable<Scene>;
  108469. /**
  108470. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  108471. */
  108472. onAfterRenderCameraObservable: Observable<Camera>;
  108473. private _onAfterRenderObserver;
  108474. /** Sets a function to be executed after rendering this scene */
  108475. set afterRender(callback: Nullable<() => void>);
  108476. /**
  108477. * An event triggered before animating the scene
  108478. */
  108479. onBeforeAnimationsObservable: Observable<Scene>;
  108480. /**
  108481. * An event triggered after animations processing
  108482. */
  108483. onAfterAnimationsObservable: Observable<Scene>;
  108484. /**
  108485. * An event triggered before draw calls are ready to be sent
  108486. */
  108487. onBeforeDrawPhaseObservable: Observable<Scene>;
  108488. /**
  108489. * An event triggered after draw calls have been sent
  108490. */
  108491. onAfterDrawPhaseObservable: Observable<Scene>;
  108492. /**
  108493. * An event triggered when the scene is ready
  108494. */
  108495. onReadyObservable: Observable<Scene>;
  108496. /**
  108497. * An event triggered before rendering a camera
  108498. */
  108499. onBeforeCameraRenderObservable: Observable<Camera>;
  108500. private _onBeforeCameraRenderObserver;
  108501. /** Sets a function to be executed before rendering a camera*/
  108502. set beforeCameraRender(callback: () => void);
  108503. /**
  108504. * An event triggered after rendering a camera
  108505. */
  108506. onAfterCameraRenderObservable: Observable<Camera>;
  108507. private _onAfterCameraRenderObserver;
  108508. /** Sets a function to be executed after rendering a camera*/
  108509. set afterCameraRender(callback: () => void);
  108510. /**
  108511. * An event triggered when active meshes evaluation is about to start
  108512. */
  108513. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  108514. /**
  108515. * An event triggered when active meshes evaluation is done
  108516. */
  108517. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  108518. /**
  108519. * An event triggered when particles rendering is about to start
  108520. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108521. */
  108522. onBeforeParticlesRenderingObservable: Observable<Scene>;
  108523. /**
  108524. * An event triggered when particles rendering is done
  108525. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108526. */
  108527. onAfterParticlesRenderingObservable: Observable<Scene>;
  108528. /**
  108529. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  108530. */
  108531. onDataLoadedObservable: Observable<Scene>;
  108532. /**
  108533. * An event triggered when a camera is created
  108534. */
  108535. onNewCameraAddedObservable: Observable<Camera>;
  108536. /**
  108537. * An event triggered when a camera is removed
  108538. */
  108539. onCameraRemovedObservable: Observable<Camera>;
  108540. /**
  108541. * An event triggered when a light is created
  108542. */
  108543. onNewLightAddedObservable: Observable<Light>;
  108544. /**
  108545. * An event triggered when a light is removed
  108546. */
  108547. onLightRemovedObservable: Observable<Light>;
  108548. /**
  108549. * An event triggered when a geometry is created
  108550. */
  108551. onNewGeometryAddedObservable: Observable<Geometry>;
  108552. /**
  108553. * An event triggered when a geometry is removed
  108554. */
  108555. onGeometryRemovedObservable: Observable<Geometry>;
  108556. /**
  108557. * An event triggered when a transform node is created
  108558. */
  108559. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  108560. /**
  108561. * An event triggered when a transform node is removed
  108562. */
  108563. onTransformNodeRemovedObservable: Observable<TransformNode>;
  108564. /**
  108565. * An event triggered when a mesh is created
  108566. */
  108567. onNewMeshAddedObservable: Observable<AbstractMesh>;
  108568. /**
  108569. * An event triggered when a mesh is removed
  108570. */
  108571. onMeshRemovedObservable: Observable<AbstractMesh>;
  108572. /**
  108573. * An event triggered when a skeleton is created
  108574. */
  108575. onNewSkeletonAddedObservable: Observable<Skeleton>;
  108576. /**
  108577. * An event triggered when a skeleton is removed
  108578. */
  108579. onSkeletonRemovedObservable: Observable<Skeleton>;
  108580. /**
  108581. * An event triggered when a material is created
  108582. */
  108583. onNewMaterialAddedObservable: Observable<Material>;
  108584. /**
  108585. * An event triggered when a material is removed
  108586. */
  108587. onMaterialRemovedObservable: Observable<Material>;
  108588. /**
  108589. * An event triggered when a texture is created
  108590. */
  108591. onNewTextureAddedObservable: Observable<BaseTexture>;
  108592. /**
  108593. * An event triggered when a texture is removed
  108594. */
  108595. onTextureRemovedObservable: Observable<BaseTexture>;
  108596. /**
  108597. * An event triggered when render targets are about to be rendered
  108598. * Can happen multiple times per frame.
  108599. */
  108600. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  108601. /**
  108602. * An event triggered when render targets were rendered.
  108603. * Can happen multiple times per frame.
  108604. */
  108605. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  108606. /**
  108607. * An event triggered before calculating deterministic simulation step
  108608. */
  108609. onBeforeStepObservable: Observable<Scene>;
  108610. /**
  108611. * An event triggered after calculating deterministic simulation step
  108612. */
  108613. onAfterStepObservable: Observable<Scene>;
  108614. /**
  108615. * An event triggered when the activeCamera property is updated
  108616. */
  108617. onActiveCameraChanged: Observable<Scene>;
  108618. /**
  108619. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  108620. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108621. * 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)
  108622. */
  108623. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108624. /**
  108625. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  108626. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108627. * 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)
  108628. */
  108629. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108630. /**
  108631. * This Observable will when a mesh has been imported into the scene.
  108632. */
  108633. onMeshImportedObservable: Observable<AbstractMesh>;
  108634. /**
  108635. * This Observable will when an animation file has been imported into the scene.
  108636. */
  108637. onAnimationFileImportedObservable: Observable<Scene>;
  108638. /**
  108639. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  108640. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  108641. */
  108642. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  108643. /** @hidden */
  108644. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  108645. /**
  108646. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  108647. */
  108648. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  108649. /**
  108650. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  108651. */
  108652. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  108653. /**
  108654. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  108655. */
  108656. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  108657. /** Callback called when a pointer move is detected */
  108658. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108659. /** Callback called when a pointer down is detected */
  108660. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108661. /** Callback called when a pointer up is detected */
  108662. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  108663. /** Callback called when a pointer pick is detected */
  108664. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  108665. /**
  108666. * 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).
  108667. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  108668. */
  108669. onPrePointerObservable: Observable<PointerInfoPre>;
  108670. /**
  108671. * Observable event triggered each time an input event is received from the rendering canvas
  108672. */
  108673. onPointerObservable: Observable<PointerInfo>;
  108674. /**
  108675. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  108676. */
  108677. get unTranslatedPointer(): Vector2;
  108678. /**
  108679. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  108680. */
  108681. static get DragMovementThreshold(): number;
  108682. static set DragMovementThreshold(value: number);
  108683. /**
  108684. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  108685. */
  108686. static get LongPressDelay(): number;
  108687. static set LongPressDelay(value: number);
  108688. /**
  108689. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  108690. */
  108691. static get DoubleClickDelay(): number;
  108692. static set DoubleClickDelay(value: number);
  108693. /** If you need to check double click without raising a single click at first click, enable this flag */
  108694. static get ExclusiveDoubleClickMode(): boolean;
  108695. static set ExclusiveDoubleClickMode(value: boolean);
  108696. /** @hidden */
  108697. _mirroredCameraPosition: Nullable<Vector3>;
  108698. /**
  108699. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  108700. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  108701. */
  108702. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  108703. /**
  108704. * Observable event triggered each time an keyboard event is received from the hosting window
  108705. */
  108706. onKeyboardObservable: Observable<KeyboardInfo>;
  108707. private _useRightHandedSystem;
  108708. /**
  108709. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  108710. */
  108711. set useRightHandedSystem(value: boolean);
  108712. get useRightHandedSystem(): boolean;
  108713. private _timeAccumulator;
  108714. private _currentStepId;
  108715. private _currentInternalStep;
  108716. /**
  108717. * Sets the step Id used by deterministic lock step
  108718. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108719. * @param newStepId defines the step Id
  108720. */
  108721. setStepId(newStepId: number): void;
  108722. /**
  108723. * Gets the step Id used by deterministic lock step
  108724. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108725. * @returns the step Id
  108726. */
  108727. getStepId(): number;
  108728. /**
  108729. * Gets the internal step used by deterministic lock step
  108730. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108731. * @returns the internal step
  108732. */
  108733. getInternalStep(): number;
  108734. private _fogEnabled;
  108735. /**
  108736. * Gets or sets a boolean indicating if fog is enabled on this scene
  108737. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108738. * (Default is true)
  108739. */
  108740. set fogEnabled(value: boolean);
  108741. get fogEnabled(): boolean;
  108742. private _fogMode;
  108743. /**
  108744. * Gets or sets the fog mode to use
  108745. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108746. * | mode | value |
  108747. * | --- | --- |
  108748. * | FOGMODE_NONE | 0 |
  108749. * | FOGMODE_EXP | 1 |
  108750. * | FOGMODE_EXP2 | 2 |
  108751. * | FOGMODE_LINEAR | 3 |
  108752. */
  108753. set fogMode(value: number);
  108754. get fogMode(): number;
  108755. /**
  108756. * Gets or sets the fog color to use
  108757. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108758. * (Default is Color3(0.2, 0.2, 0.3))
  108759. */
  108760. fogColor: Color3;
  108761. /**
  108762. * Gets or sets the fog density to use
  108763. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108764. * (Default is 0.1)
  108765. */
  108766. fogDensity: number;
  108767. /**
  108768. * Gets or sets the fog start distance to use
  108769. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108770. * (Default is 0)
  108771. */
  108772. fogStart: number;
  108773. /**
  108774. * Gets or sets the fog end distance to use
  108775. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108776. * (Default is 1000)
  108777. */
  108778. fogEnd: number;
  108779. private _shadowsEnabled;
  108780. /**
  108781. * Gets or sets a boolean indicating if shadows are enabled on this scene
  108782. */
  108783. set shadowsEnabled(value: boolean);
  108784. get shadowsEnabled(): boolean;
  108785. private _lightsEnabled;
  108786. /**
  108787. * Gets or sets a boolean indicating if lights are enabled on this scene
  108788. */
  108789. set lightsEnabled(value: boolean);
  108790. get lightsEnabled(): boolean;
  108791. /** All of the active cameras added to this scene. */
  108792. activeCameras: Camera[];
  108793. /** @hidden */
  108794. _activeCamera: Nullable<Camera>;
  108795. /** Gets or sets the current active camera */
  108796. get activeCamera(): Nullable<Camera>;
  108797. set activeCamera(value: Nullable<Camera>);
  108798. private _defaultMaterial;
  108799. /** The default material used on meshes when no material is affected */
  108800. get defaultMaterial(): Material;
  108801. /** The default material used on meshes when no material is affected */
  108802. set defaultMaterial(value: Material);
  108803. private _texturesEnabled;
  108804. /**
  108805. * Gets or sets a boolean indicating if textures are enabled on this scene
  108806. */
  108807. set texturesEnabled(value: boolean);
  108808. get texturesEnabled(): boolean;
  108809. /**
  108810. * Gets or sets a boolean indicating if particles are enabled on this scene
  108811. */
  108812. particlesEnabled: boolean;
  108813. /**
  108814. * Gets or sets a boolean indicating if sprites are enabled on this scene
  108815. */
  108816. spritesEnabled: boolean;
  108817. private _skeletonsEnabled;
  108818. /**
  108819. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  108820. */
  108821. set skeletonsEnabled(value: boolean);
  108822. get skeletonsEnabled(): boolean;
  108823. /**
  108824. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  108825. */
  108826. lensFlaresEnabled: boolean;
  108827. /**
  108828. * Gets or sets a boolean indicating if collisions are enabled on this scene
  108829. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108830. */
  108831. collisionsEnabled: boolean;
  108832. private _collisionCoordinator;
  108833. /** @hidden */
  108834. get collisionCoordinator(): ICollisionCoordinator;
  108835. /**
  108836. * Defines the gravity applied to this scene (used only for collisions)
  108837. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108838. */
  108839. gravity: Vector3;
  108840. /**
  108841. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  108842. */
  108843. postProcessesEnabled: boolean;
  108844. /**
  108845. * The list of postprocesses added to the scene
  108846. */
  108847. postProcesses: PostProcess[];
  108848. /**
  108849. * Gets the current postprocess manager
  108850. */
  108851. postProcessManager: PostProcessManager;
  108852. /**
  108853. * Gets or sets a boolean indicating if render targets are enabled on this scene
  108854. */
  108855. renderTargetsEnabled: boolean;
  108856. /**
  108857. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  108858. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  108859. */
  108860. dumpNextRenderTargets: boolean;
  108861. /**
  108862. * The list of user defined render targets added to the scene
  108863. */
  108864. customRenderTargets: RenderTargetTexture[];
  108865. /**
  108866. * Defines if texture loading must be delayed
  108867. * If true, textures will only be loaded when they need to be rendered
  108868. */
  108869. useDelayedTextureLoading: boolean;
  108870. /**
  108871. * Gets the list of meshes imported to the scene through SceneLoader
  108872. */
  108873. importedMeshesFiles: String[];
  108874. /**
  108875. * Gets or sets a boolean indicating if probes are enabled on this scene
  108876. */
  108877. probesEnabled: boolean;
  108878. /**
  108879. * Gets or sets the current offline provider to use to store scene data
  108880. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  108881. */
  108882. offlineProvider: IOfflineProvider;
  108883. /**
  108884. * Gets or sets the action manager associated with the scene
  108885. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  108886. */
  108887. actionManager: AbstractActionManager;
  108888. private _meshesForIntersections;
  108889. /**
  108890. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  108891. */
  108892. proceduralTexturesEnabled: boolean;
  108893. private _engine;
  108894. private _totalVertices;
  108895. /** @hidden */
  108896. _activeIndices: PerfCounter;
  108897. /** @hidden */
  108898. _activeParticles: PerfCounter;
  108899. /** @hidden */
  108900. _activeBones: PerfCounter;
  108901. private _animationRatio;
  108902. /** @hidden */
  108903. _animationTimeLast: number;
  108904. /** @hidden */
  108905. _animationTime: number;
  108906. /**
  108907. * Gets or sets a general scale for animation speed
  108908. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  108909. */
  108910. animationTimeScale: number;
  108911. /** @hidden */
  108912. _cachedMaterial: Nullable<Material>;
  108913. /** @hidden */
  108914. _cachedEffect: Nullable<Effect>;
  108915. /** @hidden */
  108916. _cachedVisibility: Nullable<number>;
  108917. private _renderId;
  108918. private _frameId;
  108919. private _executeWhenReadyTimeoutId;
  108920. private _intermediateRendering;
  108921. private _viewUpdateFlag;
  108922. private _projectionUpdateFlag;
  108923. /** @hidden */
  108924. _toBeDisposed: Nullable<IDisposable>[];
  108925. private _activeRequests;
  108926. /** @hidden */
  108927. _pendingData: any[];
  108928. private _isDisposed;
  108929. /**
  108930. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  108931. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  108932. */
  108933. dispatchAllSubMeshesOfActiveMeshes: boolean;
  108934. private _activeMeshes;
  108935. private _processedMaterials;
  108936. private _renderTargets;
  108937. /** @hidden */
  108938. _activeParticleSystems: SmartArray<IParticleSystem>;
  108939. private _activeSkeletons;
  108940. private _softwareSkinnedMeshes;
  108941. private _renderingManager;
  108942. /** @hidden */
  108943. _activeAnimatables: Animatable[];
  108944. private _transformMatrix;
  108945. private _sceneUbo;
  108946. /** @hidden */
  108947. _viewMatrix: Matrix;
  108948. private _projectionMatrix;
  108949. /** @hidden */
  108950. _forcedViewPosition: Nullable<Vector3>;
  108951. /** @hidden */
  108952. _frustumPlanes: Plane[];
  108953. /**
  108954. * Gets the list of frustum planes (built from the active camera)
  108955. */
  108956. get frustumPlanes(): Plane[];
  108957. /**
  108958. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  108959. * This is useful if there are more lights that the maximum simulteanous authorized
  108960. */
  108961. requireLightSorting: boolean;
  108962. /** @hidden */
  108963. readonly useMaterialMeshMap: boolean;
  108964. /** @hidden */
  108965. readonly useClonedMeshMap: boolean;
  108966. private _externalData;
  108967. private _uid;
  108968. /**
  108969. * @hidden
  108970. * Backing store of defined scene components.
  108971. */
  108972. _components: ISceneComponent[];
  108973. /**
  108974. * @hidden
  108975. * Backing store of defined scene components.
  108976. */
  108977. _serializableComponents: ISceneSerializableComponent[];
  108978. /**
  108979. * List of components to register on the next registration step.
  108980. */
  108981. private _transientComponents;
  108982. /**
  108983. * Registers the transient components if needed.
  108984. */
  108985. private _registerTransientComponents;
  108986. /**
  108987. * @hidden
  108988. * Add a component to the scene.
  108989. * Note that the ccomponent could be registered on th next frame if this is called after
  108990. * the register component stage.
  108991. * @param component Defines the component to add to the scene
  108992. */
  108993. _addComponent(component: ISceneComponent): void;
  108994. /**
  108995. * @hidden
  108996. * Gets a component from the scene.
  108997. * @param name defines the name of the component to retrieve
  108998. * @returns the component or null if not present
  108999. */
  109000. _getComponent(name: string): Nullable<ISceneComponent>;
  109001. /**
  109002. * @hidden
  109003. * Defines the actions happening before camera updates.
  109004. */
  109005. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  109006. /**
  109007. * @hidden
  109008. * Defines the actions happening before clear the canvas.
  109009. */
  109010. _beforeClearStage: Stage<SimpleStageAction>;
  109011. /**
  109012. * @hidden
  109013. * Defines the actions when collecting render targets for the frame.
  109014. */
  109015. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109016. /**
  109017. * @hidden
  109018. * Defines the actions happening for one camera in the frame.
  109019. */
  109020. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109021. /**
  109022. * @hidden
  109023. * Defines the actions happening during the per mesh ready checks.
  109024. */
  109025. _isReadyForMeshStage: Stage<MeshStageAction>;
  109026. /**
  109027. * @hidden
  109028. * Defines the actions happening before evaluate active mesh checks.
  109029. */
  109030. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  109031. /**
  109032. * @hidden
  109033. * Defines the actions happening during the evaluate sub mesh checks.
  109034. */
  109035. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  109036. /**
  109037. * @hidden
  109038. * Defines the actions happening during the active mesh stage.
  109039. */
  109040. _activeMeshStage: Stage<ActiveMeshStageAction>;
  109041. /**
  109042. * @hidden
  109043. * Defines the actions happening during the per camera render target step.
  109044. */
  109045. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  109046. /**
  109047. * @hidden
  109048. * Defines the actions happening just before the active camera is drawing.
  109049. */
  109050. _beforeCameraDrawStage: Stage<CameraStageAction>;
  109051. /**
  109052. * @hidden
  109053. * Defines the actions happening just before a render target is drawing.
  109054. */
  109055. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109056. /**
  109057. * @hidden
  109058. * Defines the actions happening just before a rendering group is drawing.
  109059. */
  109060. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109061. /**
  109062. * @hidden
  109063. * Defines the actions happening just before a mesh is drawing.
  109064. */
  109065. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109066. /**
  109067. * @hidden
  109068. * Defines the actions happening just after a mesh has been drawn.
  109069. */
  109070. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109071. /**
  109072. * @hidden
  109073. * Defines the actions happening just after a rendering group has been drawn.
  109074. */
  109075. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109076. /**
  109077. * @hidden
  109078. * Defines the actions happening just after the active camera has been drawn.
  109079. */
  109080. _afterCameraDrawStage: Stage<CameraStageAction>;
  109081. /**
  109082. * @hidden
  109083. * Defines the actions happening just after a render target has been drawn.
  109084. */
  109085. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109086. /**
  109087. * @hidden
  109088. * Defines the actions happening just after rendering all cameras and computing intersections.
  109089. */
  109090. _afterRenderStage: Stage<SimpleStageAction>;
  109091. /**
  109092. * @hidden
  109093. * Defines the actions happening when a pointer move event happens.
  109094. */
  109095. _pointerMoveStage: Stage<PointerMoveStageAction>;
  109096. /**
  109097. * @hidden
  109098. * Defines the actions happening when a pointer down event happens.
  109099. */
  109100. _pointerDownStage: Stage<PointerUpDownStageAction>;
  109101. /**
  109102. * @hidden
  109103. * Defines the actions happening when a pointer up event happens.
  109104. */
  109105. _pointerUpStage: Stage<PointerUpDownStageAction>;
  109106. /**
  109107. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  109108. */
  109109. private geometriesByUniqueId;
  109110. /**
  109111. * Creates a new Scene
  109112. * @param engine defines the engine to use to render this scene
  109113. * @param options defines the scene options
  109114. */
  109115. constructor(engine: Engine, options?: SceneOptions);
  109116. /**
  109117. * Gets a string idenfifying the name of the class
  109118. * @returns "Scene" string
  109119. */
  109120. getClassName(): string;
  109121. private _defaultMeshCandidates;
  109122. /**
  109123. * @hidden
  109124. */
  109125. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109126. private _defaultSubMeshCandidates;
  109127. /**
  109128. * @hidden
  109129. */
  109130. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109131. /**
  109132. * Sets the default candidate providers for the scene.
  109133. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  109134. * and getCollidingSubMeshCandidates to their default function
  109135. */
  109136. setDefaultCandidateProviders(): void;
  109137. /**
  109138. * Gets the mesh that is currently under the pointer
  109139. */
  109140. get meshUnderPointer(): Nullable<AbstractMesh>;
  109141. /**
  109142. * Gets or sets the current on-screen X position of the pointer
  109143. */
  109144. get pointerX(): number;
  109145. set pointerX(value: number);
  109146. /**
  109147. * Gets or sets the current on-screen Y position of the pointer
  109148. */
  109149. get pointerY(): number;
  109150. set pointerY(value: number);
  109151. /**
  109152. * Gets the cached material (ie. the latest rendered one)
  109153. * @returns the cached material
  109154. */
  109155. getCachedMaterial(): Nullable<Material>;
  109156. /**
  109157. * Gets the cached effect (ie. the latest rendered one)
  109158. * @returns the cached effect
  109159. */
  109160. getCachedEffect(): Nullable<Effect>;
  109161. /**
  109162. * Gets the cached visibility state (ie. the latest rendered one)
  109163. * @returns the cached visibility state
  109164. */
  109165. getCachedVisibility(): Nullable<number>;
  109166. /**
  109167. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  109168. * @param material defines the current material
  109169. * @param effect defines the current effect
  109170. * @param visibility defines the current visibility state
  109171. * @returns true if one parameter is not cached
  109172. */
  109173. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  109174. /**
  109175. * Gets the engine associated with the scene
  109176. * @returns an Engine
  109177. */
  109178. getEngine(): Engine;
  109179. /**
  109180. * Gets the total number of vertices rendered per frame
  109181. * @returns the total number of vertices rendered per frame
  109182. */
  109183. getTotalVertices(): number;
  109184. /**
  109185. * Gets the performance counter for total vertices
  109186. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109187. */
  109188. get totalVerticesPerfCounter(): PerfCounter;
  109189. /**
  109190. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  109191. * @returns the total number of active indices rendered per frame
  109192. */
  109193. getActiveIndices(): number;
  109194. /**
  109195. * Gets the performance counter for active indices
  109196. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109197. */
  109198. get totalActiveIndicesPerfCounter(): PerfCounter;
  109199. /**
  109200. * Gets the total number of active particles rendered per frame
  109201. * @returns the total number of active particles rendered per frame
  109202. */
  109203. getActiveParticles(): number;
  109204. /**
  109205. * Gets the performance counter for active particles
  109206. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109207. */
  109208. get activeParticlesPerfCounter(): PerfCounter;
  109209. /**
  109210. * Gets the total number of active bones rendered per frame
  109211. * @returns the total number of active bones rendered per frame
  109212. */
  109213. getActiveBones(): number;
  109214. /**
  109215. * Gets the performance counter for active bones
  109216. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109217. */
  109218. get activeBonesPerfCounter(): PerfCounter;
  109219. /**
  109220. * Gets the array of active meshes
  109221. * @returns an array of AbstractMesh
  109222. */
  109223. getActiveMeshes(): SmartArray<AbstractMesh>;
  109224. /**
  109225. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  109226. * @returns a number
  109227. */
  109228. getAnimationRatio(): number;
  109229. /**
  109230. * Gets an unique Id for the current render phase
  109231. * @returns a number
  109232. */
  109233. getRenderId(): number;
  109234. /**
  109235. * Gets an unique Id for the current frame
  109236. * @returns a number
  109237. */
  109238. getFrameId(): number;
  109239. /** Call this function if you want to manually increment the render Id*/
  109240. incrementRenderId(): void;
  109241. private _createUbo;
  109242. /**
  109243. * Use this method to simulate a pointer move on a mesh
  109244. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109245. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109246. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109247. * @returns the current scene
  109248. */
  109249. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109250. /**
  109251. * Use this method to simulate a pointer down on a mesh
  109252. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109253. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109254. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109255. * @returns the current scene
  109256. */
  109257. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109258. /**
  109259. * Use this method to simulate a pointer up on a mesh
  109260. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109261. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109262. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109263. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109264. * @returns the current scene
  109265. */
  109266. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  109267. /**
  109268. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109269. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109270. * @returns true if the pointer was captured
  109271. */
  109272. isPointerCaptured(pointerId?: number): boolean;
  109273. /**
  109274. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109275. * @param attachUp defines if you want to attach events to pointerup
  109276. * @param attachDown defines if you want to attach events to pointerdown
  109277. * @param attachMove defines if you want to attach events to pointermove
  109278. */
  109279. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  109280. /** Detaches all event handlers*/
  109281. detachControl(): void;
  109282. /**
  109283. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  109284. * Delay loaded resources are not taking in account
  109285. * @return true if all required resources are ready
  109286. */
  109287. isReady(): boolean;
  109288. /** Resets all cached information relative to material (including effect and visibility) */
  109289. resetCachedMaterial(): void;
  109290. /**
  109291. * Registers a function to be called before every frame render
  109292. * @param func defines the function to register
  109293. */
  109294. registerBeforeRender(func: () => void): void;
  109295. /**
  109296. * Unregisters a function called before every frame render
  109297. * @param func defines the function to unregister
  109298. */
  109299. unregisterBeforeRender(func: () => void): void;
  109300. /**
  109301. * Registers a function to be called after every frame render
  109302. * @param func defines the function to register
  109303. */
  109304. registerAfterRender(func: () => void): void;
  109305. /**
  109306. * Unregisters a function called after every frame render
  109307. * @param func defines the function to unregister
  109308. */
  109309. unregisterAfterRender(func: () => void): void;
  109310. private _executeOnceBeforeRender;
  109311. /**
  109312. * The provided function will run before render once and will be disposed afterwards.
  109313. * A timeout delay can be provided so that the function will be executed in N ms.
  109314. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  109315. * @param func The function to be executed.
  109316. * @param timeout optional delay in ms
  109317. */
  109318. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  109319. /** @hidden */
  109320. _addPendingData(data: any): void;
  109321. /** @hidden */
  109322. _removePendingData(data: any): void;
  109323. /**
  109324. * Returns the number of items waiting to be loaded
  109325. * @returns the number of items waiting to be loaded
  109326. */
  109327. getWaitingItemsCount(): number;
  109328. /**
  109329. * Returns a boolean indicating if the scene is still loading data
  109330. */
  109331. get isLoading(): boolean;
  109332. /**
  109333. * Registers a function to be executed when the scene is ready
  109334. * @param {Function} func - the function to be executed
  109335. */
  109336. executeWhenReady(func: () => void): void;
  109337. /**
  109338. * Returns a promise that resolves when the scene is ready
  109339. * @returns A promise that resolves when the scene is ready
  109340. */
  109341. whenReadyAsync(): Promise<void>;
  109342. /** @hidden */
  109343. _checkIsReady(): void;
  109344. /**
  109345. * Gets all animatable attached to the scene
  109346. */
  109347. get animatables(): Animatable[];
  109348. /**
  109349. * Resets the last animation time frame.
  109350. * Useful to override when animations start running when loading a scene for the first time.
  109351. */
  109352. resetLastAnimationTimeFrame(): void;
  109353. /**
  109354. * Gets the current view matrix
  109355. * @returns a Matrix
  109356. */
  109357. getViewMatrix(): Matrix;
  109358. /**
  109359. * Gets the current projection matrix
  109360. * @returns a Matrix
  109361. */
  109362. getProjectionMatrix(): Matrix;
  109363. /**
  109364. * Gets the current transform matrix
  109365. * @returns a Matrix made of View * Projection
  109366. */
  109367. getTransformMatrix(): Matrix;
  109368. /**
  109369. * Sets the current transform matrix
  109370. * @param viewL defines the View matrix to use
  109371. * @param projectionL defines the Projection matrix to use
  109372. * @param viewR defines the right View matrix to use (if provided)
  109373. * @param projectionR defines the right Projection matrix to use (if provided)
  109374. */
  109375. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  109376. /**
  109377. * Gets the uniform buffer used to store scene data
  109378. * @returns a UniformBuffer
  109379. */
  109380. getSceneUniformBuffer(): UniformBuffer;
  109381. /**
  109382. * Gets an unique (relatively to the current scene) Id
  109383. * @returns an unique number for the scene
  109384. */
  109385. getUniqueId(): number;
  109386. /**
  109387. * Add a mesh to the list of scene's meshes
  109388. * @param newMesh defines the mesh to add
  109389. * @param recursive if all child meshes should also be added to the scene
  109390. */
  109391. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  109392. /**
  109393. * Remove a mesh for the list of scene's meshes
  109394. * @param toRemove defines the mesh to remove
  109395. * @param recursive if all child meshes should also be removed from the scene
  109396. * @returns the index where the mesh was in the mesh list
  109397. */
  109398. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  109399. /**
  109400. * Add a transform node to the list of scene's transform nodes
  109401. * @param newTransformNode defines the transform node to add
  109402. */
  109403. addTransformNode(newTransformNode: TransformNode): void;
  109404. /**
  109405. * Remove a transform node for the list of scene's transform nodes
  109406. * @param toRemove defines the transform node to remove
  109407. * @returns the index where the transform node was in the transform node list
  109408. */
  109409. removeTransformNode(toRemove: TransformNode): number;
  109410. /**
  109411. * Remove a skeleton for the list of scene's skeletons
  109412. * @param toRemove defines the skeleton to remove
  109413. * @returns the index where the skeleton was in the skeleton list
  109414. */
  109415. removeSkeleton(toRemove: Skeleton): number;
  109416. /**
  109417. * Remove a morph target for the list of scene's morph targets
  109418. * @param toRemove defines the morph target to remove
  109419. * @returns the index where the morph target was in the morph target list
  109420. */
  109421. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  109422. /**
  109423. * Remove a light for the list of scene's lights
  109424. * @param toRemove defines the light to remove
  109425. * @returns the index where the light was in the light list
  109426. */
  109427. removeLight(toRemove: Light): number;
  109428. /**
  109429. * Remove a camera for the list of scene's cameras
  109430. * @param toRemove defines the camera to remove
  109431. * @returns the index where the camera was in the camera list
  109432. */
  109433. removeCamera(toRemove: Camera): number;
  109434. /**
  109435. * Remove a particle system for the list of scene's particle systems
  109436. * @param toRemove defines the particle system to remove
  109437. * @returns the index where the particle system was in the particle system list
  109438. */
  109439. removeParticleSystem(toRemove: IParticleSystem): number;
  109440. /**
  109441. * Remove a animation for the list of scene's animations
  109442. * @param toRemove defines the animation to remove
  109443. * @returns the index where the animation was in the animation list
  109444. */
  109445. removeAnimation(toRemove: Animation): number;
  109446. /**
  109447. * Will stop the animation of the given target
  109448. * @param target - the target
  109449. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  109450. * @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)
  109451. */
  109452. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  109453. /**
  109454. * Removes the given animation group from this scene.
  109455. * @param toRemove The animation group to remove
  109456. * @returns The index of the removed animation group
  109457. */
  109458. removeAnimationGroup(toRemove: AnimationGroup): number;
  109459. /**
  109460. * Removes the given multi-material from this scene.
  109461. * @param toRemove The multi-material to remove
  109462. * @returns The index of the removed multi-material
  109463. */
  109464. removeMultiMaterial(toRemove: MultiMaterial): number;
  109465. /**
  109466. * Removes the given material from this scene.
  109467. * @param toRemove The material to remove
  109468. * @returns The index of the removed material
  109469. */
  109470. removeMaterial(toRemove: Material): number;
  109471. /**
  109472. * Removes the given action manager from this scene.
  109473. * @param toRemove The action manager to remove
  109474. * @returns The index of the removed action manager
  109475. */
  109476. removeActionManager(toRemove: AbstractActionManager): number;
  109477. /**
  109478. * Removes the given texture from this scene.
  109479. * @param toRemove The texture to remove
  109480. * @returns The index of the removed texture
  109481. */
  109482. removeTexture(toRemove: BaseTexture): number;
  109483. /**
  109484. * Adds the given light to this scene
  109485. * @param newLight The light to add
  109486. */
  109487. addLight(newLight: Light): void;
  109488. /**
  109489. * Sorts the list list based on light priorities
  109490. */
  109491. sortLightsByPriority(): void;
  109492. /**
  109493. * Adds the given camera to this scene
  109494. * @param newCamera The camera to add
  109495. */
  109496. addCamera(newCamera: Camera): void;
  109497. /**
  109498. * Adds the given skeleton to this scene
  109499. * @param newSkeleton The skeleton to add
  109500. */
  109501. addSkeleton(newSkeleton: Skeleton): void;
  109502. /**
  109503. * Adds the given particle system to this scene
  109504. * @param newParticleSystem The particle system to add
  109505. */
  109506. addParticleSystem(newParticleSystem: IParticleSystem): void;
  109507. /**
  109508. * Adds the given animation to this scene
  109509. * @param newAnimation The animation to add
  109510. */
  109511. addAnimation(newAnimation: Animation): void;
  109512. /**
  109513. * Adds the given animation group to this scene.
  109514. * @param newAnimationGroup The animation group to add
  109515. */
  109516. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  109517. /**
  109518. * Adds the given multi-material to this scene
  109519. * @param newMultiMaterial The multi-material to add
  109520. */
  109521. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  109522. /**
  109523. * Adds the given material to this scene
  109524. * @param newMaterial The material to add
  109525. */
  109526. addMaterial(newMaterial: Material): void;
  109527. /**
  109528. * Adds the given morph target to this scene
  109529. * @param newMorphTargetManager The morph target to add
  109530. */
  109531. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  109532. /**
  109533. * Adds the given geometry to this scene
  109534. * @param newGeometry The geometry to add
  109535. */
  109536. addGeometry(newGeometry: Geometry): void;
  109537. /**
  109538. * Adds the given action manager to this scene
  109539. * @param newActionManager The action manager to add
  109540. */
  109541. addActionManager(newActionManager: AbstractActionManager): void;
  109542. /**
  109543. * Adds the given texture to this scene.
  109544. * @param newTexture The texture to add
  109545. */
  109546. addTexture(newTexture: BaseTexture): void;
  109547. /**
  109548. * Switch active camera
  109549. * @param newCamera defines the new active camera
  109550. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  109551. */
  109552. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  109553. /**
  109554. * sets the active camera of the scene using its ID
  109555. * @param id defines the camera's ID
  109556. * @return the new active camera or null if none found.
  109557. */
  109558. setActiveCameraByID(id: string): Nullable<Camera>;
  109559. /**
  109560. * sets the active camera of the scene using its name
  109561. * @param name defines the camera's name
  109562. * @returns the new active camera or null if none found.
  109563. */
  109564. setActiveCameraByName(name: string): Nullable<Camera>;
  109565. /**
  109566. * get an animation group using its name
  109567. * @param name defines the material's name
  109568. * @return the animation group or null if none found.
  109569. */
  109570. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  109571. /**
  109572. * Get a material using its unique id
  109573. * @param uniqueId defines the material's unique id
  109574. * @return the material or null if none found.
  109575. */
  109576. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  109577. /**
  109578. * get a material using its id
  109579. * @param id defines the material's ID
  109580. * @return the material or null if none found.
  109581. */
  109582. getMaterialByID(id: string): Nullable<Material>;
  109583. /**
  109584. * Gets a the last added material using a given id
  109585. * @param id defines the material's ID
  109586. * @return the last material with the given id or null if none found.
  109587. */
  109588. getLastMaterialByID(id: string): Nullable<Material>;
  109589. /**
  109590. * Gets a material using its name
  109591. * @param name defines the material's name
  109592. * @return the material or null if none found.
  109593. */
  109594. getMaterialByName(name: string): Nullable<Material>;
  109595. /**
  109596. * Get a texture using its unique id
  109597. * @param uniqueId defines the texture's unique id
  109598. * @return the texture or null if none found.
  109599. */
  109600. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  109601. /**
  109602. * Gets a camera using its id
  109603. * @param id defines the id to look for
  109604. * @returns the camera or null if not found
  109605. */
  109606. getCameraByID(id: string): Nullable<Camera>;
  109607. /**
  109608. * Gets a camera using its unique id
  109609. * @param uniqueId defines the unique id to look for
  109610. * @returns the camera or null if not found
  109611. */
  109612. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  109613. /**
  109614. * Gets a camera using its name
  109615. * @param name defines the camera's name
  109616. * @return the camera or null if none found.
  109617. */
  109618. getCameraByName(name: string): Nullable<Camera>;
  109619. /**
  109620. * Gets a bone using its id
  109621. * @param id defines the bone's id
  109622. * @return the bone or null if not found
  109623. */
  109624. getBoneByID(id: string): Nullable<Bone>;
  109625. /**
  109626. * Gets a bone using its id
  109627. * @param name defines the bone's name
  109628. * @return the bone or null if not found
  109629. */
  109630. getBoneByName(name: string): Nullable<Bone>;
  109631. /**
  109632. * Gets a light node using its name
  109633. * @param name defines the the light's name
  109634. * @return the light or null if none found.
  109635. */
  109636. getLightByName(name: string): Nullable<Light>;
  109637. /**
  109638. * Gets a light node using its id
  109639. * @param id defines the light's id
  109640. * @return the light or null if none found.
  109641. */
  109642. getLightByID(id: string): Nullable<Light>;
  109643. /**
  109644. * Gets a light node using its scene-generated unique ID
  109645. * @param uniqueId defines the light's unique id
  109646. * @return the light or null if none found.
  109647. */
  109648. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  109649. /**
  109650. * Gets a particle system by id
  109651. * @param id defines the particle system id
  109652. * @return the corresponding system or null if none found
  109653. */
  109654. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  109655. /**
  109656. * Gets a geometry using its ID
  109657. * @param id defines the geometry's id
  109658. * @return the geometry or null if none found.
  109659. */
  109660. getGeometryByID(id: string): Nullable<Geometry>;
  109661. private _getGeometryByUniqueID;
  109662. /**
  109663. * Add a new geometry to this scene
  109664. * @param geometry defines the geometry to be added to the scene.
  109665. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  109666. * @return a boolean defining if the geometry was added or not
  109667. */
  109668. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  109669. /**
  109670. * Removes an existing geometry
  109671. * @param geometry defines the geometry to be removed from the scene
  109672. * @return a boolean defining if the geometry was removed or not
  109673. */
  109674. removeGeometry(geometry: Geometry): boolean;
  109675. /**
  109676. * Gets the list of geometries attached to the scene
  109677. * @returns an array of Geometry
  109678. */
  109679. getGeometries(): Geometry[];
  109680. /**
  109681. * Gets the first added mesh found of a given ID
  109682. * @param id defines the id to search for
  109683. * @return the mesh found or null if not found at all
  109684. */
  109685. getMeshByID(id: string): Nullable<AbstractMesh>;
  109686. /**
  109687. * Gets a list of meshes using their id
  109688. * @param id defines the id to search for
  109689. * @returns a list of meshes
  109690. */
  109691. getMeshesByID(id: string): Array<AbstractMesh>;
  109692. /**
  109693. * Gets the first added transform node found of a given ID
  109694. * @param id defines the id to search for
  109695. * @return the found transform node or null if not found at all.
  109696. */
  109697. getTransformNodeByID(id: string): Nullable<TransformNode>;
  109698. /**
  109699. * Gets a transform node with its auto-generated unique id
  109700. * @param uniqueId efines the unique id to search for
  109701. * @return the found transform node or null if not found at all.
  109702. */
  109703. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  109704. /**
  109705. * Gets a list of transform nodes using their id
  109706. * @param id defines the id to search for
  109707. * @returns a list of transform nodes
  109708. */
  109709. getTransformNodesByID(id: string): Array<TransformNode>;
  109710. /**
  109711. * Gets a mesh with its auto-generated unique id
  109712. * @param uniqueId defines the unique id to search for
  109713. * @return the found mesh or null if not found at all.
  109714. */
  109715. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  109716. /**
  109717. * Gets a the last added mesh using a given id
  109718. * @param id defines the id to search for
  109719. * @return the found mesh or null if not found at all.
  109720. */
  109721. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  109722. /**
  109723. * Gets a the last added node (Mesh, Camera, Light) using a given id
  109724. * @param id defines the id to search for
  109725. * @return the found node or null if not found at all
  109726. */
  109727. getLastEntryByID(id: string): Nullable<Node>;
  109728. /**
  109729. * Gets a node (Mesh, Camera, Light) using a given id
  109730. * @param id defines the id to search for
  109731. * @return the found node or null if not found at all
  109732. */
  109733. getNodeByID(id: string): Nullable<Node>;
  109734. /**
  109735. * Gets a node (Mesh, Camera, Light) using a given name
  109736. * @param name defines the name to search for
  109737. * @return the found node or null if not found at all.
  109738. */
  109739. getNodeByName(name: string): Nullable<Node>;
  109740. /**
  109741. * Gets a mesh using a given name
  109742. * @param name defines the name to search for
  109743. * @return the found mesh or null if not found at all.
  109744. */
  109745. getMeshByName(name: string): Nullable<AbstractMesh>;
  109746. /**
  109747. * Gets a transform node using a given name
  109748. * @param name defines the name to search for
  109749. * @return the found transform node or null if not found at all.
  109750. */
  109751. getTransformNodeByName(name: string): Nullable<TransformNode>;
  109752. /**
  109753. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  109754. * @param id defines the id to search for
  109755. * @return the found skeleton or null if not found at all.
  109756. */
  109757. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  109758. /**
  109759. * Gets a skeleton using a given auto generated unique id
  109760. * @param uniqueId defines the unique id to search for
  109761. * @return the found skeleton or null if not found at all.
  109762. */
  109763. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  109764. /**
  109765. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  109766. * @param id defines the id to search for
  109767. * @return the found skeleton or null if not found at all.
  109768. */
  109769. getSkeletonById(id: string): Nullable<Skeleton>;
  109770. /**
  109771. * Gets a skeleton using a given name
  109772. * @param name defines the name to search for
  109773. * @return the found skeleton or null if not found at all.
  109774. */
  109775. getSkeletonByName(name: string): Nullable<Skeleton>;
  109776. /**
  109777. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  109778. * @param id defines the id to search for
  109779. * @return the found morph target manager or null if not found at all.
  109780. */
  109781. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  109782. /**
  109783. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  109784. * @param id defines the id to search for
  109785. * @return the found morph target or null if not found at all.
  109786. */
  109787. getMorphTargetById(id: string): Nullable<MorphTarget>;
  109788. /**
  109789. * Gets a boolean indicating if the given mesh is active
  109790. * @param mesh defines the mesh to look for
  109791. * @returns true if the mesh is in the active list
  109792. */
  109793. isActiveMesh(mesh: AbstractMesh): boolean;
  109794. /**
  109795. * Return a unique id as a string which can serve as an identifier for the scene
  109796. */
  109797. get uid(): string;
  109798. /**
  109799. * Add an externaly attached data from its key.
  109800. * This method call will fail and return false, if such key already exists.
  109801. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  109802. * @param key the unique key that identifies the data
  109803. * @param data the data object to associate to the key for this Engine instance
  109804. * @return true if no such key were already present and the data was added successfully, false otherwise
  109805. */
  109806. addExternalData<T>(key: string, data: T): boolean;
  109807. /**
  109808. * Get an externaly attached data from its key
  109809. * @param key the unique key that identifies the data
  109810. * @return the associated data, if present (can be null), or undefined if not present
  109811. */
  109812. getExternalData<T>(key: string): Nullable<T>;
  109813. /**
  109814. * Get an externaly attached data from its key, create it using a factory if it's not already present
  109815. * @param key the unique key that identifies the data
  109816. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  109817. * @return the associated data, can be null if the factory returned null.
  109818. */
  109819. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  109820. /**
  109821. * Remove an externaly attached data from the Engine instance
  109822. * @param key the unique key that identifies the data
  109823. * @return true if the data was successfully removed, false if it doesn't exist
  109824. */
  109825. removeExternalData(key: string): boolean;
  109826. private _evaluateSubMesh;
  109827. /**
  109828. * Clear the processed materials smart array preventing retention point in material dispose.
  109829. */
  109830. freeProcessedMaterials(): void;
  109831. private _preventFreeActiveMeshesAndRenderingGroups;
  109832. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  109833. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  109834. * when disposing several meshes in a row or a hierarchy of meshes.
  109835. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  109836. */
  109837. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  109838. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  109839. /**
  109840. * Clear the active meshes smart array preventing retention point in mesh dispose.
  109841. */
  109842. freeActiveMeshes(): void;
  109843. /**
  109844. * Clear the info related to rendering groups preventing retention points during dispose.
  109845. */
  109846. freeRenderingGroups(): void;
  109847. /** @hidden */
  109848. _isInIntermediateRendering(): boolean;
  109849. /**
  109850. * Lambda returning the list of potentially active meshes.
  109851. */
  109852. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  109853. /**
  109854. * Lambda returning the list of potentially active sub meshes.
  109855. */
  109856. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  109857. /**
  109858. * Lambda returning the list of potentially intersecting sub meshes.
  109859. */
  109860. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  109861. /**
  109862. * Lambda returning the list of potentially colliding sub meshes.
  109863. */
  109864. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  109865. private _activeMeshesFrozen;
  109866. private _skipEvaluateActiveMeshesCompletely;
  109867. /**
  109868. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  109869. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  109870. * @returns the current scene
  109871. */
  109872. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  109873. /**
  109874. * Use this function to restart evaluating active meshes on every frame
  109875. * @returns the current scene
  109876. */
  109877. unfreezeActiveMeshes(): Scene;
  109878. private _evaluateActiveMeshes;
  109879. private _activeMesh;
  109880. /**
  109881. * Update the transform matrix to update from the current active camera
  109882. * @param force defines a boolean used to force the update even if cache is up to date
  109883. */
  109884. updateTransformMatrix(force?: boolean): void;
  109885. private _bindFrameBuffer;
  109886. /** @hidden */
  109887. _allowPostProcessClearColor: boolean;
  109888. /** @hidden */
  109889. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  109890. private _processSubCameras;
  109891. private _checkIntersections;
  109892. /** @hidden */
  109893. _advancePhysicsEngineStep(step: number): void;
  109894. /**
  109895. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  109896. */
  109897. getDeterministicFrameTime: () => number;
  109898. /** @hidden */
  109899. _animate(): void;
  109900. /** Execute all animations (for a frame) */
  109901. animate(): void;
  109902. /**
  109903. * Render the scene
  109904. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  109905. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  109906. */
  109907. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  109908. /**
  109909. * Freeze all materials
  109910. * A frozen material will not be updatable but should be faster to render
  109911. */
  109912. freezeMaterials(): void;
  109913. /**
  109914. * Unfreeze all materials
  109915. * A frozen material will not be updatable but should be faster to render
  109916. */
  109917. unfreezeMaterials(): void;
  109918. /**
  109919. * Releases all held ressources
  109920. */
  109921. dispose(): void;
  109922. /**
  109923. * Gets if the scene is already disposed
  109924. */
  109925. get isDisposed(): boolean;
  109926. /**
  109927. * Call this function to reduce memory footprint of the scene.
  109928. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  109929. */
  109930. clearCachedVertexData(): void;
  109931. /**
  109932. * This function will remove the local cached buffer data from texture.
  109933. * It will save memory but will prevent the texture from being rebuilt
  109934. */
  109935. cleanCachedTextureBuffer(): void;
  109936. /**
  109937. * Get the world extend vectors with an optional filter
  109938. *
  109939. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  109940. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  109941. */
  109942. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  109943. min: Vector3;
  109944. max: Vector3;
  109945. };
  109946. /**
  109947. * Creates a ray that can be used to pick in the scene
  109948. * @param x defines the x coordinate of the origin (on-screen)
  109949. * @param y defines the y coordinate of the origin (on-screen)
  109950. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  109951. * @param camera defines the camera to use for the picking
  109952. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  109953. * @returns a Ray
  109954. */
  109955. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  109956. /**
  109957. * Creates a ray that can be used to pick in the scene
  109958. * @param x defines the x coordinate of the origin (on-screen)
  109959. * @param y defines the y coordinate of the origin (on-screen)
  109960. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  109961. * @param result defines the ray where to store the picking ray
  109962. * @param camera defines the camera to use for the picking
  109963. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  109964. * @returns the current scene
  109965. */
  109966. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  109967. /**
  109968. * Creates a ray that can be used to pick in the scene
  109969. * @param x defines the x coordinate of the origin (on-screen)
  109970. * @param y defines the y coordinate of the origin (on-screen)
  109971. * @param camera defines the camera to use for the picking
  109972. * @returns a Ray
  109973. */
  109974. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  109975. /**
  109976. * Creates a ray that can be used to pick in the scene
  109977. * @param x defines the x coordinate of the origin (on-screen)
  109978. * @param y defines the y coordinate of the origin (on-screen)
  109979. * @param result defines the ray where to store the picking ray
  109980. * @param camera defines the camera to use for the picking
  109981. * @returns the current scene
  109982. */
  109983. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  109984. /** Launch a ray to try to pick a mesh in the scene
  109985. * @param x position on screen
  109986. * @param y position on screen
  109987. * @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
  109988. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  109989. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  109990. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109991. * @returns a PickingInfo
  109992. */
  109993. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  109994. /** Use the given ray to pick a mesh in the scene
  109995. * @param ray The ray to use to pick meshes
  109996. * @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
  109997. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  109998. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  109999. * @returns a PickingInfo
  110000. */
  110001. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110002. /**
  110003. * Launch a ray to try to pick a mesh in the scene
  110004. * @param x X position on screen
  110005. * @param y Y position on screen
  110006. * @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
  110007. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110008. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110009. * @returns an array of PickingInfo
  110010. */
  110011. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110012. /**
  110013. * Launch a ray to try to pick a mesh in the scene
  110014. * @param ray Ray to use
  110015. * @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
  110016. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110017. * @returns an array of PickingInfo
  110018. */
  110019. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110020. /**
  110021. * Force the value of meshUnderPointer
  110022. * @param mesh defines the mesh to use
  110023. */
  110024. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  110025. /**
  110026. * Gets the mesh under the pointer
  110027. * @returns a Mesh or null if no mesh is under the pointer
  110028. */
  110029. getPointerOverMesh(): Nullable<AbstractMesh>;
  110030. /** @hidden */
  110031. _rebuildGeometries(): void;
  110032. /** @hidden */
  110033. _rebuildTextures(): void;
  110034. private _getByTags;
  110035. /**
  110036. * Get a list of meshes by tags
  110037. * @param tagsQuery defines the tags query to use
  110038. * @param forEach defines a predicate used to filter results
  110039. * @returns an array of Mesh
  110040. */
  110041. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  110042. /**
  110043. * Get a list of cameras by tags
  110044. * @param tagsQuery defines the tags query to use
  110045. * @param forEach defines a predicate used to filter results
  110046. * @returns an array of Camera
  110047. */
  110048. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  110049. /**
  110050. * Get a list of lights by tags
  110051. * @param tagsQuery defines the tags query to use
  110052. * @param forEach defines a predicate used to filter results
  110053. * @returns an array of Light
  110054. */
  110055. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  110056. /**
  110057. * Get a list of materials by tags
  110058. * @param tagsQuery defines the tags query to use
  110059. * @param forEach defines a predicate used to filter results
  110060. * @returns an array of Material
  110061. */
  110062. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  110063. /**
  110064. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110065. * This allowed control for front to back rendering or reversly depending of the special needs.
  110066. *
  110067. * @param renderingGroupId The rendering group id corresponding to its index
  110068. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110069. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110070. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110071. */
  110072. 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;
  110073. /**
  110074. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110075. *
  110076. * @param renderingGroupId The rendering group id corresponding to its index
  110077. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110078. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110079. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110080. */
  110081. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110082. /**
  110083. * Gets the current auto clear configuration for one rendering group of the rendering
  110084. * manager.
  110085. * @param index the rendering group index to get the information for
  110086. * @returns The auto clear setup for the requested rendering group
  110087. */
  110088. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110089. private _blockMaterialDirtyMechanism;
  110090. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  110091. get blockMaterialDirtyMechanism(): boolean;
  110092. set blockMaterialDirtyMechanism(value: boolean);
  110093. /**
  110094. * Will flag all materials as dirty to trigger new shader compilation
  110095. * @param flag defines the flag used to specify which material part must be marked as dirty
  110096. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  110097. */
  110098. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  110099. /** @hidden */
  110100. _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;
  110101. /** @hidden */
  110102. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110103. /** @hidden */
  110104. _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;
  110105. /** @hidden */
  110106. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  110107. /** @hidden */
  110108. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110109. /** @hidden */
  110110. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110111. }
  110112. }
  110113. declare module BABYLON {
  110114. /**
  110115. * Set of assets to keep when moving a scene into an asset container.
  110116. */
  110117. export class KeepAssets extends AbstractScene {
  110118. }
  110119. /**
  110120. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  110121. */
  110122. export class InstantiatedEntries {
  110123. /**
  110124. * List of new root nodes (eg. nodes with no parent)
  110125. */
  110126. rootNodes: TransformNode[];
  110127. /**
  110128. * List of new skeletons
  110129. */
  110130. skeletons: Skeleton[];
  110131. /**
  110132. * List of new animation groups
  110133. */
  110134. animationGroups: AnimationGroup[];
  110135. }
  110136. /**
  110137. * Container with a set of assets that can be added or removed from a scene.
  110138. */
  110139. export class AssetContainer extends AbstractScene {
  110140. private _wasAddedToScene;
  110141. /**
  110142. * The scene the AssetContainer belongs to.
  110143. */
  110144. scene: Scene;
  110145. /**
  110146. * Instantiates an AssetContainer.
  110147. * @param scene The scene the AssetContainer belongs to.
  110148. */
  110149. constructor(scene: Scene);
  110150. /**
  110151. * Instantiate or clone all meshes and add the new ones to the scene.
  110152. * Skeletons and animation groups will all be cloned
  110153. * @param nameFunction defines an optional function used to get new names for clones
  110154. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  110155. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  110156. */
  110157. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  110158. /**
  110159. * Adds all the assets from the container to the scene.
  110160. */
  110161. addAllToScene(): void;
  110162. /**
  110163. * Removes all the assets in the container from the scene
  110164. */
  110165. removeAllFromScene(): void;
  110166. /**
  110167. * Disposes all the assets in the container
  110168. */
  110169. dispose(): void;
  110170. private _moveAssets;
  110171. /**
  110172. * Removes all the assets contained in the scene and adds them to the container.
  110173. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  110174. */
  110175. moveAllFromScene(keepAssets?: KeepAssets): void;
  110176. /**
  110177. * 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.
  110178. * @returns the root mesh
  110179. */
  110180. createRootMesh(): Mesh;
  110181. /**
  110182. * Merge animations from this asset container into a scene
  110183. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110184. * @param animatables set of animatables to retarget to a node from the scene
  110185. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  110186. */
  110187. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  110188. }
  110189. }
  110190. declare module BABYLON {
  110191. /**
  110192. * Defines how the parser contract is defined.
  110193. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  110194. */
  110195. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  110196. /**
  110197. * Defines how the individual parser contract is defined.
  110198. * These parser can parse an individual asset
  110199. */
  110200. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  110201. /**
  110202. * Base class of the scene acting as a container for the different elements composing a scene.
  110203. * This class is dynamically extended by the different components of the scene increasing
  110204. * flexibility and reducing coupling
  110205. */
  110206. export abstract class AbstractScene {
  110207. /**
  110208. * Stores the list of available parsers in the application.
  110209. */
  110210. private static _BabylonFileParsers;
  110211. /**
  110212. * Stores the list of available individual parsers in the application.
  110213. */
  110214. private static _IndividualBabylonFileParsers;
  110215. /**
  110216. * Adds a parser in the list of available ones
  110217. * @param name Defines the name of the parser
  110218. * @param parser Defines the parser to add
  110219. */
  110220. static AddParser(name: string, parser: BabylonFileParser): void;
  110221. /**
  110222. * Gets a general parser from the list of avaialble ones
  110223. * @param name Defines the name of the parser
  110224. * @returns the requested parser or null
  110225. */
  110226. static GetParser(name: string): Nullable<BabylonFileParser>;
  110227. /**
  110228. * Adds n individual parser in the list of available ones
  110229. * @param name Defines the name of the parser
  110230. * @param parser Defines the parser to add
  110231. */
  110232. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  110233. /**
  110234. * Gets an individual parser from the list of avaialble ones
  110235. * @param name Defines the name of the parser
  110236. * @returns the requested parser or null
  110237. */
  110238. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  110239. /**
  110240. * Parser json data and populate both a scene and its associated container object
  110241. * @param jsonData Defines the data to parse
  110242. * @param scene Defines the scene to parse the data for
  110243. * @param container Defines the container attached to the parsing sequence
  110244. * @param rootUrl Defines the root url of the data
  110245. */
  110246. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  110247. /**
  110248. * Gets the list of root nodes (ie. nodes with no parent)
  110249. */
  110250. rootNodes: Node[];
  110251. /** All of the cameras added to this scene
  110252. * @see http://doc.babylonjs.com/babylon101/cameras
  110253. */
  110254. cameras: Camera[];
  110255. /**
  110256. * All of the lights added to this scene
  110257. * @see http://doc.babylonjs.com/babylon101/lights
  110258. */
  110259. lights: Light[];
  110260. /**
  110261. * All of the (abstract) meshes added to this scene
  110262. */
  110263. meshes: AbstractMesh[];
  110264. /**
  110265. * The list of skeletons added to the scene
  110266. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110267. */
  110268. skeletons: Skeleton[];
  110269. /**
  110270. * All of the particle systems added to this scene
  110271. * @see http://doc.babylonjs.com/babylon101/particles
  110272. */
  110273. particleSystems: IParticleSystem[];
  110274. /**
  110275. * Gets a list of Animations associated with the scene
  110276. */
  110277. animations: Animation[];
  110278. /**
  110279. * All of the animation groups added to this scene
  110280. * @see http://doc.babylonjs.com/how_to/group
  110281. */
  110282. animationGroups: AnimationGroup[];
  110283. /**
  110284. * All of the multi-materials added to this scene
  110285. * @see http://doc.babylonjs.com/how_to/multi_materials
  110286. */
  110287. multiMaterials: MultiMaterial[];
  110288. /**
  110289. * All of the materials added to this scene
  110290. * In the context of a Scene, it is not supposed to be modified manually.
  110291. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  110292. * Note also that the order of the Material within the array is not significant and might change.
  110293. * @see http://doc.babylonjs.com/babylon101/materials
  110294. */
  110295. materials: Material[];
  110296. /**
  110297. * The list of morph target managers added to the scene
  110298. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110299. */
  110300. morphTargetManagers: MorphTargetManager[];
  110301. /**
  110302. * The list of geometries used in the scene.
  110303. */
  110304. geometries: Geometry[];
  110305. /**
  110306. * All of the tranform nodes added to this scene
  110307. * In the context of a Scene, it is not supposed to be modified manually.
  110308. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  110309. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  110310. * @see http://doc.babylonjs.com/how_to/transformnode
  110311. */
  110312. transformNodes: TransformNode[];
  110313. /**
  110314. * ActionManagers available on the scene.
  110315. */
  110316. actionManagers: AbstractActionManager[];
  110317. /**
  110318. * Textures to keep.
  110319. */
  110320. textures: BaseTexture[];
  110321. /**
  110322. * Environment texture for the scene
  110323. */
  110324. environmentTexture: Nullable<BaseTexture>;
  110325. /**
  110326. * @returns all meshes, lights, cameras, transformNodes and bones
  110327. */
  110328. getNodes(): Array<Node>;
  110329. }
  110330. }
  110331. declare module BABYLON {
  110332. /**
  110333. * Interface used to define options for Sound class
  110334. */
  110335. export interface ISoundOptions {
  110336. /**
  110337. * Does the sound autoplay once loaded.
  110338. */
  110339. autoplay?: boolean;
  110340. /**
  110341. * Does the sound loop after it finishes playing once.
  110342. */
  110343. loop?: boolean;
  110344. /**
  110345. * Sound's volume
  110346. */
  110347. volume?: number;
  110348. /**
  110349. * Is it a spatial sound?
  110350. */
  110351. spatialSound?: boolean;
  110352. /**
  110353. * Maximum distance to hear that sound
  110354. */
  110355. maxDistance?: number;
  110356. /**
  110357. * Uses user defined attenuation function
  110358. */
  110359. useCustomAttenuation?: boolean;
  110360. /**
  110361. * Define the roll off factor of spatial sounds.
  110362. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110363. */
  110364. rolloffFactor?: number;
  110365. /**
  110366. * Define the reference distance the sound should be heard perfectly.
  110367. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110368. */
  110369. refDistance?: number;
  110370. /**
  110371. * Define the distance attenuation model the sound will follow.
  110372. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110373. */
  110374. distanceModel?: string;
  110375. /**
  110376. * Defines the playback speed (1 by default)
  110377. */
  110378. playbackRate?: number;
  110379. /**
  110380. * Defines if the sound is from a streaming source
  110381. */
  110382. streaming?: boolean;
  110383. /**
  110384. * Defines an optional length (in seconds) inside the sound file
  110385. */
  110386. length?: number;
  110387. /**
  110388. * Defines an optional offset (in seconds) inside the sound file
  110389. */
  110390. offset?: number;
  110391. /**
  110392. * If true, URLs will not be required to state the audio file codec to use.
  110393. */
  110394. skipCodecCheck?: boolean;
  110395. }
  110396. /**
  110397. * Defines a sound that can be played in the application.
  110398. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  110399. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110400. */
  110401. export class Sound {
  110402. /**
  110403. * The name of the sound in the scene.
  110404. */
  110405. name: string;
  110406. /**
  110407. * Does the sound autoplay once loaded.
  110408. */
  110409. autoplay: boolean;
  110410. /**
  110411. * Does the sound loop after it finishes playing once.
  110412. */
  110413. loop: boolean;
  110414. /**
  110415. * Does the sound use a custom attenuation curve to simulate the falloff
  110416. * happening when the source gets further away from the camera.
  110417. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110418. */
  110419. useCustomAttenuation: boolean;
  110420. /**
  110421. * The sound track id this sound belongs to.
  110422. */
  110423. soundTrackId: number;
  110424. /**
  110425. * Is this sound currently played.
  110426. */
  110427. isPlaying: boolean;
  110428. /**
  110429. * Is this sound currently paused.
  110430. */
  110431. isPaused: boolean;
  110432. /**
  110433. * Does this sound enables spatial sound.
  110434. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110435. */
  110436. spatialSound: boolean;
  110437. /**
  110438. * Define the reference distance the sound should be heard perfectly.
  110439. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110440. */
  110441. refDistance: number;
  110442. /**
  110443. * Define the roll off factor of spatial sounds.
  110444. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110445. */
  110446. rolloffFactor: number;
  110447. /**
  110448. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  110449. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110450. */
  110451. maxDistance: number;
  110452. /**
  110453. * Define the distance attenuation model the sound will follow.
  110454. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110455. */
  110456. distanceModel: string;
  110457. /**
  110458. * @hidden
  110459. * Back Compat
  110460. **/
  110461. onended: () => any;
  110462. /**
  110463. * Observable event when the current playing sound finishes.
  110464. */
  110465. onEndedObservable: Observable<Sound>;
  110466. private _panningModel;
  110467. private _playbackRate;
  110468. private _streaming;
  110469. private _startTime;
  110470. private _startOffset;
  110471. private _position;
  110472. /** @hidden */
  110473. _positionInEmitterSpace: boolean;
  110474. private _localDirection;
  110475. private _volume;
  110476. private _isReadyToPlay;
  110477. private _isDirectional;
  110478. private _readyToPlayCallback;
  110479. private _audioBuffer;
  110480. private _soundSource;
  110481. private _streamingSource;
  110482. private _soundPanner;
  110483. private _soundGain;
  110484. private _inputAudioNode;
  110485. private _outputAudioNode;
  110486. private _coneInnerAngle;
  110487. private _coneOuterAngle;
  110488. private _coneOuterGain;
  110489. private _scene;
  110490. private _connectedTransformNode;
  110491. private _customAttenuationFunction;
  110492. private _registerFunc;
  110493. private _isOutputConnected;
  110494. private _htmlAudioElement;
  110495. private _urlType;
  110496. private _length?;
  110497. private _offset?;
  110498. /** @hidden */
  110499. static _SceneComponentInitialization: (scene: Scene) => void;
  110500. /**
  110501. * Create a sound and attach it to a scene
  110502. * @param name Name of your sound
  110503. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  110504. * @param scene defines the scene the sound belongs to
  110505. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  110506. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  110507. */
  110508. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  110509. /**
  110510. * Release the sound and its associated resources
  110511. */
  110512. dispose(): void;
  110513. /**
  110514. * Gets if the sounds is ready to be played or not.
  110515. * @returns true if ready, otherwise false
  110516. */
  110517. isReady(): boolean;
  110518. private _soundLoaded;
  110519. /**
  110520. * Sets the data of the sound from an audiobuffer
  110521. * @param audioBuffer The audioBuffer containing the data
  110522. */
  110523. setAudioBuffer(audioBuffer: AudioBuffer): void;
  110524. /**
  110525. * Updates the current sounds options such as maxdistance, loop...
  110526. * @param options A JSON object containing values named as the object properties
  110527. */
  110528. updateOptions(options: ISoundOptions): void;
  110529. private _createSpatialParameters;
  110530. private _updateSpatialParameters;
  110531. /**
  110532. * Switch the panning model to HRTF:
  110533. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110534. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110535. */
  110536. switchPanningModelToHRTF(): void;
  110537. /**
  110538. * Switch the panning model to Equal Power:
  110539. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110540. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110541. */
  110542. switchPanningModelToEqualPower(): void;
  110543. private _switchPanningModel;
  110544. /**
  110545. * Connect this sound to a sound track audio node like gain...
  110546. * @param soundTrackAudioNode the sound track audio node to connect to
  110547. */
  110548. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  110549. /**
  110550. * Transform this sound into a directional source
  110551. * @param coneInnerAngle Size of the inner cone in degree
  110552. * @param coneOuterAngle Size of the outer cone in degree
  110553. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  110554. */
  110555. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  110556. /**
  110557. * Gets or sets the inner angle for the directional cone.
  110558. */
  110559. get directionalConeInnerAngle(): number;
  110560. /**
  110561. * Gets or sets the inner angle for the directional cone.
  110562. */
  110563. set directionalConeInnerAngle(value: number);
  110564. /**
  110565. * Gets or sets the outer angle for the directional cone.
  110566. */
  110567. get directionalConeOuterAngle(): number;
  110568. /**
  110569. * Gets or sets the outer angle for the directional cone.
  110570. */
  110571. set directionalConeOuterAngle(value: number);
  110572. /**
  110573. * Sets the position of the emitter if spatial sound is enabled
  110574. * @param newPosition Defines the new posisiton
  110575. */
  110576. setPosition(newPosition: Vector3): void;
  110577. /**
  110578. * Sets the local direction of the emitter if spatial sound is enabled
  110579. * @param newLocalDirection Defines the new local direction
  110580. */
  110581. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  110582. private _updateDirection;
  110583. /** @hidden */
  110584. updateDistanceFromListener(): void;
  110585. /**
  110586. * Sets a new custom attenuation function for the sound.
  110587. * @param callback Defines the function used for the attenuation
  110588. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110589. */
  110590. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  110591. /**
  110592. * Play the sound
  110593. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  110594. * @param offset (optional) Start the sound at a specific time in seconds
  110595. * @param length (optional) Sound duration (in seconds)
  110596. */
  110597. play(time?: number, offset?: number, length?: number): void;
  110598. private _onended;
  110599. /**
  110600. * Stop the sound
  110601. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  110602. */
  110603. stop(time?: number): void;
  110604. /**
  110605. * Put the sound in pause
  110606. */
  110607. pause(): void;
  110608. /**
  110609. * Sets a dedicated volume for this sounds
  110610. * @param newVolume Define the new volume of the sound
  110611. * @param time Define time for gradual change to new volume
  110612. */
  110613. setVolume(newVolume: number, time?: number): void;
  110614. /**
  110615. * Set the sound play back rate
  110616. * @param newPlaybackRate Define the playback rate the sound should be played at
  110617. */
  110618. setPlaybackRate(newPlaybackRate: number): void;
  110619. /**
  110620. * Gets the volume of the sound.
  110621. * @returns the volume of the sound
  110622. */
  110623. getVolume(): number;
  110624. /**
  110625. * Attach the sound to a dedicated mesh
  110626. * @param transformNode The transform node to connect the sound with
  110627. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110628. */
  110629. attachToMesh(transformNode: TransformNode): void;
  110630. /**
  110631. * Detach the sound from the previously attached mesh
  110632. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110633. */
  110634. detachFromMesh(): void;
  110635. private _onRegisterAfterWorldMatrixUpdate;
  110636. /**
  110637. * Clone the current sound in the scene.
  110638. * @returns the new sound clone
  110639. */
  110640. clone(): Nullable<Sound>;
  110641. /**
  110642. * Gets the current underlying audio buffer containing the data
  110643. * @returns the audio buffer
  110644. */
  110645. getAudioBuffer(): Nullable<AudioBuffer>;
  110646. /**
  110647. * Serializes the Sound in a JSON representation
  110648. * @returns the JSON representation of the sound
  110649. */
  110650. serialize(): any;
  110651. /**
  110652. * Parse a JSON representation of a sound to innstantiate in a given scene
  110653. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  110654. * @param scene Define the scene the new parsed sound should be created in
  110655. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  110656. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  110657. * @returns the newly parsed sound
  110658. */
  110659. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  110660. }
  110661. }
  110662. declare module BABYLON {
  110663. /**
  110664. * This defines an action helpful to play a defined sound on a triggered action.
  110665. */
  110666. export class PlaySoundAction extends Action {
  110667. private _sound;
  110668. /**
  110669. * Instantiate the action
  110670. * @param triggerOptions defines the trigger options
  110671. * @param sound defines the sound to play
  110672. * @param condition defines the trigger related conditions
  110673. */
  110674. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110675. /** @hidden */
  110676. _prepare(): void;
  110677. /**
  110678. * Execute the action and play the sound.
  110679. */
  110680. execute(): void;
  110681. /**
  110682. * Serializes the actions and its related information.
  110683. * @param parent defines the object to serialize in
  110684. * @returns the serialized object
  110685. */
  110686. serialize(parent: any): any;
  110687. }
  110688. /**
  110689. * This defines an action helpful to stop a defined sound on a triggered action.
  110690. */
  110691. export class StopSoundAction extends Action {
  110692. private _sound;
  110693. /**
  110694. * Instantiate the action
  110695. * @param triggerOptions defines the trigger options
  110696. * @param sound defines the sound to stop
  110697. * @param condition defines the trigger related conditions
  110698. */
  110699. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110700. /** @hidden */
  110701. _prepare(): void;
  110702. /**
  110703. * Execute the action and stop the sound.
  110704. */
  110705. execute(): void;
  110706. /**
  110707. * Serializes the actions and its related information.
  110708. * @param parent defines the object to serialize in
  110709. * @returns the serialized object
  110710. */
  110711. serialize(parent: any): any;
  110712. }
  110713. }
  110714. declare module BABYLON {
  110715. /**
  110716. * This defines an action responsible to change the value of a property
  110717. * by interpolating between its current value and the newly set one once triggered.
  110718. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110719. */
  110720. export class InterpolateValueAction extends Action {
  110721. /**
  110722. * Defines the path of the property where the value should be interpolated
  110723. */
  110724. propertyPath: string;
  110725. /**
  110726. * Defines the target value at the end of the interpolation.
  110727. */
  110728. value: any;
  110729. /**
  110730. * Defines the time it will take for the property to interpolate to the value.
  110731. */
  110732. duration: number;
  110733. /**
  110734. * Defines if the other scene animations should be stopped when the action has been triggered
  110735. */
  110736. stopOtherAnimations?: boolean;
  110737. /**
  110738. * Defines a callback raised once the interpolation animation has been done.
  110739. */
  110740. onInterpolationDone?: () => void;
  110741. /**
  110742. * Observable triggered once the interpolation animation has been done.
  110743. */
  110744. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  110745. private _target;
  110746. private _effectiveTarget;
  110747. private _property;
  110748. /**
  110749. * Instantiate the action
  110750. * @param triggerOptions defines the trigger options
  110751. * @param target defines the object containing the value to interpolate
  110752. * @param propertyPath defines the path to the property in the target object
  110753. * @param value defines the target value at the end of the interpolation
  110754. * @param duration deines the time it will take for the property to interpolate to the value.
  110755. * @param condition defines the trigger related conditions
  110756. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  110757. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  110758. */
  110759. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  110760. /** @hidden */
  110761. _prepare(): void;
  110762. /**
  110763. * Execute the action starts the value interpolation.
  110764. */
  110765. execute(): void;
  110766. /**
  110767. * Serializes the actions and its related information.
  110768. * @param parent defines the object to serialize in
  110769. * @returns the serialized object
  110770. */
  110771. serialize(parent: any): any;
  110772. }
  110773. }
  110774. declare module BABYLON {
  110775. /**
  110776. * Options allowed during the creation of a sound track.
  110777. */
  110778. export interface ISoundTrackOptions {
  110779. /**
  110780. * The volume the sound track should take during creation
  110781. */
  110782. volume?: number;
  110783. /**
  110784. * Define if the sound track is the main sound track of the scene
  110785. */
  110786. mainTrack?: boolean;
  110787. }
  110788. /**
  110789. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  110790. * It will be also used in a future release to apply effects on a specific track.
  110791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110792. */
  110793. export class SoundTrack {
  110794. /**
  110795. * The unique identifier of the sound track in the scene.
  110796. */
  110797. id: number;
  110798. /**
  110799. * The list of sounds included in the sound track.
  110800. */
  110801. soundCollection: Array<Sound>;
  110802. private _outputAudioNode;
  110803. private _scene;
  110804. private _connectedAnalyser;
  110805. private _options;
  110806. private _isInitialized;
  110807. /**
  110808. * Creates a new sound track.
  110809. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110810. * @param scene Define the scene the sound track belongs to
  110811. * @param options
  110812. */
  110813. constructor(scene: Scene, options?: ISoundTrackOptions);
  110814. private _initializeSoundTrackAudioGraph;
  110815. /**
  110816. * Release the sound track and its associated resources
  110817. */
  110818. dispose(): void;
  110819. /**
  110820. * Adds a sound to this sound track
  110821. * @param sound define the cound to add
  110822. * @ignoreNaming
  110823. */
  110824. AddSound(sound: Sound): void;
  110825. /**
  110826. * Removes a sound to this sound track
  110827. * @param sound define the cound to remove
  110828. * @ignoreNaming
  110829. */
  110830. RemoveSound(sound: Sound): void;
  110831. /**
  110832. * Set a global volume for the full sound track.
  110833. * @param newVolume Define the new volume of the sound track
  110834. */
  110835. setVolume(newVolume: number): void;
  110836. /**
  110837. * Switch the panning model to HRTF:
  110838. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110839. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110840. */
  110841. switchPanningModelToHRTF(): void;
  110842. /**
  110843. * Switch the panning model to Equal Power:
  110844. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110845. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110846. */
  110847. switchPanningModelToEqualPower(): void;
  110848. /**
  110849. * Connect the sound track to an audio analyser allowing some amazing
  110850. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  110851. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  110852. * @param analyser The analyser to connect to the engine
  110853. */
  110854. connectToAnalyser(analyser: Analyser): void;
  110855. }
  110856. }
  110857. declare module BABYLON {
  110858. interface AbstractScene {
  110859. /**
  110860. * The list of sounds used in the scene.
  110861. */
  110862. sounds: Nullable<Array<Sound>>;
  110863. }
  110864. interface Scene {
  110865. /**
  110866. * @hidden
  110867. * Backing field
  110868. */
  110869. _mainSoundTrack: SoundTrack;
  110870. /**
  110871. * The main sound track played by the scene.
  110872. * It cotains your primary collection of sounds.
  110873. */
  110874. mainSoundTrack: SoundTrack;
  110875. /**
  110876. * The list of sound tracks added to the scene
  110877. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110878. */
  110879. soundTracks: Nullable<Array<SoundTrack>>;
  110880. /**
  110881. * Gets a sound using a given name
  110882. * @param name defines the name to search for
  110883. * @return the found sound or null if not found at all.
  110884. */
  110885. getSoundByName(name: string): Nullable<Sound>;
  110886. /**
  110887. * Gets or sets if audio support is enabled
  110888. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110889. */
  110890. audioEnabled: boolean;
  110891. /**
  110892. * Gets or sets if audio will be output to headphones
  110893. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110894. */
  110895. headphone: boolean;
  110896. /**
  110897. * Gets or sets custom audio listener position provider
  110898. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110899. */
  110900. audioListenerPositionProvider: Nullable<() => Vector3>;
  110901. /**
  110902. * Gets or sets a refresh rate when using 3D audio positioning
  110903. */
  110904. audioPositioningRefreshRate: number;
  110905. }
  110906. /**
  110907. * Defines the sound scene component responsible to manage any sounds
  110908. * in a given scene.
  110909. */
  110910. export class AudioSceneComponent implements ISceneSerializableComponent {
  110911. /**
  110912. * The component name helpfull to identify the component in the list of scene components.
  110913. */
  110914. readonly name: string;
  110915. /**
  110916. * The scene the component belongs to.
  110917. */
  110918. scene: Scene;
  110919. private _audioEnabled;
  110920. /**
  110921. * Gets whether audio is enabled or not.
  110922. * Please use related enable/disable method to switch state.
  110923. */
  110924. get audioEnabled(): boolean;
  110925. private _headphone;
  110926. /**
  110927. * Gets whether audio is outputing to headphone or not.
  110928. * Please use the according Switch methods to change output.
  110929. */
  110930. get headphone(): boolean;
  110931. /**
  110932. * Gets or sets a refresh rate when using 3D audio positioning
  110933. */
  110934. audioPositioningRefreshRate: number;
  110935. private _audioListenerPositionProvider;
  110936. /**
  110937. * Gets the current audio listener position provider
  110938. */
  110939. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  110940. /**
  110941. * Sets a custom listener position for all sounds in the scene
  110942. * By default, this is the position of the first active camera
  110943. */
  110944. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  110945. /**
  110946. * Creates a new instance of the component for the given scene
  110947. * @param scene Defines the scene to register the component in
  110948. */
  110949. constructor(scene: Scene);
  110950. /**
  110951. * Registers the component in a given scene
  110952. */
  110953. register(): void;
  110954. /**
  110955. * Rebuilds the elements related to this component in case of
  110956. * context lost for instance.
  110957. */
  110958. rebuild(): void;
  110959. /**
  110960. * Serializes the component data to the specified json object
  110961. * @param serializationObject The object to serialize to
  110962. */
  110963. serialize(serializationObject: any): void;
  110964. /**
  110965. * Adds all the elements from the container to the scene
  110966. * @param container the container holding the elements
  110967. */
  110968. addFromContainer(container: AbstractScene): void;
  110969. /**
  110970. * Removes all the elements in the container from the scene
  110971. * @param container contains the elements to remove
  110972. * @param dispose if the removed element should be disposed (default: false)
  110973. */
  110974. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110975. /**
  110976. * Disposes the component and the associated ressources.
  110977. */
  110978. dispose(): void;
  110979. /**
  110980. * Disables audio in the associated scene.
  110981. */
  110982. disableAudio(): void;
  110983. /**
  110984. * Enables audio in the associated scene.
  110985. */
  110986. enableAudio(): void;
  110987. /**
  110988. * Switch audio to headphone output.
  110989. */
  110990. switchAudioModeForHeadphones(): void;
  110991. /**
  110992. * Switch audio to normal speakers.
  110993. */
  110994. switchAudioModeForNormalSpeakers(): void;
  110995. private _cachedCameraDirection;
  110996. private _cachedCameraPosition;
  110997. private _lastCheck;
  110998. private _afterRender;
  110999. }
  111000. }
  111001. declare module BABYLON {
  111002. /**
  111003. * Wraps one or more Sound objects and selects one with random weight for playback.
  111004. */
  111005. export class WeightedSound {
  111006. /** When true a Sound will be selected and played when the current playing Sound completes. */
  111007. loop: boolean;
  111008. private _coneInnerAngle;
  111009. private _coneOuterAngle;
  111010. private _volume;
  111011. /** A Sound is currently playing. */
  111012. isPlaying: boolean;
  111013. /** A Sound is currently paused. */
  111014. isPaused: boolean;
  111015. private _sounds;
  111016. private _weights;
  111017. private _currentIndex?;
  111018. /**
  111019. * Creates a new WeightedSound from the list of sounds given.
  111020. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  111021. * @param sounds Array of Sounds that will be selected from.
  111022. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  111023. */
  111024. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  111025. /**
  111026. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  111027. */
  111028. get directionalConeInnerAngle(): number;
  111029. /**
  111030. * The size of cone in degress for a directional sound in which there will be no attenuation.
  111031. */
  111032. set directionalConeInnerAngle(value: number);
  111033. /**
  111034. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111035. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111036. */
  111037. get directionalConeOuterAngle(): number;
  111038. /**
  111039. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111040. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111041. */
  111042. set directionalConeOuterAngle(value: number);
  111043. /**
  111044. * Playback volume.
  111045. */
  111046. get volume(): number;
  111047. /**
  111048. * Playback volume.
  111049. */
  111050. set volume(value: number);
  111051. private _onended;
  111052. /**
  111053. * Suspend playback
  111054. */
  111055. pause(): void;
  111056. /**
  111057. * Stop playback
  111058. */
  111059. stop(): void;
  111060. /**
  111061. * Start playback.
  111062. * @param startOffset Position the clip head at a specific time in seconds.
  111063. */
  111064. play(startOffset?: number): void;
  111065. }
  111066. }
  111067. declare module BABYLON {
  111068. /**
  111069. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  111070. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111071. */
  111072. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  111073. /**
  111074. * Gets the name of the behavior.
  111075. */
  111076. get name(): string;
  111077. /**
  111078. * The easing function used by animations
  111079. */
  111080. static EasingFunction: BackEase;
  111081. /**
  111082. * The easing mode used by animations
  111083. */
  111084. static EasingMode: number;
  111085. /**
  111086. * The duration of the animation, in milliseconds
  111087. */
  111088. transitionDuration: number;
  111089. /**
  111090. * Length of the distance animated by the transition when lower radius is reached
  111091. */
  111092. lowerRadiusTransitionRange: number;
  111093. /**
  111094. * Length of the distance animated by the transition when upper radius is reached
  111095. */
  111096. upperRadiusTransitionRange: number;
  111097. private _autoTransitionRange;
  111098. /**
  111099. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111100. */
  111101. get autoTransitionRange(): boolean;
  111102. /**
  111103. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111104. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  111105. */
  111106. set autoTransitionRange(value: boolean);
  111107. private _attachedCamera;
  111108. private _onAfterCheckInputsObserver;
  111109. private _onMeshTargetChangedObserver;
  111110. /**
  111111. * Initializes the behavior.
  111112. */
  111113. init(): void;
  111114. /**
  111115. * Attaches the behavior to its arc rotate camera.
  111116. * @param camera Defines the camera to attach the behavior to
  111117. */
  111118. attach(camera: ArcRotateCamera): void;
  111119. /**
  111120. * Detaches the behavior from its current arc rotate camera.
  111121. */
  111122. detach(): void;
  111123. private _radiusIsAnimating;
  111124. private _radiusBounceTransition;
  111125. private _animatables;
  111126. private _cachedWheelPrecision;
  111127. /**
  111128. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  111129. * @param radiusLimit The limit to check against.
  111130. * @return Bool to indicate if at limit.
  111131. */
  111132. private _isRadiusAtLimit;
  111133. /**
  111134. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  111135. * @param radiusDelta The delta by which to animate to. Can be negative.
  111136. */
  111137. private _applyBoundRadiusAnimation;
  111138. /**
  111139. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  111140. */
  111141. protected _clearAnimationLocks(): void;
  111142. /**
  111143. * Stops and removes all animations that have been applied to the camera
  111144. */
  111145. stopAllAnimations(): void;
  111146. }
  111147. }
  111148. declare module BABYLON {
  111149. /**
  111150. * 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.
  111151. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111152. */
  111153. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  111154. /**
  111155. * Gets the name of the behavior.
  111156. */
  111157. get name(): string;
  111158. private _mode;
  111159. private _radiusScale;
  111160. private _positionScale;
  111161. private _defaultElevation;
  111162. private _elevationReturnTime;
  111163. private _elevationReturnWaitTime;
  111164. private _zoomStopsAnimation;
  111165. private _framingTime;
  111166. /**
  111167. * The easing function used by animations
  111168. */
  111169. static EasingFunction: ExponentialEase;
  111170. /**
  111171. * The easing mode used by animations
  111172. */
  111173. static EasingMode: number;
  111174. /**
  111175. * Sets the current mode used by the behavior
  111176. */
  111177. set mode(mode: number);
  111178. /**
  111179. * Gets current mode used by the behavior.
  111180. */
  111181. get mode(): number;
  111182. /**
  111183. * Sets the scale applied to the radius (1 by default)
  111184. */
  111185. set radiusScale(radius: number);
  111186. /**
  111187. * Gets the scale applied to the radius
  111188. */
  111189. get radiusScale(): number;
  111190. /**
  111191. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111192. */
  111193. set positionScale(scale: number);
  111194. /**
  111195. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111196. */
  111197. get positionScale(): number;
  111198. /**
  111199. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111200. * behaviour is triggered, in radians.
  111201. */
  111202. set defaultElevation(elevation: number);
  111203. /**
  111204. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111205. * behaviour is triggered, in radians.
  111206. */
  111207. get defaultElevation(): number;
  111208. /**
  111209. * Sets the time (in milliseconds) taken to return to the default beta position.
  111210. * Negative value indicates camera should not return to default.
  111211. */
  111212. set elevationReturnTime(speed: number);
  111213. /**
  111214. * Gets the time (in milliseconds) taken to return to the default beta position.
  111215. * Negative value indicates camera should not return to default.
  111216. */
  111217. get elevationReturnTime(): number;
  111218. /**
  111219. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111220. */
  111221. set elevationReturnWaitTime(time: number);
  111222. /**
  111223. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111224. */
  111225. get elevationReturnWaitTime(): number;
  111226. /**
  111227. * Sets the flag that indicates if user zooming should stop animation.
  111228. */
  111229. set zoomStopsAnimation(flag: boolean);
  111230. /**
  111231. * Gets the flag that indicates if user zooming should stop animation.
  111232. */
  111233. get zoomStopsAnimation(): boolean;
  111234. /**
  111235. * Sets the transition time when framing the mesh, in milliseconds
  111236. */
  111237. set framingTime(time: number);
  111238. /**
  111239. * Gets the transition time when framing the mesh, in milliseconds
  111240. */
  111241. get framingTime(): number;
  111242. /**
  111243. * Define if the behavior should automatically change the configured
  111244. * camera limits and sensibilities.
  111245. */
  111246. autoCorrectCameraLimitsAndSensibility: boolean;
  111247. private _onPrePointerObservableObserver;
  111248. private _onAfterCheckInputsObserver;
  111249. private _onMeshTargetChangedObserver;
  111250. private _attachedCamera;
  111251. private _isPointerDown;
  111252. private _lastInteractionTime;
  111253. /**
  111254. * Initializes the behavior.
  111255. */
  111256. init(): void;
  111257. /**
  111258. * Attaches the behavior to its arc rotate camera.
  111259. * @param camera Defines the camera to attach the behavior to
  111260. */
  111261. attach(camera: ArcRotateCamera): void;
  111262. /**
  111263. * Detaches the behavior from its current arc rotate camera.
  111264. */
  111265. detach(): void;
  111266. private _animatables;
  111267. private _betaIsAnimating;
  111268. private _betaTransition;
  111269. private _radiusTransition;
  111270. private _vectorTransition;
  111271. /**
  111272. * Targets the given mesh and updates zoom level accordingly.
  111273. * @param mesh The mesh to target.
  111274. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111275. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111276. */
  111277. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111278. /**
  111279. * Targets the given mesh with its children and updates zoom level accordingly.
  111280. * @param mesh The mesh to target.
  111281. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111282. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111283. */
  111284. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111285. /**
  111286. * Targets the given meshes with their children and updates zoom level accordingly.
  111287. * @param meshes The mesh to target.
  111288. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111289. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111290. */
  111291. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111292. /**
  111293. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  111294. * @param minimumWorld Determines the smaller position of the bounding box extend
  111295. * @param maximumWorld Determines the bigger position of the bounding box extend
  111296. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111297. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111298. */
  111299. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111300. /**
  111301. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  111302. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  111303. * frustum width.
  111304. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  111305. * to fully enclose the mesh in the viewing frustum.
  111306. */
  111307. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  111308. /**
  111309. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  111310. * is automatically returned to its default position (expected to be above ground plane).
  111311. */
  111312. private _maintainCameraAboveGround;
  111313. /**
  111314. * Returns the frustum slope based on the canvas ratio and camera FOV
  111315. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  111316. */
  111317. private _getFrustumSlope;
  111318. /**
  111319. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  111320. */
  111321. private _clearAnimationLocks;
  111322. /**
  111323. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111324. */
  111325. private _applyUserInteraction;
  111326. /**
  111327. * Stops and removes all animations that have been applied to the camera
  111328. */
  111329. stopAllAnimations(): void;
  111330. /**
  111331. * Gets a value indicating if the user is moving the camera
  111332. */
  111333. get isUserIsMoving(): boolean;
  111334. /**
  111335. * The camera can move all the way towards the mesh.
  111336. */
  111337. static IgnoreBoundsSizeMode: number;
  111338. /**
  111339. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  111340. */
  111341. static FitFrustumSidesMode: number;
  111342. }
  111343. }
  111344. declare module BABYLON {
  111345. /**
  111346. * Base class for Camera Pointer Inputs.
  111347. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  111348. * for example usage.
  111349. */
  111350. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  111351. /**
  111352. * Defines the camera the input is attached to.
  111353. */
  111354. abstract camera: Camera;
  111355. /**
  111356. * Whether keyboard modifier keys are pressed at time of last mouse event.
  111357. */
  111358. protected _altKey: boolean;
  111359. protected _ctrlKey: boolean;
  111360. protected _metaKey: boolean;
  111361. protected _shiftKey: boolean;
  111362. /**
  111363. * Which mouse buttons were pressed at time of last mouse event.
  111364. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  111365. */
  111366. protected _buttonsPressed: number;
  111367. /**
  111368. * Defines the buttons associated with the input to handle camera move.
  111369. */
  111370. buttons: number[];
  111371. /**
  111372. * Attach the input controls to a specific dom element to get the input from.
  111373. * @param element Defines the element the controls should be listened from
  111374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111375. */
  111376. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111377. /**
  111378. * Detach the current controls from the specified dom element.
  111379. * @param element Defines the element to stop listening the inputs from
  111380. */
  111381. detachControl(element: Nullable<HTMLElement>): void;
  111382. /**
  111383. * Gets the class name of the current input.
  111384. * @returns the class name
  111385. */
  111386. getClassName(): string;
  111387. /**
  111388. * Get the friendly name associated with the input class.
  111389. * @returns the input friendly name
  111390. */
  111391. getSimpleName(): string;
  111392. /**
  111393. * Called on pointer POINTERDOUBLETAP event.
  111394. * Override this method to provide functionality on POINTERDOUBLETAP event.
  111395. */
  111396. protected onDoubleTap(type: string): void;
  111397. /**
  111398. * Called on pointer POINTERMOVE event if only a single touch is active.
  111399. * Override this method to provide functionality.
  111400. */
  111401. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111402. /**
  111403. * Called on pointer POINTERMOVE event if multiple touches are active.
  111404. * Override this method to provide functionality.
  111405. */
  111406. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111407. /**
  111408. * Called on JS contextmenu event.
  111409. * Override this method to provide functionality.
  111410. */
  111411. protected onContextMenu(evt: PointerEvent): void;
  111412. /**
  111413. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111414. * press.
  111415. * Override this method to provide functionality.
  111416. */
  111417. protected onButtonDown(evt: PointerEvent): void;
  111418. /**
  111419. * Called each time a new POINTERUP event occurs. Ie, for each button
  111420. * release.
  111421. * Override this method to provide functionality.
  111422. */
  111423. protected onButtonUp(evt: PointerEvent): void;
  111424. /**
  111425. * Called when window becomes inactive.
  111426. * Override this method to provide functionality.
  111427. */
  111428. protected onLostFocus(): void;
  111429. private _pointerInput;
  111430. private _observer;
  111431. private _onLostFocus;
  111432. private pointA;
  111433. private pointB;
  111434. }
  111435. }
  111436. declare module BABYLON {
  111437. /**
  111438. * Manage the pointers inputs to control an arc rotate camera.
  111439. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111440. */
  111441. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  111442. /**
  111443. * Defines the camera the input is attached to.
  111444. */
  111445. camera: ArcRotateCamera;
  111446. /**
  111447. * Gets the class name of the current input.
  111448. * @returns the class name
  111449. */
  111450. getClassName(): string;
  111451. /**
  111452. * Defines the buttons associated with the input to handle camera move.
  111453. */
  111454. buttons: number[];
  111455. /**
  111456. * Defines the pointer angular sensibility along the X axis or how fast is
  111457. * the camera rotating.
  111458. */
  111459. angularSensibilityX: number;
  111460. /**
  111461. * Defines the pointer angular sensibility along the Y axis or how fast is
  111462. * the camera rotating.
  111463. */
  111464. angularSensibilityY: number;
  111465. /**
  111466. * Defines the pointer pinch precision or how fast is the camera zooming.
  111467. */
  111468. pinchPrecision: number;
  111469. /**
  111470. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  111471. * from 0.
  111472. * It defines the percentage of current camera.radius to use as delta when
  111473. * pinch zoom is used.
  111474. */
  111475. pinchDeltaPercentage: number;
  111476. /**
  111477. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111478. * that any object in the plane at the camera's target point will scale
  111479. * perfectly with finger motion.
  111480. * Overrides pinchDeltaPercentage and pinchPrecision.
  111481. */
  111482. useNaturalPinchZoom: boolean;
  111483. /**
  111484. * Defines the pointer panning sensibility or how fast is the camera moving.
  111485. */
  111486. panningSensibility: number;
  111487. /**
  111488. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  111489. */
  111490. multiTouchPanning: boolean;
  111491. /**
  111492. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  111493. * zoom (pinch) through multitouch.
  111494. */
  111495. multiTouchPanAndZoom: boolean;
  111496. /**
  111497. * Revers pinch action direction.
  111498. */
  111499. pinchInwards: boolean;
  111500. private _isPanClick;
  111501. private _twoFingerActivityCount;
  111502. private _isPinching;
  111503. /**
  111504. * Called on pointer POINTERMOVE event if only a single touch is active.
  111505. */
  111506. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111507. /**
  111508. * Called on pointer POINTERDOUBLETAP event.
  111509. */
  111510. protected onDoubleTap(type: string): void;
  111511. /**
  111512. * Called on pointer POINTERMOVE event if multiple touches are active.
  111513. */
  111514. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111515. /**
  111516. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111517. * press.
  111518. */
  111519. protected onButtonDown(evt: PointerEvent): void;
  111520. /**
  111521. * Called each time a new POINTERUP event occurs. Ie, for each button
  111522. * release.
  111523. */
  111524. protected onButtonUp(evt: PointerEvent): void;
  111525. /**
  111526. * Called when window becomes inactive.
  111527. */
  111528. protected onLostFocus(): void;
  111529. }
  111530. }
  111531. declare module BABYLON {
  111532. /**
  111533. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  111534. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111535. */
  111536. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  111537. /**
  111538. * Defines the camera the input is attached to.
  111539. */
  111540. camera: ArcRotateCamera;
  111541. /**
  111542. * Defines the list of key codes associated with the up action (increase alpha)
  111543. */
  111544. keysUp: number[];
  111545. /**
  111546. * Defines the list of key codes associated with the down action (decrease alpha)
  111547. */
  111548. keysDown: number[];
  111549. /**
  111550. * Defines the list of key codes associated with the left action (increase beta)
  111551. */
  111552. keysLeft: number[];
  111553. /**
  111554. * Defines the list of key codes associated with the right action (decrease beta)
  111555. */
  111556. keysRight: number[];
  111557. /**
  111558. * Defines the list of key codes associated with the reset action.
  111559. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  111560. */
  111561. keysReset: number[];
  111562. /**
  111563. * Defines the panning sensibility of the inputs.
  111564. * (How fast is the camera panning)
  111565. */
  111566. panningSensibility: number;
  111567. /**
  111568. * Defines the zooming sensibility of the inputs.
  111569. * (How fast is the camera zooming)
  111570. */
  111571. zoomingSensibility: number;
  111572. /**
  111573. * Defines whether maintaining the alt key down switch the movement mode from
  111574. * orientation to zoom.
  111575. */
  111576. useAltToZoom: boolean;
  111577. /**
  111578. * Rotation speed of the camera
  111579. */
  111580. angularSpeed: number;
  111581. private _keys;
  111582. private _ctrlPressed;
  111583. private _altPressed;
  111584. private _onCanvasBlurObserver;
  111585. private _onKeyboardObserver;
  111586. private _engine;
  111587. private _scene;
  111588. /**
  111589. * Attach the input controls to a specific dom element to get the input from.
  111590. * @param element Defines the element the controls should be listened from
  111591. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111592. */
  111593. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111594. /**
  111595. * Detach the current controls from the specified dom element.
  111596. * @param element Defines the element to stop listening the inputs from
  111597. */
  111598. detachControl(element: Nullable<HTMLElement>): void;
  111599. /**
  111600. * Update the current camera state depending on the inputs that have been used this frame.
  111601. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111602. */
  111603. checkInputs(): void;
  111604. /**
  111605. * Gets the class name of the current intput.
  111606. * @returns the class name
  111607. */
  111608. getClassName(): string;
  111609. /**
  111610. * Get the friendly name associated with the input class.
  111611. * @returns the input friendly name
  111612. */
  111613. getSimpleName(): string;
  111614. }
  111615. }
  111616. declare module BABYLON {
  111617. /**
  111618. * Manage the mouse wheel inputs to control an arc rotate camera.
  111619. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111620. */
  111621. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  111622. /**
  111623. * Defines the camera the input is attached to.
  111624. */
  111625. camera: ArcRotateCamera;
  111626. /**
  111627. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111628. */
  111629. wheelPrecision: number;
  111630. /**
  111631. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  111632. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  111633. */
  111634. wheelDeltaPercentage: number;
  111635. private _wheel;
  111636. private _observer;
  111637. private computeDeltaFromMouseWheelLegacyEvent;
  111638. /**
  111639. * Attach the input controls to a specific dom element to get the input from.
  111640. * @param element Defines the element the controls should be listened from
  111641. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111642. */
  111643. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111644. /**
  111645. * Detach the current controls from the specified dom element.
  111646. * @param element Defines the element to stop listening the inputs from
  111647. */
  111648. detachControl(element: Nullable<HTMLElement>): void;
  111649. /**
  111650. * Gets the class name of the current intput.
  111651. * @returns the class name
  111652. */
  111653. getClassName(): string;
  111654. /**
  111655. * Get the friendly name associated with the input class.
  111656. * @returns the input friendly name
  111657. */
  111658. getSimpleName(): string;
  111659. }
  111660. }
  111661. declare module BABYLON {
  111662. /**
  111663. * Default Inputs manager for the ArcRotateCamera.
  111664. * It groups all the default supported inputs for ease of use.
  111665. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111666. */
  111667. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  111668. /**
  111669. * Instantiates a new ArcRotateCameraInputsManager.
  111670. * @param camera Defines the camera the inputs belong to
  111671. */
  111672. constructor(camera: ArcRotateCamera);
  111673. /**
  111674. * Add mouse wheel input support to the input manager.
  111675. * @returns the current input manager
  111676. */
  111677. addMouseWheel(): ArcRotateCameraInputsManager;
  111678. /**
  111679. * Add pointers input support to the input manager.
  111680. * @returns the current input manager
  111681. */
  111682. addPointers(): ArcRotateCameraInputsManager;
  111683. /**
  111684. * Add keyboard input support to the input manager.
  111685. * @returns the current input manager
  111686. */
  111687. addKeyboard(): ArcRotateCameraInputsManager;
  111688. }
  111689. }
  111690. declare module BABYLON {
  111691. /**
  111692. * This represents an orbital type of camera.
  111693. *
  111694. * 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.
  111695. * 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.
  111696. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  111697. */
  111698. export class ArcRotateCamera extends TargetCamera {
  111699. /**
  111700. * Defines the rotation angle of the camera along the longitudinal axis.
  111701. */
  111702. alpha: number;
  111703. /**
  111704. * Defines the rotation angle of the camera along the latitudinal axis.
  111705. */
  111706. beta: number;
  111707. /**
  111708. * Defines the radius of the camera from it s target point.
  111709. */
  111710. radius: number;
  111711. protected _target: Vector3;
  111712. protected _targetHost: Nullable<AbstractMesh>;
  111713. /**
  111714. * Defines the target point of the camera.
  111715. * The camera looks towards it form the radius distance.
  111716. */
  111717. get target(): Vector3;
  111718. set target(value: Vector3);
  111719. /**
  111720. * Define the current local position of the camera in the scene
  111721. */
  111722. get position(): Vector3;
  111723. set position(newPosition: Vector3);
  111724. protected _upVector: Vector3;
  111725. protected _upToYMatrix: Matrix;
  111726. protected _YToUpMatrix: Matrix;
  111727. /**
  111728. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  111729. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  111730. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  111731. */
  111732. set upVector(vec: Vector3);
  111733. get upVector(): Vector3;
  111734. /**
  111735. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  111736. */
  111737. setMatUp(): void;
  111738. /**
  111739. * Current inertia value on the longitudinal axis.
  111740. * The bigger this number the longer it will take for the camera to stop.
  111741. */
  111742. inertialAlphaOffset: number;
  111743. /**
  111744. * Current inertia value on the latitudinal axis.
  111745. * The bigger this number the longer it will take for the camera to stop.
  111746. */
  111747. inertialBetaOffset: number;
  111748. /**
  111749. * Current inertia value on the radius axis.
  111750. * The bigger this number the longer it will take for the camera to stop.
  111751. */
  111752. inertialRadiusOffset: number;
  111753. /**
  111754. * Minimum allowed angle on the longitudinal axis.
  111755. * This can help limiting how the Camera is able to move in the scene.
  111756. */
  111757. lowerAlphaLimit: Nullable<number>;
  111758. /**
  111759. * Maximum allowed angle on the longitudinal axis.
  111760. * This can help limiting how the Camera is able to move in the scene.
  111761. */
  111762. upperAlphaLimit: Nullable<number>;
  111763. /**
  111764. * Minimum allowed angle on the latitudinal axis.
  111765. * This can help limiting how the Camera is able to move in the scene.
  111766. */
  111767. lowerBetaLimit: number;
  111768. /**
  111769. * Maximum allowed angle on the latitudinal axis.
  111770. * This can help limiting how the Camera is able to move in the scene.
  111771. */
  111772. upperBetaLimit: number;
  111773. /**
  111774. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  111775. * This can help limiting how the Camera is able to move in the scene.
  111776. */
  111777. lowerRadiusLimit: Nullable<number>;
  111778. /**
  111779. * Maximum allowed distance of the camera to the target (The camera can not get further).
  111780. * This can help limiting how the Camera is able to move in the scene.
  111781. */
  111782. upperRadiusLimit: Nullable<number>;
  111783. /**
  111784. * Defines the current inertia value used during panning of the camera along the X axis.
  111785. */
  111786. inertialPanningX: number;
  111787. /**
  111788. * Defines the current inertia value used during panning of the camera along the Y axis.
  111789. */
  111790. inertialPanningY: number;
  111791. /**
  111792. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  111793. * Basically if your fingers moves away from more than this distance you will be considered
  111794. * in pinch mode.
  111795. */
  111796. pinchToPanMaxDistance: number;
  111797. /**
  111798. * Defines the maximum distance the camera can pan.
  111799. * This could help keeping the cammera always in your scene.
  111800. */
  111801. panningDistanceLimit: Nullable<number>;
  111802. /**
  111803. * Defines the target of the camera before paning.
  111804. */
  111805. panningOriginTarget: Vector3;
  111806. /**
  111807. * Defines the value of the inertia used during panning.
  111808. * 0 would mean stop inertia and one would mean no decelleration at all.
  111809. */
  111810. panningInertia: number;
  111811. /**
  111812. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  111813. */
  111814. get angularSensibilityX(): number;
  111815. set angularSensibilityX(value: number);
  111816. /**
  111817. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  111818. */
  111819. get angularSensibilityY(): number;
  111820. set angularSensibilityY(value: number);
  111821. /**
  111822. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  111823. */
  111824. get pinchPrecision(): number;
  111825. set pinchPrecision(value: number);
  111826. /**
  111827. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  111828. * It will be used instead of pinchDeltaPrecision if different from 0.
  111829. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111830. */
  111831. get pinchDeltaPercentage(): number;
  111832. set pinchDeltaPercentage(value: number);
  111833. /**
  111834. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  111835. * and pinch delta percentage.
  111836. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111837. * that any object in the plane at the camera's target point will scale
  111838. * perfectly with finger motion.
  111839. */
  111840. get useNaturalPinchZoom(): boolean;
  111841. set useNaturalPinchZoom(value: boolean);
  111842. /**
  111843. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  111844. */
  111845. get panningSensibility(): number;
  111846. set panningSensibility(value: number);
  111847. /**
  111848. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  111849. */
  111850. get keysUp(): number[];
  111851. set keysUp(value: number[]);
  111852. /**
  111853. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  111854. */
  111855. get keysDown(): number[];
  111856. set keysDown(value: number[]);
  111857. /**
  111858. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  111859. */
  111860. get keysLeft(): number[];
  111861. set keysLeft(value: number[]);
  111862. /**
  111863. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  111864. */
  111865. get keysRight(): number[];
  111866. set keysRight(value: number[]);
  111867. /**
  111868. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111869. */
  111870. get wheelPrecision(): number;
  111871. set wheelPrecision(value: number);
  111872. /**
  111873. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  111874. * It will be used instead of pinchDeltaPrecision if different from 0.
  111875. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111876. */
  111877. get wheelDeltaPercentage(): number;
  111878. set wheelDeltaPercentage(value: number);
  111879. /**
  111880. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  111881. */
  111882. zoomOnFactor: number;
  111883. /**
  111884. * Defines a screen offset for the camera position.
  111885. */
  111886. targetScreenOffset: Vector2;
  111887. /**
  111888. * Allows the camera to be completely reversed.
  111889. * If false the camera can not arrive upside down.
  111890. */
  111891. allowUpsideDown: boolean;
  111892. /**
  111893. * Define if double tap/click is used to restore the previously saved state of the camera.
  111894. */
  111895. useInputToRestoreState: boolean;
  111896. /** @hidden */
  111897. _viewMatrix: Matrix;
  111898. /** @hidden */
  111899. _useCtrlForPanning: boolean;
  111900. /** @hidden */
  111901. _panningMouseButton: number;
  111902. /**
  111903. * Defines the input associated to the camera.
  111904. */
  111905. inputs: ArcRotateCameraInputsManager;
  111906. /** @hidden */
  111907. _reset: () => void;
  111908. /**
  111909. * Defines the allowed panning axis.
  111910. */
  111911. panningAxis: Vector3;
  111912. protected _localDirection: Vector3;
  111913. protected _transformedDirection: Vector3;
  111914. private _bouncingBehavior;
  111915. /**
  111916. * Gets the bouncing behavior of the camera if it has been enabled.
  111917. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111918. */
  111919. get bouncingBehavior(): Nullable<BouncingBehavior>;
  111920. /**
  111921. * Defines if the bouncing behavior of the camera is enabled on the camera.
  111922. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111923. */
  111924. get useBouncingBehavior(): boolean;
  111925. set useBouncingBehavior(value: boolean);
  111926. private _framingBehavior;
  111927. /**
  111928. * Gets the framing behavior of the camera if it has been enabled.
  111929. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111930. */
  111931. get framingBehavior(): Nullable<FramingBehavior>;
  111932. /**
  111933. * Defines if the framing behavior of the camera is enabled on the camera.
  111934. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111935. */
  111936. get useFramingBehavior(): boolean;
  111937. set useFramingBehavior(value: boolean);
  111938. private _autoRotationBehavior;
  111939. /**
  111940. * Gets the auto rotation behavior of the camera if it has been enabled.
  111941. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111942. */
  111943. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  111944. /**
  111945. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  111946. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  111947. */
  111948. get useAutoRotationBehavior(): boolean;
  111949. set useAutoRotationBehavior(value: boolean);
  111950. /**
  111951. * Observable triggered when the mesh target has been changed on the camera.
  111952. */
  111953. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  111954. /**
  111955. * Event raised when the camera is colliding with a mesh.
  111956. */
  111957. onCollide: (collidedMesh: AbstractMesh) => void;
  111958. /**
  111959. * Defines whether the camera should check collision with the objects oh the scene.
  111960. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  111961. */
  111962. checkCollisions: boolean;
  111963. /**
  111964. * Defines the collision radius of the camera.
  111965. * This simulates a sphere around the camera.
  111966. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  111967. */
  111968. collisionRadius: Vector3;
  111969. protected _collider: Collider;
  111970. protected _previousPosition: Vector3;
  111971. protected _collisionVelocity: Vector3;
  111972. protected _newPosition: Vector3;
  111973. protected _previousAlpha: number;
  111974. protected _previousBeta: number;
  111975. protected _previousRadius: number;
  111976. protected _collisionTriggered: boolean;
  111977. protected _targetBoundingCenter: Nullable<Vector3>;
  111978. private _computationVector;
  111979. /**
  111980. * Instantiates a new ArcRotateCamera in a given scene
  111981. * @param name Defines the name of the camera
  111982. * @param alpha Defines the camera rotation along the logitudinal axis
  111983. * @param beta Defines the camera rotation along the latitudinal axis
  111984. * @param radius Defines the camera distance from its target
  111985. * @param target Defines the camera target
  111986. * @param scene Defines the scene the camera belongs to
  111987. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  111988. */
  111989. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  111990. /** @hidden */
  111991. _initCache(): void;
  111992. /** @hidden */
  111993. _updateCache(ignoreParentClass?: boolean): void;
  111994. protected _getTargetPosition(): Vector3;
  111995. private _storedAlpha;
  111996. private _storedBeta;
  111997. private _storedRadius;
  111998. private _storedTarget;
  111999. private _storedTargetScreenOffset;
  112000. /**
  112001. * Stores the current state of the camera (alpha, beta, radius and target)
  112002. * @returns the camera itself
  112003. */
  112004. storeState(): Camera;
  112005. /**
  112006. * @hidden
  112007. * Restored camera state. You must call storeState() first
  112008. */
  112009. _restoreStateValues(): boolean;
  112010. /** @hidden */
  112011. _isSynchronizedViewMatrix(): boolean;
  112012. /**
  112013. * Attached controls to the current camera.
  112014. * @param element Defines the element the controls should be listened from
  112015. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112016. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  112017. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  112018. */
  112019. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  112020. /**
  112021. * Detach the current controls from the camera.
  112022. * The camera will stop reacting to inputs.
  112023. * @param element Defines the element to stop listening the inputs from
  112024. */
  112025. detachControl(element: HTMLElement): void;
  112026. /** @hidden */
  112027. _checkInputs(): void;
  112028. protected _checkLimits(): void;
  112029. /**
  112030. * Rebuilds angles (alpha, beta) and radius from the give position and target
  112031. */
  112032. rebuildAnglesAndRadius(): void;
  112033. /**
  112034. * Use a position to define the current camera related information like alpha, beta and radius
  112035. * @param position Defines the position to set the camera at
  112036. */
  112037. setPosition(position: Vector3): void;
  112038. /**
  112039. * Defines the target the camera should look at.
  112040. * This will automatically adapt alpha beta and radius to fit within the new target.
  112041. * @param target Defines the new target as a Vector or a mesh
  112042. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  112043. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  112044. */
  112045. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  112046. /** @hidden */
  112047. _getViewMatrix(): Matrix;
  112048. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  112049. /**
  112050. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  112051. * @param meshes Defines the mesh to zoom on
  112052. * @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)
  112053. */
  112054. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  112055. /**
  112056. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  112057. * The target will be changed but the radius
  112058. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  112059. * @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)
  112060. */
  112061. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  112062. min: Vector3;
  112063. max: Vector3;
  112064. distance: number;
  112065. }, doNotUpdateMaxZ?: boolean): void;
  112066. /**
  112067. * @override
  112068. * Override Camera.createRigCamera
  112069. */
  112070. createRigCamera(name: string, cameraIndex: number): Camera;
  112071. /**
  112072. * @hidden
  112073. * @override
  112074. * Override Camera._updateRigCameras
  112075. */
  112076. _updateRigCameras(): void;
  112077. /**
  112078. * Destroy the camera and release the current resources hold by it.
  112079. */
  112080. dispose(): void;
  112081. /**
  112082. * Gets the current object class name.
  112083. * @return the class name
  112084. */
  112085. getClassName(): string;
  112086. }
  112087. }
  112088. declare module BABYLON {
  112089. /**
  112090. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  112091. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112092. */
  112093. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  112094. /**
  112095. * Gets the name of the behavior.
  112096. */
  112097. get name(): string;
  112098. private _zoomStopsAnimation;
  112099. private _idleRotationSpeed;
  112100. private _idleRotationWaitTime;
  112101. private _idleRotationSpinupTime;
  112102. /**
  112103. * Sets the flag that indicates if user zooming should stop animation.
  112104. */
  112105. set zoomStopsAnimation(flag: boolean);
  112106. /**
  112107. * Gets the flag that indicates if user zooming should stop animation.
  112108. */
  112109. get zoomStopsAnimation(): boolean;
  112110. /**
  112111. * Sets the default speed at which the camera rotates around the model.
  112112. */
  112113. set idleRotationSpeed(speed: number);
  112114. /**
  112115. * Gets the default speed at which the camera rotates around the model.
  112116. */
  112117. get idleRotationSpeed(): number;
  112118. /**
  112119. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  112120. */
  112121. set idleRotationWaitTime(time: number);
  112122. /**
  112123. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  112124. */
  112125. get idleRotationWaitTime(): number;
  112126. /**
  112127. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112128. */
  112129. set idleRotationSpinupTime(time: number);
  112130. /**
  112131. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112132. */
  112133. get idleRotationSpinupTime(): number;
  112134. /**
  112135. * Gets a value indicating if the camera is currently rotating because of this behavior
  112136. */
  112137. get rotationInProgress(): boolean;
  112138. private _onPrePointerObservableObserver;
  112139. private _onAfterCheckInputsObserver;
  112140. private _attachedCamera;
  112141. private _isPointerDown;
  112142. private _lastFrameTime;
  112143. private _lastInteractionTime;
  112144. private _cameraRotationSpeed;
  112145. /**
  112146. * Initializes the behavior.
  112147. */
  112148. init(): void;
  112149. /**
  112150. * Attaches the behavior to its arc rotate camera.
  112151. * @param camera Defines the camera to attach the behavior to
  112152. */
  112153. attach(camera: ArcRotateCamera): void;
  112154. /**
  112155. * Detaches the behavior from its current arc rotate camera.
  112156. */
  112157. detach(): void;
  112158. /**
  112159. * Returns true if user is scrolling.
  112160. * @return true if user is scrolling.
  112161. */
  112162. private _userIsZooming;
  112163. private _lastFrameRadius;
  112164. private _shouldAnimationStopForInteraction;
  112165. /**
  112166. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112167. */
  112168. private _applyUserInteraction;
  112169. private _userIsMoving;
  112170. }
  112171. }
  112172. declare module BABYLON {
  112173. /**
  112174. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  112175. */
  112176. export class AttachToBoxBehavior implements Behavior<Mesh> {
  112177. private ui;
  112178. /**
  112179. * The name of the behavior
  112180. */
  112181. name: string;
  112182. /**
  112183. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  112184. */
  112185. distanceAwayFromFace: number;
  112186. /**
  112187. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  112188. */
  112189. distanceAwayFromBottomOfFace: number;
  112190. private _faceVectors;
  112191. private _target;
  112192. private _scene;
  112193. private _onRenderObserver;
  112194. private _tmpMatrix;
  112195. private _tmpVector;
  112196. /**
  112197. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  112198. * @param ui The transform node that should be attched to the mesh
  112199. */
  112200. constructor(ui: TransformNode);
  112201. /**
  112202. * Initializes the behavior
  112203. */
  112204. init(): void;
  112205. private _closestFace;
  112206. private _zeroVector;
  112207. private _lookAtTmpMatrix;
  112208. private _lookAtToRef;
  112209. /**
  112210. * Attaches the AttachToBoxBehavior to the passed in mesh
  112211. * @param target The mesh that the specified node will be attached to
  112212. */
  112213. attach(target: Mesh): void;
  112214. /**
  112215. * Detaches the behavior from the mesh
  112216. */
  112217. detach(): void;
  112218. }
  112219. }
  112220. declare module BABYLON {
  112221. /**
  112222. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  112223. */
  112224. export class FadeInOutBehavior implements Behavior<Mesh> {
  112225. /**
  112226. * Time in milliseconds to delay before fading in (Default: 0)
  112227. */
  112228. delay: number;
  112229. /**
  112230. * Time in milliseconds for the mesh to fade in (Default: 300)
  112231. */
  112232. fadeInTime: number;
  112233. private _millisecondsPerFrame;
  112234. private _hovered;
  112235. private _hoverValue;
  112236. private _ownerNode;
  112237. /**
  112238. * Instatiates the FadeInOutBehavior
  112239. */
  112240. constructor();
  112241. /**
  112242. * The name of the behavior
  112243. */
  112244. get name(): string;
  112245. /**
  112246. * Initializes the behavior
  112247. */
  112248. init(): void;
  112249. /**
  112250. * Attaches the fade behavior on the passed in mesh
  112251. * @param ownerNode The mesh that will be faded in/out once attached
  112252. */
  112253. attach(ownerNode: Mesh): void;
  112254. /**
  112255. * Detaches the behavior from the mesh
  112256. */
  112257. detach(): void;
  112258. /**
  112259. * Triggers the mesh to begin fading in or out
  112260. * @param value if the object should fade in or out (true to fade in)
  112261. */
  112262. fadeIn(value: boolean): void;
  112263. private _update;
  112264. private _setAllVisibility;
  112265. }
  112266. }
  112267. declare module BABYLON {
  112268. /**
  112269. * Class containing a set of static utilities functions for managing Pivots
  112270. * @hidden
  112271. */
  112272. export class PivotTools {
  112273. private static _PivotCached;
  112274. private static _OldPivotPoint;
  112275. private static _PivotTranslation;
  112276. private static _PivotTmpVector;
  112277. /** @hidden */
  112278. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  112279. /** @hidden */
  112280. static _RestorePivotPoint(mesh: AbstractMesh): void;
  112281. }
  112282. }
  112283. declare module BABYLON {
  112284. /**
  112285. * Class containing static functions to help procedurally build meshes
  112286. */
  112287. export class PlaneBuilder {
  112288. /**
  112289. * Creates a plane mesh
  112290. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  112291. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  112292. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  112293. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112294. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112295. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112296. * @param name defines the name of the mesh
  112297. * @param options defines the options used to create the mesh
  112298. * @param scene defines the hosting scene
  112299. * @returns the plane mesh
  112300. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  112301. */
  112302. static CreatePlane(name: string, options: {
  112303. size?: number;
  112304. width?: number;
  112305. height?: number;
  112306. sideOrientation?: number;
  112307. frontUVs?: Vector4;
  112308. backUVs?: Vector4;
  112309. updatable?: boolean;
  112310. sourcePlane?: Plane;
  112311. }, scene?: Nullable<Scene>): Mesh;
  112312. }
  112313. }
  112314. declare module BABYLON {
  112315. /**
  112316. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  112317. */
  112318. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  112319. private static _AnyMouseID;
  112320. /**
  112321. * Abstract mesh the behavior is set on
  112322. */
  112323. attachedNode: AbstractMesh;
  112324. private _dragPlane;
  112325. private _scene;
  112326. private _pointerObserver;
  112327. private _beforeRenderObserver;
  112328. private static _planeScene;
  112329. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  112330. /**
  112331. * 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)
  112332. */
  112333. maxDragAngle: number;
  112334. /**
  112335. * @hidden
  112336. */
  112337. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  112338. /**
  112339. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112340. */
  112341. currentDraggingPointerID: number;
  112342. /**
  112343. * The last position where the pointer hit the drag plane in world space
  112344. */
  112345. lastDragPosition: Vector3;
  112346. /**
  112347. * If the behavior is currently in a dragging state
  112348. */
  112349. dragging: boolean;
  112350. /**
  112351. * 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)
  112352. */
  112353. dragDeltaRatio: number;
  112354. /**
  112355. * If the drag plane orientation should be updated during the dragging (Default: true)
  112356. */
  112357. updateDragPlane: boolean;
  112358. private _debugMode;
  112359. private _moving;
  112360. /**
  112361. * Fires each time the attached mesh is dragged with the pointer
  112362. * * delta between last drag position and current drag position in world space
  112363. * * dragDistance along the drag axis
  112364. * * dragPlaneNormal normal of the current drag plane used during the drag
  112365. * * dragPlanePoint in world space where the drag intersects the drag plane
  112366. */
  112367. onDragObservable: Observable<{
  112368. delta: Vector3;
  112369. dragPlanePoint: Vector3;
  112370. dragPlaneNormal: Vector3;
  112371. dragDistance: number;
  112372. pointerId: number;
  112373. }>;
  112374. /**
  112375. * Fires each time a drag begins (eg. mouse down on mesh)
  112376. */
  112377. onDragStartObservable: Observable<{
  112378. dragPlanePoint: Vector3;
  112379. pointerId: number;
  112380. }>;
  112381. /**
  112382. * Fires each time a drag ends (eg. mouse release after drag)
  112383. */
  112384. onDragEndObservable: Observable<{
  112385. dragPlanePoint: Vector3;
  112386. pointerId: number;
  112387. }>;
  112388. /**
  112389. * If the attached mesh should be moved when dragged
  112390. */
  112391. moveAttached: boolean;
  112392. /**
  112393. * If the drag behavior will react to drag events (Default: true)
  112394. */
  112395. enabled: boolean;
  112396. /**
  112397. * If pointer events should start and release the drag (Default: true)
  112398. */
  112399. startAndReleaseDragOnPointerEvents: boolean;
  112400. /**
  112401. * If camera controls should be detached during the drag
  112402. */
  112403. detachCameraControls: boolean;
  112404. /**
  112405. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  112406. */
  112407. useObjectOrientationForDragging: boolean;
  112408. private _options;
  112409. /**
  112410. * Gets the options used by the behavior
  112411. */
  112412. get options(): {
  112413. dragAxis?: Vector3;
  112414. dragPlaneNormal?: Vector3;
  112415. };
  112416. /**
  112417. * Sets the options used by the behavior
  112418. */
  112419. set options(options: {
  112420. dragAxis?: Vector3;
  112421. dragPlaneNormal?: Vector3;
  112422. });
  112423. /**
  112424. * Creates a pointer drag behavior that can be attached to a mesh
  112425. * @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)
  112426. */
  112427. constructor(options?: {
  112428. dragAxis?: Vector3;
  112429. dragPlaneNormal?: Vector3;
  112430. });
  112431. /**
  112432. * Predicate to determine if it is valid to move the object to a new position when it is moved
  112433. */
  112434. validateDrag: (targetPosition: Vector3) => boolean;
  112435. /**
  112436. * The name of the behavior
  112437. */
  112438. get name(): string;
  112439. /**
  112440. * Initializes the behavior
  112441. */
  112442. init(): void;
  112443. private _tmpVector;
  112444. private _alternatePickedPoint;
  112445. private _worldDragAxis;
  112446. private _targetPosition;
  112447. private _attachedElement;
  112448. /**
  112449. * Attaches the drag behavior the passed in mesh
  112450. * @param ownerNode The mesh that will be dragged around once attached
  112451. * @param predicate Predicate to use for pick filtering
  112452. */
  112453. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  112454. /**
  112455. * Force relase the drag action by code.
  112456. */
  112457. releaseDrag(): void;
  112458. private _startDragRay;
  112459. private _lastPointerRay;
  112460. /**
  112461. * Simulates the start of a pointer drag event on the behavior
  112462. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  112463. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  112464. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  112465. */
  112466. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  112467. private _startDrag;
  112468. private _dragDelta;
  112469. private _moveDrag;
  112470. private _pickWithRayOnDragPlane;
  112471. private _pointA;
  112472. private _pointB;
  112473. private _pointC;
  112474. private _lineA;
  112475. private _lineB;
  112476. private _localAxis;
  112477. private _lookAt;
  112478. private _updateDragPlanePosition;
  112479. /**
  112480. * Detaches the behavior from the mesh
  112481. */
  112482. detach(): void;
  112483. }
  112484. }
  112485. declare module BABYLON {
  112486. /**
  112487. * A behavior that when attached to a mesh will allow the mesh to be scaled
  112488. */
  112489. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  112490. private _dragBehaviorA;
  112491. private _dragBehaviorB;
  112492. private _startDistance;
  112493. private _initialScale;
  112494. private _targetScale;
  112495. private _ownerNode;
  112496. private _sceneRenderObserver;
  112497. /**
  112498. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  112499. */
  112500. constructor();
  112501. /**
  112502. * The name of the behavior
  112503. */
  112504. get name(): string;
  112505. /**
  112506. * Initializes the behavior
  112507. */
  112508. init(): void;
  112509. private _getCurrentDistance;
  112510. /**
  112511. * Attaches the scale behavior the passed in mesh
  112512. * @param ownerNode The mesh that will be scaled around once attached
  112513. */
  112514. attach(ownerNode: Mesh): void;
  112515. /**
  112516. * Detaches the behavior from the mesh
  112517. */
  112518. detach(): void;
  112519. }
  112520. }
  112521. declare module BABYLON {
  112522. /**
  112523. * 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
  112524. */
  112525. export class SixDofDragBehavior implements Behavior<Mesh> {
  112526. private static _virtualScene;
  112527. private _ownerNode;
  112528. private _sceneRenderObserver;
  112529. private _scene;
  112530. private _targetPosition;
  112531. private _virtualOriginMesh;
  112532. private _virtualDragMesh;
  112533. private _pointerObserver;
  112534. private _moving;
  112535. private _startingOrientation;
  112536. /**
  112537. * 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)
  112538. */
  112539. private zDragFactor;
  112540. /**
  112541. * If the object should rotate to face the drag origin
  112542. */
  112543. rotateDraggedObject: boolean;
  112544. /**
  112545. * If the behavior is currently in a dragging state
  112546. */
  112547. dragging: boolean;
  112548. /**
  112549. * 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)
  112550. */
  112551. dragDeltaRatio: number;
  112552. /**
  112553. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112554. */
  112555. currentDraggingPointerID: number;
  112556. /**
  112557. * If camera controls should be detached during the drag
  112558. */
  112559. detachCameraControls: boolean;
  112560. /**
  112561. * Fires each time a drag starts
  112562. */
  112563. onDragStartObservable: Observable<{}>;
  112564. /**
  112565. * Fires each time a drag ends (eg. mouse release after drag)
  112566. */
  112567. onDragEndObservable: Observable<{}>;
  112568. /**
  112569. * 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
  112570. */
  112571. constructor();
  112572. /**
  112573. * The name of the behavior
  112574. */
  112575. get name(): string;
  112576. /**
  112577. * Initializes the behavior
  112578. */
  112579. init(): void;
  112580. /**
  112581. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  112582. */
  112583. private get _pointerCamera();
  112584. /**
  112585. * Attaches the scale behavior the passed in mesh
  112586. * @param ownerNode The mesh that will be scaled around once attached
  112587. */
  112588. attach(ownerNode: Mesh): void;
  112589. /**
  112590. * Detaches the behavior from the mesh
  112591. */
  112592. detach(): void;
  112593. }
  112594. }
  112595. declare module BABYLON {
  112596. /**
  112597. * Class used to apply inverse kinematics to bones
  112598. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  112599. */
  112600. export class BoneIKController {
  112601. private static _tmpVecs;
  112602. private static _tmpQuat;
  112603. private static _tmpMats;
  112604. /**
  112605. * Gets or sets the target mesh
  112606. */
  112607. targetMesh: AbstractMesh;
  112608. /** Gets or sets the mesh used as pole */
  112609. poleTargetMesh: AbstractMesh;
  112610. /**
  112611. * Gets or sets the bone used as pole
  112612. */
  112613. poleTargetBone: Nullable<Bone>;
  112614. /**
  112615. * Gets or sets the target position
  112616. */
  112617. targetPosition: Vector3;
  112618. /**
  112619. * Gets or sets the pole target position
  112620. */
  112621. poleTargetPosition: Vector3;
  112622. /**
  112623. * Gets or sets the pole target local offset
  112624. */
  112625. poleTargetLocalOffset: Vector3;
  112626. /**
  112627. * Gets or sets the pole angle
  112628. */
  112629. poleAngle: number;
  112630. /**
  112631. * Gets or sets the mesh associated with the controller
  112632. */
  112633. mesh: AbstractMesh;
  112634. /**
  112635. * 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)
  112636. */
  112637. slerpAmount: number;
  112638. private _bone1Quat;
  112639. private _bone1Mat;
  112640. private _bone2Ang;
  112641. private _bone1;
  112642. private _bone2;
  112643. private _bone1Length;
  112644. private _bone2Length;
  112645. private _maxAngle;
  112646. private _maxReach;
  112647. private _rightHandedSystem;
  112648. private _bendAxis;
  112649. private _slerping;
  112650. private _adjustRoll;
  112651. /**
  112652. * Gets or sets maximum allowed angle
  112653. */
  112654. get maxAngle(): number;
  112655. set maxAngle(value: number);
  112656. /**
  112657. * Creates a new BoneIKController
  112658. * @param mesh defines the mesh to control
  112659. * @param bone defines the bone to control
  112660. * @param options defines options to set up the controller
  112661. */
  112662. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  112663. targetMesh?: AbstractMesh;
  112664. poleTargetMesh?: AbstractMesh;
  112665. poleTargetBone?: Bone;
  112666. poleTargetLocalOffset?: Vector3;
  112667. poleAngle?: number;
  112668. bendAxis?: Vector3;
  112669. maxAngle?: number;
  112670. slerpAmount?: number;
  112671. });
  112672. private _setMaxAngle;
  112673. /**
  112674. * Force the controller to update the bones
  112675. */
  112676. update(): void;
  112677. }
  112678. }
  112679. declare module BABYLON {
  112680. /**
  112681. * Class used to make a bone look toward a point in space
  112682. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  112683. */
  112684. export class BoneLookController {
  112685. private static _tmpVecs;
  112686. private static _tmpQuat;
  112687. private static _tmpMats;
  112688. /**
  112689. * The target Vector3 that the bone will look at
  112690. */
  112691. target: Vector3;
  112692. /**
  112693. * The mesh that the bone is attached to
  112694. */
  112695. mesh: AbstractMesh;
  112696. /**
  112697. * The bone that will be looking to the target
  112698. */
  112699. bone: Bone;
  112700. /**
  112701. * The up axis of the coordinate system that is used when the bone is rotated
  112702. */
  112703. upAxis: Vector3;
  112704. /**
  112705. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  112706. */
  112707. upAxisSpace: Space;
  112708. /**
  112709. * Used to make an adjustment to the yaw of the bone
  112710. */
  112711. adjustYaw: number;
  112712. /**
  112713. * Used to make an adjustment to the pitch of the bone
  112714. */
  112715. adjustPitch: number;
  112716. /**
  112717. * Used to make an adjustment to the roll of the bone
  112718. */
  112719. adjustRoll: number;
  112720. /**
  112721. * 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)
  112722. */
  112723. slerpAmount: number;
  112724. private _minYaw;
  112725. private _maxYaw;
  112726. private _minPitch;
  112727. private _maxPitch;
  112728. private _minYawSin;
  112729. private _minYawCos;
  112730. private _maxYawSin;
  112731. private _maxYawCos;
  112732. private _midYawConstraint;
  112733. private _minPitchTan;
  112734. private _maxPitchTan;
  112735. private _boneQuat;
  112736. private _slerping;
  112737. private _transformYawPitch;
  112738. private _transformYawPitchInv;
  112739. private _firstFrameSkipped;
  112740. private _yawRange;
  112741. private _fowardAxis;
  112742. /**
  112743. * Gets or sets the minimum yaw angle that the bone can look to
  112744. */
  112745. get minYaw(): number;
  112746. set minYaw(value: number);
  112747. /**
  112748. * Gets or sets the maximum yaw angle that the bone can look to
  112749. */
  112750. get maxYaw(): number;
  112751. set maxYaw(value: number);
  112752. /**
  112753. * Gets or sets the minimum pitch angle that the bone can look to
  112754. */
  112755. get minPitch(): number;
  112756. set minPitch(value: number);
  112757. /**
  112758. * Gets or sets the maximum pitch angle that the bone can look to
  112759. */
  112760. get maxPitch(): number;
  112761. set maxPitch(value: number);
  112762. /**
  112763. * Create a BoneLookController
  112764. * @param mesh the mesh that the bone belongs to
  112765. * @param bone the bone that will be looking to the target
  112766. * @param target the target Vector3 to look at
  112767. * @param options optional settings:
  112768. * * maxYaw: the maximum angle the bone will yaw to
  112769. * * minYaw: the minimum angle the bone will yaw to
  112770. * * maxPitch: the maximum angle the bone will pitch to
  112771. * * minPitch: the minimum angle the bone will yaw to
  112772. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  112773. * * upAxis: the up axis of the coordinate system
  112774. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  112775. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  112776. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  112777. * * adjustYaw: used to make an adjustment to the yaw of the bone
  112778. * * adjustPitch: used to make an adjustment to the pitch of the bone
  112779. * * adjustRoll: used to make an adjustment to the roll of the bone
  112780. **/
  112781. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  112782. maxYaw?: number;
  112783. minYaw?: number;
  112784. maxPitch?: number;
  112785. minPitch?: number;
  112786. slerpAmount?: number;
  112787. upAxis?: Vector3;
  112788. upAxisSpace?: Space;
  112789. yawAxis?: Vector3;
  112790. pitchAxis?: Vector3;
  112791. adjustYaw?: number;
  112792. adjustPitch?: number;
  112793. adjustRoll?: number;
  112794. });
  112795. /**
  112796. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  112797. */
  112798. update(): void;
  112799. private _getAngleDiff;
  112800. private _getAngleBetween;
  112801. private _isAngleBetween;
  112802. }
  112803. }
  112804. declare module BABYLON {
  112805. /**
  112806. * Manage the gamepad inputs to control an arc rotate camera.
  112807. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112808. */
  112809. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  112810. /**
  112811. * Defines the camera the input is attached to.
  112812. */
  112813. camera: ArcRotateCamera;
  112814. /**
  112815. * Defines the gamepad the input is gathering event from.
  112816. */
  112817. gamepad: Nullable<Gamepad>;
  112818. /**
  112819. * Defines the gamepad rotation sensiblity.
  112820. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  112821. */
  112822. gamepadRotationSensibility: number;
  112823. /**
  112824. * Defines the gamepad move sensiblity.
  112825. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  112826. */
  112827. gamepadMoveSensibility: number;
  112828. private _yAxisScale;
  112829. /**
  112830. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  112831. */
  112832. get invertYAxis(): boolean;
  112833. set invertYAxis(value: boolean);
  112834. private _onGamepadConnectedObserver;
  112835. private _onGamepadDisconnectedObserver;
  112836. /**
  112837. * Attach the input controls to a specific dom element to get the input from.
  112838. * @param element Defines the element the controls should be listened from
  112839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112840. */
  112841. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112842. /**
  112843. * Detach the current controls from the specified dom element.
  112844. * @param element Defines the element to stop listening the inputs from
  112845. */
  112846. detachControl(element: Nullable<HTMLElement>): void;
  112847. /**
  112848. * Update the current camera state depending on the inputs that have been used this frame.
  112849. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112850. */
  112851. checkInputs(): void;
  112852. /**
  112853. * Gets the class name of the current intput.
  112854. * @returns the class name
  112855. */
  112856. getClassName(): string;
  112857. /**
  112858. * Get the friendly name associated with the input class.
  112859. * @returns the input friendly name
  112860. */
  112861. getSimpleName(): string;
  112862. }
  112863. }
  112864. declare module BABYLON {
  112865. interface ArcRotateCameraInputsManager {
  112866. /**
  112867. * Add orientation input support to the input manager.
  112868. * @returns the current input manager
  112869. */
  112870. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  112871. }
  112872. /**
  112873. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  112874. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112875. */
  112876. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  112877. /**
  112878. * Defines the camera the input is attached to.
  112879. */
  112880. camera: ArcRotateCamera;
  112881. /**
  112882. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  112883. */
  112884. alphaCorrection: number;
  112885. /**
  112886. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  112887. */
  112888. gammaCorrection: number;
  112889. private _alpha;
  112890. private _gamma;
  112891. private _dirty;
  112892. private _deviceOrientationHandler;
  112893. /**
  112894. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  112895. */
  112896. constructor();
  112897. /**
  112898. * Attach the input controls to a specific dom element to get the input from.
  112899. * @param element Defines the element the controls should be listened from
  112900. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112901. */
  112902. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112903. /** @hidden */
  112904. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  112905. /**
  112906. * Update the current camera state depending on the inputs that have been used this frame.
  112907. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112908. */
  112909. checkInputs(): void;
  112910. /**
  112911. * Detach the current controls from the specified dom element.
  112912. * @param element Defines the element to stop listening the inputs from
  112913. */
  112914. detachControl(element: Nullable<HTMLElement>): void;
  112915. /**
  112916. * Gets the class name of the current intput.
  112917. * @returns the class name
  112918. */
  112919. getClassName(): string;
  112920. /**
  112921. * Get the friendly name associated with the input class.
  112922. * @returns the input friendly name
  112923. */
  112924. getSimpleName(): string;
  112925. }
  112926. }
  112927. declare module BABYLON {
  112928. /**
  112929. * Listen to mouse events to control the camera.
  112930. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112931. */
  112932. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  112933. /**
  112934. * Defines the camera the input is attached to.
  112935. */
  112936. camera: FlyCamera;
  112937. /**
  112938. * Defines if touch is enabled. (Default is true.)
  112939. */
  112940. touchEnabled: boolean;
  112941. /**
  112942. * Defines the buttons associated with the input to handle camera rotation.
  112943. */
  112944. buttons: number[];
  112945. /**
  112946. * Assign buttons for Yaw control.
  112947. */
  112948. buttonsYaw: number[];
  112949. /**
  112950. * Assign buttons for Pitch control.
  112951. */
  112952. buttonsPitch: number[];
  112953. /**
  112954. * Assign buttons for Roll control.
  112955. */
  112956. buttonsRoll: number[];
  112957. /**
  112958. * Detect if any button is being pressed while mouse is moved.
  112959. * -1 = Mouse locked.
  112960. * 0 = Left button.
  112961. * 1 = Middle Button.
  112962. * 2 = Right Button.
  112963. */
  112964. activeButton: number;
  112965. /**
  112966. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  112967. * Higher values reduce its sensitivity.
  112968. */
  112969. angularSensibility: number;
  112970. private _mousemoveCallback;
  112971. private _observer;
  112972. private _rollObserver;
  112973. private previousPosition;
  112974. private noPreventDefault;
  112975. private element;
  112976. /**
  112977. * Listen to mouse events to control the camera.
  112978. * @param touchEnabled Define if touch is enabled. (Default is true.)
  112979. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112980. */
  112981. constructor(touchEnabled?: boolean);
  112982. /**
  112983. * Attach the mouse control to the HTML DOM element.
  112984. * @param element Defines the element that listens to the input events.
  112985. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  112986. */
  112987. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112988. /**
  112989. * Detach the current controls from the specified dom element.
  112990. * @param element Defines the element to stop listening the inputs from
  112991. */
  112992. detachControl(element: Nullable<HTMLElement>): void;
  112993. /**
  112994. * Gets the class name of the current input.
  112995. * @returns the class name.
  112996. */
  112997. getClassName(): string;
  112998. /**
  112999. * Get the friendly name associated with the input class.
  113000. * @returns the input's friendly name.
  113001. */
  113002. getSimpleName(): string;
  113003. private _pointerInput;
  113004. private _onMouseMove;
  113005. /**
  113006. * Rotate camera by mouse offset.
  113007. */
  113008. private rotateCamera;
  113009. }
  113010. }
  113011. declare module BABYLON {
  113012. /**
  113013. * Default Inputs manager for the FlyCamera.
  113014. * It groups all the default supported inputs for ease of use.
  113015. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113016. */
  113017. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  113018. /**
  113019. * Instantiates a new FlyCameraInputsManager.
  113020. * @param camera Defines the camera the inputs belong to.
  113021. */
  113022. constructor(camera: FlyCamera);
  113023. /**
  113024. * Add keyboard input support to the input manager.
  113025. * @returns the new FlyCameraKeyboardMoveInput().
  113026. */
  113027. addKeyboard(): FlyCameraInputsManager;
  113028. /**
  113029. * Add mouse input support to the input manager.
  113030. * @param touchEnabled Enable touch screen support.
  113031. * @returns the new FlyCameraMouseInput().
  113032. */
  113033. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  113034. }
  113035. }
  113036. declare module BABYLON {
  113037. /**
  113038. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113039. * such as in a 3D Space Shooter or a Flight Simulator.
  113040. */
  113041. export class FlyCamera extends TargetCamera {
  113042. /**
  113043. * Define the collision ellipsoid of the camera.
  113044. * This is helpful for simulating a camera body, like a player's body.
  113045. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113046. */
  113047. ellipsoid: Vector3;
  113048. /**
  113049. * Define an offset for the position of the ellipsoid around the camera.
  113050. * This can be helpful if the camera is attached away from the player's body center,
  113051. * such as at its head.
  113052. */
  113053. ellipsoidOffset: Vector3;
  113054. /**
  113055. * Enable or disable collisions of the camera with the rest of the scene objects.
  113056. */
  113057. checkCollisions: boolean;
  113058. /**
  113059. * Enable or disable gravity on the camera.
  113060. */
  113061. applyGravity: boolean;
  113062. /**
  113063. * Define the current direction the camera is moving to.
  113064. */
  113065. cameraDirection: Vector3;
  113066. /**
  113067. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  113068. * This overrides and empties cameraRotation.
  113069. */
  113070. rotationQuaternion: Quaternion;
  113071. /**
  113072. * Track Roll to maintain the wanted Rolling when looking around.
  113073. */
  113074. _trackRoll: number;
  113075. /**
  113076. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  113077. */
  113078. rollCorrect: number;
  113079. /**
  113080. * Mimic a banked turn, Rolling the camera when Yawing.
  113081. * It's recommended to use rollCorrect = 10 for faster banking correction.
  113082. */
  113083. bankedTurn: boolean;
  113084. /**
  113085. * Limit in radians for how much Roll banking will add. (Default: 90°)
  113086. */
  113087. bankedTurnLimit: number;
  113088. /**
  113089. * Value of 0 disables the banked Roll.
  113090. * Value of 1 is equal to the Yaw angle in radians.
  113091. */
  113092. bankedTurnMultiplier: number;
  113093. /**
  113094. * The inputs manager loads all the input sources, such as keyboard and mouse.
  113095. */
  113096. inputs: FlyCameraInputsManager;
  113097. /**
  113098. * Gets the input sensibility for mouse input.
  113099. * Higher values reduce sensitivity.
  113100. */
  113101. get angularSensibility(): number;
  113102. /**
  113103. * Sets the input sensibility for a mouse input.
  113104. * Higher values reduce sensitivity.
  113105. */
  113106. set angularSensibility(value: number);
  113107. /**
  113108. * Get the keys for camera movement forward.
  113109. */
  113110. get keysForward(): number[];
  113111. /**
  113112. * Set the keys for camera movement forward.
  113113. */
  113114. set keysForward(value: number[]);
  113115. /**
  113116. * Get the keys for camera movement backward.
  113117. */
  113118. get keysBackward(): number[];
  113119. set keysBackward(value: number[]);
  113120. /**
  113121. * Get the keys for camera movement up.
  113122. */
  113123. get keysUp(): number[];
  113124. /**
  113125. * Set the keys for camera movement up.
  113126. */
  113127. set keysUp(value: number[]);
  113128. /**
  113129. * Get the keys for camera movement down.
  113130. */
  113131. get keysDown(): number[];
  113132. /**
  113133. * Set the keys for camera movement down.
  113134. */
  113135. set keysDown(value: number[]);
  113136. /**
  113137. * Get the keys for camera movement left.
  113138. */
  113139. get keysLeft(): number[];
  113140. /**
  113141. * Set the keys for camera movement left.
  113142. */
  113143. set keysLeft(value: number[]);
  113144. /**
  113145. * Set the keys for camera movement right.
  113146. */
  113147. get keysRight(): number[];
  113148. /**
  113149. * Set the keys for camera movement right.
  113150. */
  113151. set keysRight(value: number[]);
  113152. /**
  113153. * Event raised when the camera collides with a mesh in the scene.
  113154. */
  113155. onCollide: (collidedMesh: AbstractMesh) => void;
  113156. private _collider;
  113157. private _needMoveForGravity;
  113158. private _oldPosition;
  113159. private _diffPosition;
  113160. private _newPosition;
  113161. /** @hidden */
  113162. _localDirection: Vector3;
  113163. /** @hidden */
  113164. _transformedDirection: Vector3;
  113165. /**
  113166. * Instantiates a FlyCamera.
  113167. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113168. * such as in a 3D Space Shooter or a Flight Simulator.
  113169. * @param name Define the name of the camera in the scene.
  113170. * @param position Define the starting position of the camera in the scene.
  113171. * @param scene Define the scene the camera belongs to.
  113172. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  113173. */
  113174. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113175. /**
  113176. * Attach a control to the HTML DOM element.
  113177. * @param element Defines the element that listens to the input events.
  113178. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  113179. */
  113180. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113181. /**
  113182. * Detach a control from the HTML DOM element.
  113183. * The camera will stop reacting to that input.
  113184. * @param element Defines the element that listens to the input events.
  113185. */
  113186. detachControl(element: HTMLElement): void;
  113187. private _collisionMask;
  113188. /**
  113189. * Get the mask that the camera ignores in collision events.
  113190. */
  113191. get collisionMask(): number;
  113192. /**
  113193. * Set the mask that the camera ignores in collision events.
  113194. */
  113195. set collisionMask(mask: number);
  113196. /** @hidden */
  113197. _collideWithWorld(displacement: Vector3): void;
  113198. /** @hidden */
  113199. private _onCollisionPositionChange;
  113200. /** @hidden */
  113201. _checkInputs(): void;
  113202. /** @hidden */
  113203. _decideIfNeedsToMove(): boolean;
  113204. /** @hidden */
  113205. _updatePosition(): void;
  113206. /**
  113207. * Restore the Roll to its target value at the rate specified.
  113208. * @param rate - Higher means slower restoring.
  113209. * @hidden
  113210. */
  113211. restoreRoll(rate: number): void;
  113212. /**
  113213. * Destroy the camera and release the current resources held by it.
  113214. */
  113215. dispose(): void;
  113216. /**
  113217. * Get the current object class name.
  113218. * @returns the class name.
  113219. */
  113220. getClassName(): string;
  113221. }
  113222. }
  113223. declare module BABYLON {
  113224. /**
  113225. * Listen to keyboard events to control the camera.
  113226. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113227. */
  113228. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  113229. /**
  113230. * Defines the camera the input is attached to.
  113231. */
  113232. camera: FlyCamera;
  113233. /**
  113234. * The list of keyboard keys used to control the forward move of the camera.
  113235. */
  113236. keysForward: number[];
  113237. /**
  113238. * The list of keyboard keys used to control the backward move of the camera.
  113239. */
  113240. keysBackward: number[];
  113241. /**
  113242. * The list of keyboard keys used to control the forward move of the camera.
  113243. */
  113244. keysUp: number[];
  113245. /**
  113246. * The list of keyboard keys used to control the backward move of the camera.
  113247. */
  113248. keysDown: number[];
  113249. /**
  113250. * The list of keyboard keys used to control the right strafe move of the camera.
  113251. */
  113252. keysRight: number[];
  113253. /**
  113254. * The list of keyboard keys used to control the left strafe move of the camera.
  113255. */
  113256. keysLeft: number[];
  113257. private _keys;
  113258. private _onCanvasBlurObserver;
  113259. private _onKeyboardObserver;
  113260. private _engine;
  113261. private _scene;
  113262. /**
  113263. * Attach the input controls to a specific dom element to get the input from.
  113264. * @param element Defines the element the controls should be listened from
  113265. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113266. */
  113267. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113268. /**
  113269. * Detach the current controls from the specified dom element.
  113270. * @param element Defines the element to stop listening the inputs from
  113271. */
  113272. detachControl(element: Nullable<HTMLElement>): void;
  113273. /**
  113274. * Gets the class name of the current intput.
  113275. * @returns the class name
  113276. */
  113277. getClassName(): string;
  113278. /** @hidden */
  113279. _onLostFocus(e: FocusEvent): void;
  113280. /**
  113281. * Get the friendly name associated with the input class.
  113282. * @returns the input friendly name
  113283. */
  113284. getSimpleName(): string;
  113285. /**
  113286. * Update the current camera state depending on the inputs that have been used this frame.
  113287. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113288. */
  113289. checkInputs(): void;
  113290. }
  113291. }
  113292. declare module BABYLON {
  113293. /**
  113294. * Manage the mouse wheel inputs to control a follow camera.
  113295. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113296. */
  113297. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  113298. /**
  113299. * Defines the camera the input is attached to.
  113300. */
  113301. camera: FollowCamera;
  113302. /**
  113303. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  113304. */
  113305. axisControlRadius: boolean;
  113306. /**
  113307. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  113308. */
  113309. axisControlHeight: boolean;
  113310. /**
  113311. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  113312. */
  113313. axisControlRotation: boolean;
  113314. /**
  113315. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  113316. * relation to mouseWheel events.
  113317. */
  113318. wheelPrecision: number;
  113319. /**
  113320. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113321. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113322. */
  113323. wheelDeltaPercentage: number;
  113324. private _wheel;
  113325. private _observer;
  113326. /**
  113327. * Attach the input controls to a specific dom element to get the input from.
  113328. * @param element Defines the element the controls should be listened from
  113329. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113330. */
  113331. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113332. /**
  113333. * Detach the current controls from the specified dom element.
  113334. * @param element Defines the element to stop listening the inputs from
  113335. */
  113336. detachControl(element: Nullable<HTMLElement>): void;
  113337. /**
  113338. * Gets the class name of the current intput.
  113339. * @returns the class name
  113340. */
  113341. getClassName(): string;
  113342. /**
  113343. * Get the friendly name associated with the input class.
  113344. * @returns the input friendly name
  113345. */
  113346. getSimpleName(): string;
  113347. }
  113348. }
  113349. declare module BABYLON {
  113350. /**
  113351. * Manage the pointers inputs to control an follow camera.
  113352. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113353. */
  113354. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  113355. /**
  113356. * Defines the camera the input is attached to.
  113357. */
  113358. camera: FollowCamera;
  113359. /**
  113360. * Gets the class name of the current input.
  113361. * @returns the class name
  113362. */
  113363. getClassName(): string;
  113364. /**
  113365. * Defines the pointer angular sensibility along the X axis or how fast is
  113366. * the camera rotating.
  113367. * A negative number will reverse the axis direction.
  113368. */
  113369. angularSensibilityX: number;
  113370. /**
  113371. * Defines the pointer angular sensibility along the Y axis or how fast is
  113372. * the camera rotating.
  113373. * A negative number will reverse the axis direction.
  113374. */
  113375. angularSensibilityY: number;
  113376. /**
  113377. * Defines the pointer pinch precision or how fast is the camera zooming.
  113378. * A negative number will reverse the axis direction.
  113379. */
  113380. pinchPrecision: number;
  113381. /**
  113382. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  113383. * from 0.
  113384. * It defines the percentage of current camera.radius to use as delta when
  113385. * pinch zoom is used.
  113386. */
  113387. pinchDeltaPercentage: number;
  113388. /**
  113389. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  113390. */
  113391. axisXControlRadius: boolean;
  113392. /**
  113393. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  113394. */
  113395. axisXControlHeight: boolean;
  113396. /**
  113397. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  113398. */
  113399. axisXControlRotation: boolean;
  113400. /**
  113401. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  113402. */
  113403. axisYControlRadius: boolean;
  113404. /**
  113405. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  113406. */
  113407. axisYControlHeight: boolean;
  113408. /**
  113409. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  113410. */
  113411. axisYControlRotation: boolean;
  113412. /**
  113413. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  113414. */
  113415. axisPinchControlRadius: boolean;
  113416. /**
  113417. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  113418. */
  113419. axisPinchControlHeight: boolean;
  113420. /**
  113421. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  113422. */
  113423. axisPinchControlRotation: boolean;
  113424. /**
  113425. * Log error messages if basic misconfiguration has occurred.
  113426. */
  113427. warningEnable: boolean;
  113428. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113429. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113430. private _warningCounter;
  113431. private _warning;
  113432. }
  113433. }
  113434. declare module BABYLON {
  113435. /**
  113436. * Default Inputs manager for the FollowCamera.
  113437. * It groups all the default supported inputs for ease of use.
  113438. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113439. */
  113440. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  113441. /**
  113442. * Instantiates a new FollowCameraInputsManager.
  113443. * @param camera Defines the camera the inputs belong to
  113444. */
  113445. constructor(camera: FollowCamera);
  113446. /**
  113447. * Add keyboard input support to the input manager.
  113448. * @returns the current input manager
  113449. */
  113450. addKeyboard(): FollowCameraInputsManager;
  113451. /**
  113452. * Add mouse wheel input support to the input manager.
  113453. * @returns the current input manager
  113454. */
  113455. addMouseWheel(): FollowCameraInputsManager;
  113456. /**
  113457. * Add pointers input support to the input manager.
  113458. * @returns the current input manager
  113459. */
  113460. addPointers(): FollowCameraInputsManager;
  113461. /**
  113462. * Add orientation input support to the input manager.
  113463. * @returns the current input manager
  113464. */
  113465. addVRDeviceOrientation(): FollowCameraInputsManager;
  113466. }
  113467. }
  113468. declare module BABYLON {
  113469. /**
  113470. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  113471. * an arc rotate version arcFollowCamera are available.
  113472. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113473. */
  113474. export class FollowCamera extends TargetCamera {
  113475. /**
  113476. * Distance the follow camera should follow an object at
  113477. */
  113478. radius: number;
  113479. /**
  113480. * Minimum allowed distance of the camera to the axis of rotation
  113481. * (The camera can not get closer).
  113482. * This can help limiting how the Camera is able to move in the scene.
  113483. */
  113484. lowerRadiusLimit: Nullable<number>;
  113485. /**
  113486. * Maximum allowed distance of the camera to the axis of rotation
  113487. * (The camera can not get further).
  113488. * This can help limiting how the Camera is able to move in the scene.
  113489. */
  113490. upperRadiusLimit: Nullable<number>;
  113491. /**
  113492. * Define a rotation offset between the camera and the object it follows
  113493. */
  113494. rotationOffset: number;
  113495. /**
  113496. * Minimum allowed angle to camera position relative to target object.
  113497. * This can help limiting how the Camera is able to move in the scene.
  113498. */
  113499. lowerRotationOffsetLimit: Nullable<number>;
  113500. /**
  113501. * Maximum allowed angle to camera position relative to target object.
  113502. * This can help limiting how the Camera is able to move in the scene.
  113503. */
  113504. upperRotationOffsetLimit: Nullable<number>;
  113505. /**
  113506. * Define a height offset between the camera and the object it follows.
  113507. * It can help following an object from the top (like a car chaing a plane)
  113508. */
  113509. heightOffset: number;
  113510. /**
  113511. * Minimum allowed height of camera position relative to target object.
  113512. * This can help limiting how the Camera is able to move in the scene.
  113513. */
  113514. lowerHeightOffsetLimit: Nullable<number>;
  113515. /**
  113516. * Maximum allowed height of camera position relative to target object.
  113517. * This can help limiting how the Camera is able to move in the scene.
  113518. */
  113519. upperHeightOffsetLimit: Nullable<number>;
  113520. /**
  113521. * Define how fast the camera can accelerate to follow it s target.
  113522. */
  113523. cameraAcceleration: number;
  113524. /**
  113525. * Define the speed limit of the camera following an object.
  113526. */
  113527. maxCameraSpeed: number;
  113528. /**
  113529. * Define the target of the camera.
  113530. */
  113531. lockedTarget: Nullable<AbstractMesh>;
  113532. /**
  113533. * Defines the input associated with the camera.
  113534. */
  113535. inputs: FollowCameraInputsManager;
  113536. /**
  113537. * Instantiates the follow camera.
  113538. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113539. * @param name Define the name of the camera in the scene
  113540. * @param position Define the position of the camera
  113541. * @param scene Define the scene the camera belong to
  113542. * @param lockedTarget Define the target of the camera
  113543. */
  113544. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  113545. private _follow;
  113546. /**
  113547. * Attached controls to the current camera.
  113548. * @param element Defines the element the controls should be listened from
  113549. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113550. */
  113551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113552. /**
  113553. * Detach the current controls from the camera.
  113554. * The camera will stop reacting to inputs.
  113555. * @param element Defines the element to stop listening the inputs from
  113556. */
  113557. detachControl(element: HTMLElement): void;
  113558. /** @hidden */
  113559. _checkInputs(): void;
  113560. private _checkLimits;
  113561. /**
  113562. * Gets the camera class name.
  113563. * @returns the class name
  113564. */
  113565. getClassName(): string;
  113566. }
  113567. /**
  113568. * Arc Rotate version of the follow camera.
  113569. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  113570. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113571. */
  113572. export class ArcFollowCamera extends TargetCamera {
  113573. /** The longitudinal angle of the camera */
  113574. alpha: number;
  113575. /** The latitudinal angle of the camera */
  113576. beta: number;
  113577. /** The radius of the camera from its target */
  113578. radius: number;
  113579. /** Define the camera target (the messh it should follow) */
  113580. target: Nullable<AbstractMesh>;
  113581. private _cartesianCoordinates;
  113582. /**
  113583. * Instantiates a new ArcFollowCamera
  113584. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113585. * @param name Define the name of the camera
  113586. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  113587. * @param beta Define the rotation angle of the camera around the elevation axis
  113588. * @param radius Define the radius of the camera from its target point
  113589. * @param target Define the target of the camera
  113590. * @param scene Define the scene the camera belongs to
  113591. */
  113592. constructor(name: string,
  113593. /** The longitudinal angle of the camera */
  113594. alpha: number,
  113595. /** The latitudinal angle of the camera */
  113596. beta: number,
  113597. /** The radius of the camera from its target */
  113598. radius: number,
  113599. /** Define the camera target (the messh it should follow) */
  113600. target: Nullable<AbstractMesh>, scene: Scene);
  113601. private _follow;
  113602. /** @hidden */
  113603. _checkInputs(): void;
  113604. /**
  113605. * Returns the class name of the object.
  113606. * It is mostly used internally for serialization purposes.
  113607. */
  113608. getClassName(): string;
  113609. }
  113610. }
  113611. declare module BABYLON {
  113612. /**
  113613. * Manage the keyboard inputs to control the movement of a follow camera.
  113614. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113615. */
  113616. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  113617. /**
  113618. * Defines the camera the input is attached to.
  113619. */
  113620. camera: FollowCamera;
  113621. /**
  113622. * Defines the list of key codes associated with the up action (increase heightOffset)
  113623. */
  113624. keysHeightOffsetIncr: number[];
  113625. /**
  113626. * Defines the list of key codes associated with the down action (decrease heightOffset)
  113627. */
  113628. keysHeightOffsetDecr: number[];
  113629. /**
  113630. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  113631. */
  113632. keysHeightOffsetModifierAlt: boolean;
  113633. /**
  113634. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  113635. */
  113636. keysHeightOffsetModifierCtrl: boolean;
  113637. /**
  113638. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  113639. */
  113640. keysHeightOffsetModifierShift: boolean;
  113641. /**
  113642. * Defines the list of key codes associated with the left action (increase rotationOffset)
  113643. */
  113644. keysRotationOffsetIncr: number[];
  113645. /**
  113646. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  113647. */
  113648. keysRotationOffsetDecr: number[];
  113649. /**
  113650. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  113651. */
  113652. keysRotationOffsetModifierAlt: boolean;
  113653. /**
  113654. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  113655. */
  113656. keysRotationOffsetModifierCtrl: boolean;
  113657. /**
  113658. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  113659. */
  113660. keysRotationOffsetModifierShift: boolean;
  113661. /**
  113662. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  113663. */
  113664. keysRadiusIncr: number[];
  113665. /**
  113666. * Defines the list of key codes associated with the zoom-out action (increase radius)
  113667. */
  113668. keysRadiusDecr: number[];
  113669. /**
  113670. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  113671. */
  113672. keysRadiusModifierAlt: boolean;
  113673. /**
  113674. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  113675. */
  113676. keysRadiusModifierCtrl: boolean;
  113677. /**
  113678. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  113679. */
  113680. keysRadiusModifierShift: boolean;
  113681. /**
  113682. * Defines the rate of change of heightOffset.
  113683. */
  113684. heightSensibility: number;
  113685. /**
  113686. * Defines the rate of change of rotationOffset.
  113687. */
  113688. rotationSensibility: number;
  113689. /**
  113690. * Defines the rate of change of radius.
  113691. */
  113692. radiusSensibility: number;
  113693. private _keys;
  113694. private _ctrlPressed;
  113695. private _altPressed;
  113696. private _shiftPressed;
  113697. private _onCanvasBlurObserver;
  113698. private _onKeyboardObserver;
  113699. private _engine;
  113700. private _scene;
  113701. /**
  113702. * Attach the input controls to a specific dom element to get the input from.
  113703. * @param element Defines the element the controls should be listened from
  113704. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113705. */
  113706. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113707. /**
  113708. * Detach the current controls from the specified dom element.
  113709. * @param element Defines the element to stop listening the inputs from
  113710. */
  113711. detachControl(element: Nullable<HTMLElement>): void;
  113712. /**
  113713. * Update the current camera state depending on the inputs that have been used this frame.
  113714. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113715. */
  113716. checkInputs(): void;
  113717. /**
  113718. * Gets the class name of the current input.
  113719. * @returns the class name
  113720. */
  113721. getClassName(): string;
  113722. /**
  113723. * Get the friendly name associated with the input class.
  113724. * @returns the input friendly name
  113725. */
  113726. getSimpleName(): string;
  113727. /**
  113728. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113729. * allow modification of the heightOffset value.
  113730. */
  113731. private _modifierHeightOffset;
  113732. /**
  113733. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113734. * allow modification of the rotationOffset value.
  113735. */
  113736. private _modifierRotationOffset;
  113737. /**
  113738. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113739. * allow modification of the radius value.
  113740. */
  113741. private _modifierRadius;
  113742. }
  113743. }
  113744. declare module BABYLON {
  113745. interface FreeCameraInputsManager {
  113746. /**
  113747. * @hidden
  113748. */
  113749. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  113750. /**
  113751. * Add orientation input support to the input manager.
  113752. * @returns the current input manager
  113753. */
  113754. addDeviceOrientation(): FreeCameraInputsManager;
  113755. }
  113756. /**
  113757. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  113758. * Screen rotation is taken into account.
  113759. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113760. */
  113761. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  113762. private _camera;
  113763. private _screenOrientationAngle;
  113764. private _constantTranform;
  113765. private _screenQuaternion;
  113766. private _alpha;
  113767. private _beta;
  113768. private _gamma;
  113769. /**
  113770. * Can be used to detect if a device orientation sensor is available on a device
  113771. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  113772. * @returns a promise that will resolve on orientation change
  113773. */
  113774. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  113775. /**
  113776. * @hidden
  113777. */
  113778. _onDeviceOrientationChangedObservable: Observable<void>;
  113779. /**
  113780. * Instantiates a new input
  113781. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113782. */
  113783. constructor();
  113784. /**
  113785. * Define the camera controlled by the input.
  113786. */
  113787. get camera(): FreeCamera;
  113788. set camera(camera: FreeCamera);
  113789. /**
  113790. * Attach the input controls to a specific dom element to get the input from.
  113791. * @param element Defines the element the controls should be listened from
  113792. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113793. */
  113794. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113795. private _orientationChanged;
  113796. private _deviceOrientation;
  113797. /**
  113798. * Detach the current controls from the specified dom element.
  113799. * @param element Defines the element to stop listening the inputs from
  113800. */
  113801. detachControl(element: Nullable<HTMLElement>): void;
  113802. /**
  113803. * Update the current camera state depending on the inputs that have been used this frame.
  113804. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113805. */
  113806. checkInputs(): void;
  113807. /**
  113808. * Gets the class name of the current intput.
  113809. * @returns the class name
  113810. */
  113811. getClassName(): string;
  113812. /**
  113813. * Get the friendly name associated with the input class.
  113814. * @returns the input friendly name
  113815. */
  113816. getSimpleName(): string;
  113817. }
  113818. }
  113819. declare module BABYLON {
  113820. /**
  113821. * Manage the gamepad inputs to control a free camera.
  113822. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113823. */
  113824. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  113825. /**
  113826. * Define the camera the input is attached to.
  113827. */
  113828. camera: FreeCamera;
  113829. /**
  113830. * Define the Gamepad controlling the input
  113831. */
  113832. gamepad: Nullable<Gamepad>;
  113833. /**
  113834. * Defines the gamepad rotation sensiblity.
  113835. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113836. */
  113837. gamepadAngularSensibility: number;
  113838. /**
  113839. * Defines the gamepad move sensiblity.
  113840. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113841. */
  113842. gamepadMoveSensibility: number;
  113843. private _yAxisScale;
  113844. /**
  113845. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  113846. */
  113847. get invertYAxis(): boolean;
  113848. set invertYAxis(value: boolean);
  113849. private _onGamepadConnectedObserver;
  113850. private _onGamepadDisconnectedObserver;
  113851. private _cameraTransform;
  113852. private _deltaTransform;
  113853. private _vector3;
  113854. private _vector2;
  113855. /**
  113856. * Attach the input controls to a specific dom element to get the input from.
  113857. * @param element Defines the element the controls should be listened from
  113858. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113859. */
  113860. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113861. /**
  113862. * Detach the current controls from the specified dom element.
  113863. * @param element Defines the element to stop listening the inputs from
  113864. */
  113865. detachControl(element: Nullable<HTMLElement>): void;
  113866. /**
  113867. * Update the current camera state depending on the inputs that have been used this frame.
  113868. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113869. */
  113870. checkInputs(): void;
  113871. /**
  113872. * Gets the class name of the current intput.
  113873. * @returns the class name
  113874. */
  113875. getClassName(): string;
  113876. /**
  113877. * Get the friendly name associated with the input class.
  113878. * @returns the input friendly name
  113879. */
  113880. getSimpleName(): string;
  113881. }
  113882. }
  113883. declare module BABYLON {
  113884. /**
  113885. * Defines the potential axis of a Joystick
  113886. */
  113887. export enum JoystickAxis {
  113888. /** X axis */
  113889. X = 0,
  113890. /** Y axis */
  113891. Y = 1,
  113892. /** Z axis */
  113893. Z = 2
  113894. }
  113895. /**
  113896. * Class used to define virtual joystick (used in touch mode)
  113897. */
  113898. export class VirtualJoystick {
  113899. /**
  113900. * Gets or sets a boolean indicating that left and right values must be inverted
  113901. */
  113902. reverseLeftRight: boolean;
  113903. /**
  113904. * Gets or sets a boolean indicating that up and down values must be inverted
  113905. */
  113906. reverseUpDown: boolean;
  113907. /**
  113908. * Gets the offset value for the position (ie. the change of the position value)
  113909. */
  113910. deltaPosition: Vector3;
  113911. /**
  113912. * Gets a boolean indicating if the virtual joystick was pressed
  113913. */
  113914. pressed: boolean;
  113915. /**
  113916. * Canvas the virtual joystick will render onto, default z-index of this is 5
  113917. */
  113918. static Canvas: Nullable<HTMLCanvasElement>;
  113919. private static _globalJoystickIndex;
  113920. private static vjCanvasContext;
  113921. private static vjCanvasWidth;
  113922. private static vjCanvasHeight;
  113923. private static halfWidth;
  113924. private _action;
  113925. private _axisTargetedByLeftAndRight;
  113926. private _axisTargetedByUpAndDown;
  113927. private _joystickSensibility;
  113928. private _inversedSensibility;
  113929. private _joystickPointerID;
  113930. private _joystickColor;
  113931. private _joystickPointerPos;
  113932. private _joystickPreviousPointerPos;
  113933. private _joystickPointerStartPos;
  113934. private _deltaJoystickVector;
  113935. private _leftJoystick;
  113936. private _touches;
  113937. private _onPointerDownHandlerRef;
  113938. private _onPointerMoveHandlerRef;
  113939. private _onPointerUpHandlerRef;
  113940. private _onResize;
  113941. /**
  113942. * Creates a new virtual joystick
  113943. * @param leftJoystick defines that the joystick is for left hand (false by default)
  113944. */
  113945. constructor(leftJoystick?: boolean);
  113946. /**
  113947. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  113948. * @param newJoystickSensibility defines the new sensibility
  113949. */
  113950. setJoystickSensibility(newJoystickSensibility: number): void;
  113951. private _onPointerDown;
  113952. private _onPointerMove;
  113953. private _onPointerUp;
  113954. /**
  113955. * Change the color of the virtual joystick
  113956. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  113957. */
  113958. setJoystickColor(newColor: string): void;
  113959. /**
  113960. * Defines a callback to call when the joystick is touched
  113961. * @param action defines the callback
  113962. */
  113963. setActionOnTouch(action: () => any): void;
  113964. /**
  113965. * Defines which axis you'd like to control for left & right
  113966. * @param axis defines the axis to use
  113967. */
  113968. setAxisForLeftRight(axis: JoystickAxis): void;
  113969. /**
  113970. * Defines which axis you'd like to control for up & down
  113971. * @param axis defines the axis to use
  113972. */
  113973. setAxisForUpDown(axis: JoystickAxis): void;
  113974. private _drawVirtualJoystick;
  113975. /**
  113976. * Release internal HTML canvas
  113977. */
  113978. releaseCanvas(): void;
  113979. }
  113980. }
  113981. declare module BABYLON {
  113982. interface FreeCameraInputsManager {
  113983. /**
  113984. * Add virtual joystick input support to the input manager.
  113985. * @returns the current input manager
  113986. */
  113987. addVirtualJoystick(): FreeCameraInputsManager;
  113988. }
  113989. /**
  113990. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  113991. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113992. */
  113993. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  113994. /**
  113995. * Defines the camera the input is attached to.
  113996. */
  113997. camera: FreeCamera;
  113998. private _leftjoystick;
  113999. private _rightjoystick;
  114000. /**
  114001. * Gets the left stick of the virtual joystick.
  114002. * @returns The virtual Joystick
  114003. */
  114004. getLeftJoystick(): VirtualJoystick;
  114005. /**
  114006. * Gets the right stick of the virtual joystick.
  114007. * @returns The virtual Joystick
  114008. */
  114009. getRightJoystick(): VirtualJoystick;
  114010. /**
  114011. * Update the current camera state depending on the inputs that have been used this frame.
  114012. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114013. */
  114014. checkInputs(): void;
  114015. /**
  114016. * Attach the input controls to a specific dom element to get the input from.
  114017. * @param element Defines the element the controls should be listened from
  114018. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114019. */
  114020. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114021. /**
  114022. * Detach the current controls from the specified dom element.
  114023. * @param element Defines the element to stop listening the inputs from
  114024. */
  114025. detachControl(element: Nullable<HTMLElement>): void;
  114026. /**
  114027. * Gets the class name of the current intput.
  114028. * @returns the class name
  114029. */
  114030. getClassName(): string;
  114031. /**
  114032. * Get the friendly name associated with the input class.
  114033. * @returns the input friendly name
  114034. */
  114035. getSimpleName(): string;
  114036. }
  114037. }
  114038. declare module BABYLON {
  114039. /**
  114040. * This represents a FPS type of camera controlled by touch.
  114041. * This is like a universal camera minus the Gamepad controls.
  114042. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114043. */
  114044. export class TouchCamera extends FreeCamera {
  114045. /**
  114046. * Defines the touch sensibility for rotation.
  114047. * The higher the faster.
  114048. */
  114049. get touchAngularSensibility(): number;
  114050. set touchAngularSensibility(value: number);
  114051. /**
  114052. * Defines the touch sensibility for move.
  114053. * The higher the faster.
  114054. */
  114055. get touchMoveSensibility(): number;
  114056. set touchMoveSensibility(value: number);
  114057. /**
  114058. * Instantiates a new touch camera.
  114059. * This represents a FPS type of camera controlled by touch.
  114060. * This is like a universal camera minus the Gamepad controls.
  114061. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114062. * @param name Define the name of the camera in the scene
  114063. * @param position Define the start position of the camera in the scene
  114064. * @param scene Define the scene the camera belongs to
  114065. */
  114066. constructor(name: string, position: Vector3, scene: Scene);
  114067. /**
  114068. * Gets the current object class name.
  114069. * @return the class name
  114070. */
  114071. getClassName(): string;
  114072. /** @hidden */
  114073. _setupInputs(): void;
  114074. }
  114075. }
  114076. declare module BABYLON {
  114077. /**
  114078. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  114079. * being tilted forward or back and left or right.
  114080. */
  114081. export class DeviceOrientationCamera extends FreeCamera {
  114082. private _initialQuaternion;
  114083. private _quaternionCache;
  114084. private _tmpDragQuaternion;
  114085. private _disablePointerInputWhenUsingDeviceOrientation;
  114086. /**
  114087. * Creates a new device orientation camera
  114088. * @param name The name of the camera
  114089. * @param position The start position camera
  114090. * @param scene The scene the camera belongs to
  114091. */
  114092. constructor(name: string, position: Vector3, scene: Scene);
  114093. /**
  114094. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  114095. */
  114096. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  114097. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  114098. private _dragFactor;
  114099. /**
  114100. * Enabled turning on the y axis when the orientation sensor is active
  114101. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  114102. */
  114103. enableHorizontalDragging(dragFactor?: number): void;
  114104. /**
  114105. * Gets the current instance class name ("DeviceOrientationCamera").
  114106. * This helps avoiding instanceof at run time.
  114107. * @returns the class name
  114108. */
  114109. getClassName(): string;
  114110. /**
  114111. * @hidden
  114112. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  114113. */
  114114. _checkInputs(): void;
  114115. /**
  114116. * Reset the camera to its default orientation on the specified axis only.
  114117. * @param axis The axis to reset
  114118. */
  114119. resetToCurrentRotation(axis?: Axis): void;
  114120. }
  114121. }
  114122. declare module BABYLON {
  114123. /**
  114124. * Defines supported buttons for XBox360 compatible gamepads
  114125. */
  114126. export enum Xbox360Button {
  114127. /** A */
  114128. A = 0,
  114129. /** B */
  114130. B = 1,
  114131. /** X */
  114132. X = 2,
  114133. /** Y */
  114134. Y = 3,
  114135. /** Start */
  114136. Start = 4,
  114137. /** Back */
  114138. Back = 5,
  114139. /** Left button */
  114140. LB = 6,
  114141. /** Right button */
  114142. RB = 7,
  114143. /** Left stick */
  114144. LeftStick = 8,
  114145. /** Right stick */
  114146. RightStick = 9
  114147. }
  114148. /** Defines values for XBox360 DPad */
  114149. export enum Xbox360Dpad {
  114150. /** Up */
  114151. Up = 0,
  114152. /** Down */
  114153. Down = 1,
  114154. /** Left */
  114155. Left = 2,
  114156. /** Right */
  114157. Right = 3
  114158. }
  114159. /**
  114160. * Defines a XBox360 gamepad
  114161. */
  114162. export class Xbox360Pad extends Gamepad {
  114163. private _leftTrigger;
  114164. private _rightTrigger;
  114165. private _onlefttriggerchanged;
  114166. private _onrighttriggerchanged;
  114167. private _onbuttondown;
  114168. private _onbuttonup;
  114169. private _ondpaddown;
  114170. private _ondpadup;
  114171. /** Observable raised when a button is pressed */
  114172. onButtonDownObservable: Observable<Xbox360Button>;
  114173. /** Observable raised when a button is released */
  114174. onButtonUpObservable: Observable<Xbox360Button>;
  114175. /** Observable raised when a pad is pressed */
  114176. onPadDownObservable: Observable<Xbox360Dpad>;
  114177. /** Observable raised when a pad is released */
  114178. onPadUpObservable: Observable<Xbox360Dpad>;
  114179. private _buttonA;
  114180. private _buttonB;
  114181. private _buttonX;
  114182. private _buttonY;
  114183. private _buttonBack;
  114184. private _buttonStart;
  114185. private _buttonLB;
  114186. private _buttonRB;
  114187. private _buttonLeftStick;
  114188. private _buttonRightStick;
  114189. private _dPadUp;
  114190. private _dPadDown;
  114191. private _dPadLeft;
  114192. private _dPadRight;
  114193. private _isXboxOnePad;
  114194. /**
  114195. * Creates a new XBox360 gamepad object
  114196. * @param id defines the id of this gamepad
  114197. * @param index defines its index
  114198. * @param gamepad defines the internal HTML gamepad object
  114199. * @param xboxOne defines if it is a XBox One gamepad
  114200. */
  114201. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  114202. /**
  114203. * Defines the callback to call when left trigger is pressed
  114204. * @param callback defines the callback to use
  114205. */
  114206. onlefttriggerchanged(callback: (value: number) => void): void;
  114207. /**
  114208. * Defines the callback to call when right trigger is pressed
  114209. * @param callback defines the callback to use
  114210. */
  114211. onrighttriggerchanged(callback: (value: number) => void): void;
  114212. /**
  114213. * Gets the left trigger value
  114214. */
  114215. get leftTrigger(): number;
  114216. /**
  114217. * Sets the left trigger value
  114218. */
  114219. set leftTrigger(newValue: number);
  114220. /**
  114221. * Gets the right trigger value
  114222. */
  114223. get rightTrigger(): number;
  114224. /**
  114225. * Sets the right trigger value
  114226. */
  114227. set rightTrigger(newValue: number);
  114228. /**
  114229. * Defines the callback to call when a button is pressed
  114230. * @param callback defines the callback to use
  114231. */
  114232. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  114233. /**
  114234. * Defines the callback to call when a button is released
  114235. * @param callback defines the callback to use
  114236. */
  114237. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  114238. /**
  114239. * Defines the callback to call when a pad is pressed
  114240. * @param callback defines the callback to use
  114241. */
  114242. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  114243. /**
  114244. * Defines the callback to call when a pad is released
  114245. * @param callback defines the callback to use
  114246. */
  114247. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  114248. private _setButtonValue;
  114249. private _setDPadValue;
  114250. /**
  114251. * Gets the value of the `A` button
  114252. */
  114253. get buttonA(): number;
  114254. /**
  114255. * Sets the value of the `A` button
  114256. */
  114257. set buttonA(value: number);
  114258. /**
  114259. * Gets the value of the `B` button
  114260. */
  114261. get buttonB(): number;
  114262. /**
  114263. * Sets the value of the `B` button
  114264. */
  114265. set buttonB(value: number);
  114266. /**
  114267. * Gets the value of the `X` button
  114268. */
  114269. get buttonX(): number;
  114270. /**
  114271. * Sets the value of the `X` button
  114272. */
  114273. set buttonX(value: number);
  114274. /**
  114275. * Gets the value of the `Y` button
  114276. */
  114277. get buttonY(): number;
  114278. /**
  114279. * Sets the value of the `Y` button
  114280. */
  114281. set buttonY(value: number);
  114282. /**
  114283. * Gets the value of the `Start` button
  114284. */
  114285. get buttonStart(): number;
  114286. /**
  114287. * Sets the value of the `Start` button
  114288. */
  114289. set buttonStart(value: number);
  114290. /**
  114291. * Gets the value of the `Back` button
  114292. */
  114293. get buttonBack(): number;
  114294. /**
  114295. * Sets the value of the `Back` button
  114296. */
  114297. set buttonBack(value: number);
  114298. /**
  114299. * Gets the value of the `Left` button
  114300. */
  114301. get buttonLB(): number;
  114302. /**
  114303. * Sets the value of the `Left` button
  114304. */
  114305. set buttonLB(value: number);
  114306. /**
  114307. * Gets the value of the `Right` button
  114308. */
  114309. get buttonRB(): number;
  114310. /**
  114311. * Sets the value of the `Right` button
  114312. */
  114313. set buttonRB(value: number);
  114314. /**
  114315. * Gets the value of the Left joystick
  114316. */
  114317. get buttonLeftStick(): number;
  114318. /**
  114319. * Sets the value of the Left joystick
  114320. */
  114321. set buttonLeftStick(value: number);
  114322. /**
  114323. * Gets the value of the Right joystick
  114324. */
  114325. get buttonRightStick(): number;
  114326. /**
  114327. * Sets the value of the Right joystick
  114328. */
  114329. set buttonRightStick(value: number);
  114330. /**
  114331. * Gets the value of D-pad up
  114332. */
  114333. get dPadUp(): number;
  114334. /**
  114335. * Sets the value of D-pad up
  114336. */
  114337. set dPadUp(value: number);
  114338. /**
  114339. * Gets the value of D-pad down
  114340. */
  114341. get dPadDown(): number;
  114342. /**
  114343. * Sets the value of D-pad down
  114344. */
  114345. set dPadDown(value: number);
  114346. /**
  114347. * Gets the value of D-pad left
  114348. */
  114349. get dPadLeft(): number;
  114350. /**
  114351. * Sets the value of D-pad left
  114352. */
  114353. set dPadLeft(value: number);
  114354. /**
  114355. * Gets the value of D-pad right
  114356. */
  114357. get dPadRight(): number;
  114358. /**
  114359. * Sets the value of D-pad right
  114360. */
  114361. set dPadRight(value: number);
  114362. /**
  114363. * Force the gamepad to synchronize with device values
  114364. */
  114365. update(): void;
  114366. /**
  114367. * Disposes the gamepad
  114368. */
  114369. dispose(): void;
  114370. }
  114371. }
  114372. declare module BABYLON {
  114373. /**
  114374. * Defines supported buttons for DualShock compatible gamepads
  114375. */
  114376. export enum DualShockButton {
  114377. /** Cross */
  114378. Cross = 0,
  114379. /** Circle */
  114380. Circle = 1,
  114381. /** Square */
  114382. Square = 2,
  114383. /** Triangle */
  114384. Triangle = 3,
  114385. /** Options */
  114386. Options = 4,
  114387. /** Share */
  114388. Share = 5,
  114389. /** L1 */
  114390. L1 = 6,
  114391. /** R1 */
  114392. R1 = 7,
  114393. /** Left stick */
  114394. LeftStick = 8,
  114395. /** Right stick */
  114396. RightStick = 9
  114397. }
  114398. /** Defines values for DualShock DPad */
  114399. export enum DualShockDpad {
  114400. /** Up */
  114401. Up = 0,
  114402. /** Down */
  114403. Down = 1,
  114404. /** Left */
  114405. Left = 2,
  114406. /** Right */
  114407. Right = 3
  114408. }
  114409. /**
  114410. * Defines a DualShock gamepad
  114411. */
  114412. export class DualShockPad extends Gamepad {
  114413. private _leftTrigger;
  114414. private _rightTrigger;
  114415. private _onlefttriggerchanged;
  114416. private _onrighttriggerchanged;
  114417. private _onbuttondown;
  114418. private _onbuttonup;
  114419. private _ondpaddown;
  114420. private _ondpadup;
  114421. /** Observable raised when a button is pressed */
  114422. onButtonDownObservable: Observable<DualShockButton>;
  114423. /** Observable raised when a button is released */
  114424. onButtonUpObservable: Observable<DualShockButton>;
  114425. /** Observable raised when a pad is pressed */
  114426. onPadDownObservable: Observable<DualShockDpad>;
  114427. /** Observable raised when a pad is released */
  114428. onPadUpObservable: Observable<DualShockDpad>;
  114429. private _buttonCross;
  114430. private _buttonCircle;
  114431. private _buttonSquare;
  114432. private _buttonTriangle;
  114433. private _buttonShare;
  114434. private _buttonOptions;
  114435. private _buttonL1;
  114436. private _buttonR1;
  114437. private _buttonLeftStick;
  114438. private _buttonRightStick;
  114439. private _dPadUp;
  114440. private _dPadDown;
  114441. private _dPadLeft;
  114442. private _dPadRight;
  114443. /**
  114444. * Creates a new DualShock gamepad object
  114445. * @param id defines the id of this gamepad
  114446. * @param index defines its index
  114447. * @param gamepad defines the internal HTML gamepad object
  114448. */
  114449. constructor(id: string, index: number, gamepad: any);
  114450. /**
  114451. * Defines the callback to call when left trigger is pressed
  114452. * @param callback defines the callback to use
  114453. */
  114454. onlefttriggerchanged(callback: (value: number) => void): void;
  114455. /**
  114456. * Defines the callback to call when right trigger is pressed
  114457. * @param callback defines the callback to use
  114458. */
  114459. onrighttriggerchanged(callback: (value: number) => void): void;
  114460. /**
  114461. * Gets the left trigger value
  114462. */
  114463. get leftTrigger(): number;
  114464. /**
  114465. * Sets the left trigger value
  114466. */
  114467. set leftTrigger(newValue: number);
  114468. /**
  114469. * Gets the right trigger value
  114470. */
  114471. get rightTrigger(): number;
  114472. /**
  114473. * Sets the right trigger value
  114474. */
  114475. set rightTrigger(newValue: number);
  114476. /**
  114477. * Defines the callback to call when a button is pressed
  114478. * @param callback defines the callback to use
  114479. */
  114480. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  114481. /**
  114482. * Defines the callback to call when a button is released
  114483. * @param callback defines the callback to use
  114484. */
  114485. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  114486. /**
  114487. * Defines the callback to call when a pad is pressed
  114488. * @param callback defines the callback to use
  114489. */
  114490. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  114491. /**
  114492. * Defines the callback to call when a pad is released
  114493. * @param callback defines the callback to use
  114494. */
  114495. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  114496. private _setButtonValue;
  114497. private _setDPadValue;
  114498. /**
  114499. * Gets the value of the `Cross` button
  114500. */
  114501. get buttonCross(): number;
  114502. /**
  114503. * Sets the value of the `Cross` button
  114504. */
  114505. set buttonCross(value: number);
  114506. /**
  114507. * Gets the value of the `Circle` button
  114508. */
  114509. get buttonCircle(): number;
  114510. /**
  114511. * Sets the value of the `Circle` button
  114512. */
  114513. set buttonCircle(value: number);
  114514. /**
  114515. * Gets the value of the `Square` button
  114516. */
  114517. get buttonSquare(): number;
  114518. /**
  114519. * Sets the value of the `Square` button
  114520. */
  114521. set buttonSquare(value: number);
  114522. /**
  114523. * Gets the value of the `Triangle` button
  114524. */
  114525. get buttonTriangle(): number;
  114526. /**
  114527. * Sets the value of the `Triangle` button
  114528. */
  114529. set buttonTriangle(value: number);
  114530. /**
  114531. * Gets the value of the `Options` button
  114532. */
  114533. get buttonOptions(): number;
  114534. /**
  114535. * Sets the value of the `Options` button
  114536. */
  114537. set buttonOptions(value: number);
  114538. /**
  114539. * Gets the value of the `Share` button
  114540. */
  114541. get buttonShare(): number;
  114542. /**
  114543. * Sets the value of the `Share` button
  114544. */
  114545. set buttonShare(value: number);
  114546. /**
  114547. * Gets the value of the `L1` button
  114548. */
  114549. get buttonL1(): number;
  114550. /**
  114551. * Sets the value of the `L1` button
  114552. */
  114553. set buttonL1(value: number);
  114554. /**
  114555. * Gets the value of the `R1` button
  114556. */
  114557. get buttonR1(): number;
  114558. /**
  114559. * Sets the value of the `R1` button
  114560. */
  114561. set buttonR1(value: number);
  114562. /**
  114563. * Gets the value of the Left joystick
  114564. */
  114565. get buttonLeftStick(): number;
  114566. /**
  114567. * Sets the value of the Left joystick
  114568. */
  114569. set buttonLeftStick(value: number);
  114570. /**
  114571. * Gets the value of the Right joystick
  114572. */
  114573. get buttonRightStick(): number;
  114574. /**
  114575. * Sets the value of the Right joystick
  114576. */
  114577. set buttonRightStick(value: number);
  114578. /**
  114579. * Gets the value of D-pad up
  114580. */
  114581. get dPadUp(): number;
  114582. /**
  114583. * Sets the value of D-pad up
  114584. */
  114585. set dPadUp(value: number);
  114586. /**
  114587. * Gets the value of D-pad down
  114588. */
  114589. get dPadDown(): number;
  114590. /**
  114591. * Sets the value of D-pad down
  114592. */
  114593. set dPadDown(value: number);
  114594. /**
  114595. * Gets the value of D-pad left
  114596. */
  114597. get dPadLeft(): number;
  114598. /**
  114599. * Sets the value of D-pad left
  114600. */
  114601. set dPadLeft(value: number);
  114602. /**
  114603. * Gets the value of D-pad right
  114604. */
  114605. get dPadRight(): number;
  114606. /**
  114607. * Sets the value of D-pad right
  114608. */
  114609. set dPadRight(value: number);
  114610. /**
  114611. * Force the gamepad to synchronize with device values
  114612. */
  114613. update(): void;
  114614. /**
  114615. * Disposes the gamepad
  114616. */
  114617. dispose(): void;
  114618. }
  114619. }
  114620. declare module BABYLON {
  114621. /**
  114622. * Manager for handling gamepads
  114623. */
  114624. export class GamepadManager {
  114625. private _scene?;
  114626. private _babylonGamepads;
  114627. private _oneGamepadConnected;
  114628. /** @hidden */
  114629. _isMonitoring: boolean;
  114630. private _gamepadEventSupported;
  114631. private _gamepadSupport?;
  114632. /**
  114633. * observable to be triggered when the gamepad controller has been connected
  114634. */
  114635. onGamepadConnectedObservable: Observable<Gamepad>;
  114636. /**
  114637. * observable to be triggered when the gamepad controller has been disconnected
  114638. */
  114639. onGamepadDisconnectedObservable: Observable<Gamepad>;
  114640. private _onGamepadConnectedEvent;
  114641. private _onGamepadDisconnectedEvent;
  114642. /**
  114643. * Initializes the gamepad manager
  114644. * @param _scene BabylonJS scene
  114645. */
  114646. constructor(_scene?: Scene | undefined);
  114647. /**
  114648. * The gamepads in the game pad manager
  114649. */
  114650. get gamepads(): Gamepad[];
  114651. /**
  114652. * Get the gamepad controllers based on type
  114653. * @param type The type of gamepad controller
  114654. * @returns Nullable gamepad
  114655. */
  114656. getGamepadByType(type?: number): Nullable<Gamepad>;
  114657. /**
  114658. * Disposes the gamepad manager
  114659. */
  114660. dispose(): void;
  114661. private _addNewGamepad;
  114662. private _startMonitoringGamepads;
  114663. private _stopMonitoringGamepads;
  114664. /** @hidden */
  114665. _checkGamepadsStatus(): void;
  114666. private _updateGamepadObjects;
  114667. }
  114668. }
  114669. declare module BABYLON {
  114670. interface Scene {
  114671. /** @hidden */
  114672. _gamepadManager: Nullable<GamepadManager>;
  114673. /**
  114674. * Gets the gamepad manager associated with the scene
  114675. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  114676. */
  114677. gamepadManager: GamepadManager;
  114678. }
  114679. /**
  114680. * Interface representing a free camera inputs manager
  114681. */
  114682. interface FreeCameraInputsManager {
  114683. /**
  114684. * Adds gamepad input support to the FreeCameraInputsManager.
  114685. * @returns the FreeCameraInputsManager
  114686. */
  114687. addGamepad(): FreeCameraInputsManager;
  114688. }
  114689. /**
  114690. * Interface representing an arc rotate camera inputs manager
  114691. */
  114692. interface ArcRotateCameraInputsManager {
  114693. /**
  114694. * Adds gamepad input support to the ArcRotateCamera InputManager.
  114695. * @returns the camera inputs manager
  114696. */
  114697. addGamepad(): ArcRotateCameraInputsManager;
  114698. }
  114699. /**
  114700. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  114701. */
  114702. export class GamepadSystemSceneComponent implements ISceneComponent {
  114703. /**
  114704. * The component name helpfull to identify the component in the list of scene components.
  114705. */
  114706. readonly name: string;
  114707. /**
  114708. * The scene the component belongs to.
  114709. */
  114710. scene: Scene;
  114711. /**
  114712. * Creates a new instance of the component for the given scene
  114713. * @param scene Defines the scene to register the component in
  114714. */
  114715. constructor(scene: Scene);
  114716. /**
  114717. * Registers the component in a given scene
  114718. */
  114719. register(): void;
  114720. /**
  114721. * Rebuilds the elements related to this component in case of
  114722. * context lost for instance.
  114723. */
  114724. rebuild(): void;
  114725. /**
  114726. * Disposes the component and the associated ressources
  114727. */
  114728. dispose(): void;
  114729. private _beforeCameraUpdate;
  114730. }
  114731. }
  114732. declare module BABYLON {
  114733. /**
  114734. * 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,
  114735. * which still works and will still be found in many Playgrounds.
  114736. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114737. */
  114738. export class UniversalCamera extends TouchCamera {
  114739. /**
  114740. * Defines the gamepad rotation sensiblity.
  114741. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114742. */
  114743. get gamepadAngularSensibility(): number;
  114744. set gamepadAngularSensibility(value: number);
  114745. /**
  114746. * Defines the gamepad move sensiblity.
  114747. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114748. */
  114749. get gamepadMoveSensibility(): number;
  114750. set gamepadMoveSensibility(value: number);
  114751. /**
  114752. * 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,
  114753. * which still works and will still be found in many Playgrounds.
  114754. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114755. * @param name Define the name of the camera in the scene
  114756. * @param position Define the start position of the camera in the scene
  114757. * @param scene Define the scene the camera belongs to
  114758. */
  114759. constructor(name: string, position: Vector3, scene: Scene);
  114760. /**
  114761. * Gets the current object class name.
  114762. * @return the class name
  114763. */
  114764. getClassName(): string;
  114765. }
  114766. }
  114767. declare module BABYLON {
  114768. /**
  114769. * This represents a FPS type of camera. This is only here for back compat purpose.
  114770. * Please use the UniversalCamera instead as both are identical.
  114771. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114772. */
  114773. export class GamepadCamera extends UniversalCamera {
  114774. /**
  114775. * Instantiates a new Gamepad Camera
  114776. * This represents a FPS type of camera. This is only here for back compat purpose.
  114777. * Please use the UniversalCamera instead as both are identical.
  114778. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114779. * @param name Define the name of the camera in the scene
  114780. * @param position Define the start position of the camera in the scene
  114781. * @param scene Define the scene the camera belongs to
  114782. */
  114783. constructor(name: string, position: Vector3, scene: Scene);
  114784. /**
  114785. * Gets the current object class name.
  114786. * @return the class name
  114787. */
  114788. getClassName(): string;
  114789. }
  114790. }
  114791. declare module BABYLON {
  114792. /** @hidden */
  114793. export var passPixelShader: {
  114794. name: string;
  114795. shader: string;
  114796. };
  114797. }
  114798. declare module BABYLON {
  114799. /** @hidden */
  114800. export var passCubePixelShader: {
  114801. name: string;
  114802. shader: string;
  114803. };
  114804. }
  114805. declare module BABYLON {
  114806. /**
  114807. * PassPostProcess which produces an output the same as it's input
  114808. */
  114809. export class PassPostProcess extends PostProcess {
  114810. /**
  114811. * Creates the PassPostProcess
  114812. * @param name The name of the effect.
  114813. * @param options The required width/height ratio to downsize to before computing the render pass.
  114814. * @param camera The camera to apply the render pass to.
  114815. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114816. * @param engine The engine which the post process will be applied. (default: current engine)
  114817. * @param reusable If the post process can be reused on the same frame. (default: false)
  114818. * @param textureType The type of texture to be used when performing the post processing.
  114819. * @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)
  114820. */
  114821. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114822. }
  114823. /**
  114824. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  114825. */
  114826. export class PassCubePostProcess extends PostProcess {
  114827. private _face;
  114828. /**
  114829. * Gets or sets the cube face to display.
  114830. * * 0 is +X
  114831. * * 1 is -X
  114832. * * 2 is +Y
  114833. * * 3 is -Y
  114834. * * 4 is +Z
  114835. * * 5 is -Z
  114836. */
  114837. get face(): number;
  114838. set face(value: number);
  114839. /**
  114840. * Creates the PassCubePostProcess
  114841. * @param name The name of the effect.
  114842. * @param options The required width/height ratio to downsize to before computing the render pass.
  114843. * @param camera The camera to apply the render pass to.
  114844. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114845. * @param engine The engine which the post process will be applied. (default: current engine)
  114846. * @param reusable If the post process can be reused on the same frame. (default: false)
  114847. * @param textureType The type of texture to be used when performing the post processing.
  114848. * @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)
  114849. */
  114850. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114851. }
  114852. }
  114853. declare module BABYLON {
  114854. /** @hidden */
  114855. export var anaglyphPixelShader: {
  114856. name: string;
  114857. shader: string;
  114858. };
  114859. }
  114860. declare module BABYLON {
  114861. /**
  114862. * Postprocess used to generate anaglyphic rendering
  114863. */
  114864. export class AnaglyphPostProcess extends PostProcess {
  114865. private _passedProcess;
  114866. /**
  114867. * Creates a new AnaglyphPostProcess
  114868. * @param name defines postprocess name
  114869. * @param options defines creation options or target ratio scale
  114870. * @param rigCameras defines cameras using this postprocess
  114871. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  114872. * @param engine defines hosting engine
  114873. * @param reusable defines if the postprocess will be reused multiple times per frame
  114874. */
  114875. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  114876. }
  114877. }
  114878. declare module BABYLON {
  114879. /**
  114880. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  114881. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114882. */
  114883. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  114884. /**
  114885. * Creates a new AnaglyphArcRotateCamera
  114886. * @param name defines camera name
  114887. * @param alpha defines alpha angle (in radians)
  114888. * @param beta defines beta angle (in radians)
  114889. * @param radius defines radius
  114890. * @param target defines camera target
  114891. * @param interaxialDistance defines distance between each color axis
  114892. * @param scene defines the hosting scene
  114893. */
  114894. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  114895. /**
  114896. * Gets camera class name
  114897. * @returns AnaglyphArcRotateCamera
  114898. */
  114899. getClassName(): string;
  114900. }
  114901. }
  114902. declare module BABYLON {
  114903. /**
  114904. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  114905. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114906. */
  114907. export class AnaglyphFreeCamera extends FreeCamera {
  114908. /**
  114909. * Creates a new AnaglyphFreeCamera
  114910. * @param name defines camera name
  114911. * @param position defines initial position
  114912. * @param interaxialDistance defines distance between each color axis
  114913. * @param scene defines the hosting scene
  114914. */
  114915. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114916. /**
  114917. * Gets camera class name
  114918. * @returns AnaglyphFreeCamera
  114919. */
  114920. getClassName(): string;
  114921. }
  114922. }
  114923. declare module BABYLON {
  114924. /**
  114925. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  114926. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114927. */
  114928. export class AnaglyphGamepadCamera extends GamepadCamera {
  114929. /**
  114930. * Creates a new AnaglyphGamepadCamera
  114931. * @param name defines camera name
  114932. * @param position defines initial position
  114933. * @param interaxialDistance defines distance between each color axis
  114934. * @param scene defines the hosting scene
  114935. */
  114936. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114937. /**
  114938. * Gets camera class name
  114939. * @returns AnaglyphGamepadCamera
  114940. */
  114941. getClassName(): string;
  114942. }
  114943. }
  114944. declare module BABYLON {
  114945. /**
  114946. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  114947. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  114948. */
  114949. export class AnaglyphUniversalCamera extends UniversalCamera {
  114950. /**
  114951. * Creates a new AnaglyphUniversalCamera
  114952. * @param name defines camera name
  114953. * @param position defines initial position
  114954. * @param interaxialDistance defines distance between each color axis
  114955. * @param scene defines the hosting scene
  114956. */
  114957. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  114958. /**
  114959. * Gets camera class name
  114960. * @returns AnaglyphUniversalCamera
  114961. */
  114962. getClassName(): string;
  114963. }
  114964. }
  114965. declare module BABYLON {
  114966. /** @hidden */
  114967. export var stereoscopicInterlacePixelShader: {
  114968. name: string;
  114969. shader: string;
  114970. };
  114971. }
  114972. declare module BABYLON {
  114973. /**
  114974. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  114975. */
  114976. export class StereoscopicInterlacePostProcessI extends PostProcess {
  114977. private _stepSize;
  114978. private _passedProcess;
  114979. /**
  114980. * Initializes a StereoscopicInterlacePostProcessI
  114981. * @param name The name of the effect.
  114982. * @param rigCameras The rig cameras to be appled to the post process
  114983. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  114984. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  114985. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114986. * @param engine The engine which the post process will be applied. (default: current engine)
  114987. * @param reusable If the post process can be reused on the same frame. (default: false)
  114988. */
  114989. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  114990. }
  114991. /**
  114992. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  114993. */
  114994. export class StereoscopicInterlacePostProcess extends PostProcess {
  114995. private _stepSize;
  114996. private _passedProcess;
  114997. /**
  114998. * Initializes a StereoscopicInterlacePostProcess
  114999. * @param name The name of the effect.
  115000. * @param rigCameras The rig cameras to be appled to the post process
  115001. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  115002. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115003. * @param engine The engine which the post process will be applied. (default: current engine)
  115004. * @param reusable If the post process can be reused on the same frame. (default: false)
  115005. */
  115006. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115007. }
  115008. }
  115009. declare module BABYLON {
  115010. /**
  115011. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  115012. * @see http://doc.babylonjs.com/features/cameras
  115013. */
  115014. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  115015. /**
  115016. * Creates a new StereoscopicArcRotateCamera
  115017. * @param name defines camera name
  115018. * @param alpha defines alpha angle (in radians)
  115019. * @param beta defines beta angle (in radians)
  115020. * @param radius defines radius
  115021. * @param target defines camera target
  115022. * @param interaxialDistance defines distance between each color axis
  115023. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115024. * @param scene defines the hosting scene
  115025. */
  115026. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115027. /**
  115028. * Gets camera class name
  115029. * @returns StereoscopicArcRotateCamera
  115030. */
  115031. getClassName(): string;
  115032. }
  115033. }
  115034. declare module BABYLON {
  115035. /**
  115036. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  115037. * @see http://doc.babylonjs.com/features/cameras
  115038. */
  115039. export class StereoscopicFreeCamera extends FreeCamera {
  115040. /**
  115041. * Creates a new StereoscopicFreeCamera
  115042. * @param name defines camera name
  115043. * @param position defines initial position
  115044. * @param interaxialDistance defines distance between each color axis
  115045. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115046. * @param scene defines the hosting scene
  115047. */
  115048. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115049. /**
  115050. * Gets camera class name
  115051. * @returns StereoscopicFreeCamera
  115052. */
  115053. getClassName(): string;
  115054. }
  115055. }
  115056. declare module BABYLON {
  115057. /**
  115058. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  115059. * @see http://doc.babylonjs.com/features/cameras
  115060. */
  115061. export class StereoscopicGamepadCamera extends GamepadCamera {
  115062. /**
  115063. * Creates a new StereoscopicGamepadCamera
  115064. * @param name defines camera name
  115065. * @param position defines initial position
  115066. * @param interaxialDistance defines distance between each color axis
  115067. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115068. * @param scene defines the hosting scene
  115069. */
  115070. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115071. /**
  115072. * Gets camera class name
  115073. * @returns StereoscopicGamepadCamera
  115074. */
  115075. getClassName(): string;
  115076. }
  115077. }
  115078. declare module BABYLON {
  115079. /**
  115080. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  115081. * @see http://doc.babylonjs.com/features/cameras
  115082. */
  115083. export class StereoscopicUniversalCamera extends UniversalCamera {
  115084. /**
  115085. * Creates a new StereoscopicUniversalCamera
  115086. * @param name defines camera name
  115087. * @param position defines initial position
  115088. * @param interaxialDistance defines distance between each color axis
  115089. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115090. * @param scene defines the hosting scene
  115091. */
  115092. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115093. /**
  115094. * Gets camera class name
  115095. * @returns StereoscopicUniversalCamera
  115096. */
  115097. getClassName(): string;
  115098. }
  115099. }
  115100. declare module BABYLON {
  115101. /**
  115102. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  115103. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115104. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115105. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115106. */
  115107. export class VirtualJoysticksCamera extends FreeCamera {
  115108. /**
  115109. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  115110. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115111. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115112. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115113. * @param name Define the name of the camera in the scene
  115114. * @param position Define the start position of the camera in the scene
  115115. * @param scene Define the scene the camera belongs to
  115116. */
  115117. constructor(name: string, position: Vector3, scene: Scene);
  115118. /**
  115119. * Gets the current object class name.
  115120. * @return the class name
  115121. */
  115122. getClassName(): string;
  115123. }
  115124. }
  115125. declare module BABYLON {
  115126. /**
  115127. * This represents all the required metrics to create a VR camera.
  115128. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  115129. */
  115130. export class VRCameraMetrics {
  115131. /**
  115132. * Define the horizontal resolution off the screen.
  115133. */
  115134. hResolution: number;
  115135. /**
  115136. * Define the vertical resolution off the screen.
  115137. */
  115138. vResolution: number;
  115139. /**
  115140. * Define the horizontal screen size.
  115141. */
  115142. hScreenSize: number;
  115143. /**
  115144. * Define the vertical screen size.
  115145. */
  115146. vScreenSize: number;
  115147. /**
  115148. * Define the vertical screen center position.
  115149. */
  115150. vScreenCenter: number;
  115151. /**
  115152. * Define the distance of the eyes to the screen.
  115153. */
  115154. eyeToScreenDistance: number;
  115155. /**
  115156. * Define the distance between both lenses
  115157. */
  115158. lensSeparationDistance: number;
  115159. /**
  115160. * Define the distance between both viewer's eyes.
  115161. */
  115162. interpupillaryDistance: number;
  115163. /**
  115164. * Define the distortion factor of the VR postprocess.
  115165. * Please, touch with care.
  115166. */
  115167. distortionK: number[];
  115168. /**
  115169. * Define the chromatic aberration correction factors for the VR post process.
  115170. */
  115171. chromaAbCorrection: number[];
  115172. /**
  115173. * Define the scale factor of the post process.
  115174. * The smaller the better but the slower.
  115175. */
  115176. postProcessScaleFactor: number;
  115177. /**
  115178. * Define an offset for the lens center.
  115179. */
  115180. lensCenterOffset: number;
  115181. /**
  115182. * Define if the current vr camera should compensate the distortion of the lense or not.
  115183. */
  115184. compensateDistortion: boolean;
  115185. /**
  115186. * Defines if multiview should be enabled when rendering (Default: false)
  115187. */
  115188. multiviewEnabled: boolean;
  115189. /**
  115190. * Gets the rendering aspect ratio based on the provided resolutions.
  115191. */
  115192. get aspectRatio(): number;
  115193. /**
  115194. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  115195. */
  115196. get aspectRatioFov(): number;
  115197. /**
  115198. * @hidden
  115199. */
  115200. get leftHMatrix(): Matrix;
  115201. /**
  115202. * @hidden
  115203. */
  115204. get rightHMatrix(): Matrix;
  115205. /**
  115206. * @hidden
  115207. */
  115208. get leftPreViewMatrix(): Matrix;
  115209. /**
  115210. * @hidden
  115211. */
  115212. get rightPreViewMatrix(): Matrix;
  115213. /**
  115214. * Get the default VRMetrics based on the most generic setup.
  115215. * @returns the default vr metrics
  115216. */
  115217. static GetDefault(): VRCameraMetrics;
  115218. }
  115219. }
  115220. declare module BABYLON {
  115221. /** @hidden */
  115222. export var vrDistortionCorrectionPixelShader: {
  115223. name: string;
  115224. shader: string;
  115225. };
  115226. }
  115227. declare module BABYLON {
  115228. /**
  115229. * VRDistortionCorrectionPostProcess used for mobile VR
  115230. */
  115231. export class VRDistortionCorrectionPostProcess extends PostProcess {
  115232. private _isRightEye;
  115233. private _distortionFactors;
  115234. private _postProcessScaleFactor;
  115235. private _lensCenterOffset;
  115236. private _scaleIn;
  115237. private _scaleFactor;
  115238. private _lensCenter;
  115239. /**
  115240. * Initializes the VRDistortionCorrectionPostProcess
  115241. * @param name The name of the effect.
  115242. * @param camera The camera to apply the render pass to.
  115243. * @param isRightEye If this is for the right eye distortion
  115244. * @param vrMetrics All the required metrics for the VR camera
  115245. */
  115246. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  115247. }
  115248. }
  115249. declare module BABYLON {
  115250. /**
  115251. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  115252. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115253. */
  115254. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  115255. /**
  115256. * Creates a new VRDeviceOrientationArcRotateCamera
  115257. * @param name defines camera name
  115258. * @param alpha defines the camera rotation along the logitudinal axis
  115259. * @param beta defines the camera rotation along the latitudinal axis
  115260. * @param radius defines the camera distance from its target
  115261. * @param target defines the camera target
  115262. * @param scene defines the scene the camera belongs to
  115263. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115264. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115265. */
  115266. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115267. /**
  115268. * Gets camera class name
  115269. * @returns VRDeviceOrientationArcRotateCamera
  115270. */
  115271. getClassName(): string;
  115272. }
  115273. }
  115274. declare module BABYLON {
  115275. /**
  115276. * Camera used to simulate VR rendering (based on FreeCamera)
  115277. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115278. */
  115279. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  115280. /**
  115281. * Creates a new VRDeviceOrientationFreeCamera
  115282. * @param name defines camera name
  115283. * @param position defines the start position of the camera
  115284. * @param scene defines the scene the camera belongs to
  115285. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115286. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115287. */
  115288. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115289. /**
  115290. * Gets camera class name
  115291. * @returns VRDeviceOrientationFreeCamera
  115292. */
  115293. getClassName(): string;
  115294. }
  115295. }
  115296. declare module BABYLON {
  115297. /**
  115298. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  115299. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115300. */
  115301. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  115302. /**
  115303. * Creates a new VRDeviceOrientationGamepadCamera
  115304. * @param name defines camera name
  115305. * @param position defines the start position of the camera
  115306. * @param scene defines the scene the camera belongs to
  115307. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115308. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115309. */
  115310. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115311. /**
  115312. * Gets camera class name
  115313. * @returns VRDeviceOrientationGamepadCamera
  115314. */
  115315. getClassName(): string;
  115316. }
  115317. }
  115318. declare module BABYLON {
  115319. /** @hidden */
  115320. export var imageProcessingPixelShader: {
  115321. name: string;
  115322. shader: string;
  115323. };
  115324. }
  115325. declare module BABYLON {
  115326. /**
  115327. * ImageProcessingPostProcess
  115328. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  115329. */
  115330. export class ImageProcessingPostProcess extends PostProcess {
  115331. /**
  115332. * Default configuration related to image processing available in the PBR Material.
  115333. */
  115334. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115335. /**
  115336. * Gets the image processing configuration used either in this material.
  115337. */
  115338. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115339. /**
  115340. * Sets the Default image processing configuration used either in the this material.
  115341. *
  115342. * If sets to null, the scene one is in use.
  115343. */
  115344. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  115345. /**
  115346. * Keep track of the image processing observer to allow dispose and replace.
  115347. */
  115348. private _imageProcessingObserver;
  115349. /**
  115350. * Attaches a new image processing configuration to the PBR Material.
  115351. * @param configuration
  115352. */
  115353. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  115354. /**
  115355. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115356. */
  115357. get colorCurves(): Nullable<ColorCurves>;
  115358. /**
  115359. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115360. */
  115361. set colorCurves(value: Nullable<ColorCurves>);
  115362. /**
  115363. * Gets wether the color curves effect is enabled.
  115364. */
  115365. get colorCurvesEnabled(): boolean;
  115366. /**
  115367. * Sets wether the color curves effect is enabled.
  115368. */
  115369. set colorCurvesEnabled(value: boolean);
  115370. /**
  115371. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115372. */
  115373. get colorGradingTexture(): Nullable<BaseTexture>;
  115374. /**
  115375. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115376. */
  115377. set colorGradingTexture(value: Nullable<BaseTexture>);
  115378. /**
  115379. * Gets wether the color grading effect is enabled.
  115380. */
  115381. get colorGradingEnabled(): boolean;
  115382. /**
  115383. * Gets wether the color grading effect is enabled.
  115384. */
  115385. set colorGradingEnabled(value: boolean);
  115386. /**
  115387. * Gets exposure used in the effect.
  115388. */
  115389. get exposure(): number;
  115390. /**
  115391. * Sets exposure used in the effect.
  115392. */
  115393. set exposure(value: number);
  115394. /**
  115395. * Gets wether tonemapping is enabled or not.
  115396. */
  115397. get toneMappingEnabled(): boolean;
  115398. /**
  115399. * Sets wether tonemapping is enabled or not
  115400. */
  115401. set toneMappingEnabled(value: boolean);
  115402. /**
  115403. * Gets the type of tone mapping effect.
  115404. */
  115405. get toneMappingType(): number;
  115406. /**
  115407. * Sets the type of tone mapping effect.
  115408. */
  115409. set toneMappingType(value: number);
  115410. /**
  115411. * Gets contrast used in the effect.
  115412. */
  115413. get contrast(): number;
  115414. /**
  115415. * Sets contrast used in the effect.
  115416. */
  115417. set contrast(value: number);
  115418. /**
  115419. * Gets Vignette stretch size.
  115420. */
  115421. get vignetteStretch(): number;
  115422. /**
  115423. * Sets Vignette stretch size.
  115424. */
  115425. set vignetteStretch(value: number);
  115426. /**
  115427. * Gets Vignette centre X Offset.
  115428. */
  115429. get vignetteCentreX(): number;
  115430. /**
  115431. * Sets Vignette centre X Offset.
  115432. */
  115433. set vignetteCentreX(value: number);
  115434. /**
  115435. * Gets Vignette centre Y Offset.
  115436. */
  115437. get vignetteCentreY(): number;
  115438. /**
  115439. * Sets Vignette centre Y Offset.
  115440. */
  115441. set vignetteCentreY(value: number);
  115442. /**
  115443. * Gets Vignette weight or intensity of the vignette effect.
  115444. */
  115445. get vignetteWeight(): number;
  115446. /**
  115447. * Sets Vignette weight or intensity of the vignette effect.
  115448. */
  115449. set vignetteWeight(value: number);
  115450. /**
  115451. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115452. * if vignetteEnabled is set to true.
  115453. */
  115454. get vignetteColor(): Color4;
  115455. /**
  115456. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115457. * if vignetteEnabled is set to true.
  115458. */
  115459. set vignetteColor(value: Color4);
  115460. /**
  115461. * Gets Camera field of view used by the Vignette effect.
  115462. */
  115463. get vignetteCameraFov(): number;
  115464. /**
  115465. * Sets Camera field of view used by the Vignette effect.
  115466. */
  115467. set vignetteCameraFov(value: number);
  115468. /**
  115469. * Gets the vignette blend mode allowing different kind of effect.
  115470. */
  115471. get vignetteBlendMode(): number;
  115472. /**
  115473. * Sets the vignette blend mode allowing different kind of effect.
  115474. */
  115475. set vignetteBlendMode(value: number);
  115476. /**
  115477. * Gets wether the vignette effect is enabled.
  115478. */
  115479. get vignetteEnabled(): boolean;
  115480. /**
  115481. * Sets wether the vignette effect is enabled.
  115482. */
  115483. set vignetteEnabled(value: boolean);
  115484. private _fromLinearSpace;
  115485. /**
  115486. * Gets wether the input of the processing is in Gamma or Linear Space.
  115487. */
  115488. get fromLinearSpace(): boolean;
  115489. /**
  115490. * Sets wether the input of the processing is in Gamma or Linear Space.
  115491. */
  115492. set fromLinearSpace(value: boolean);
  115493. /**
  115494. * Defines cache preventing GC.
  115495. */
  115496. private _defines;
  115497. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  115498. /**
  115499. * "ImageProcessingPostProcess"
  115500. * @returns "ImageProcessingPostProcess"
  115501. */
  115502. getClassName(): string;
  115503. protected _updateParameters(): void;
  115504. dispose(camera?: Camera): void;
  115505. }
  115506. }
  115507. declare module BABYLON {
  115508. /**
  115509. * Class containing static functions to help procedurally build meshes
  115510. */
  115511. export class GroundBuilder {
  115512. /**
  115513. * Creates a ground mesh
  115514. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115515. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115517. * @param name defines the name of the mesh
  115518. * @param options defines the options used to create the mesh
  115519. * @param scene defines the hosting scene
  115520. * @returns the ground mesh
  115521. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115522. */
  115523. static CreateGround(name: string, options: {
  115524. width?: number;
  115525. height?: number;
  115526. subdivisions?: number;
  115527. subdivisionsX?: number;
  115528. subdivisionsY?: number;
  115529. updatable?: boolean;
  115530. }, scene: any): Mesh;
  115531. /**
  115532. * Creates a tiled ground mesh
  115533. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115534. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115535. * * 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
  115536. * * 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
  115537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115538. * @param name defines the name of the mesh
  115539. * @param options defines the options used to create the mesh
  115540. * @param scene defines the hosting scene
  115541. * @returns the tiled ground mesh
  115542. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115543. */
  115544. static CreateTiledGround(name: string, options: {
  115545. xmin: number;
  115546. zmin: number;
  115547. xmax: number;
  115548. zmax: number;
  115549. subdivisions?: {
  115550. w: number;
  115551. h: number;
  115552. };
  115553. precision?: {
  115554. w: number;
  115555. h: number;
  115556. };
  115557. updatable?: boolean;
  115558. }, scene?: Nullable<Scene>): Mesh;
  115559. /**
  115560. * Creates a ground mesh from a height map
  115561. * * The parameter `url` sets the URL of the height map image resource.
  115562. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115563. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115564. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115565. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115566. * * 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.
  115567. * * 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).
  115568. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115570. * @param name defines the name of the mesh
  115571. * @param url defines the url to the height map
  115572. * @param options defines the options used to create the mesh
  115573. * @param scene defines the hosting scene
  115574. * @returns the ground mesh
  115575. * @see https://doc.babylonjs.com/babylon101/height_map
  115576. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115577. */
  115578. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115579. width?: number;
  115580. height?: number;
  115581. subdivisions?: number;
  115582. minHeight?: number;
  115583. maxHeight?: number;
  115584. colorFilter?: Color3;
  115585. alphaFilter?: number;
  115586. updatable?: boolean;
  115587. onReady?: (mesh: GroundMesh) => void;
  115588. }, scene?: Nullable<Scene>): GroundMesh;
  115589. }
  115590. }
  115591. declare module BABYLON {
  115592. /**
  115593. * Class containing static functions to help procedurally build meshes
  115594. */
  115595. export class TorusBuilder {
  115596. /**
  115597. * Creates a torus mesh
  115598. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115599. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115600. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115601. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115602. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115604. * @param name defines the name of the mesh
  115605. * @param options defines the options used to create the mesh
  115606. * @param scene defines the hosting scene
  115607. * @returns the torus mesh
  115608. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115609. */
  115610. static CreateTorus(name: string, options: {
  115611. diameter?: number;
  115612. thickness?: number;
  115613. tessellation?: number;
  115614. updatable?: boolean;
  115615. sideOrientation?: number;
  115616. frontUVs?: Vector4;
  115617. backUVs?: Vector4;
  115618. }, scene: any): Mesh;
  115619. }
  115620. }
  115621. declare module BABYLON {
  115622. /**
  115623. * Class containing static functions to help procedurally build meshes
  115624. */
  115625. export class CylinderBuilder {
  115626. /**
  115627. * Creates a cylinder or a cone mesh
  115628. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115629. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115630. * * 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.
  115631. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115632. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115633. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115634. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115635. * * 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).
  115636. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115637. * * 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).
  115638. * * 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
  115639. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115640. * * 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
  115641. * * 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.
  115642. * * If `enclose` is false, a ring surface is one element.
  115643. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115644. * * 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
  115645. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115646. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115648. * @param name defines the name of the mesh
  115649. * @param options defines the options used to create the mesh
  115650. * @param scene defines the hosting scene
  115651. * @returns the cylinder mesh
  115652. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115653. */
  115654. static CreateCylinder(name: string, options: {
  115655. height?: number;
  115656. diameterTop?: number;
  115657. diameterBottom?: number;
  115658. diameter?: number;
  115659. tessellation?: number;
  115660. subdivisions?: number;
  115661. arc?: number;
  115662. faceColors?: Color4[];
  115663. faceUV?: Vector4[];
  115664. updatable?: boolean;
  115665. hasRings?: boolean;
  115666. enclose?: boolean;
  115667. cap?: number;
  115668. sideOrientation?: number;
  115669. frontUVs?: Vector4;
  115670. backUVs?: Vector4;
  115671. }, scene: any): Mesh;
  115672. }
  115673. }
  115674. declare module BABYLON {
  115675. /**
  115676. * States of the webXR experience
  115677. */
  115678. export enum WebXRState {
  115679. /**
  115680. * Transitioning to being in XR mode
  115681. */
  115682. ENTERING_XR = 0,
  115683. /**
  115684. * Transitioning to non XR mode
  115685. */
  115686. EXITING_XR = 1,
  115687. /**
  115688. * In XR mode and presenting
  115689. */
  115690. IN_XR = 2,
  115691. /**
  115692. * Not entered XR mode
  115693. */
  115694. NOT_IN_XR = 3
  115695. }
  115696. /**
  115697. * Abstraction of the XR render target
  115698. */
  115699. export interface WebXRRenderTarget extends IDisposable {
  115700. /**
  115701. * xrpresent context of the canvas which can be used to display/mirror xr content
  115702. */
  115703. canvasContext: WebGLRenderingContext;
  115704. /**
  115705. * xr layer for the canvas
  115706. */
  115707. xrLayer: Nullable<XRWebGLLayer>;
  115708. /**
  115709. * Initializes the xr layer for the session
  115710. * @param xrSession xr session
  115711. * @returns a promise that will resolve once the XR Layer has been created
  115712. */
  115713. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115714. }
  115715. }
  115716. declare module BABYLON {
  115717. /**
  115718. * COnfiguration object for WebXR output canvas
  115719. */
  115720. export class WebXRManagedOutputCanvasOptions {
  115721. /**
  115722. * An optional canvas in case you wish to create it yourself and provide it here.
  115723. * If not provided, a new canvas will be created
  115724. */
  115725. canvasElement?: HTMLCanvasElement;
  115726. /**
  115727. * Options for this XR Layer output
  115728. */
  115729. canvasOptions?: XRWebGLLayerOptions;
  115730. /**
  115731. * CSS styling for a newly created canvas (if not provided)
  115732. */
  115733. newCanvasCssStyle?: string;
  115734. /**
  115735. * Get the default values of the configuration object
  115736. * @returns default values of this configuration object
  115737. */
  115738. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  115739. }
  115740. /**
  115741. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  115742. */
  115743. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  115744. private _options;
  115745. private _canvas;
  115746. private _engine;
  115747. /**
  115748. * Rendering context of the canvas which can be used to display/mirror xr content
  115749. */
  115750. canvasContext: WebGLRenderingContext;
  115751. /**
  115752. * xr layer for the canvas
  115753. */
  115754. xrLayer: Nullable<XRWebGLLayer>;
  115755. /**
  115756. * Initializes the canvas to be added/removed upon entering/exiting xr
  115757. * @param _xrSessionManager The XR Session manager
  115758. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  115759. */
  115760. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  115761. /**
  115762. * Disposes of the object
  115763. */
  115764. dispose(): void;
  115765. /**
  115766. * Initializes the xr layer for the session
  115767. * @param xrSession xr session
  115768. * @returns a promise that will resolve once the XR Layer has been created
  115769. */
  115770. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115771. private _addCanvas;
  115772. private _removeCanvas;
  115773. private _setManagedOutputCanvas;
  115774. }
  115775. }
  115776. declare module BABYLON {
  115777. /**
  115778. * Manages an XRSession to work with Babylon's engine
  115779. * @see https://doc.babylonjs.com/how_to/webxr
  115780. */
  115781. export class WebXRSessionManager implements IDisposable {
  115782. /** The scene which the session should be created for */
  115783. scene: Scene;
  115784. private _referenceSpace;
  115785. private _rttProvider;
  115786. private _sessionEnded;
  115787. private _xrNavigator;
  115788. private baseLayer;
  115789. /**
  115790. * The base reference space from which the session started. good if you want to reset your
  115791. * reference space
  115792. */
  115793. baseReferenceSpace: XRReferenceSpace;
  115794. /**
  115795. * Current XR frame
  115796. */
  115797. currentFrame: Nullable<XRFrame>;
  115798. /** WebXR timestamp updated every frame */
  115799. currentTimestamp: number;
  115800. /**
  115801. * Used just in case of a failure to initialize an immersive session.
  115802. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  115803. */
  115804. defaultHeightCompensation: number;
  115805. /**
  115806. * Fires every time a new xrFrame arrives which can be used to update the camera
  115807. */
  115808. onXRFrameObservable: Observable<XRFrame>;
  115809. /**
  115810. * Fires when the reference space changed
  115811. */
  115812. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  115813. /**
  115814. * Fires when the xr session is ended either by the device or manually done
  115815. */
  115816. onXRSessionEnded: Observable<any>;
  115817. /**
  115818. * Fires when the xr session is ended either by the device or manually done
  115819. */
  115820. onXRSessionInit: Observable<XRSession>;
  115821. /**
  115822. * Underlying xr session
  115823. */
  115824. session: XRSession;
  115825. /**
  115826. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  115827. * or get the offset the player is currently at.
  115828. */
  115829. viewerReferenceSpace: XRReferenceSpace;
  115830. /**
  115831. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  115832. * @param scene The scene which the session should be created for
  115833. */
  115834. constructor(
  115835. /** The scene which the session should be created for */
  115836. scene: Scene);
  115837. /**
  115838. * The current reference space used in this session. This reference space can constantly change!
  115839. * It is mainly used to offset the camera's position.
  115840. */
  115841. get referenceSpace(): XRReferenceSpace;
  115842. /**
  115843. * Set a new reference space and triggers the observable
  115844. */
  115845. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  115846. /**
  115847. * Disposes of the session manager
  115848. */
  115849. dispose(): void;
  115850. /**
  115851. * Stops the xrSession and restores the render loop
  115852. * @returns Promise which resolves after it exits XR
  115853. */
  115854. exitXRAsync(): Promise<void>;
  115855. /**
  115856. * Gets the correct render target texture to be rendered this frame for this eye
  115857. * @param eye the eye for which to get the render target
  115858. * @returns the render target for the specified eye
  115859. */
  115860. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  115861. /**
  115862. * Creates a WebXRRenderTarget object for the XR session
  115863. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  115864. * @param options optional options to provide when creating a new render target
  115865. * @returns a WebXR render target to which the session can render
  115866. */
  115867. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  115868. /**
  115869. * Initializes the manager
  115870. * After initialization enterXR can be called to start an XR session
  115871. * @returns Promise which resolves after it is initialized
  115872. */
  115873. initializeAsync(): Promise<void>;
  115874. /**
  115875. * Initializes an xr session
  115876. * @param xrSessionMode mode to initialize
  115877. * @param xrSessionInit defines optional and required values to pass to the session builder
  115878. * @returns a promise which will resolve once the session has been initialized
  115879. */
  115880. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  115881. /**
  115882. * Checks if a session would be supported for the creation options specified
  115883. * @param sessionMode session mode to check if supported eg. immersive-vr
  115884. * @returns A Promise that resolves to true if supported and false if not
  115885. */
  115886. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115887. /**
  115888. * Resets the reference space to the one started the session
  115889. */
  115890. resetReferenceSpace(): void;
  115891. /**
  115892. * Starts rendering to the xr layer
  115893. */
  115894. runXRRenderLoop(): void;
  115895. /**
  115896. * Sets the reference space on the xr session
  115897. * @param referenceSpaceType space to set
  115898. * @returns a promise that will resolve once the reference space has been set
  115899. */
  115900. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  115901. /**
  115902. * Updates the render state of the session
  115903. * @param state state to set
  115904. * @returns a promise that resolves once the render state has been updated
  115905. */
  115906. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  115907. /**
  115908. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  115909. * @param sessionMode defines the session to test
  115910. * @returns a promise with boolean as final value
  115911. */
  115912. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  115913. private _createRenderTargetTexture;
  115914. }
  115915. }
  115916. declare module BABYLON {
  115917. /**
  115918. * WebXR Camera which holds the views for the xrSession
  115919. * @see https://doc.babylonjs.com/how_to/webxr_camera
  115920. */
  115921. export class WebXRCamera extends FreeCamera {
  115922. private _xrSessionManager;
  115923. private _firstFrame;
  115924. private _referenceQuaternion;
  115925. private _referencedPosition;
  115926. private _xrInvPositionCache;
  115927. private _xrInvQuaternionCache;
  115928. /**
  115929. * Should position compensation execute on first frame.
  115930. * This is used when copying the position from a native (non XR) camera
  115931. */
  115932. compensateOnFirstFrame: boolean;
  115933. /**
  115934. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  115935. * @param name the name of the camera
  115936. * @param scene the scene to add the camera to
  115937. * @param _xrSessionManager a constructed xr session manager
  115938. */
  115939. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  115940. /**
  115941. * Return the user's height, unrelated to the current ground.
  115942. * This will be the y position of this camera, when ground level is 0.
  115943. */
  115944. get realWorldHeight(): number;
  115945. /** @hidden */
  115946. _updateForDualEyeDebugging(): void;
  115947. /**
  115948. * Sets this camera's transformation based on a non-vr camera
  115949. * @param otherCamera the non-vr camera to copy the transformation from
  115950. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  115951. */
  115952. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  115953. private _updateFromXRSession;
  115954. private _updateNumberOfRigCameras;
  115955. private _updateReferenceSpace;
  115956. private _updateReferenceSpaceOffset;
  115957. }
  115958. }
  115959. declare module BABYLON {
  115960. /**
  115961. * Defining the interface required for a (webxr) feature
  115962. */
  115963. export interface IWebXRFeature extends IDisposable {
  115964. /**
  115965. * Is this feature attached
  115966. */
  115967. attached: boolean;
  115968. /**
  115969. * Should auto-attach be disabled?
  115970. */
  115971. disableAutoAttach: boolean;
  115972. /**
  115973. * Attach the feature to the session
  115974. * Will usually be called by the features manager
  115975. *
  115976. * @param force should attachment be forced (even when already attached)
  115977. * @returns true if successful.
  115978. */
  115979. attach(force?: boolean): boolean;
  115980. /**
  115981. * Detach the feature from the session
  115982. * Will usually be called by the features manager
  115983. *
  115984. * @returns true if successful.
  115985. */
  115986. detach(): boolean;
  115987. }
  115988. /**
  115989. * A list of the currently available features without referencing them
  115990. */
  115991. export class WebXRFeatureName {
  115992. /**
  115993. * The name of the anchor system feature
  115994. */
  115995. static ANCHOR_SYSTEM: string;
  115996. /**
  115997. * The name of the background remover feature
  115998. */
  115999. static BACKGROUND_REMOVER: string;
  116000. /**
  116001. * The name of the hit test feature
  116002. */
  116003. static HIT_TEST: string;
  116004. /**
  116005. * physics impostors for xr controllers feature
  116006. */
  116007. static PHYSICS_CONTROLLERS: string;
  116008. /**
  116009. * The name of the plane detection feature
  116010. */
  116011. static PLANE_DETECTION: string;
  116012. /**
  116013. * The name of the pointer selection feature
  116014. */
  116015. static POINTER_SELECTION: string;
  116016. /**
  116017. * The name of the teleportation feature
  116018. */
  116019. static TELEPORTATION: string;
  116020. }
  116021. /**
  116022. * Defining the constructor of a feature. Used to register the modules.
  116023. */
  116024. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  116025. /**
  116026. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  116027. * It is mainly used in AR sessions.
  116028. *
  116029. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  116030. */
  116031. export class WebXRFeaturesManager implements IDisposable {
  116032. private _xrSessionManager;
  116033. private static readonly _AvailableFeatures;
  116034. private _features;
  116035. /**
  116036. * constructs a new features manages.
  116037. *
  116038. * @param _xrSessionManager an instance of WebXRSessionManager
  116039. */
  116040. constructor(_xrSessionManager: WebXRSessionManager);
  116041. /**
  116042. * Used to register a module. After calling this function a developer can use this feature in the scene.
  116043. * Mainly used internally.
  116044. *
  116045. * @param featureName the name of the feature to register
  116046. * @param constructorFunction the function used to construct the module
  116047. * @param version the (babylon) version of the module
  116048. * @param stable is that a stable version of this module
  116049. */
  116050. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  116051. /**
  116052. * Returns a constructor of a specific feature.
  116053. *
  116054. * @param featureName the name of the feature to construct
  116055. * @param version the version of the feature to load
  116056. * @param xrSessionManager the xrSessionManager. Used to construct the module
  116057. * @param options optional options provided to the module.
  116058. * @returns a function that, when called, will return a new instance of this feature
  116059. */
  116060. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  116061. /**
  116062. * Can be used to return the list of features currently registered
  116063. *
  116064. * @returns an Array of available features
  116065. */
  116066. static GetAvailableFeatures(): string[];
  116067. /**
  116068. * Gets the versions available for a specific feature
  116069. * @param featureName the name of the feature
  116070. * @returns an array with the available versions
  116071. */
  116072. static GetAvailableVersions(featureName: string): string[];
  116073. /**
  116074. * Return the latest unstable version of this feature
  116075. * @param featureName the name of the feature to search
  116076. * @returns the version number. if not found will return -1
  116077. */
  116078. static GetLatestVersionOfFeature(featureName: string): number;
  116079. /**
  116080. * Return the latest stable version of this feature
  116081. * @param featureName the name of the feature to search
  116082. * @returns the version number. if not found will return -1
  116083. */
  116084. static GetStableVersionOfFeature(featureName: string): number;
  116085. /**
  116086. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  116087. * Can be used during a session to start a feature
  116088. * @param featureName the name of feature to attach
  116089. */
  116090. attachFeature(featureName: string): void;
  116091. /**
  116092. * Can be used inside a session or when the session ends to detach a specific feature
  116093. * @param featureName the name of the feature to detach
  116094. */
  116095. detachFeature(featureName: string): void;
  116096. /**
  116097. * Used to disable an already-enabled feature
  116098. * The feature will be disposed and will be recreated once enabled.
  116099. * @param featureName the feature to disable
  116100. * @returns true if disable was successful
  116101. */
  116102. disableFeature(featureName: string | {
  116103. Name: string;
  116104. }): boolean;
  116105. /**
  116106. * dispose this features manager
  116107. */
  116108. dispose(): void;
  116109. /**
  116110. * 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.
  116111. * If used twice, the old version will be disposed and a new one will be constructed. This way you can re-enable with different configuration.
  116112. *
  116113. * @param featureName the name of the feature to load or the class of the feature
  116114. * @param version optional version to load. if not provided the latest version will be enabled
  116115. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  116116. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  116117. * @returns a new constructed feature or throws an error if feature not found.
  116118. */
  116119. enableFeature(featureName: string | {
  116120. Name: string;
  116121. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  116122. /**
  116123. * get the implementation of an enabled feature.
  116124. * @param featureName the name of the feature to load
  116125. * @returns the feature class, if found
  116126. */
  116127. getEnabledFeature(featureName: string): IWebXRFeature;
  116128. /**
  116129. * Get the list of enabled features
  116130. * @returns an array of enabled features
  116131. */
  116132. getEnabledFeatures(): string[];
  116133. }
  116134. }
  116135. declare module BABYLON {
  116136. /**
  116137. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  116138. * @see https://doc.babylonjs.com/how_to/webxr
  116139. */
  116140. export class WebXRExperienceHelper implements IDisposable {
  116141. private scene;
  116142. private _nonVRCamera;
  116143. private _originalSceneAutoClear;
  116144. private _supported;
  116145. /**
  116146. * Camera used to render xr content
  116147. */
  116148. camera: WebXRCamera;
  116149. /** A features manager for this xr session */
  116150. featuresManager: WebXRFeaturesManager;
  116151. /**
  116152. * Observers registered here will be triggered after the camera's initial transformation is set
  116153. * This can be used to set a different ground level or an extra rotation.
  116154. *
  116155. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  116156. * to the position set after this observable is done executing.
  116157. */
  116158. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  116159. /**
  116160. * Fires when the state of the experience helper has changed
  116161. */
  116162. onStateChangedObservable: Observable<WebXRState>;
  116163. /** Session manager used to keep track of xr session */
  116164. sessionManager: WebXRSessionManager;
  116165. /**
  116166. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  116167. */
  116168. state: WebXRState;
  116169. /**
  116170. * Creates a WebXRExperienceHelper
  116171. * @param scene The scene the helper should be created in
  116172. */
  116173. private constructor();
  116174. /**
  116175. * Creates the experience helper
  116176. * @param scene the scene to attach the experience helper to
  116177. * @returns a promise for the experience helper
  116178. */
  116179. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  116180. /**
  116181. * Disposes of the experience helper
  116182. */
  116183. dispose(): void;
  116184. /**
  116185. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  116186. * @param sessionMode options for the XR session
  116187. * @param referenceSpaceType frame of reference of the XR session
  116188. * @param renderTarget the output canvas that will be used to enter XR mode
  116189. * @returns promise that resolves after xr mode has entered
  116190. */
  116191. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  116192. /**
  116193. * Exits XR mode and returns the scene to its original state
  116194. * @returns promise that resolves after xr mode has exited
  116195. */
  116196. exitXRAsync(): Promise<void>;
  116197. private _nonXRToXRCamera;
  116198. private _setState;
  116199. }
  116200. }
  116201. declare module BABYLON {
  116202. /**
  116203. * X-Y values for axes in WebXR
  116204. */
  116205. export interface IWebXRMotionControllerAxesValue {
  116206. /**
  116207. * The value of the x axis
  116208. */
  116209. x: number;
  116210. /**
  116211. * The value of the y-axis
  116212. */
  116213. y: number;
  116214. }
  116215. /**
  116216. * changed / previous values for the values of this component
  116217. */
  116218. export interface IWebXRMotionControllerComponentChangesValues<T> {
  116219. /**
  116220. * current (this frame) value
  116221. */
  116222. current: T;
  116223. /**
  116224. * previous (last change) value
  116225. */
  116226. previous: T;
  116227. }
  116228. /**
  116229. * Represents changes in the component between current frame and last values recorded
  116230. */
  116231. export interface IWebXRMotionControllerComponentChanges {
  116232. /**
  116233. * will be populated with previous and current values if axes changed
  116234. */
  116235. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  116236. /**
  116237. * will be populated with previous and current values if pressed changed
  116238. */
  116239. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116240. /**
  116241. * will be populated with previous and current values if touched changed
  116242. */
  116243. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116244. /**
  116245. * will be populated with previous and current values if value changed
  116246. */
  116247. value?: IWebXRMotionControllerComponentChangesValues<number>;
  116248. }
  116249. /**
  116250. * This class represents a single component (for example button or thumbstick) of a motion controller
  116251. */
  116252. export class WebXRControllerComponent implements IDisposable {
  116253. /**
  116254. * the id of this component
  116255. */
  116256. id: string;
  116257. /**
  116258. * the type of the component
  116259. */
  116260. type: MotionControllerComponentType;
  116261. private _buttonIndex;
  116262. private _axesIndices;
  116263. private _axes;
  116264. private _changes;
  116265. private _currentValue;
  116266. private _hasChanges;
  116267. private _pressed;
  116268. private _touched;
  116269. /**
  116270. * button component type
  116271. */
  116272. static BUTTON_TYPE: MotionControllerComponentType;
  116273. /**
  116274. * squeeze component type
  116275. */
  116276. static SQUEEZE_TYPE: MotionControllerComponentType;
  116277. /**
  116278. * Thumbstick component type
  116279. */
  116280. static THUMBSTICK_TYPE: MotionControllerComponentType;
  116281. /**
  116282. * Touchpad component type
  116283. */
  116284. static TOUCHPAD_TYPE: MotionControllerComponentType;
  116285. /**
  116286. * trigger component type
  116287. */
  116288. static TRIGGER_TYPE: MotionControllerComponentType;
  116289. /**
  116290. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  116291. * the axes data changes
  116292. */
  116293. onAxisValueChangedObservable: Observable<{
  116294. x: number;
  116295. y: number;
  116296. }>;
  116297. /**
  116298. * Observers registered here will be triggered when the state of a button changes
  116299. * State change is either pressed / touched / value
  116300. */
  116301. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  116302. /**
  116303. * Creates a new component for a motion controller.
  116304. * It is created by the motion controller itself
  116305. *
  116306. * @param id the id of this component
  116307. * @param type the type of the component
  116308. * @param _buttonIndex index in the buttons array of the gamepad
  116309. * @param _axesIndices indices of the values in the axes array of the gamepad
  116310. */
  116311. constructor(
  116312. /**
  116313. * the id of this component
  116314. */
  116315. id: string,
  116316. /**
  116317. * the type of the component
  116318. */
  116319. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  116320. /**
  116321. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  116322. */
  116323. get axes(): IWebXRMotionControllerAxesValue;
  116324. /**
  116325. * Get the changes. Elements will be populated only if they changed with their previous and current value
  116326. */
  116327. get changes(): IWebXRMotionControllerComponentChanges;
  116328. /**
  116329. * Return whether or not the component changed the last frame
  116330. */
  116331. get hasChanges(): boolean;
  116332. /**
  116333. * is the button currently pressed
  116334. */
  116335. get pressed(): boolean;
  116336. /**
  116337. * is the button currently touched
  116338. */
  116339. get touched(): boolean;
  116340. /**
  116341. * Get the current value of this component
  116342. */
  116343. get value(): number;
  116344. /**
  116345. * Dispose this component
  116346. */
  116347. dispose(): void;
  116348. /**
  116349. * Are there axes correlating to this component
  116350. * @return true is axes data is available
  116351. */
  116352. isAxes(): boolean;
  116353. /**
  116354. * Is this component a button (hence - pressable)
  116355. * @returns true if can be pressed
  116356. */
  116357. isButton(): boolean;
  116358. /**
  116359. * update this component using the gamepad object it is in. Called on every frame
  116360. * @param nativeController the native gamepad controller object
  116361. */
  116362. update(nativeController: IMinimalMotionControllerObject): void;
  116363. }
  116364. }
  116365. declare module BABYLON {
  116366. /**
  116367. * Class used to represent data loading progression
  116368. */
  116369. export class SceneLoaderProgressEvent {
  116370. /** defines if data length to load can be evaluated */
  116371. readonly lengthComputable: boolean;
  116372. /** defines the loaded data length */
  116373. readonly loaded: number;
  116374. /** defines the data length to load */
  116375. readonly total: number;
  116376. /**
  116377. * Create a new progress event
  116378. * @param lengthComputable defines if data length to load can be evaluated
  116379. * @param loaded defines the loaded data length
  116380. * @param total defines the data length to load
  116381. */
  116382. constructor(
  116383. /** defines if data length to load can be evaluated */
  116384. lengthComputable: boolean,
  116385. /** defines the loaded data length */
  116386. loaded: number,
  116387. /** defines the data length to load */
  116388. total: number);
  116389. /**
  116390. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  116391. * @param event defines the source event
  116392. * @returns a new SceneLoaderProgressEvent
  116393. */
  116394. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  116395. }
  116396. /**
  116397. * Interface used by SceneLoader plugins to define supported file extensions
  116398. */
  116399. export interface ISceneLoaderPluginExtensions {
  116400. /**
  116401. * Defines the list of supported extensions
  116402. */
  116403. [extension: string]: {
  116404. isBinary: boolean;
  116405. };
  116406. }
  116407. /**
  116408. * Interface used by SceneLoader plugin factory
  116409. */
  116410. export interface ISceneLoaderPluginFactory {
  116411. /**
  116412. * Defines the name of the factory
  116413. */
  116414. name: string;
  116415. /**
  116416. * Function called to create a new plugin
  116417. * @return the new plugin
  116418. */
  116419. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  116420. /**
  116421. * The callback that returns true if the data can be directly loaded.
  116422. * @param data string containing the file data
  116423. * @returns if the data can be loaded directly
  116424. */
  116425. canDirectLoad?(data: string): boolean;
  116426. }
  116427. /**
  116428. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  116429. */
  116430. export interface ISceneLoaderPluginBase {
  116431. /**
  116432. * The friendly name of this plugin.
  116433. */
  116434. name: string;
  116435. /**
  116436. * The file extensions supported by this plugin.
  116437. */
  116438. extensions: string | ISceneLoaderPluginExtensions;
  116439. /**
  116440. * The callback called when loading from a url.
  116441. * @param scene scene loading this url
  116442. * @param url url to load
  116443. * @param onSuccess callback called when the file successfully loads
  116444. * @param onProgress callback called while file is loading (if the server supports this mode)
  116445. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116446. * @param onError callback called when the file fails to load
  116447. * @returns a file request object
  116448. */
  116449. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116450. /**
  116451. * The callback called when loading from a file object.
  116452. * @param scene scene loading this file
  116453. * @param file defines the file to load
  116454. * @param onSuccess defines the callback to call when data is loaded
  116455. * @param onProgress defines the callback to call during loading process
  116456. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  116457. * @param onError defines the callback to call when an error occurs
  116458. * @returns a file request object
  116459. */
  116460. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116461. /**
  116462. * The callback that returns true if the data can be directly loaded.
  116463. * @param data string containing the file data
  116464. * @returns if the data can be loaded directly
  116465. */
  116466. canDirectLoad?(data: string): boolean;
  116467. /**
  116468. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  116469. * @param scene scene loading this data
  116470. * @param data string containing the data
  116471. * @returns data to pass to the plugin
  116472. */
  116473. directLoad?(scene: Scene, data: string): any;
  116474. /**
  116475. * The callback that allows custom handling of the root url based on the response url.
  116476. * @param rootUrl the original root url
  116477. * @param responseURL the response url if available
  116478. * @returns the new root url
  116479. */
  116480. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  116481. }
  116482. /**
  116483. * Interface used to define a SceneLoader plugin
  116484. */
  116485. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  116486. /**
  116487. * Import meshes into a scene.
  116488. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116489. * @param scene The scene to import into
  116490. * @param data The data to import
  116491. * @param rootUrl The root url for scene and resources
  116492. * @param meshes The meshes array to import into
  116493. * @param particleSystems The particle systems array to import into
  116494. * @param skeletons The skeletons array to import into
  116495. * @param onError The callback when import fails
  116496. * @returns True if successful or false otherwise
  116497. */
  116498. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  116499. /**
  116500. * Load into a scene.
  116501. * @param scene The scene to load into
  116502. * @param data The data to import
  116503. * @param rootUrl The root url for scene and resources
  116504. * @param onError The callback when import fails
  116505. * @returns True if successful or false otherwise
  116506. */
  116507. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  116508. /**
  116509. * Load into an asset container.
  116510. * @param scene The scene to load into
  116511. * @param data The data to import
  116512. * @param rootUrl The root url for scene and resources
  116513. * @param onError The callback when import fails
  116514. * @returns The loaded asset container
  116515. */
  116516. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  116517. }
  116518. /**
  116519. * Interface used to define an async SceneLoader plugin
  116520. */
  116521. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  116522. /**
  116523. * Import meshes into a scene.
  116524. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116525. * @param scene The scene to import into
  116526. * @param data The data to import
  116527. * @param rootUrl The root url for scene and resources
  116528. * @param onProgress The callback when the load progresses
  116529. * @param fileName Defines the name of the file to load
  116530. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  116531. */
  116532. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  116533. meshes: AbstractMesh[];
  116534. particleSystems: IParticleSystem[];
  116535. skeletons: Skeleton[];
  116536. animationGroups: AnimationGroup[];
  116537. }>;
  116538. /**
  116539. * Load into a scene.
  116540. * @param scene The scene to load into
  116541. * @param data The data to import
  116542. * @param rootUrl The root url for scene and resources
  116543. * @param onProgress The callback when the load progresses
  116544. * @param fileName Defines the name of the file to load
  116545. * @returns Nothing
  116546. */
  116547. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  116548. /**
  116549. * Load into an asset container.
  116550. * @param scene The scene to load into
  116551. * @param data The data to import
  116552. * @param rootUrl The root url for scene and resources
  116553. * @param onProgress The callback when the load progresses
  116554. * @param fileName Defines the name of the file to load
  116555. * @returns The loaded asset container
  116556. */
  116557. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  116558. }
  116559. /**
  116560. * Mode that determines how to handle old animation groups before loading new ones.
  116561. */
  116562. export enum SceneLoaderAnimationGroupLoadingMode {
  116563. /**
  116564. * Reset all old animations to initial state then dispose them.
  116565. */
  116566. Clean = 0,
  116567. /**
  116568. * Stop all old animations.
  116569. */
  116570. Stop = 1,
  116571. /**
  116572. * Restart old animations from first frame.
  116573. */
  116574. Sync = 2,
  116575. /**
  116576. * Old animations remains untouched.
  116577. */
  116578. NoSync = 3
  116579. }
  116580. /**
  116581. * Class used to load scene from various file formats using registered plugins
  116582. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  116583. */
  116584. export class SceneLoader {
  116585. /**
  116586. * No logging while loading
  116587. */
  116588. static readonly NO_LOGGING: number;
  116589. /**
  116590. * Minimal logging while loading
  116591. */
  116592. static readonly MINIMAL_LOGGING: number;
  116593. /**
  116594. * Summary logging while loading
  116595. */
  116596. static readonly SUMMARY_LOGGING: number;
  116597. /**
  116598. * Detailled logging while loading
  116599. */
  116600. static readonly DETAILED_LOGGING: number;
  116601. /**
  116602. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  116603. */
  116604. static get ForceFullSceneLoadingForIncremental(): boolean;
  116605. static set ForceFullSceneLoadingForIncremental(value: boolean);
  116606. /**
  116607. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  116608. */
  116609. static get ShowLoadingScreen(): boolean;
  116610. static set ShowLoadingScreen(value: boolean);
  116611. /**
  116612. * Defines the current logging level (while loading the scene)
  116613. * @ignorenaming
  116614. */
  116615. static get loggingLevel(): number;
  116616. static set loggingLevel(value: number);
  116617. /**
  116618. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  116619. */
  116620. static get CleanBoneMatrixWeights(): boolean;
  116621. static set CleanBoneMatrixWeights(value: boolean);
  116622. /**
  116623. * Event raised when a plugin is used to load a scene
  116624. */
  116625. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  116626. private static _registeredPlugins;
  116627. private static _getDefaultPlugin;
  116628. private static _getPluginForExtension;
  116629. private static _getPluginForDirectLoad;
  116630. private static _getPluginForFilename;
  116631. private static _getDirectLoad;
  116632. private static _loadData;
  116633. private static _getFileInfo;
  116634. /**
  116635. * Gets a plugin that can load the given extension
  116636. * @param extension defines the extension to load
  116637. * @returns a plugin or null if none works
  116638. */
  116639. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  116640. /**
  116641. * Gets a boolean indicating that the given extension can be loaded
  116642. * @param extension defines the extension to load
  116643. * @returns true if the extension is supported
  116644. */
  116645. static IsPluginForExtensionAvailable(extension: string): boolean;
  116646. /**
  116647. * Adds a new plugin to the list of registered plugins
  116648. * @param plugin defines the plugin to add
  116649. */
  116650. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  116651. /**
  116652. * Import meshes into a scene
  116653. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116654. * @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)
  116655. * @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)
  116656. * @param scene the instance of BABYLON.Scene to append to
  116657. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  116658. * @param onProgress a callback with a progress event for each file being loaded
  116659. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116660. * @param pluginExtension the extension used to determine the plugin
  116661. * @returns The loaded plugin
  116662. */
  116663. 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>;
  116664. /**
  116665. * Import meshes into a scene
  116666. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116667. * @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)
  116668. * @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)
  116669. * @param scene the instance of BABYLON.Scene to append to
  116670. * @param onProgress a callback with a progress event for each file being loaded
  116671. * @param pluginExtension the extension used to determine the plugin
  116672. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  116673. */
  116674. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  116675. meshes: AbstractMesh[];
  116676. particleSystems: IParticleSystem[];
  116677. skeletons: Skeleton[];
  116678. animationGroups: AnimationGroup[];
  116679. }>;
  116680. /**
  116681. * Load a scene
  116682. * @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)
  116683. * @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)
  116684. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116685. * @param onSuccess a callback with the scene when import succeeds
  116686. * @param onProgress a callback with a progress event for each file being loaded
  116687. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116688. * @param pluginExtension the extension used to determine the plugin
  116689. * @returns The loaded plugin
  116690. */
  116691. 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>;
  116692. /**
  116693. * Load a scene
  116694. * @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)
  116695. * @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)
  116696. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116697. * @param onProgress a callback with a progress event for each file being loaded
  116698. * @param pluginExtension the extension used to determine the plugin
  116699. * @returns The loaded scene
  116700. */
  116701. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116702. /**
  116703. * Append a scene
  116704. * @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)
  116705. * @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)
  116706. * @param scene is the instance of BABYLON.Scene to append to
  116707. * @param onSuccess a callback with the scene when import succeeds
  116708. * @param onProgress a callback with a progress event for each file being loaded
  116709. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116710. * @param pluginExtension the extension used to determine the plugin
  116711. * @returns The loaded plugin
  116712. */
  116713. 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>;
  116714. /**
  116715. * Append a scene
  116716. * @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)
  116717. * @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)
  116718. * @param scene is the instance of BABYLON.Scene to append to
  116719. * @param onProgress a callback with a progress event for each file being loaded
  116720. * @param pluginExtension the extension used to determine the plugin
  116721. * @returns The given scene
  116722. */
  116723. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116724. /**
  116725. * Load a scene into an asset container
  116726. * @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)
  116727. * @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)
  116728. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116729. * @param onSuccess a callback with the scene when import succeeds
  116730. * @param onProgress a callback with a progress event for each file being loaded
  116731. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116732. * @param pluginExtension the extension used to determine the plugin
  116733. * @returns The loaded plugin
  116734. */
  116735. 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>;
  116736. /**
  116737. * Load a scene into an asset container
  116738. * @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)
  116739. * @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)
  116740. * @param scene is the instance of Scene to append to
  116741. * @param onProgress a callback with a progress event for each file being loaded
  116742. * @param pluginExtension the extension used to determine the plugin
  116743. * @returns The loaded asset container
  116744. */
  116745. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  116746. /**
  116747. * Import animations from a file into a scene
  116748. * @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)
  116749. * @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)
  116750. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116751. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116752. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116753. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116754. * @param onSuccess a callback with the scene when import succeeds
  116755. * @param onProgress a callback with a progress event for each file being loaded
  116756. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116757. */
  116758. 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;
  116759. /**
  116760. * Import animations from a file into a scene
  116761. * @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)
  116762. * @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)
  116763. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116764. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116765. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116766. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116767. * @param onSuccess a callback with the scene when import succeeds
  116768. * @param onProgress a callback with a progress event for each file being loaded
  116769. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116770. * @returns the updated scene with imported animations
  116771. */
  116772. 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>;
  116773. }
  116774. }
  116775. declare module BABYLON {
  116776. /**
  116777. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  116778. */
  116779. export type MotionControllerHandness = "none" | "left" | "right";
  116780. /**
  116781. * The type of components available in motion controllers.
  116782. * This is not the name of the component.
  116783. */
  116784. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  116785. /**
  116786. * The state of a controller component
  116787. */
  116788. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  116789. /**
  116790. * The schema of motion controller layout.
  116791. * No object will be initialized using this interface
  116792. * This is used just to define the profile.
  116793. */
  116794. export interface IMotionControllerLayout {
  116795. /**
  116796. * Path to load the assets. Usually relative to the base path
  116797. */
  116798. assetPath: string;
  116799. /**
  116800. * Available components (unsorted)
  116801. */
  116802. components: {
  116803. /**
  116804. * A map of component Ids
  116805. */
  116806. [componentId: string]: {
  116807. /**
  116808. * The type of input the component outputs
  116809. */
  116810. type: MotionControllerComponentType;
  116811. /**
  116812. * The indices of this component in the gamepad object
  116813. */
  116814. gamepadIndices: {
  116815. /**
  116816. * Index of button
  116817. */
  116818. button?: number;
  116819. /**
  116820. * If available, index of x-axis
  116821. */
  116822. xAxis?: number;
  116823. /**
  116824. * If available, index of y-axis
  116825. */
  116826. yAxis?: number;
  116827. };
  116828. /**
  116829. * The mesh's root node name
  116830. */
  116831. rootNodeName: string;
  116832. /**
  116833. * Animation definitions for this model
  116834. */
  116835. visualResponses: {
  116836. [stateKey: string]: {
  116837. /**
  116838. * What property will be animated
  116839. */
  116840. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  116841. /**
  116842. * What states influence this visual response
  116843. */
  116844. states: MotionControllerComponentStateType[];
  116845. /**
  116846. * Type of animation - movement or visibility
  116847. */
  116848. valueNodeProperty: "transform" | "visibility";
  116849. /**
  116850. * Base node name to move. Its position will be calculated according to the min and max nodes
  116851. */
  116852. valueNodeName?: string;
  116853. /**
  116854. * Minimum movement node
  116855. */
  116856. minNodeName?: string;
  116857. /**
  116858. * Max movement node
  116859. */
  116860. maxNodeName?: string;
  116861. };
  116862. };
  116863. /**
  116864. * If touch enabled, what is the name of node to display user feedback
  116865. */
  116866. touchPointNodeName?: string;
  116867. };
  116868. };
  116869. /**
  116870. * Is it xr standard mapping or not
  116871. */
  116872. gamepadMapping: "" | "xr-standard";
  116873. /**
  116874. * Base root node of this entire model
  116875. */
  116876. rootNodeName: string;
  116877. /**
  116878. * Defines the main button component id
  116879. */
  116880. selectComponentId: string;
  116881. }
  116882. /**
  116883. * A definition for the layout map in the input profile
  116884. */
  116885. export interface IMotionControllerLayoutMap {
  116886. /**
  116887. * Layouts with handness type as a key
  116888. */
  116889. [handness: string]: IMotionControllerLayout;
  116890. }
  116891. /**
  116892. * The XR Input profile schema
  116893. * Profiles can be found here:
  116894. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  116895. */
  116896. export interface IMotionControllerProfile {
  116897. /**
  116898. * fallback profiles for this profileId
  116899. */
  116900. fallbackProfileIds: string[];
  116901. /**
  116902. * The layout map, with handness as key
  116903. */
  116904. layouts: IMotionControllerLayoutMap;
  116905. /**
  116906. * The id of this profile
  116907. * correlates to the profile(s) in the xrInput.profiles array
  116908. */
  116909. profileId: string;
  116910. }
  116911. /**
  116912. * A helper-interface for the 3 meshes needed for controller button animation
  116913. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  116914. */
  116915. export interface IMotionControllerButtonMeshMap {
  116916. /**
  116917. * the mesh that defines the pressed value mesh position.
  116918. * This is used to find the max-position of this button
  116919. */
  116920. pressedMesh: AbstractMesh;
  116921. /**
  116922. * the mesh that defines the unpressed value mesh position.
  116923. * This is used to find the min (or initial) position of this button
  116924. */
  116925. unpressedMesh: AbstractMesh;
  116926. /**
  116927. * The mesh that will be changed when value changes
  116928. */
  116929. valueMesh: AbstractMesh;
  116930. }
  116931. /**
  116932. * A helper-interface for the 3 meshes needed for controller axis animation.
  116933. * This will be expanded when touchpad animations are fully supported
  116934. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  116935. */
  116936. export interface IMotionControllerMeshMap {
  116937. /**
  116938. * the mesh that defines the maximum value mesh position.
  116939. */
  116940. maxMesh?: AbstractMesh;
  116941. /**
  116942. * the mesh that defines the minimum value mesh position.
  116943. */
  116944. minMesh?: AbstractMesh;
  116945. /**
  116946. * The mesh that will be changed when axis value changes
  116947. */
  116948. valueMesh: AbstractMesh;
  116949. }
  116950. /**
  116951. * The elements needed for change-detection of the gamepad objects in motion controllers
  116952. */
  116953. export interface IMinimalMotionControllerObject {
  116954. /**
  116955. * Available axes of this controller
  116956. */
  116957. axes: number[];
  116958. /**
  116959. * An array of available buttons
  116960. */
  116961. buttons: Array<{
  116962. /**
  116963. * Value of the button/trigger
  116964. */
  116965. value: number;
  116966. /**
  116967. * If the button/trigger is currently touched
  116968. */
  116969. touched: boolean;
  116970. /**
  116971. * If the button/trigger is currently pressed
  116972. */
  116973. pressed: boolean;
  116974. }>;
  116975. }
  116976. /**
  116977. * An Abstract Motion controller
  116978. * This class receives an xrInput and a profile layout and uses those to initialize the components
  116979. * Each component has an observable to check for changes in value and state
  116980. */
  116981. export abstract class WebXRAbstractMotionController implements IDisposable {
  116982. protected scene: Scene;
  116983. protected layout: IMotionControllerLayout;
  116984. /**
  116985. * The gamepad object correlating to this controller
  116986. */
  116987. gamepadObject: IMinimalMotionControllerObject;
  116988. /**
  116989. * handness (left/right/none) of this controller
  116990. */
  116991. handness: MotionControllerHandness;
  116992. private _initComponent;
  116993. private _modelReady;
  116994. /**
  116995. * A map of components (WebXRControllerComponent) in this motion controller
  116996. * Components have a ComponentType and can also have both button and axis definitions
  116997. */
  116998. readonly components: {
  116999. [id: string]: WebXRControllerComponent;
  117000. };
  117001. /**
  117002. * Disable the model's animation. Can be set at any time.
  117003. */
  117004. disableAnimation: boolean;
  117005. /**
  117006. * Observers registered here will be triggered when the model of this controller is done loading
  117007. */
  117008. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  117009. /**
  117010. * The profile id of this motion controller
  117011. */
  117012. abstract profileId: string;
  117013. /**
  117014. * The root mesh of the model. It is null if the model was not yet initialized
  117015. */
  117016. rootMesh: Nullable<AbstractMesh>;
  117017. /**
  117018. * constructs a new abstract motion controller
  117019. * @param scene the scene to which the model of the controller will be added
  117020. * @param layout The profile layout to load
  117021. * @param gamepadObject The gamepad object correlating to this controller
  117022. * @param handness handness (left/right/none) of this controller
  117023. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  117024. */
  117025. constructor(scene: Scene, layout: IMotionControllerLayout,
  117026. /**
  117027. * The gamepad object correlating to this controller
  117028. */
  117029. gamepadObject: IMinimalMotionControllerObject,
  117030. /**
  117031. * handness (left/right/none) of this controller
  117032. */
  117033. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  117034. /**
  117035. * Dispose this controller, the model mesh and all its components
  117036. */
  117037. dispose(): void;
  117038. /**
  117039. * Returns all components of specific type
  117040. * @param type the type to search for
  117041. * @return an array of components with this type
  117042. */
  117043. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  117044. /**
  117045. * get a component based an its component id as defined in layout.components
  117046. * @param id the id of the component
  117047. * @returns the component correlates to the id or undefined if not found
  117048. */
  117049. getComponent(id: string): WebXRControllerComponent;
  117050. /**
  117051. * Get the list of components available in this motion controller
  117052. * @returns an array of strings correlating to available components
  117053. */
  117054. getComponentIds(): string[];
  117055. /**
  117056. * Get the first component of specific type
  117057. * @param type type of component to find
  117058. * @return a controller component or null if not found
  117059. */
  117060. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  117061. /**
  117062. * Get the main (Select) component of this controller as defined in the layout
  117063. * @returns the main component of this controller
  117064. */
  117065. getMainComponent(): WebXRControllerComponent;
  117066. /**
  117067. * Loads the model correlating to this controller
  117068. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  117069. * @returns A promise fulfilled with the result of the model loading
  117070. */
  117071. loadModel(): Promise<boolean>;
  117072. /**
  117073. * Update this model using the current XRFrame
  117074. * @param xrFrame the current xr frame to use and update the model
  117075. */
  117076. updateFromXRFrame(xrFrame: XRFrame): void;
  117077. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117078. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117079. /**
  117080. * Moves the axis on the controller mesh based on its current state
  117081. * @param axis the index of the axis
  117082. * @param axisValue the value of the axis which determines the meshes new position
  117083. * @hidden
  117084. */
  117085. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  117086. /**
  117087. * Update the model itself with the current frame data
  117088. * @param xrFrame the frame to use for updating the model mesh
  117089. */
  117090. protected updateModel(xrFrame: XRFrame): void;
  117091. /**
  117092. * Get the filename and path for this controller's model
  117093. * @returns a map of filename and path
  117094. */
  117095. protected abstract _getFilenameAndPath(): {
  117096. filename: string;
  117097. path: string;
  117098. };
  117099. /**
  117100. * This function is called before the mesh is loaded. It checks for loading constraints.
  117101. * For example, this function can check if the GLB loader is available
  117102. * If this function returns false, the generic controller will be loaded instead
  117103. * @returns Is the client ready to load the mesh
  117104. */
  117105. protected abstract _getModelLoadingConstraints(): boolean;
  117106. /**
  117107. * This function will be called after the model was successfully loaded and can be used
  117108. * for mesh transformations before it is available for the user
  117109. * @param meshes the loaded meshes
  117110. */
  117111. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  117112. /**
  117113. * Set the root mesh for this controller. Important for the WebXR controller class
  117114. * @param meshes the loaded meshes
  117115. */
  117116. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  117117. /**
  117118. * A function executed each frame that updates the mesh (if needed)
  117119. * @param xrFrame the current xrFrame
  117120. */
  117121. protected abstract _updateModel(xrFrame: XRFrame): void;
  117122. private _getGenericFilenameAndPath;
  117123. private _getGenericParentMesh;
  117124. }
  117125. }
  117126. declare module BABYLON {
  117127. /**
  117128. * A generic trigger-only motion controller for WebXR
  117129. */
  117130. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  117131. /**
  117132. * Static version of the profile id of this controller
  117133. */
  117134. static ProfileId: string;
  117135. profileId: string;
  117136. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  117137. protected _getFilenameAndPath(): {
  117138. filename: string;
  117139. path: string;
  117140. };
  117141. protected _getModelLoadingConstraints(): boolean;
  117142. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  117143. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117144. protected _updateModel(): void;
  117145. }
  117146. }
  117147. declare module BABYLON {
  117148. /**
  117149. * Class containing static functions to help procedurally build meshes
  117150. */
  117151. export class SphereBuilder {
  117152. /**
  117153. * Creates a sphere mesh
  117154. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117155. * * 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`)
  117156. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117157. * * 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
  117158. * * 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)
  117159. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117160. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117161. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117162. * @param name defines the name of the mesh
  117163. * @param options defines the options used to create the mesh
  117164. * @param scene defines the hosting scene
  117165. * @returns the sphere mesh
  117166. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117167. */
  117168. static CreateSphere(name: string, options: {
  117169. segments?: number;
  117170. diameter?: number;
  117171. diameterX?: number;
  117172. diameterY?: number;
  117173. diameterZ?: number;
  117174. arc?: number;
  117175. slice?: number;
  117176. sideOrientation?: number;
  117177. frontUVs?: Vector4;
  117178. backUVs?: Vector4;
  117179. updatable?: boolean;
  117180. }, scene?: Nullable<Scene>): Mesh;
  117181. }
  117182. }
  117183. declare module BABYLON {
  117184. /**
  117185. * A profiled motion controller has its profile loaded from an online repository.
  117186. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  117187. */
  117188. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  117189. private _repositoryUrl;
  117190. private _buttonMeshMapping;
  117191. private _touchDots;
  117192. /**
  117193. * The profile ID of this controller. Will be populated when the controller initializes.
  117194. */
  117195. profileId: string;
  117196. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  117197. dispose(): void;
  117198. protected _getFilenameAndPath(): {
  117199. filename: string;
  117200. path: string;
  117201. };
  117202. protected _getModelLoadingConstraints(): boolean;
  117203. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117204. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117205. protected _updateModel(_xrFrame: XRFrame): void;
  117206. }
  117207. }
  117208. declare module BABYLON {
  117209. /**
  117210. * A construction function type to create a new controller based on an xrInput object
  117211. */
  117212. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  117213. /**
  117214. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  117215. *
  117216. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  117217. * it should be replaced with auto-loaded controllers.
  117218. *
  117219. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  117220. */
  117221. export class WebXRMotionControllerManager {
  117222. private static _AvailableControllers;
  117223. private static _Fallbacks;
  117224. private static _ProfileLoadingPromises;
  117225. private static _ProfilesList;
  117226. /**
  117227. * The base URL of the online controller repository. Can be changed at any time.
  117228. */
  117229. static BaseRepositoryUrl: string;
  117230. /**
  117231. * Which repository gets priority - local or online
  117232. */
  117233. static PrioritizeOnlineRepository: boolean;
  117234. /**
  117235. * Use the online repository, or use only locally-defined controllers
  117236. */
  117237. static UseOnlineRepository: boolean;
  117238. /**
  117239. * Clear the cache used for profile loading and reload when requested again
  117240. */
  117241. static ClearProfilesCache(): void;
  117242. /**
  117243. * Register the default fallbacks.
  117244. * This function is called automatically when this file is imported.
  117245. */
  117246. static DefaultFallbacks(): void;
  117247. /**
  117248. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  117249. * @param profileId the profile to which a fallback needs to be found
  117250. * @return an array with corresponding fallback profiles
  117251. */
  117252. static FindFallbackWithProfileId(profileId: string): string[];
  117253. /**
  117254. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  117255. * The order of search:
  117256. *
  117257. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  117258. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  117259. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  117260. * 4) return the generic trigger controller if none were found
  117261. *
  117262. * @param xrInput the xrInput to which a new controller is initialized
  117263. * @param scene the scene to which the model will be added
  117264. * @param forceProfile force a certain profile for this controller
  117265. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  117266. */
  117267. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  117268. /**
  117269. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  117270. *
  117271. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  117272. *
  117273. * @param type the profile type to register
  117274. * @param constructFunction the function to be called when loading this profile
  117275. */
  117276. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  117277. /**
  117278. * Register a fallback to a specific profile.
  117279. * @param profileId the profileId that will receive the fallbacks
  117280. * @param fallbacks A list of fallback profiles
  117281. */
  117282. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  117283. /**
  117284. * Will update the list of profiles available in the repository
  117285. * @return a promise that resolves to a map of profiles available online
  117286. */
  117287. static UpdateProfilesList(): Promise<{
  117288. [profile: string]: string;
  117289. }>;
  117290. private static _LoadProfileFromRepository;
  117291. private static _LoadProfilesFromAvailableControllers;
  117292. }
  117293. }
  117294. declare module BABYLON {
  117295. /**
  117296. * Configuration options for the WebXR controller creation
  117297. */
  117298. export interface IWebXRControllerOptions {
  117299. /**
  117300. * Should the controller mesh be animated when a user interacts with it
  117301. * The pressed buttons / thumbstick and touchpad animations will be disabled
  117302. */
  117303. disableMotionControllerAnimation?: boolean;
  117304. /**
  117305. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  117306. */
  117307. doNotLoadControllerMesh?: boolean;
  117308. /**
  117309. * Force a specific controller type for this controller.
  117310. * This can be used when creating your own profile or when testing different controllers
  117311. */
  117312. forceControllerProfile?: string;
  117313. }
  117314. /**
  117315. * Represents an XR controller
  117316. */
  117317. export class WebXRInputSource {
  117318. private _scene;
  117319. /** The underlying input source for the controller */
  117320. inputSource: XRInputSource;
  117321. private _options;
  117322. private _tmpQuaternion;
  117323. private _tmpVector;
  117324. private _uniqueId;
  117325. /**
  117326. * 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
  117327. */
  117328. grip?: AbstractMesh;
  117329. /**
  117330. * If available, this is the gamepad object related to this controller.
  117331. * Using this object it is possible to get click events and trackpad changes of the
  117332. * webxr controller that is currently being used.
  117333. */
  117334. motionController?: WebXRAbstractMotionController;
  117335. /**
  117336. * Event that fires when the controller is removed/disposed.
  117337. * The object provided as event data is this controller, after associated assets were disposed.
  117338. * uniqueId is still available.
  117339. */
  117340. onDisposeObservable: Observable<WebXRInputSource>;
  117341. /**
  117342. * Will be triggered when the mesh associated with the motion controller is done loading.
  117343. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  117344. * A shortened version of controller -> motion controller -> on mesh loaded.
  117345. */
  117346. onMeshLoadedObservable: Observable<AbstractMesh>;
  117347. /**
  117348. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  117349. */
  117350. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  117351. /**
  117352. * Pointer which can be used to select objects or attach a visible laser to
  117353. */
  117354. pointer: AbstractMesh;
  117355. /**
  117356. * Creates the controller
  117357. * @see https://doc.babylonjs.com/how_to/webxr
  117358. * @param _scene the scene which the controller should be associated to
  117359. * @param inputSource the underlying input source for the controller
  117360. * @param _options options for this controller creation
  117361. */
  117362. constructor(_scene: Scene,
  117363. /** The underlying input source for the controller */
  117364. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  117365. /**
  117366. * Get this controllers unique id
  117367. */
  117368. get uniqueId(): string;
  117369. /**
  117370. * Disposes of the object
  117371. */
  117372. dispose(): void;
  117373. /**
  117374. * Gets a world space ray coming from the pointer or grip
  117375. * @param result the resulting ray
  117376. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  117377. */
  117378. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  117379. /**
  117380. * Updates the controller pose based on the given XRFrame
  117381. * @param xrFrame xr frame to update the pose with
  117382. * @param referenceSpace reference space to use
  117383. */
  117384. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  117385. }
  117386. }
  117387. declare module BABYLON {
  117388. /**
  117389. * The schema for initialization options of the XR Input class
  117390. */
  117391. export interface IWebXRInputOptions {
  117392. /**
  117393. * If set to true no model will be automatically loaded
  117394. */
  117395. doNotLoadControllerMeshes?: boolean;
  117396. /**
  117397. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  117398. * If not found, the xr input profile data will be used.
  117399. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  117400. */
  117401. forceInputProfile?: string;
  117402. /**
  117403. * Do not send a request to the controller repository to load the profile.
  117404. *
  117405. * Instead, use the controllers available in babylon itself.
  117406. */
  117407. disableOnlineControllerRepository?: boolean;
  117408. /**
  117409. * A custom URL for the controllers repository
  117410. */
  117411. customControllersRepositoryURL?: string;
  117412. /**
  117413. * Should the controller model's components not move according to the user input
  117414. */
  117415. disableControllerAnimation?: boolean;
  117416. }
  117417. /**
  117418. * XR input used to track XR inputs such as controllers/rays
  117419. */
  117420. export class WebXRInput implements IDisposable {
  117421. /**
  117422. * the xr session manager for this session
  117423. */
  117424. xrSessionManager: WebXRSessionManager;
  117425. /**
  117426. * the WebXR camera for this session. Mainly used for teleportation
  117427. */
  117428. xrCamera: WebXRCamera;
  117429. private readonly options;
  117430. /**
  117431. * XR controllers being tracked
  117432. */
  117433. controllers: Array<WebXRInputSource>;
  117434. private _frameObserver;
  117435. private _sessionEndedObserver;
  117436. private _sessionInitObserver;
  117437. /**
  117438. * Event when a controller has been connected/added
  117439. */
  117440. onControllerAddedObservable: Observable<WebXRInputSource>;
  117441. /**
  117442. * Event when a controller has been removed/disconnected
  117443. */
  117444. onControllerRemovedObservable: Observable<WebXRInputSource>;
  117445. /**
  117446. * Initializes the WebXRInput
  117447. * @param xrSessionManager the xr session manager for this session
  117448. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  117449. * @param options = initialization options for this xr input
  117450. */
  117451. constructor(
  117452. /**
  117453. * the xr session manager for this session
  117454. */
  117455. xrSessionManager: WebXRSessionManager,
  117456. /**
  117457. * the WebXR camera for this session. Mainly used for teleportation
  117458. */
  117459. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  117460. private _onInputSourcesChange;
  117461. private _addAndRemoveControllers;
  117462. /**
  117463. * Disposes of the object
  117464. */
  117465. dispose(): void;
  117466. }
  117467. }
  117468. declare module BABYLON {
  117469. /**
  117470. * This is the base class for all WebXR features.
  117471. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  117472. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  117473. */
  117474. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  117475. protected _xrSessionManager: WebXRSessionManager;
  117476. private _attached;
  117477. private _removeOnDetach;
  117478. /**
  117479. * Should auto-attach be disabled?
  117480. */
  117481. disableAutoAttach: boolean;
  117482. /**
  117483. * Construct a new (abstract) WebXR feature
  117484. * @param _xrSessionManager the xr session manager for this feature
  117485. */
  117486. constructor(_xrSessionManager: WebXRSessionManager);
  117487. /**
  117488. * Is this feature attached
  117489. */
  117490. get attached(): boolean;
  117491. /**
  117492. * attach this feature
  117493. *
  117494. * @param force should attachment be forced (even when already attached)
  117495. * @returns true if successful, false is failed or already attached
  117496. */
  117497. attach(force?: boolean): boolean;
  117498. /**
  117499. * detach this feature.
  117500. *
  117501. * @returns true if successful, false if failed or already detached
  117502. */
  117503. detach(): boolean;
  117504. /**
  117505. * Dispose this feature and all of the resources attached
  117506. */
  117507. dispose(): void;
  117508. /**
  117509. * This is used to register callbacks that will automatically be removed when detach is called.
  117510. * @param observable the observable to which the observer will be attached
  117511. * @param callback the callback to register
  117512. */
  117513. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  117514. /**
  117515. * Code in this function will be executed on each xrFrame received from the browser.
  117516. * This function will not execute after the feature is detached.
  117517. * @param _xrFrame the current frame
  117518. */
  117519. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  117520. }
  117521. }
  117522. declare module BABYLON {
  117523. /**
  117524. * Renders a layer on top of an existing scene
  117525. */
  117526. export class UtilityLayerRenderer implements IDisposable {
  117527. /** the original scene that will be rendered on top of */
  117528. originalScene: Scene;
  117529. private _pointerCaptures;
  117530. private _lastPointerEvents;
  117531. private static _DefaultUtilityLayer;
  117532. private static _DefaultKeepDepthUtilityLayer;
  117533. private _sharedGizmoLight;
  117534. private _renderCamera;
  117535. /**
  117536. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  117537. * @returns the camera that is used when rendering the utility layer
  117538. */
  117539. getRenderCamera(): Camera;
  117540. /**
  117541. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  117542. * @param cam the camera that should be used when rendering the utility layer
  117543. */
  117544. setRenderCamera(cam: Nullable<Camera>): void;
  117545. /**
  117546. * @hidden
  117547. * Light which used by gizmos to get light shading
  117548. */
  117549. _getSharedGizmoLight(): HemisphericLight;
  117550. /**
  117551. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  117552. */
  117553. pickUtilitySceneFirst: boolean;
  117554. /**
  117555. * 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)
  117556. */
  117557. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  117558. /**
  117559. * 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)
  117560. */
  117561. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  117562. /**
  117563. * The scene that is rendered on top of the original scene
  117564. */
  117565. utilityLayerScene: Scene;
  117566. /**
  117567. * If the utility layer should automatically be rendered on top of existing scene
  117568. */
  117569. shouldRender: boolean;
  117570. /**
  117571. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  117572. */
  117573. onlyCheckPointerDownEvents: boolean;
  117574. /**
  117575. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  117576. */
  117577. processAllEvents: boolean;
  117578. /**
  117579. * Observable raised when the pointer move from the utility layer scene to the main scene
  117580. */
  117581. onPointerOutObservable: Observable<number>;
  117582. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  117583. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  117584. private _afterRenderObserver;
  117585. private _sceneDisposeObserver;
  117586. private _originalPointerObserver;
  117587. /**
  117588. * Instantiates a UtilityLayerRenderer
  117589. * @param originalScene the original scene that will be rendered on top of
  117590. * @param handleEvents boolean indicating if the utility layer should handle events
  117591. */
  117592. constructor(
  117593. /** the original scene that will be rendered on top of */
  117594. originalScene: Scene, handleEvents?: boolean);
  117595. private _notifyObservers;
  117596. /**
  117597. * Renders the utility layers scene on top of the original scene
  117598. */
  117599. render(): void;
  117600. /**
  117601. * Disposes of the renderer
  117602. */
  117603. dispose(): void;
  117604. private _updateCamera;
  117605. }
  117606. }
  117607. declare module BABYLON {
  117608. /**
  117609. * Options interface for the pointer selection module
  117610. */
  117611. export interface IWebXRControllerPointerSelectionOptions {
  117612. /**
  117613. * if provided, this scene will be used to render meshes.
  117614. */
  117615. customUtilityLayerScene?: Scene;
  117616. /**
  117617. * Disable the pointer up event when the xr controller in screen and gaze mode is disposed (meaning - when the user removed the finger from the screen)
  117618. * If not disabled, the last picked point will be used to execute a pointer up event
  117619. * If disabled, pointer up event will be triggered right after the pointer down event.
  117620. * Used in screen and gaze target ray mode only
  117621. */
  117622. disablePointerUpOnTouchOut: boolean;
  117623. /**
  117624. * For gaze mode (time to select instead of press)
  117625. */
  117626. forceGazeMode: boolean;
  117627. /**
  117628. * Factor to be applied to the pointer-moved function in the gaze mode. How sensitive should the gaze mode be when checking if the pointer moved
  117629. * to start a new countdown to the pointer down event.
  117630. * Defaults to 1.
  117631. */
  117632. gazeModePointerMovedFactor?: number;
  117633. /**
  117634. * Different button type to use instead of the main component
  117635. */
  117636. overrideButtonId?: string;
  117637. /**
  117638. * use this rendering group id for the meshes (optional)
  117639. */
  117640. renderingGroupId?: number;
  117641. /**
  117642. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  117643. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  117644. * 3000 means 3 seconds between pointing at something and selecting it
  117645. */
  117646. timeToSelect?: number;
  117647. /**
  117648. * Should meshes created here be added to a utility layer or the main scene
  117649. */
  117650. useUtilityLayer?: boolean;
  117651. /**
  117652. * the xr input to use with this pointer selection
  117653. */
  117654. xrInput: WebXRInput;
  117655. }
  117656. /**
  117657. * A module that will enable pointer selection for motion controllers of XR Input Sources
  117658. */
  117659. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  117660. private readonly _options;
  117661. private static _idCounter;
  117662. private _attachController;
  117663. private _controllers;
  117664. private _scene;
  117665. private _tmpVectorForPickCompare;
  117666. /**
  117667. * The module's name
  117668. */
  117669. static readonly Name: string;
  117670. /**
  117671. * The (Babylon) version of this module.
  117672. * This is an integer representing the implementation version.
  117673. * This number does not correspond to the WebXR specs version
  117674. */
  117675. static readonly Version: number;
  117676. /**
  117677. * Disable lighting on the laser pointer (so it will always be visible)
  117678. */
  117679. disablePointerLighting: boolean;
  117680. /**
  117681. * Disable lighting on the selection mesh (so it will always be visible)
  117682. */
  117683. disableSelectionMeshLighting: boolean;
  117684. /**
  117685. * Should the laser pointer be displayed
  117686. */
  117687. displayLaserPointer: boolean;
  117688. /**
  117689. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  117690. */
  117691. displaySelectionMesh: boolean;
  117692. /**
  117693. * This color will be set to the laser pointer when selection is triggered
  117694. */
  117695. laserPointerPickedColor: Color3;
  117696. /**
  117697. * Default color of the laser pointer
  117698. */
  117699. lasterPointerDefaultColor: Color3;
  117700. /**
  117701. * default color of the selection ring
  117702. */
  117703. selectionMeshDefaultColor: Color3;
  117704. /**
  117705. * This color will be applied to the selection ring when selection is triggered
  117706. */
  117707. selectionMeshPickedColor: Color3;
  117708. /**
  117709. * constructs a new background remover module
  117710. * @param _xrSessionManager the session manager for this module
  117711. * @param _options read-only options to be used in this module
  117712. */
  117713. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  117714. /**
  117715. * attach this feature
  117716. * Will usually be called by the features manager
  117717. *
  117718. * @returns true if successful.
  117719. */
  117720. attach(): boolean;
  117721. /**
  117722. * detach this feature.
  117723. * Will usually be called by the features manager
  117724. *
  117725. * @returns true if successful.
  117726. */
  117727. detach(): boolean;
  117728. /**
  117729. * Will get the mesh under a specific pointer.
  117730. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  117731. * @param controllerId the controllerId to check
  117732. * @returns The mesh under pointer or null if no mesh is under the pointer
  117733. */
  117734. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  117735. /**
  117736. * Get the xr controller that correlates to the pointer id in the pointer event
  117737. *
  117738. * @param id the pointer id to search for
  117739. * @returns the controller that correlates to this id or null if not found
  117740. */
  117741. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  117742. protected _onXRFrame(_xrFrame: XRFrame): void;
  117743. private _attachGazeMode;
  117744. private _attachScreenRayMode;
  117745. private _attachTrackedPointerRayMode;
  117746. private _convertNormalToDirectionOfRay;
  117747. private _detachController;
  117748. private _generateNewMeshPair;
  117749. private _pickingMoved;
  117750. private _updatePointerDistance;
  117751. }
  117752. }
  117753. declare module BABYLON {
  117754. /**
  117755. * Button which can be used to enter a different mode of XR
  117756. */
  117757. export class WebXREnterExitUIButton {
  117758. /** button element */
  117759. element: HTMLElement;
  117760. /** XR initialization options for the button */
  117761. sessionMode: XRSessionMode;
  117762. /** Reference space type */
  117763. referenceSpaceType: XRReferenceSpaceType;
  117764. /**
  117765. * Creates a WebXREnterExitUIButton
  117766. * @param element button element
  117767. * @param sessionMode XR initialization session mode
  117768. * @param referenceSpaceType the type of reference space to be used
  117769. */
  117770. constructor(
  117771. /** button element */
  117772. element: HTMLElement,
  117773. /** XR initialization options for the button */
  117774. sessionMode: XRSessionMode,
  117775. /** Reference space type */
  117776. referenceSpaceType: XRReferenceSpaceType);
  117777. /**
  117778. * Extendable function which can be used to update the button's visuals when the state changes
  117779. * @param activeButton the current active button in the UI
  117780. */
  117781. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  117782. }
  117783. /**
  117784. * Options to create the webXR UI
  117785. */
  117786. export class WebXREnterExitUIOptions {
  117787. /**
  117788. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  117789. */
  117790. customButtons?: Array<WebXREnterExitUIButton>;
  117791. /**
  117792. * A reference space type to use when creating the default button.
  117793. * Default is local-floor
  117794. */
  117795. referenceSpaceType?: XRReferenceSpaceType;
  117796. /**
  117797. * Context to enter xr with
  117798. */
  117799. renderTarget?: Nullable<WebXRRenderTarget>;
  117800. /**
  117801. * A session mode to use when creating the default button.
  117802. * Default is immersive-vr
  117803. */
  117804. sessionMode?: XRSessionMode;
  117805. }
  117806. /**
  117807. * UI to allow the user to enter/exit XR mode
  117808. */
  117809. export class WebXREnterExitUI implements IDisposable {
  117810. private scene;
  117811. /** version of the options passed to this UI */
  117812. options: WebXREnterExitUIOptions;
  117813. private _activeButton;
  117814. private _buttons;
  117815. private _overlay;
  117816. /**
  117817. * Fired every time the active button is changed.
  117818. *
  117819. * When xr is entered via a button that launches xr that button will be the callback parameter
  117820. *
  117821. * When exiting xr the callback parameter will be null)
  117822. */
  117823. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  117824. /**
  117825. *
  117826. * @param scene babylon scene object to use
  117827. * @param options (read-only) version of the options passed to this UI
  117828. */
  117829. private constructor();
  117830. /**
  117831. * Creates UI to allow the user to enter/exit XR mode
  117832. * @param scene the scene to add the ui to
  117833. * @param helper the xr experience helper to enter/exit xr with
  117834. * @param options options to configure the UI
  117835. * @returns the created ui
  117836. */
  117837. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  117838. /**
  117839. * Disposes of the XR UI component
  117840. */
  117841. dispose(): void;
  117842. private _updateButtons;
  117843. }
  117844. }
  117845. declare module BABYLON {
  117846. /**
  117847. * Class containing static functions to help procedurally build meshes
  117848. */
  117849. export class LinesBuilder {
  117850. /**
  117851. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  117852. * * 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
  117853. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  117854. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  117855. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  117856. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  117857. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117858. * * 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
  117859. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  117860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117861. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  117862. * @param name defines the name of the new line system
  117863. * @param options defines the options used to create the line system
  117864. * @param scene defines the hosting scene
  117865. * @returns a new line system mesh
  117866. */
  117867. static CreateLineSystem(name: string, options: {
  117868. lines: Vector3[][];
  117869. updatable?: boolean;
  117870. instance?: Nullable<LinesMesh>;
  117871. colors?: Nullable<Color4[][]>;
  117872. useVertexAlpha?: boolean;
  117873. }, scene: Nullable<Scene>): LinesMesh;
  117874. /**
  117875. * Creates a line mesh
  117876. * 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
  117877. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117878. * * The parameter `points` is an array successive Vector3
  117879. * * 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
  117880. * * The optional parameter `colors` is an array of successive Color4, one per line point
  117881. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  117882. * * When updating an instance, remember that only point positions can change, not the number of points
  117883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117884. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  117885. * @param name defines the name of the new line system
  117886. * @param options defines the options used to create the line system
  117887. * @param scene defines the hosting scene
  117888. * @returns a new line mesh
  117889. */
  117890. static CreateLines(name: string, options: {
  117891. points: Vector3[];
  117892. updatable?: boolean;
  117893. instance?: Nullable<LinesMesh>;
  117894. colors?: Color4[];
  117895. useVertexAlpha?: boolean;
  117896. }, scene?: Nullable<Scene>): LinesMesh;
  117897. /**
  117898. * Creates a dashed line mesh
  117899. * * 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
  117900. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  117901. * * The parameter `points` is an array successive Vector3
  117902. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  117903. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  117904. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  117905. * * 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
  117906. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  117907. * * When updating an instance, remember that only point positions can change, not the number of points
  117908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117909. * @param name defines the name of the mesh
  117910. * @param options defines the options used to create the mesh
  117911. * @param scene defines the hosting scene
  117912. * @returns the dashed line mesh
  117913. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  117914. */
  117915. static CreateDashedLines(name: string, options: {
  117916. points: Vector3[];
  117917. dashSize?: number;
  117918. gapSize?: number;
  117919. dashNb?: number;
  117920. updatable?: boolean;
  117921. instance?: LinesMesh;
  117922. useVertexAlpha?: boolean;
  117923. }, scene?: Nullable<Scene>): LinesMesh;
  117924. }
  117925. }
  117926. declare module BABYLON {
  117927. /**
  117928. * The options container for the teleportation module
  117929. */
  117930. export interface IWebXRTeleportationOptions {
  117931. /**
  117932. * if provided, this scene will be used to render meshes.
  117933. */
  117934. customUtilityLayerScene?: Scene;
  117935. /**
  117936. * Values to configure the default target mesh
  117937. */
  117938. defaultTargetMeshOptions?: {
  117939. /**
  117940. * Fill color of the teleportation area
  117941. */
  117942. teleportationFillColor?: string;
  117943. /**
  117944. * Border color for the teleportation area
  117945. */
  117946. teleportationBorderColor?: string;
  117947. /**
  117948. * Disable the mesh's animation sequence
  117949. */
  117950. disableAnimation?: boolean;
  117951. /**
  117952. * Disable lighting on the material or the ring and arrow
  117953. */
  117954. disableLighting?: boolean;
  117955. /**
  117956. * Override the default material of the torus and arrow
  117957. */
  117958. torusArrowMaterial?: Material;
  117959. };
  117960. /**
  117961. * A list of meshes to use as floor meshes.
  117962. * Meshes can be added and removed after initializing the feature using the
  117963. * addFloorMesh and removeFloorMesh functions
  117964. * If empty, rotation will still work
  117965. */
  117966. floorMeshes?: AbstractMesh[];
  117967. /**
  117968. * use this rendering group id for the meshes (optional)
  117969. */
  117970. renderingGroupId?: number;
  117971. /**
  117972. * Should teleportation move only to snap points
  117973. */
  117974. snapPointsOnly?: boolean;
  117975. /**
  117976. * An array of points to which the teleportation will snap to.
  117977. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  117978. */
  117979. snapPositions?: Vector3[];
  117980. /**
  117981. * How close should the teleportation ray be in order to snap to position.
  117982. * Default to 0.8 units (meters)
  117983. */
  117984. snapToPositionRadius?: number;
  117985. /**
  117986. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  117987. * If you want to support rotation, make sure your mesh has a direction indicator.
  117988. *
  117989. * When left untouched, the default mesh will be initialized.
  117990. */
  117991. teleportationTargetMesh?: AbstractMesh;
  117992. /**
  117993. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  117994. */
  117995. timeToTeleport?: number;
  117996. /**
  117997. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  117998. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  117999. */
  118000. useMainComponentOnly?: boolean;
  118001. /**
  118002. * Should meshes created here be added to a utility layer or the main scene
  118003. */
  118004. useUtilityLayer?: boolean;
  118005. /**
  118006. * Babylon XR Input class for controller
  118007. */
  118008. xrInput: WebXRInput;
  118009. }
  118010. /**
  118011. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  118012. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  118013. * the input of the attached controllers.
  118014. */
  118015. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  118016. private _options;
  118017. private _controllers;
  118018. private _currentTeleportationControllerId;
  118019. private _floorMeshes;
  118020. private _quadraticBezierCurve;
  118021. private _selectionFeature;
  118022. private _snapToPositions;
  118023. private _snappedToPoint;
  118024. private _teleportationRingMaterial?;
  118025. private _tmpRay;
  118026. private _tmpVector;
  118027. /**
  118028. * The module's name
  118029. */
  118030. static readonly Name: string;
  118031. /**
  118032. * The (Babylon) version of this module.
  118033. * This is an integer representing the implementation version.
  118034. * This number does not correspond to the webxr specs version
  118035. */
  118036. static readonly Version: number;
  118037. /**
  118038. * Is movement backwards enabled
  118039. */
  118040. backwardsMovementEnabled: boolean;
  118041. /**
  118042. * Distance to travel when moving backwards
  118043. */
  118044. backwardsTeleportationDistance: number;
  118045. /**
  118046. * The distance from the user to the inspection point in the direction of the controller
  118047. * A higher number will allow the user to move further
  118048. * defaults to 5 (meters, in xr units)
  118049. */
  118050. parabolicCheckRadius: number;
  118051. /**
  118052. * Should the module support parabolic ray on top of direct ray
  118053. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  118054. * Very helpful when moving between floors / different heights
  118055. */
  118056. parabolicRayEnabled: boolean;
  118057. /**
  118058. * How much rotation should be applied when rotating right and left
  118059. */
  118060. rotationAngle: number;
  118061. /**
  118062. * Is rotation enabled when moving forward?
  118063. * Disabling this feature will prevent the user from deciding the direction when teleporting
  118064. */
  118065. rotationEnabled: boolean;
  118066. /**
  118067. * constructs a new anchor system
  118068. * @param _xrSessionManager an instance of WebXRSessionManager
  118069. * @param _options configuration object for this feature
  118070. */
  118071. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  118072. /**
  118073. * Get the snapPointsOnly flag
  118074. */
  118075. get snapPointsOnly(): boolean;
  118076. /**
  118077. * Sets the snapPointsOnly flag
  118078. * @param snapToPoints should teleportation be exclusively to snap points
  118079. */
  118080. set snapPointsOnly(snapToPoints: boolean);
  118081. /**
  118082. * Add a new mesh to the floor meshes array
  118083. * @param mesh the mesh to use as floor mesh
  118084. */
  118085. addFloorMesh(mesh: AbstractMesh): void;
  118086. /**
  118087. * Add a new snap-to point to fix teleportation to this position
  118088. * @param newSnapPoint The new Snap-To point
  118089. */
  118090. addSnapPoint(newSnapPoint: Vector3): void;
  118091. attach(): boolean;
  118092. detach(): boolean;
  118093. dispose(): void;
  118094. /**
  118095. * Remove a mesh from the floor meshes array
  118096. * @param mesh the mesh to remove
  118097. */
  118098. removeFloorMesh(mesh: AbstractMesh): void;
  118099. /**
  118100. * Remove a mesh from the floor meshes array using its name
  118101. * @param name the mesh name to remove
  118102. */
  118103. removeFloorMeshByName(name: string): void;
  118104. /**
  118105. * This function will iterate through the array, searching for this point or equal to it. It will then remove it from the snap-to array
  118106. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  118107. * @returns was the point found and removed or not
  118108. */
  118109. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  118110. /**
  118111. * This function sets a selection feature that will be disabled when
  118112. * the forward ray is shown and will be reattached when hidden.
  118113. * This is used to remove the selection rays when moving.
  118114. * @param selectionFeature the feature to disable when forward movement is enabled
  118115. */
  118116. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  118117. protected _onXRFrame(_xrFrame: XRFrame): void;
  118118. private _attachController;
  118119. private _createDefaultTargetMesh;
  118120. private _detachController;
  118121. private _findClosestSnapPointWithRadius;
  118122. private _setTargetMeshPosition;
  118123. private _setTargetMeshVisibility;
  118124. private _showParabolicPath;
  118125. private _teleportForward;
  118126. }
  118127. }
  118128. declare module BABYLON {
  118129. /**
  118130. * Options for the default xr helper
  118131. */
  118132. export class WebXRDefaultExperienceOptions {
  118133. /**
  118134. * Enable or disable default UI to enter XR
  118135. */
  118136. disableDefaultUI?: boolean;
  118137. /**
  118138. * Should teleportation not initialize. defaults to false.
  118139. */
  118140. disableTeleportation?: boolean;
  118141. /**
  118142. * Floor meshes that will be used for teleport
  118143. */
  118144. floorMeshes?: Array<AbstractMesh>;
  118145. /**
  118146. * If set to true, the first frame will not be used to reset position
  118147. * The first frame is mainly used when copying transformation from the old camera
  118148. * Mainly used in AR
  118149. */
  118150. ignoreNativeCameraTransformation?: boolean;
  118151. /**
  118152. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  118153. */
  118154. inputOptions?: IWebXRInputOptions;
  118155. /**
  118156. * optional configuration for the output canvas
  118157. */
  118158. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  118159. /**
  118160. * optional UI options. This can be used among other to change session mode and reference space type
  118161. */
  118162. uiOptions?: WebXREnterExitUIOptions;
  118163. /**
  118164. * When loading teleportation and pointer select, use stable versions instead of latest.
  118165. */
  118166. useStablePlugins?: boolean;
  118167. }
  118168. /**
  118169. * Default experience which provides a similar setup to the previous webVRExperience
  118170. */
  118171. export class WebXRDefaultExperience {
  118172. /**
  118173. * Base experience
  118174. */
  118175. baseExperience: WebXRExperienceHelper;
  118176. /**
  118177. * Enables ui for entering/exiting xr
  118178. */
  118179. enterExitUI: WebXREnterExitUI;
  118180. /**
  118181. * Input experience extension
  118182. */
  118183. input: WebXRInput;
  118184. /**
  118185. * Enables laser pointer and selection
  118186. */
  118187. pointerSelection: WebXRControllerPointerSelection;
  118188. /**
  118189. * Default target xr should render to
  118190. */
  118191. renderTarget: WebXRRenderTarget;
  118192. /**
  118193. * Enables teleportation
  118194. */
  118195. teleportation: WebXRMotionControllerTeleportation;
  118196. private constructor();
  118197. /**
  118198. * Creates the default xr experience
  118199. * @param scene scene
  118200. * @param options options for basic configuration
  118201. * @returns resulting WebXRDefaultExperience
  118202. */
  118203. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118204. /**
  118205. * DIsposes of the experience helper
  118206. */
  118207. dispose(): void;
  118208. }
  118209. }
  118210. declare module BABYLON {
  118211. /**
  118212. * Options to modify the vr teleportation behavior.
  118213. */
  118214. export interface VRTeleportationOptions {
  118215. /**
  118216. * The name of the mesh which should be used as the teleportation floor. (default: null)
  118217. */
  118218. floorMeshName?: string;
  118219. /**
  118220. * A list of meshes to be used as the teleportation floor. (default: empty)
  118221. */
  118222. floorMeshes?: Mesh[];
  118223. /**
  118224. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  118225. */
  118226. teleportationMode?: number;
  118227. /**
  118228. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  118229. */
  118230. teleportationTime?: number;
  118231. /**
  118232. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  118233. */
  118234. teleportationSpeed?: number;
  118235. /**
  118236. * The easing function used in the animation or null for Linear. (default CircleEase)
  118237. */
  118238. easingFunction?: EasingFunction;
  118239. }
  118240. /**
  118241. * Options to modify the vr experience helper's behavior.
  118242. */
  118243. export interface VRExperienceHelperOptions extends WebVROptions {
  118244. /**
  118245. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  118246. */
  118247. createDeviceOrientationCamera?: boolean;
  118248. /**
  118249. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  118250. */
  118251. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  118252. /**
  118253. * Uses the main button on the controller to toggle the laser casted. (default: true)
  118254. */
  118255. laserToggle?: boolean;
  118256. /**
  118257. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  118258. */
  118259. floorMeshes?: Mesh[];
  118260. /**
  118261. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  118262. */
  118263. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  118264. /**
  118265. * Defines if WebXR should be used instead of WebVR (if available)
  118266. */
  118267. useXR?: boolean;
  118268. }
  118269. /**
  118270. * Event containing information after VR has been entered
  118271. */
  118272. export class OnAfterEnteringVRObservableEvent {
  118273. /**
  118274. * If entering vr was successful
  118275. */
  118276. success: boolean;
  118277. }
  118278. /**
  118279. * Helps to quickly add VR support to an existing scene.
  118280. * See http://doc.babylonjs.com/how_to/webvr_helper
  118281. */
  118282. export class VRExperienceHelper {
  118283. /** Options to modify the vr experience helper's behavior. */
  118284. webVROptions: VRExperienceHelperOptions;
  118285. private _scene;
  118286. private _position;
  118287. private _btnVR;
  118288. private _btnVRDisplayed;
  118289. private _webVRsupported;
  118290. private _webVRready;
  118291. private _webVRrequesting;
  118292. private _webVRpresenting;
  118293. private _hasEnteredVR;
  118294. private _fullscreenVRpresenting;
  118295. private _inputElement;
  118296. private _webVRCamera;
  118297. private _vrDeviceOrientationCamera;
  118298. private _deviceOrientationCamera;
  118299. private _existingCamera;
  118300. private _onKeyDown;
  118301. private _onVrDisplayPresentChange;
  118302. private _onVRDisplayChanged;
  118303. private _onVRRequestPresentStart;
  118304. private _onVRRequestPresentComplete;
  118305. /**
  118306. * 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)
  118307. */
  118308. enableGazeEvenWhenNoPointerLock: boolean;
  118309. /**
  118310. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  118311. */
  118312. exitVROnDoubleTap: boolean;
  118313. /**
  118314. * Observable raised right before entering VR.
  118315. */
  118316. onEnteringVRObservable: Observable<VRExperienceHelper>;
  118317. /**
  118318. * Observable raised when entering VR has completed.
  118319. */
  118320. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  118321. /**
  118322. * Observable raised when exiting VR.
  118323. */
  118324. onExitingVRObservable: Observable<VRExperienceHelper>;
  118325. /**
  118326. * Observable raised when controller mesh is loaded.
  118327. */
  118328. onControllerMeshLoadedObservable: Observable<WebVRController>;
  118329. /** Return this.onEnteringVRObservable
  118330. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  118331. */
  118332. get onEnteringVR(): Observable<VRExperienceHelper>;
  118333. /** Return this.onExitingVRObservable
  118334. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  118335. */
  118336. get onExitingVR(): Observable<VRExperienceHelper>;
  118337. /** Return this.onControllerMeshLoadedObservable
  118338. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  118339. */
  118340. get onControllerMeshLoaded(): Observable<WebVRController>;
  118341. private _rayLength;
  118342. private _useCustomVRButton;
  118343. private _teleportationRequested;
  118344. private _teleportActive;
  118345. private _floorMeshName;
  118346. private _floorMeshesCollection;
  118347. private _teleportationMode;
  118348. private _teleportationTime;
  118349. private _teleportationSpeed;
  118350. private _teleportationEasing;
  118351. private _rotationAllowed;
  118352. private _teleportBackwardsVector;
  118353. private _teleportationTarget;
  118354. private _isDefaultTeleportationTarget;
  118355. private _postProcessMove;
  118356. private _teleportationFillColor;
  118357. private _teleportationBorderColor;
  118358. private _rotationAngle;
  118359. private _haloCenter;
  118360. private _cameraGazer;
  118361. private _padSensibilityUp;
  118362. private _padSensibilityDown;
  118363. private _leftController;
  118364. private _rightController;
  118365. private _gazeColor;
  118366. private _laserColor;
  118367. private _pickedLaserColor;
  118368. private _pickedGazeColor;
  118369. /**
  118370. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  118371. */
  118372. onNewMeshSelected: Observable<AbstractMesh>;
  118373. /**
  118374. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  118375. * This observable will provide the mesh and the controller used to select the mesh
  118376. */
  118377. onMeshSelectedWithController: Observable<{
  118378. mesh: AbstractMesh;
  118379. controller: WebVRController;
  118380. }>;
  118381. /**
  118382. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  118383. */
  118384. onNewMeshPicked: Observable<PickingInfo>;
  118385. private _circleEase;
  118386. /**
  118387. * Observable raised before camera teleportation
  118388. */
  118389. onBeforeCameraTeleport: Observable<Vector3>;
  118390. /**
  118391. * Observable raised after camera teleportation
  118392. */
  118393. onAfterCameraTeleport: Observable<Vector3>;
  118394. /**
  118395. * Observable raised when current selected mesh gets unselected
  118396. */
  118397. onSelectedMeshUnselected: Observable<AbstractMesh>;
  118398. private _raySelectionPredicate;
  118399. /**
  118400. * To be optionaly changed by user to define custom ray selection
  118401. */
  118402. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  118403. /**
  118404. * To be optionaly changed by user to define custom selection logic (after ray selection)
  118405. */
  118406. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118407. /**
  118408. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  118409. */
  118410. teleportationEnabled: boolean;
  118411. private _defaultHeight;
  118412. private _teleportationInitialized;
  118413. private _interactionsEnabled;
  118414. private _interactionsRequested;
  118415. private _displayGaze;
  118416. private _displayLaserPointer;
  118417. /**
  118418. * The mesh used to display where the user is going to teleport.
  118419. */
  118420. get teleportationTarget(): Mesh;
  118421. /**
  118422. * Sets the mesh to be used to display where the user is going to teleport.
  118423. */
  118424. set teleportationTarget(value: Mesh);
  118425. /**
  118426. * 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
  118427. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  118428. * See http://doc.babylonjs.com/resources/baking_transformations
  118429. */
  118430. get gazeTrackerMesh(): Mesh;
  118431. set gazeTrackerMesh(value: Mesh);
  118432. /**
  118433. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  118434. */
  118435. updateGazeTrackerScale: boolean;
  118436. /**
  118437. * If the gaze trackers color should be updated when selecting meshes
  118438. */
  118439. updateGazeTrackerColor: boolean;
  118440. /**
  118441. * If the controller laser color should be updated when selecting meshes
  118442. */
  118443. updateControllerLaserColor: boolean;
  118444. /**
  118445. * The gaze tracking mesh corresponding to the left controller
  118446. */
  118447. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  118448. /**
  118449. * The gaze tracking mesh corresponding to the right controller
  118450. */
  118451. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  118452. /**
  118453. * If the ray of the gaze should be displayed.
  118454. */
  118455. get displayGaze(): boolean;
  118456. /**
  118457. * Sets if the ray of the gaze should be displayed.
  118458. */
  118459. set displayGaze(value: boolean);
  118460. /**
  118461. * If the ray of the LaserPointer should be displayed.
  118462. */
  118463. get displayLaserPointer(): boolean;
  118464. /**
  118465. * Sets if the ray of the LaserPointer should be displayed.
  118466. */
  118467. set displayLaserPointer(value: boolean);
  118468. /**
  118469. * The deviceOrientationCamera used as the camera when not in VR.
  118470. */
  118471. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  118472. /**
  118473. * Based on the current WebVR support, returns the current VR camera used.
  118474. */
  118475. get currentVRCamera(): Nullable<Camera>;
  118476. /**
  118477. * The webVRCamera which is used when in VR.
  118478. */
  118479. get webVRCamera(): WebVRFreeCamera;
  118480. /**
  118481. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  118482. */
  118483. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  118484. /**
  118485. * The html button that is used to trigger entering into VR.
  118486. */
  118487. get vrButton(): Nullable<HTMLButtonElement>;
  118488. private get _teleportationRequestInitiated();
  118489. /**
  118490. * Defines whether or not Pointer lock should be requested when switching to
  118491. * full screen.
  118492. */
  118493. requestPointerLockOnFullScreen: boolean;
  118494. /**
  118495. * If asking to force XR, this will be populated with the default xr experience
  118496. */
  118497. xr: WebXRDefaultExperience;
  118498. /**
  118499. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  118500. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  118501. */
  118502. xrTestDone: boolean;
  118503. /**
  118504. * Instantiates a VRExperienceHelper.
  118505. * Helps to quickly add VR support to an existing scene.
  118506. * @param scene The scene the VRExperienceHelper belongs to.
  118507. * @param webVROptions Options to modify the vr experience helper's behavior.
  118508. */
  118509. constructor(scene: Scene,
  118510. /** Options to modify the vr experience helper's behavior. */
  118511. webVROptions?: VRExperienceHelperOptions);
  118512. private completeVRInit;
  118513. private _onDefaultMeshLoaded;
  118514. private _onResize;
  118515. private _onFullscreenChange;
  118516. /**
  118517. * Gets a value indicating if we are currently in VR mode.
  118518. */
  118519. get isInVRMode(): boolean;
  118520. private onVrDisplayPresentChange;
  118521. private onVRDisplayChanged;
  118522. private moveButtonToBottomRight;
  118523. private displayVRButton;
  118524. private updateButtonVisibility;
  118525. private _cachedAngularSensibility;
  118526. /**
  118527. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  118528. * Otherwise, will use the fullscreen API.
  118529. */
  118530. enterVR(): void;
  118531. /**
  118532. * Attempt to exit VR, or fullscreen.
  118533. */
  118534. exitVR(): void;
  118535. /**
  118536. * The position of the vr experience helper.
  118537. */
  118538. get position(): Vector3;
  118539. /**
  118540. * Sets the position of the vr experience helper.
  118541. */
  118542. set position(value: Vector3);
  118543. /**
  118544. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  118545. */
  118546. enableInteractions(): void;
  118547. private get _noControllerIsActive();
  118548. private beforeRender;
  118549. private _isTeleportationFloor;
  118550. /**
  118551. * Adds a floor mesh to be used for teleportation.
  118552. * @param floorMesh the mesh to be used for teleportation.
  118553. */
  118554. addFloorMesh(floorMesh: Mesh): void;
  118555. /**
  118556. * Removes a floor mesh from being used for teleportation.
  118557. * @param floorMesh the mesh to be removed.
  118558. */
  118559. removeFloorMesh(floorMesh: Mesh): void;
  118560. /**
  118561. * Enables interactions and teleportation using the VR controllers and gaze.
  118562. * @param vrTeleportationOptions options to modify teleportation behavior.
  118563. */
  118564. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  118565. private _onNewGamepadConnected;
  118566. private _tryEnableInteractionOnController;
  118567. private _onNewGamepadDisconnected;
  118568. private _enableInteractionOnController;
  118569. private _checkTeleportWithRay;
  118570. private _checkRotate;
  118571. private _checkTeleportBackwards;
  118572. private _enableTeleportationOnController;
  118573. private _createTeleportationCircles;
  118574. private _displayTeleportationTarget;
  118575. private _hideTeleportationTarget;
  118576. private _rotateCamera;
  118577. private _moveTeleportationSelectorTo;
  118578. private _workingVector;
  118579. private _workingQuaternion;
  118580. private _workingMatrix;
  118581. /**
  118582. * Time Constant Teleportation Mode
  118583. */
  118584. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  118585. /**
  118586. * Speed Constant Teleportation Mode
  118587. */
  118588. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  118589. /**
  118590. * Teleports the users feet to the desired location
  118591. * @param location The location where the user's feet should be placed
  118592. */
  118593. teleportCamera(location: Vector3): void;
  118594. private _convertNormalToDirectionOfRay;
  118595. private _castRayAndSelectObject;
  118596. private _notifySelectedMeshUnselected;
  118597. /**
  118598. * Permanently set new colors for the laser pointer
  118599. * @param color the new laser color
  118600. * @param pickedColor the new laser color when picked mesh detected
  118601. */
  118602. setLaserColor(color: Color3, pickedColor?: Color3): void;
  118603. /**
  118604. * Set lighting enabled / disabled on the laser pointer of both controllers
  118605. * @param enabled should the lighting be enabled on the laser pointer
  118606. */
  118607. setLaserLightingState(enabled?: boolean): void;
  118608. /**
  118609. * Permanently set new colors for the gaze pointer
  118610. * @param color the new gaze color
  118611. * @param pickedColor the new gaze color when picked mesh detected
  118612. */
  118613. setGazeColor(color: Color3, pickedColor?: Color3): void;
  118614. /**
  118615. * Sets the color of the laser ray from the vr controllers.
  118616. * @param color new color for the ray.
  118617. */
  118618. changeLaserColor(color: Color3): void;
  118619. /**
  118620. * Sets the color of the ray from the vr headsets gaze.
  118621. * @param color new color for the ray.
  118622. */
  118623. changeGazeColor(color: Color3): void;
  118624. /**
  118625. * Exits VR and disposes of the vr experience helper
  118626. */
  118627. dispose(): void;
  118628. /**
  118629. * Gets the name of the VRExperienceHelper class
  118630. * @returns "VRExperienceHelper"
  118631. */
  118632. getClassName(): string;
  118633. }
  118634. }
  118635. declare module BABYLON {
  118636. /**
  118637. * Contains an array of blocks representing the octree
  118638. */
  118639. export interface IOctreeContainer<T> {
  118640. /**
  118641. * Blocks within the octree
  118642. */
  118643. blocks: Array<OctreeBlock<T>>;
  118644. }
  118645. /**
  118646. * Class used to store a cell in an octree
  118647. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118648. */
  118649. export class OctreeBlock<T> {
  118650. /**
  118651. * Gets the content of the current block
  118652. */
  118653. entries: T[];
  118654. /**
  118655. * Gets the list of block children
  118656. */
  118657. blocks: Array<OctreeBlock<T>>;
  118658. private _depth;
  118659. private _maxDepth;
  118660. private _capacity;
  118661. private _minPoint;
  118662. private _maxPoint;
  118663. private _boundingVectors;
  118664. private _creationFunc;
  118665. /**
  118666. * Creates a new block
  118667. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  118668. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  118669. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118670. * @param depth defines the current depth of this block in the octree
  118671. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  118672. * @param creationFunc defines a callback to call when an element is added to the block
  118673. */
  118674. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  118675. /**
  118676. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118677. */
  118678. get capacity(): number;
  118679. /**
  118680. * Gets the minimum vector (in world space) of the block's bounding box
  118681. */
  118682. get minPoint(): Vector3;
  118683. /**
  118684. * Gets the maximum vector (in world space) of the block's bounding box
  118685. */
  118686. get maxPoint(): Vector3;
  118687. /**
  118688. * Add a new element to this block
  118689. * @param entry defines the element to add
  118690. */
  118691. addEntry(entry: T): void;
  118692. /**
  118693. * Remove an element from this block
  118694. * @param entry defines the element to remove
  118695. */
  118696. removeEntry(entry: T): void;
  118697. /**
  118698. * Add an array of elements to this block
  118699. * @param entries defines the array of elements to add
  118700. */
  118701. addEntries(entries: T[]): void;
  118702. /**
  118703. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  118704. * @param frustumPlanes defines the frustum planes to test
  118705. * @param selection defines the array to store current content if selection is positive
  118706. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118707. */
  118708. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118709. /**
  118710. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  118711. * @param sphereCenter defines the bounding sphere center
  118712. * @param sphereRadius defines the bounding sphere radius
  118713. * @param selection defines the array to store current content if selection is positive
  118714. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118715. */
  118716. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118717. /**
  118718. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  118719. * @param ray defines the ray to test with
  118720. * @param selection defines the array to store current content if selection is positive
  118721. */
  118722. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  118723. /**
  118724. * Subdivide the content into child blocks (this block will then be empty)
  118725. */
  118726. createInnerBlocks(): void;
  118727. /**
  118728. * @hidden
  118729. */
  118730. 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;
  118731. }
  118732. }
  118733. declare module BABYLON {
  118734. /**
  118735. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  118736. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118737. */
  118738. export class Octree<T> {
  118739. /** 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.) */
  118740. maxDepth: number;
  118741. /**
  118742. * Blocks within the octree containing objects
  118743. */
  118744. blocks: Array<OctreeBlock<T>>;
  118745. /**
  118746. * Content stored in the octree
  118747. */
  118748. dynamicContent: T[];
  118749. private _maxBlockCapacity;
  118750. private _selectionContent;
  118751. private _creationFunc;
  118752. /**
  118753. * Creates a octree
  118754. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118755. * @param creationFunc function to be used to instatiate the octree
  118756. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  118757. * @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.)
  118758. */
  118759. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  118760. /** 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.) */
  118761. maxDepth?: number);
  118762. /**
  118763. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  118764. * @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);
  118765. * @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);
  118766. * @param entries meshes to be added to the octree blocks
  118767. */
  118768. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  118769. /**
  118770. * Adds a mesh to the octree
  118771. * @param entry Mesh to add to the octree
  118772. */
  118773. addMesh(entry: T): void;
  118774. /**
  118775. * Remove an element from the octree
  118776. * @param entry defines the element to remove
  118777. */
  118778. removeMesh(entry: T): void;
  118779. /**
  118780. * Selects an array of meshes within the frustum
  118781. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  118782. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  118783. * @returns array of meshes within the frustum
  118784. */
  118785. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  118786. /**
  118787. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  118788. * @param sphereCenter defines the bounding sphere center
  118789. * @param sphereRadius defines the bounding sphere radius
  118790. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118791. * @returns an array of objects that intersect the sphere
  118792. */
  118793. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  118794. /**
  118795. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  118796. * @param ray defines the ray to test with
  118797. * @returns array of intersected objects
  118798. */
  118799. intersectsRay(ray: Ray): SmartArray<T>;
  118800. /**
  118801. * Adds a mesh into the octree block if it intersects the block
  118802. */
  118803. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  118804. /**
  118805. * Adds a submesh into the octree block if it intersects the block
  118806. */
  118807. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  118808. }
  118809. }
  118810. declare module BABYLON {
  118811. interface Scene {
  118812. /**
  118813. * @hidden
  118814. * Backing Filed
  118815. */
  118816. _selectionOctree: Octree<AbstractMesh>;
  118817. /**
  118818. * Gets the octree used to boost mesh selection (picking)
  118819. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118820. */
  118821. selectionOctree: Octree<AbstractMesh>;
  118822. /**
  118823. * Creates or updates the octree used to boost selection (picking)
  118824. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118825. * @param maxCapacity defines the maximum capacity per leaf
  118826. * @param maxDepth defines the maximum depth of the octree
  118827. * @returns an octree of AbstractMesh
  118828. */
  118829. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  118830. }
  118831. interface AbstractMesh {
  118832. /**
  118833. * @hidden
  118834. * Backing Field
  118835. */
  118836. _submeshesOctree: Octree<SubMesh>;
  118837. /**
  118838. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  118839. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  118840. * @param maxCapacity defines the maximum size of each block (64 by default)
  118841. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  118842. * @returns the new octree
  118843. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  118844. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118845. */
  118846. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  118847. }
  118848. /**
  118849. * Defines the octree scene component responsible to manage any octrees
  118850. * in a given scene.
  118851. */
  118852. export class OctreeSceneComponent {
  118853. /**
  118854. * The component name help to identify the component in the list of scene components.
  118855. */
  118856. readonly name: string;
  118857. /**
  118858. * The scene the component belongs to.
  118859. */
  118860. scene: Scene;
  118861. /**
  118862. * Indicates if the meshes have been checked to make sure they are isEnabled()
  118863. */
  118864. readonly checksIsEnabled: boolean;
  118865. /**
  118866. * Creates a new instance of the component for the given scene
  118867. * @param scene Defines the scene to register the component in
  118868. */
  118869. constructor(scene: Scene);
  118870. /**
  118871. * Registers the component in a given scene
  118872. */
  118873. register(): void;
  118874. /**
  118875. * Return the list of active meshes
  118876. * @returns the list of active meshes
  118877. */
  118878. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  118879. /**
  118880. * Return the list of active sub meshes
  118881. * @param mesh The mesh to get the candidates sub meshes from
  118882. * @returns the list of active sub meshes
  118883. */
  118884. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  118885. private _tempRay;
  118886. /**
  118887. * Return the list of sub meshes intersecting with a given local ray
  118888. * @param mesh defines the mesh to find the submesh for
  118889. * @param localRay defines the ray in local space
  118890. * @returns the list of intersecting sub meshes
  118891. */
  118892. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  118893. /**
  118894. * Return the list of sub meshes colliding with a collider
  118895. * @param mesh defines the mesh to find the submesh for
  118896. * @param collider defines the collider to evaluate the collision against
  118897. * @returns the list of colliding sub meshes
  118898. */
  118899. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  118900. /**
  118901. * Rebuilds the elements related to this component in case of
  118902. * context lost for instance.
  118903. */
  118904. rebuild(): void;
  118905. /**
  118906. * Disposes the component and the associated ressources.
  118907. */
  118908. dispose(): void;
  118909. }
  118910. }
  118911. declare module BABYLON {
  118912. /**
  118913. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  118914. */
  118915. export class Gizmo implements IDisposable {
  118916. /** The utility layer the gizmo will be added to */
  118917. gizmoLayer: UtilityLayerRenderer;
  118918. /**
  118919. * The root mesh of the gizmo
  118920. */
  118921. _rootMesh: Mesh;
  118922. private _attachedMesh;
  118923. /**
  118924. * Ratio for the scale of the gizmo (Default: 1)
  118925. */
  118926. scaleRatio: number;
  118927. /**
  118928. * If a custom mesh has been set (Default: false)
  118929. */
  118930. protected _customMeshSet: boolean;
  118931. /**
  118932. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  118933. * * When set, interactions will be enabled
  118934. */
  118935. get attachedMesh(): Nullable<AbstractMesh>;
  118936. set attachedMesh(value: Nullable<AbstractMesh>);
  118937. /**
  118938. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  118939. * @param mesh The mesh to replace the default mesh of the gizmo
  118940. */
  118941. setCustomMesh(mesh: Mesh): void;
  118942. /**
  118943. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  118944. */
  118945. updateGizmoRotationToMatchAttachedMesh: boolean;
  118946. /**
  118947. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  118948. */
  118949. updateGizmoPositionToMatchAttachedMesh: boolean;
  118950. /**
  118951. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  118952. */
  118953. updateScale: boolean;
  118954. protected _interactionsEnabled: boolean;
  118955. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  118956. private _beforeRenderObserver;
  118957. private _tempVector;
  118958. /**
  118959. * Creates a gizmo
  118960. * @param gizmoLayer The utility layer the gizmo will be added to
  118961. */
  118962. constructor(
  118963. /** The utility layer the gizmo will be added to */
  118964. gizmoLayer?: UtilityLayerRenderer);
  118965. /**
  118966. * Updates the gizmo to match the attached mesh's position/rotation
  118967. */
  118968. protected _update(): void;
  118969. /**
  118970. * Disposes of the gizmo
  118971. */
  118972. dispose(): void;
  118973. }
  118974. }
  118975. declare module BABYLON {
  118976. /**
  118977. * Single plane drag gizmo
  118978. */
  118979. export class PlaneDragGizmo extends Gizmo {
  118980. /**
  118981. * Drag behavior responsible for the gizmos dragging interactions
  118982. */
  118983. dragBehavior: PointerDragBehavior;
  118984. private _pointerObserver;
  118985. /**
  118986. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  118987. */
  118988. snapDistance: number;
  118989. /**
  118990. * Event that fires each time the gizmo snaps to a new location.
  118991. * * snapDistance is the the change in distance
  118992. */
  118993. onSnapObservable: Observable<{
  118994. snapDistance: number;
  118995. }>;
  118996. private _plane;
  118997. private _coloredMaterial;
  118998. private _hoverMaterial;
  118999. private _isEnabled;
  119000. private _parent;
  119001. /** @hidden */
  119002. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  119003. /** @hidden */
  119004. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119005. /**
  119006. * Creates a PlaneDragGizmo
  119007. * @param gizmoLayer The utility layer the gizmo will be added to
  119008. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  119009. * @param color The color of the gizmo
  119010. */
  119011. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119012. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119013. /**
  119014. * If the gizmo is enabled
  119015. */
  119016. set isEnabled(value: boolean);
  119017. get isEnabled(): boolean;
  119018. /**
  119019. * Disposes of the gizmo
  119020. */
  119021. dispose(): void;
  119022. }
  119023. }
  119024. declare module BABYLON {
  119025. /**
  119026. * Gizmo that enables dragging a mesh along 3 axis
  119027. */
  119028. export class PositionGizmo extends Gizmo {
  119029. /**
  119030. * Internal gizmo used for interactions on the x axis
  119031. */
  119032. xGizmo: AxisDragGizmo;
  119033. /**
  119034. * Internal gizmo used for interactions on the y axis
  119035. */
  119036. yGizmo: AxisDragGizmo;
  119037. /**
  119038. * Internal gizmo used for interactions on the z axis
  119039. */
  119040. zGizmo: AxisDragGizmo;
  119041. /**
  119042. * Internal gizmo used for interactions on the yz plane
  119043. */
  119044. xPlaneGizmo: PlaneDragGizmo;
  119045. /**
  119046. * Internal gizmo used for interactions on the xz plane
  119047. */
  119048. yPlaneGizmo: PlaneDragGizmo;
  119049. /**
  119050. * Internal gizmo used for interactions on the xy plane
  119051. */
  119052. zPlaneGizmo: PlaneDragGizmo;
  119053. /**
  119054. * private variables
  119055. */
  119056. private _meshAttached;
  119057. private _updateGizmoRotationToMatchAttachedMesh;
  119058. private _snapDistance;
  119059. private _scaleRatio;
  119060. /** Fires an event when any of it's sub gizmos are dragged */
  119061. onDragStartObservable: Observable<unknown>;
  119062. /** Fires an event when any of it's sub gizmos are released from dragging */
  119063. onDragEndObservable: Observable<unknown>;
  119064. /**
  119065. * If set to true, planar drag is enabled
  119066. */
  119067. private _planarGizmoEnabled;
  119068. get attachedMesh(): Nullable<AbstractMesh>;
  119069. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119070. /**
  119071. * Creates a PositionGizmo
  119072. * @param gizmoLayer The utility layer the gizmo will be added to
  119073. */
  119074. constructor(gizmoLayer?: UtilityLayerRenderer);
  119075. /**
  119076. * If the planar drag gizmo is enabled
  119077. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  119078. */
  119079. set planarGizmoEnabled(value: boolean);
  119080. get planarGizmoEnabled(): boolean;
  119081. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119082. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119083. /**
  119084. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119085. */
  119086. set snapDistance(value: number);
  119087. get snapDistance(): number;
  119088. /**
  119089. * Ratio for the scale of the gizmo (Default: 1)
  119090. */
  119091. set scaleRatio(value: number);
  119092. get scaleRatio(): number;
  119093. /**
  119094. * Disposes of the gizmo
  119095. */
  119096. dispose(): void;
  119097. /**
  119098. * CustomMeshes are not supported by this gizmo
  119099. * @param mesh The mesh to replace the default mesh of the gizmo
  119100. */
  119101. setCustomMesh(mesh: Mesh): void;
  119102. }
  119103. }
  119104. declare module BABYLON {
  119105. /**
  119106. * Single axis drag gizmo
  119107. */
  119108. export class AxisDragGizmo extends Gizmo {
  119109. /**
  119110. * Drag behavior responsible for the gizmos dragging interactions
  119111. */
  119112. dragBehavior: PointerDragBehavior;
  119113. private _pointerObserver;
  119114. /**
  119115. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119116. */
  119117. snapDistance: number;
  119118. /**
  119119. * Event that fires each time the gizmo snaps to a new location.
  119120. * * snapDistance is the the change in distance
  119121. */
  119122. onSnapObservable: Observable<{
  119123. snapDistance: number;
  119124. }>;
  119125. private _isEnabled;
  119126. private _parent;
  119127. private _arrow;
  119128. private _coloredMaterial;
  119129. private _hoverMaterial;
  119130. /** @hidden */
  119131. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  119132. /** @hidden */
  119133. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119134. /**
  119135. * Creates an AxisDragGizmo
  119136. * @param gizmoLayer The utility layer the gizmo will be added to
  119137. * @param dragAxis The axis which the gizmo will be able to drag on
  119138. * @param color The color of the gizmo
  119139. */
  119140. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119141. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119142. /**
  119143. * If the gizmo is enabled
  119144. */
  119145. set isEnabled(value: boolean);
  119146. get isEnabled(): boolean;
  119147. /**
  119148. * Disposes of the gizmo
  119149. */
  119150. dispose(): void;
  119151. }
  119152. }
  119153. declare module BABYLON.Debug {
  119154. /**
  119155. * The Axes viewer will show 3 axes in a specific point in space
  119156. */
  119157. export class AxesViewer {
  119158. private _xAxis;
  119159. private _yAxis;
  119160. private _zAxis;
  119161. private _scaleLinesFactor;
  119162. private _instanced;
  119163. /**
  119164. * Gets the hosting scene
  119165. */
  119166. scene: Scene;
  119167. /**
  119168. * Gets or sets a number used to scale line length
  119169. */
  119170. scaleLines: number;
  119171. /** Gets the node hierarchy used to render x-axis */
  119172. get xAxis(): TransformNode;
  119173. /** Gets the node hierarchy used to render y-axis */
  119174. get yAxis(): TransformNode;
  119175. /** Gets the node hierarchy used to render z-axis */
  119176. get zAxis(): TransformNode;
  119177. /**
  119178. * Creates a new AxesViewer
  119179. * @param scene defines the hosting scene
  119180. * @param scaleLines defines a number used to scale line length (1 by default)
  119181. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  119182. * @param xAxis defines the node hierarchy used to render the x-axis
  119183. * @param yAxis defines the node hierarchy used to render the y-axis
  119184. * @param zAxis defines the node hierarchy used to render the z-axis
  119185. */
  119186. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  119187. /**
  119188. * Force the viewer to update
  119189. * @param position defines the position of the viewer
  119190. * @param xaxis defines the x axis of the viewer
  119191. * @param yaxis defines the y axis of the viewer
  119192. * @param zaxis defines the z axis of the viewer
  119193. */
  119194. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  119195. /**
  119196. * Creates an instance of this axes viewer.
  119197. * @returns a new axes viewer with instanced meshes
  119198. */
  119199. createInstance(): AxesViewer;
  119200. /** Releases resources */
  119201. dispose(): void;
  119202. private static _SetRenderingGroupId;
  119203. }
  119204. }
  119205. declare module BABYLON.Debug {
  119206. /**
  119207. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  119208. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  119209. */
  119210. export class BoneAxesViewer extends AxesViewer {
  119211. /**
  119212. * Gets or sets the target mesh where to display the axes viewer
  119213. */
  119214. mesh: Nullable<Mesh>;
  119215. /**
  119216. * Gets or sets the target bone where to display the axes viewer
  119217. */
  119218. bone: Nullable<Bone>;
  119219. /** Gets current position */
  119220. pos: Vector3;
  119221. /** Gets direction of X axis */
  119222. xaxis: Vector3;
  119223. /** Gets direction of Y axis */
  119224. yaxis: Vector3;
  119225. /** Gets direction of Z axis */
  119226. zaxis: Vector3;
  119227. /**
  119228. * Creates a new BoneAxesViewer
  119229. * @param scene defines the hosting scene
  119230. * @param bone defines the target bone
  119231. * @param mesh defines the target mesh
  119232. * @param scaleLines defines a scaling factor for line length (1 by default)
  119233. */
  119234. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  119235. /**
  119236. * Force the viewer to update
  119237. */
  119238. update(): void;
  119239. /** Releases resources */
  119240. dispose(): void;
  119241. }
  119242. }
  119243. declare module BABYLON {
  119244. /**
  119245. * Interface used to define scene explorer extensibility option
  119246. */
  119247. export interface IExplorerExtensibilityOption {
  119248. /**
  119249. * Define the option label
  119250. */
  119251. label: string;
  119252. /**
  119253. * Defines the action to execute on click
  119254. */
  119255. action: (entity: any) => void;
  119256. }
  119257. /**
  119258. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  119259. */
  119260. export interface IExplorerExtensibilityGroup {
  119261. /**
  119262. * Defines a predicate to test if a given type mut be extended
  119263. */
  119264. predicate: (entity: any) => boolean;
  119265. /**
  119266. * Gets the list of options added to a type
  119267. */
  119268. entries: IExplorerExtensibilityOption[];
  119269. }
  119270. /**
  119271. * Interface used to define the options to use to create the Inspector
  119272. */
  119273. export interface IInspectorOptions {
  119274. /**
  119275. * Display in overlay mode (default: false)
  119276. */
  119277. overlay?: boolean;
  119278. /**
  119279. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  119280. */
  119281. globalRoot?: HTMLElement;
  119282. /**
  119283. * Display the Scene explorer
  119284. */
  119285. showExplorer?: boolean;
  119286. /**
  119287. * Display the property inspector
  119288. */
  119289. showInspector?: boolean;
  119290. /**
  119291. * Display in embed mode (both panes on the right)
  119292. */
  119293. embedMode?: boolean;
  119294. /**
  119295. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  119296. */
  119297. handleResize?: boolean;
  119298. /**
  119299. * Allow the panes to popup (default: true)
  119300. */
  119301. enablePopup?: boolean;
  119302. /**
  119303. * Allow the panes to be closed by users (default: true)
  119304. */
  119305. enableClose?: boolean;
  119306. /**
  119307. * Optional list of extensibility entries
  119308. */
  119309. explorerExtensibility?: IExplorerExtensibilityGroup[];
  119310. /**
  119311. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  119312. */
  119313. inspectorURL?: string;
  119314. /**
  119315. * Optional initial tab (default to DebugLayerTab.Properties)
  119316. */
  119317. initialTab?: DebugLayerTab;
  119318. }
  119319. interface Scene {
  119320. /**
  119321. * @hidden
  119322. * Backing field
  119323. */
  119324. _debugLayer: DebugLayer;
  119325. /**
  119326. * Gets the debug layer (aka Inspector) associated with the scene
  119327. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119328. */
  119329. debugLayer: DebugLayer;
  119330. }
  119331. /**
  119332. * Enum of inspector action tab
  119333. */
  119334. export enum DebugLayerTab {
  119335. /**
  119336. * Properties tag (default)
  119337. */
  119338. Properties = 0,
  119339. /**
  119340. * Debug tab
  119341. */
  119342. Debug = 1,
  119343. /**
  119344. * Statistics tab
  119345. */
  119346. Statistics = 2,
  119347. /**
  119348. * Tools tab
  119349. */
  119350. Tools = 3,
  119351. /**
  119352. * Settings tab
  119353. */
  119354. Settings = 4
  119355. }
  119356. /**
  119357. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119358. * what is happening in your scene
  119359. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119360. */
  119361. export class DebugLayer {
  119362. /**
  119363. * Define the url to get the inspector script from.
  119364. * By default it uses the babylonjs CDN.
  119365. * @ignoreNaming
  119366. */
  119367. static InspectorURL: string;
  119368. private _scene;
  119369. private BJSINSPECTOR;
  119370. private _onPropertyChangedObservable?;
  119371. /**
  119372. * Observable triggered when a property is changed through the inspector.
  119373. */
  119374. get onPropertyChangedObservable(): any;
  119375. /**
  119376. * Instantiates a new debug layer.
  119377. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119378. * what is happening in your scene
  119379. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119380. * @param scene Defines the scene to inspect
  119381. */
  119382. constructor(scene: Scene);
  119383. /** Creates the inspector window. */
  119384. private _createInspector;
  119385. /**
  119386. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  119387. * @param entity defines the entity to select
  119388. * @param lineContainerTitle defines the specific block to highlight
  119389. */
  119390. select(entity: any, lineContainerTitle?: string): void;
  119391. /** Get the inspector from bundle or global */
  119392. private _getGlobalInspector;
  119393. /**
  119394. * Get if the inspector is visible or not.
  119395. * @returns true if visible otherwise, false
  119396. */
  119397. isVisible(): boolean;
  119398. /**
  119399. * Hide the inspector and close its window.
  119400. */
  119401. hide(): void;
  119402. /**
  119403. * Launch the debugLayer.
  119404. * @param config Define the configuration of the inspector
  119405. * @return a promise fulfilled when the debug layer is visible
  119406. */
  119407. show(config?: IInspectorOptions): Promise<DebugLayer>;
  119408. }
  119409. }
  119410. declare module BABYLON {
  119411. /**
  119412. * Class containing static functions to help procedurally build meshes
  119413. */
  119414. export class BoxBuilder {
  119415. /**
  119416. * Creates a box mesh
  119417. * * The parameter `size` sets the size (float) of each box side (default 1)
  119418. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  119419. * * 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)
  119420. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119421. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119422. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119423. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119424. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119425. * @param name defines the name of the mesh
  119426. * @param options defines the options used to create the mesh
  119427. * @param scene defines the hosting scene
  119428. * @returns the box mesh
  119429. */
  119430. static CreateBox(name: string, options: {
  119431. size?: number;
  119432. width?: number;
  119433. height?: number;
  119434. depth?: number;
  119435. faceUV?: Vector4[];
  119436. faceColors?: Color4[];
  119437. sideOrientation?: number;
  119438. frontUVs?: Vector4;
  119439. backUVs?: Vector4;
  119440. wrap?: boolean;
  119441. topBaseAt?: number;
  119442. bottomBaseAt?: number;
  119443. updatable?: boolean;
  119444. }, scene?: Nullable<Scene>): Mesh;
  119445. }
  119446. }
  119447. declare module BABYLON.Debug {
  119448. /**
  119449. * Used to show the physics impostor around the specific mesh
  119450. */
  119451. export class PhysicsViewer {
  119452. /** @hidden */
  119453. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  119454. /** @hidden */
  119455. protected _meshes: Array<Nullable<AbstractMesh>>;
  119456. /** @hidden */
  119457. protected _scene: Nullable<Scene>;
  119458. /** @hidden */
  119459. protected _numMeshes: number;
  119460. /** @hidden */
  119461. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  119462. private _renderFunction;
  119463. private _utilityLayer;
  119464. private _debugBoxMesh;
  119465. private _debugSphereMesh;
  119466. private _debugCylinderMesh;
  119467. private _debugMaterial;
  119468. private _debugMeshMeshes;
  119469. /**
  119470. * Creates a new PhysicsViewer
  119471. * @param scene defines the hosting scene
  119472. */
  119473. constructor(scene: Scene);
  119474. /** @hidden */
  119475. protected _updateDebugMeshes(): void;
  119476. /**
  119477. * Renders a specified physic impostor
  119478. * @param impostor defines the impostor to render
  119479. * @param targetMesh defines the mesh represented by the impostor
  119480. * @returns the new debug mesh used to render the impostor
  119481. */
  119482. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  119483. /**
  119484. * Hides a specified physic impostor
  119485. * @param impostor defines the impostor to hide
  119486. */
  119487. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  119488. private _getDebugMaterial;
  119489. private _getDebugBoxMesh;
  119490. private _getDebugSphereMesh;
  119491. private _getDebugCylinderMesh;
  119492. private _getDebugMeshMesh;
  119493. private _getDebugMesh;
  119494. /** Releases all resources */
  119495. dispose(): void;
  119496. }
  119497. }
  119498. declare module BABYLON {
  119499. /**
  119500. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119501. * in order to better appreciate the issue one might have.
  119502. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119503. */
  119504. export class RayHelper {
  119505. /**
  119506. * Defines the ray we are currently tryin to visualize.
  119507. */
  119508. ray: Nullable<Ray>;
  119509. private _renderPoints;
  119510. private _renderLine;
  119511. private _renderFunction;
  119512. private _scene;
  119513. private _updateToMeshFunction;
  119514. private _attachedToMesh;
  119515. private _meshSpaceDirection;
  119516. private _meshSpaceOrigin;
  119517. /**
  119518. * Helper function to create a colored helper in a scene in one line.
  119519. * @param ray Defines the ray we are currently tryin to visualize
  119520. * @param scene Defines the scene the ray is used in
  119521. * @param color Defines the color we want to see the ray in
  119522. * @returns The newly created ray helper.
  119523. */
  119524. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  119525. /**
  119526. * Instantiate a new ray helper.
  119527. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119528. * in order to better appreciate the issue one might have.
  119529. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119530. * @param ray Defines the ray we are currently tryin to visualize
  119531. */
  119532. constructor(ray: Ray);
  119533. /**
  119534. * Shows the ray we are willing to debug.
  119535. * @param scene Defines the scene the ray needs to be rendered in
  119536. * @param color Defines the color the ray needs to be rendered in
  119537. */
  119538. show(scene: Scene, color?: Color3): void;
  119539. /**
  119540. * Hides the ray we are debugging.
  119541. */
  119542. hide(): void;
  119543. private _render;
  119544. /**
  119545. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  119546. * @param mesh Defines the mesh we want the helper attached to
  119547. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  119548. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  119549. * @param length Defines the length of the ray
  119550. */
  119551. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  119552. /**
  119553. * Detach the ray helper from the mesh it has previously been attached to.
  119554. */
  119555. detachFromMesh(): void;
  119556. private _updateToMesh;
  119557. /**
  119558. * Dispose the helper and release its associated resources.
  119559. */
  119560. dispose(): void;
  119561. }
  119562. }
  119563. declare module BABYLON.Debug {
  119564. /**
  119565. * Class used to render a debug view of a given skeleton
  119566. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  119567. */
  119568. export class SkeletonViewer {
  119569. /** defines the skeleton to render */
  119570. skeleton: Skeleton;
  119571. /** defines the mesh attached to the skeleton */
  119572. mesh: AbstractMesh;
  119573. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119574. autoUpdateBonesMatrices: boolean;
  119575. /** defines the rendering group id to use with the viewer */
  119576. renderingGroupId: number;
  119577. /** Gets or sets the color used to render the skeleton */
  119578. color: Color3;
  119579. private _scene;
  119580. private _debugLines;
  119581. private _debugMesh;
  119582. private _isEnabled;
  119583. private _renderFunction;
  119584. private _utilityLayer;
  119585. /**
  119586. * Returns the mesh used to render the bones
  119587. */
  119588. get debugMesh(): Nullable<LinesMesh>;
  119589. /**
  119590. * Creates a new SkeletonViewer
  119591. * @param skeleton defines the skeleton to render
  119592. * @param mesh defines the mesh attached to the skeleton
  119593. * @param scene defines the hosting scene
  119594. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  119595. * @param renderingGroupId defines the rendering group id to use with the viewer
  119596. */
  119597. constructor(
  119598. /** defines the skeleton to render */
  119599. skeleton: Skeleton,
  119600. /** defines the mesh attached to the skeleton */
  119601. mesh: AbstractMesh, scene: Scene,
  119602. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119603. autoUpdateBonesMatrices?: boolean,
  119604. /** defines the rendering group id to use with the viewer */
  119605. renderingGroupId?: number);
  119606. /** Gets or sets a boolean indicating if the viewer is enabled */
  119607. set isEnabled(value: boolean);
  119608. get isEnabled(): boolean;
  119609. private _getBonePosition;
  119610. private _getLinesForBonesWithLength;
  119611. private _getLinesForBonesNoLength;
  119612. /** Update the viewer to sync with current skeleton state */
  119613. update(): void;
  119614. /** Release associated resources */
  119615. dispose(): void;
  119616. }
  119617. }
  119618. declare module BABYLON {
  119619. /**
  119620. * Options to create the null engine
  119621. */
  119622. export class NullEngineOptions {
  119623. /**
  119624. * Render width (Default: 512)
  119625. */
  119626. renderWidth: number;
  119627. /**
  119628. * Render height (Default: 256)
  119629. */
  119630. renderHeight: number;
  119631. /**
  119632. * Texture size (Default: 512)
  119633. */
  119634. textureSize: number;
  119635. /**
  119636. * If delta time between frames should be constant
  119637. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119638. */
  119639. deterministicLockstep: boolean;
  119640. /**
  119641. * Maximum about of steps between frames (Default: 4)
  119642. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119643. */
  119644. lockstepMaxSteps: number;
  119645. }
  119646. /**
  119647. * The null engine class provides support for headless version of babylon.js.
  119648. * This can be used in server side scenario or for testing purposes
  119649. */
  119650. export class NullEngine extends Engine {
  119651. private _options;
  119652. /**
  119653. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  119654. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119655. * @returns true if engine is in deterministic lock step mode
  119656. */
  119657. isDeterministicLockStep(): boolean;
  119658. /**
  119659. * Gets the max steps when engine is running in deterministic lock step
  119660. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119661. * @returns the max steps
  119662. */
  119663. getLockstepMaxSteps(): number;
  119664. /**
  119665. * Gets the current hardware scaling level.
  119666. * By default the hardware scaling level is computed from the window device ratio.
  119667. * 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.
  119668. * @returns a number indicating the current hardware scaling level
  119669. */
  119670. getHardwareScalingLevel(): number;
  119671. constructor(options?: NullEngineOptions);
  119672. /**
  119673. * Creates a vertex buffer
  119674. * @param vertices the data for the vertex buffer
  119675. * @returns the new WebGL static buffer
  119676. */
  119677. createVertexBuffer(vertices: FloatArray): DataBuffer;
  119678. /**
  119679. * Creates a new index buffer
  119680. * @param indices defines the content of the index buffer
  119681. * @param updatable defines if the index buffer must be updatable
  119682. * @returns a new webGL buffer
  119683. */
  119684. createIndexBuffer(indices: IndicesArray): DataBuffer;
  119685. /**
  119686. * Clear the current render buffer or the current render target (if any is set up)
  119687. * @param color defines the color to use
  119688. * @param backBuffer defines if the back buffer must be cleared
  119689. * @param depth defines if the depth buffer must be cleared
  119690. * @param stencil defines if the stencil buffer must be cleared
  119691. */
  119692. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119693. /**
  119694. * Gets the current render width
  119695. * @param useScreen defines if screen size must be used (or the current render target if any)
  119696. * @returns a number defining the current render width
  119697. */
  119698. getRenderWidth(useScreen?: boolean): number;
  119699. /**
  119700. * Gets the current render height
  119701. * @param useScreen defines if screen size must be used (or the current render target if any)
  119702. * @returns a number defining the current render height
  119703. */
  119704. getRenderHeight(useScreen?: boolean): number;
  119705. /**
  119706. * Set the WebGL's viewport
  119707. * @param viewport defines the viewport element to be used
  119708. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119709. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119710. */
  119711. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119712. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  119713. /**
  119714. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119715. * @param pipelineContext defines the pipeline context to use
  119716. * @param uniformsNames defines the list of uniform names
  119717. * @returns an array of webGL uniform locations
  119718. */
  119719. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119720. /**
  119721. * Gets the lsit of active attributes for a given webGL program
  119722. * @param pipelineContext defines the pipeline context to use
  119723. * @param attributesNames defines the list of attribute names to get
  119724. * @returns an array of indices indicating the offset of each attribute
  119725. */
  119726. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119727. /**
  119728. * Binds an effect to the webGL context
  119729. * @param effect defines the effect to bind
  119730. */
  119731. bindSamplers(effect: Effect): void;
  119732. /**
  119733. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119734. * @param effect defines the effect to activate
  119735. */
  119736. enableEffect(effect: Effect): void;
  119737. /**
  119738. * Set various states to the webGL context
  119739. * @param culling defines backface culling state
  119740. * @param zOffset defines the value to apply to zOffset (0 by default)
  119741. * @param force defines if states must be applied even if cache is up to date
  119742. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  119743. */
  119744. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  119745. /**
  119746. * Set the value of an uniform to an array of int32
  119747. * @param uniform defines the webGL uniform location where to store the value
  119748. * @param array defines the array of int32 to store
  119749. */
  119750. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  119751. /**
  119752. * Set the value of an uniform to an array of int32 (stored as vec2)
  119753. * @param uniform defines the webGL uniform location where to store the value
  119754. * @param array defines the array of int32 to store
  119755. */
  119756. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  119757. /**
  119758. * Set the value of an uniform to an array of int32 (stored as vec3)
  119759. * @param uniform defines the webGL uniform location where to store the value
  119760. * @param array defines the array of int32 to store
  119761. */
  119762. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  119763. /**
  119764. * Set the value of an uniform to an array of int32 (stored as vec4)
  119765. * @param uniform defines the webGL uniform location where to store the value
  119766. * @param array defines the array of int32 to store
  119767. */
  119768. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  119769. /**
  119770. * Set the value of an uniform to an array of float32
  119771. * @param uniform defines the webGL uniform location where to store the value
  119772. * @param array defines the array of float32 to store
  119773. */
  119774. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  119775. /**
  119776. * Set the value of an uniform to an array of float32 (stored as vec2)
  119777. * @param uniform defines the webGL uniform location where to store the value
  119778. * @param array defines the array of float32 to store
  119779. */
  119780. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  119781. /**
  119782. * Set the value of an uniform to an array of float32 (stored as vec3)
  119783. * @param uniform defines the webGL uniform location where to store the value
  119784. * @param array defines the array of float32 to store
  119785. */
  119786. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  119787. /**
  119788. * Set the value of an uniform to an array of float32 (stored as vec4)
  119789. * @param uniform defines the webGL uniform location where to store the value
  119790. * @param array defines the array of float32 to store
  119791. */
  119792. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  119793. /**
  119794. * Set the value of an uniform to an array of number
  119795. * @param uniform defines the webGL uniform location where to store the value
  119796. * @param array defines the array of number to store
  119797. */
  119798. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  119799. /**
  119800. * Set the value of an uniform to an array of number (stored as vec2)
  119801. * @param uniform defines the webGL uniform location where to store the value
  119802. * @param array defines the array of number to store
  119803. */
  119804. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  119805. /**
  119806. * Set the value of an uniform to an array of number (stored as vec3)
  119807. * @param uniform defines the webGL uniform location where to store the value
  119808. * @param array defines the array of number to store
  119809. */
  119810. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  119811. /**
  119812. * Set the value of an uniform to an array of number (stored as vec4)
  119813. * @param uniform defines the webGL uniform location where to store the value
  119814. * @param array defines the array of number to store
  119815. */
  119816. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  119817. /**
  119818. * Set the value of an uniform to an array of float32 (stored as matrices)
  119819. * @param uniform defines the webGL uniform location where to store the value
  119820. * @param matrices defines the array of float32 to store
  119821. */
  119822. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  119823. /**
  119824. * Set the value of an uniform to a matrix (3x3)
  119825. * @param uniform defines the webGL uniform location where to store the value
  119826. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119827. */
  119828. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119829. /**
  119830. * Set the value of an uniform to a matrix (2x2)
  119831. * @param uniform defines the webGL uniform location where to store the value
  119832. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119833. */
  119834. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119835. /**
  119836. * Set the value of an uniform to a number (float)
  119837. * @param uniform defines the webGL uniform location where to store the value
  119838. * @param value defines the float number to store
  119839. */
  119840. setFloat(uniform: WebGLUniformLocation, value: number): void;
  119841. /**
  119842. * Set the value of an uniform to a vec2
  119843. * @param uniform defines the webGL uniform location where to store the value
  119844. * @param x defines the 1st component of the value
  119845. * @param y defines the 2nd component of the value
  119846. */
  119847. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  119848. /**
  119849. * Set the value of an uniform to a vec3
  119850. * @param uniform defines the webGL uniform location where to store the value
  119851. * @param x defines the 1st component of the value
  119852. * @param y defines the 2nd component of the value
  119853. * @param z defines the 3rd component of the value
  119854. */
  119855. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  119856. /**
  119857. * Set the value of an uniform to a boolean
  119858. * @param uniform defines the webGL uniform location where to store the value
  119859. * @param bool defines the boolean to store
  119860. */
  119861. setBool(uniform: WebGLUniformLocation, bool: number): void;
  119862. /**
  119863. * Set the value of an uniform to a vec4
  119864. * @param uniform defines the webGL uniform location where to store the value
  119865. * @param x defines the 1st component of the value
  119866. * @param y defines the 2nd component of the value
  119867. * @param z defines the 3rd component of the value
  119868. * @param w defines the 4th component of the value
  119869. */
  119870. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  119871. /**
  119872. * Sets the current alpha mode
  119873. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  119874. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  119875. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  119876. */
  119877. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  119878. /**
  119879. * Bind webGl buffers directly to the webGL context
  119880. * @param vertexBuffers defines the vertex buffer to bind
  119881. * @param indexBuffer defines the index buffer to bind
  119882. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  119883. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  119884. * @param effect defines the effect associated with the vertex buffer
  119885. */
  119886. bindBuffers(vertexBuffers: {
  119887. [key: string]: VertexBuffer;
  119888. }, indexBuffer: DataBuffer, effect: Effect): void;
  119889. /**
  119890. * Force the entire cache to be cleared
  119891. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  119892. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  119893. */
  119894. wipeCaches(bruteForce?: boolean): void;
  119895. /**
  119896. * Send a draw order
  119897. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  119898. * @param indexStart defines the starting index
  119899. * @param indexCount defines the number of index to draw
  119900. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119901. */
  119902. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  119903. /**
  119904. * Draw a list of indexed primitives
  119905. * @param fillMode defines the primitive to use
  119906. * @param indexStart defines the starting index
  119907. * @param indexCount defines the number of index to draw
  119908. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119909. */
  119910. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  119911. /**
  119912. * Draw a list of unindexed primitives
  119913. * @param fillMode defines the primitive to use
  119914. * @param verticesStart defines the index of first vertex to draw
  119915. * @param verticesCount defines the count of vertices to draw
  119916. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  119917. */
  119918. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  119919. /** @hidden */
  119920. _createTexture(): WebGLTexture;
  119921. /** @hidden */
  119922. _releaseTexture(texture: InternalTexture): void;
  119923. /**
  119924. * Usually called from Texture.ts.
  119925. * Passed information to create a WebGLTexture
  119926. * @param urlArg defines a value which contains one of the following:
  119927. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  119928. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  119929. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  119930. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  119931. * @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)
  119932. * @param scene needed for loading to the correct scene
  119933. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  119934. * @param onLoad optional callback to be called upon successful completion
  119935. * @param onError optional callback to be called upon failure
  119936. * @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
  119937. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  119938. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  119939. * @param forcedExtension defines the extension to use to pick the right loader
  119940. * @param mimeType defines an optional mime type
  119941. * @returns a InternalTexture for assignment back into BABYLON.Texture
  119942. */
  119943. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  119944. /**
  119945. * Creates a new render target texture
  119946. * @param size defines the size of the texture
  119947. * @param options defines the options used to create the texture
  119948. * @returns a new render target texture stored in an InternalTexture
  119949. */
  119950. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  119951. /**
  119952. * Update the sampling mode of a given texture
  119953. * @param samplingMode defines the required sampling mode
  119954. * @param texture defines the texture to update
  119955. */
  119956. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  119957. /**
  119958. * Binds the frame buffer to the specified texture.
  119959. * @param texture The texture to render to or null for the default canvas
  119960. * @param faceIndex The face of the texture to render to in case of cube texture
  119961. * @param requiredWidth The width of the target to render to
  119962. * @param requiredHeight The height of the target to render to
  119963. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  119964. * @param lodLevel defines le lod level to bind to the frame buffer
  119965. */
  119966. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  119967. /**
  119968. * Unbind the current render target texture from the webGL context
  119969. * @param texture defines the render target texture to unbind
  119970. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  119971. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  119972. */
  119973. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  119974. /**
  119975. * Creates a dynamic vertex buffer
  119976. * @param vertices the data for the dynamic vertex buffer
  119977. * @returns the new WebGL dynamic buffer
  119978. */
  119979. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  119980. /**
  119981. * Update the content of a dynamic texture
  119982. * @param texture defines the texture to update
  119983. * @param canvas defines the canvas containing the source
  119984. * @param invertY defines if data must be stored with Y axis inverted
  119985. * @param premulAlpha defines if alpha is stored as premultiplied
  119986. * @param format defines the format of the data
  119987. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  119988. */
  119989. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  119990. /**
  119991. * Gets a boolean indicating if all created effects are ready
  119992. * @returns true if all effects are ready
  119993. */
  119994. areAllEffectsReady(): boolean;
  119995. /**
  119996. * @hidden
  119997. * Get the current error code of the webGL context
  119998. * @returns the error code
  119999. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120000. */
  120001. getError(): number;
  120002. /** @hidden */
  120003. _getUnpackAlignement(): number;
  120004. /** @hidden */
  120005. _unpackFlipY(value: boolean): void;
  120006. /**
  120007. * Update a dynamic index buffer
  120008. * @param indexBuffer defines the target index buffer
  120009. * @param indices defines the data to update
  120010. * @param offset defines the offset in the target index buffer where update should start
  120011. */
  120012. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  120013. /**
  120014. * Updates a dynamic vertex buffer.
  120015. * @param vertexBuffer the vertex buffer to update
  120016. * @param vertices the data used to update the vertex buffer
  120017. * @param byteOffset the byte offset of the data (optional)
  120018. * @param byteLength the byte length of the data (optional)
  120019. */
  120020. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  120021. /** @hidden */
  120022. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  120023. /** @hidden */
  120024. _bindTexture(channel: number, texture: InternalTexture): void;
  120025. protected _deleteBuffer(buffer: WebGLBuffer): void;
  120026. /**
  120027. * 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
  120028. */
  120029. releaseEffects(): void;
  120030. displayLoadingUI(): void;
  120031. hideLoadingUI(): void;
  120032. /** @hidden */
  120033. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120034. /** @hidden */
  120035. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120036. /** @hidden */
  120037. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120038. /** @hidden */
  120039. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120040. }
  120041. }
  120042. declare module BABYLON {
  120043. /**
  120044. * @hidden
  120045. **/
  120046. export class _TimeToken {
  120047. _startTimeQuery: Nullable<WebGLQuery>;
  120048. _endTimeQuery: Nullable<WebGLQuery>;
  120049. _timeElapsedQuery: Nullable<WebGLQuery>;
  120050. _timeElapsedQueryEnded: boolean;
  120051. }
  120052. }
  120053. declare module BABYLON {
  120054. /** @hidden */
  120055. export class _OcclusionDataStorage {
  120056. /** @hidden */
  120057. occlusionInternalRetryCounter: number;
  120058. /** @hidden */
  120059. isOcclusionQueryInProgress: boolean;
  120060. /** @hidden */
  120061. isOccluded: boolean;
  120062. /** @hidden */
  120063. occlusionRetryCount: number;
  120064. /** @hidden */
  120065. occlusionType: number;
  120066. /** @hidden */
  120067. occlusionQueryAlgorithmType: number;
  120068. }
  120069. interface Engine {
  120070. /**
  120071. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  120072. * @return the new query
  120073. */
  120074. createQuery(): WebGLQuery;
  120075. /**
  120076. * Delete and release a webGL query
  120077. * @param query defines the query to delete
  120078. * @return the current engine
  120079. */
  120080. deleteQuery(query: WebGLQuery): Engine;
  120081. /**
  120082. * Check if a given query has resolved and got its value
  120083. * @param query defines the query to check
  120084. * @returns true if the query got its value
  120085. */
  120086. isQueryResultAvailable(query: WebGLQuery): boolean;
  120087. /**
  120088. * Gets the value of a given query
  120089. * @param query defines the query to check
  120090. * @returns the value of the query
  120091. */
  120092. getQueryResult(query: WebGLQuery): number;
  120093. /**
  120094. * Initiates an occlusion query
  120095. * @param algorithmType defines the algorithm to use
  120096. * @param query defines the query to use
  120097. * @returns the current engine
  120098. * @see http://doc.babylonjs.com/features/occlusionquery
  120099. */
  120100. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  120101. /**
  120102. * Ends an occlusion query
  120103. * @see http://doc.babylonjs.com/features/occlusionquery
  120104. * @param algorithmType defines the algorithm to use
  120105. * @returns the current engine
  120106. */
  120107. endOcclusionQuery(algorithmType: number): Engine;
  120108. /**
  120109. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  120110. * Please note that only one query can be issued at a time
  120111. * @returns a time token used to track the time span
  120112. */
  120113. startTimeQuery(): Nullable<_TimeToken>;
  120114. /**
  120115. * Ends a time query
  120116. * @param token defines the token used to measure the time span
  120117. * @returns the time spent (in ns)
  120118. */
  120119. endTimeQuery(token: _TimeToken): int;
  120120. /** @hidden */
  120121. _currentNonTimestampToken: Nullable<_TimeToken>;
  120122. /** @hidden */
  120123. _createTimeQuery(): WebGLQuery;
  120124. /** @hidden */
  120125. _deleteTimeQuery(query: WebGLQuery): void;
  120126. /** @hidden */
  120127. _getGlAlgorithmType(algorithmType: number): number;
  120128. /** @hidden */
  120129. _getTimeQueryResult(query: WebGLQuery): any;
  120130. /** @hidden */
  120131. _getTimeQueryAvailability(query: WebGLQuery): any;
  120132. }
  120133. interface AbstractMesh {
  120134. /**
  120135. * Backing filed
  120136. * @hidden
  120137. */
  120138. __occlusionDataStorage: _OcclusionDataStorage;
  120139. /**
  120140. * Access property
  120141. * @hidden
  120142. */
  120143. _occlusionDataStorage: _OcclusionDataStorage;
  120144. /**
  120145. * 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.
  120146. * The default value is -1 which means don't break the query and wait till the result
  120147. * @see http://doc.babylonjs.com/features/occlusionquery
  120148. */
  120149. occlusionRetryCount: number;
  120150. /**
  120151. * 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:
  120152. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  120153. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  120154. * * 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.
  120155. * @see http://doc.babylonjs.com/features/occlusionquery
  120156. */
  120157. occlusionType: number;
  120158. /**
  120159. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  120160. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  120161. * * 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.
  120162. * @see http://doc.babylonjs.com/features/occlusionquery
  120163. */
  120164. occlusionQueryAlgorithmType: number;
  120165. /**
  120166. * 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
  120167. * @see http://doc.babylonjs.com/features/occlusionquery
  120168. */
  120169. isOccluded: boolean;
  120170. /**
  120171. * Flag to check the progress status of the query
  120172. * @see http://doc.babylonjs.com/features/occlusionquery
  120173. */
  120174. isOcclusionQueryInProgress: boolean;
  120175. }
  120176. }
  120177. declare module BABYLON {
  120178. /** @hidden */
  120179. export var _forceTransformFeedbackToBundle: boolean;
  120180. interface Engine {
  120181. /**
  120182. * Creates a webGL transform feedback object
  120183. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  120184. * @returns the webGL transform feedback object
  120185. */
  120186. createTransformFeedback(): WebGLTransformFeedback;
  120187. /**
  120188. * Delete a webGL transform feedback object
  120189. * @param value defines the webGL transform feedback object to delete
  120190. */
  120191. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  120192. /**
  120193. * Bind a webGL transform feedback object to the webgl context
  120194. * @param value defines the webGL transform feedback object to bind
  120195. */
  120196. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  120197. /**
  120198. * Begins a transform feedback operation
  120199. * @param usePoints defines if points or triangles must be used
  120200. */
  120201. beginTransformFeedback(usePoints: boolean): void;
  120202. /**
  120203. * Ends a transform feedback operation
  120204. */
  120205. endTransformFeedback(): void;
  120206. /**
  120207. * Specify the varyings to use with transform feedback
  120208. * @param program defines the associated webGL program
  120209. * @param value defines the list of strings representing the varying names
  120210. */
  120211. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  120212. /**
  120213. * Bind a webGL buffer for a transform feedback operation
  120214. * @param value defines the webGL buffer to bind
  120215. */
  120216. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  120217. }
  120218. }
  120219. declare module BABYLON {
  120220. /**
  120221. * Creation options of the multi render target texture.
  120222. */
  120223. export interface IMultiRenderTargetOptions {
  120224. /**
  120225. * Define if the texture needs to create mip maps after render.
  120226. */
  120227. generateMipMaps?: boolean;
  120228. /**
  120229. * Define the types of all the draw buffers we want to create
  120230. */
  120231. types?: number[];
  120232. /**
  120233. * Define the sampling modes of all the draw buffers we want to create
  120234. */
  120235. samplingModes?: number[];
  120236. /**
  120237. * Define if a depth buffer is required
  120238. */
  120239. generateDepthBuffer?: boolean;
  120240. /**
  120241. * Define if a stencil buffer is required
  120242. */
  120243. generateStencilBuffer?: boolean;
  120244. /**
  120245. * Define if a depth texture is required instead of a depth buffer
  120246. */
  120247. generateDepthTexture?: boolean;
  120248. /**
  120249. * Define the number of desired draw buffers
  120250. */
  120251. textureCount?: number;
  120252. /**
  120253. * Define if aspect ratio should be adapted to the texture or stay the scene one
  120254. */
  120255. doNotChangeAspectRatio?: boolean;
  120256. /**
  120257. * Define the default type of the buffers we are creating
  120258. */
  120259. defaultType?: number;
  120260. }
  120261. /**
  120262. * A multi render target, like a render target provides the ability to render to a texture.
  120263. * Unlike the render target, it can render to several draw buffers in one draw.
  120264. * This is specially interesting in deferred rendering or for any effects requiring more than
  120265. * just one color from a single pass.
  120266. */
  120267. export class MultiRenderTarget extends RenderTargetTexture {
  120268. private _internalTextures;
  120269. private _textures;
  120270. private _multiRenderTargetOptions;
  120271. /**
  120272. * Get if draw buffers are currently supported by the used hardware and browser.
  120273. */
  120274. get isSupported(): boolean;
  120275. /**
  120276. * Get the list of textures generated by the multi render target.
  120277. */
  120278. get textures(): Texture[];
  120279. /**
  120280. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  120281. */
  120282. get depthTexture(): Texture;
  120283. /**
  120284. * Set the wrapping mode on U of all the textures we are rendering to.
  120285. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120286. */
  120287. set wrapU(wrap: number);
  120288. /**
  120289. * Set the wrapping mode on V of all the textures we are rendering to.
  120290. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120291. */
  120292. set wrapV(wrap: number);
  120293. /**
  120294. * Instantiate a new multi render target texture.
  120295. * A multi render target, like a render target provides the ability to render to a texture.
  120296. * Unlike the render target, it can render to several draw buffers in one draw.
  120297. * This is specially interesting in deferred rendering or for any effects requiring more than
  120298. * just one color from a single pass.
  120299. * @param name Define the name of the texture
  120300. * @param size Define the size of the buffers to render to
  120301. * @param count Define the number of target we are rendering into
  120302. * @param scene Define the scene the texture belongs to
  120303. * @param options Define the options used to create the multi render target
  120304. */
  120305. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  120306. /** @hidden */
  120307. _rebuild(): void;
  120308. private _createInternalTextures;
  120309. private _createTextures;
  120310. /**
  120311. * Define the number of samples used if MSAA is enabled.
  120312. */
  120313. get samples(): number;
  120314. set samples(value: number);
  120315. /**
  120316. * Resize all the textures in the multi render target.
  120317. * Be carrefull as it will recreate all the data in the new texture.
  120318. * @param size Define the new size
  120319. */
  120320. resize(size: any): void;
  120321. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  120322. /**
  120323. * Dispose the render targets and their associated resources
  120324. */
  120325. dispose(): void;
  120326. /**
  120327. * Release all the underlying texture used as draw buffers.
  120328. */
  120329. releaseInternalTextures(): void;
  120330. }
  120331. }
  120332. declare module BABYLON {
  120333. interface ThinEngine {
  120334. /**
  120335. * Unbind a list of render target textures from the webGL context
  120336. * This is used only when drawBuffer extension or webGL2 are active
  120337. * @param textures defines the render target textures to unbind
  120338. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120339. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120340. */
  120341. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  120342. /**
  120343. * Create a multi render target texture
  120344. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  120345. * @param size defines the size of the texture
  120346. * @param options defines the creation options
  120347. * @returns the cube texture as an InternalTexture
  120348. */
  120349. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  120350. /**
  120351. * Update the sample count for a given multiple render target texture
  120352. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  120353. * @param textures defines the textures to update
  120354. * @param samples defines the sample count to set
  120355. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  120356. */
  120357. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  120358. }
  120359. }
  120360. declare module BABYLON {
  120361. /**
  120362. * Class used to define an additional view for the engine
  120363. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120364. */
  120365. export class EngineView {
  120366. /** Defines the canvas where to render the view */
  120367. target: HTMLCanvasElement;
  120368. /** Defines an optional camera used to render the view (will use active camera else) */
  120369. camera?: Camera;
  120370. }
  120371. interface Engine {
  120372. /**
  120373. * Gets or sets the HTML element to use for attaching events
  120374. */
  120375. inputElement: Nullable<HTMLElement>;
  120376. /**
  120377. * Gets the current engine view
  120378. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120379. */
  120380. activeView: Nullable<EngineView>;
  120381. /** Gets or sets the list of views */
  120382. views: EngineView[];
  120383. /**
  120384. * Register a new child canvas
  120385. * @param canvas defines the canvas to register
  120386. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  120387. * @returns the associated view
  120388. */
  120389. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  120390. /**
  120391. * Remove a registered child canvas
  120392. * @param canvas defines the canvas to remove
  120393. * @returns the current engine
  120394. */
  120395. unRegisterView(canvas: HTMLCanvasElement): Engine;
  120396. }
  120397. }
  120398. declare module BABYLON {
  120399. /**
  120400. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  120401. */
  120402. export interface CubeMapInfo {
  120403. /**
  120404. * The pixel array for the front face.
  120405. * This is stored in format, left to right, up to down format.
  120406. */
  120407. front: Nullable<ArrayBufferView>;
  120408. /**
  120409. * The pixel array for the back face.
  120410. * This is stored in format, left to right, up to down format.
  120411. */
  120412. back: Nullable<ArrayBufferView>;
  120413. /**
  120414. * The pixel array for the left face.
  120415. * This is stored in format, left to right, up to down format.
  120416. */
  120417. left: Nullable<ArrayBufferView>;
  120418. /**
  120419. * The pixel array for the right face.
  120420. * This is stored in format, left to right, up to down format.
  120421. */
  120422. right: Nullable<ArrayBufferView>;
  120423. /**
  120424. * The pixel array for the up face.
  120425. * This is stored in format, left to right, up to down format.
  120426. */
  120427. up: Nullable<ArrayBufferView>;
  120428. /**
  120429. * The pixel array for the down face.
  120430. * This is stored in format, left to right, up to down format.
  120431. */
  120432. down: Nullable<ArrayBufferView>;
  120433. /**
  120434. * The size of the cubemap stored.
  120435. *
  120436. * Each faces will be size * size pixels.
  120437. */
  120438. size: number;
  120439. /**
  120440. * The format of the texture.
  120441. *
  120442. * RGBA, RGB.
  120443. */
  120444. format: number;
  120445. /**
  120446. * The type of the texture data.
  120447. *
  120448. * UNSIGNED_INT, FLOAT.
  120449. */
  120450. type: number;
  120451. /**
  120452. * Specifies whether the texture is in gamma space.
  120453. */
  120454. gammaSpace: boolean;
  120455. }
  120456. /**
  120457. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  120458. */
  120459. export class PanoramaToCubeMapTools {
  120460. private static FACE_FRONT;
  120461. private static FACE_BACK;
  120462. private static FACE_RIGHT;
  120463. private static FACE_LEFT;
  120464. private static FACE_DOWN;
  120465. private static FACE_UP;
  120466. /**
  120467. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  120468. *
  120469. * @param float32Array The source data.
  120470. * @param inputWidth The width of the input panorama.
  120471. * @param inputHeight The height of the input panorama.
  120472. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  120473. * @return The cubemap data
  120474. */
  120475. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  120476. private static CreateCubemapTexture;
  120477. private static CalcProjectionSpherical;
  120478. }
  120479. }
  120480. declare module BABYLON {
  120481. /**
  120482. * Helper class dealing with the extraction of spherical polynomial dataArray
  120483. * from a cube map.
  120484. */
  120485. export class CubeMapToSphericalPolynomialTools {
  120486. private static FileFaces;
  120487. /**
  120488. * Converts a texture to the according Spherical Polynomial data.
  120489. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120490. *
  120491. * @param texture The texture to extract the information from.
  120492. * @return The Spherical Polynomial data.
  120493. */
  120494. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  120495. /**
  120496. * Converts a cubemap to the according Spherical Polynomial data.
  120497. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120498. *
  120499. * @param cubeInfo The Cube map to extract the information from.
  120500. * @return The Spherical Polynomial data.
  120501. */
  120502. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  120503. }
  120504. }
  120505. declare module BABYLON {
  120506. interface BaseTexture {
  120507. /**
  120508. * Get the polynomial representation of the texture data.
  120509. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  120510. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  120511. */
  120512. sphericalPolynomial: Nullable<SphericalPolynomial>;
  120513. }
  120514. }
  120515. declare module BABYLON {
  120516. /** @hidden */
  120517. export var rgbdEncodePixelShader: {
  120518. name: string;
  120519. shader: string;
  120520. };
  120521. }
  120522. declare module BABYLON {
  120523. /** @hidden */
  120524. export var rgbdDecodePixelShader: {
  120525. name: string;
  120526. shader: string;
  120527. };
  120528. }
  120529. declare module BABYLON {
  120530. /**
  120531. * Raw texture data and descriptor sufficient for WebGL texture upload
  120532. */
  120533. export interface EnvironmentTextureInfo {
  120534. /**
  120535. * Version of the environment map
  120536. */
  120537. version: number;
  120538. /**
  120539. * Width of image
  120540. */
  120541. width: number;
  120542. /**
  120543. * Irradiance information stored in the file.
  120544. */
  120545. irradiance: any;
  120546. /**
  120547. * Specular information stored in the file.
  120548. */
  120549. specular: any;
  120550. }
  120551. /**
  120552. * Defines One Image in the file. It requires only the position in the file
  120553. * as well as the length.
  120554. */
  120555. interface BufferImageData {
  120556. /**
  120557. * Length of the image data.
  120558. */
  120559. length: number;
  120560. /**
  120561. * Position of the data from the null terminator delimiting the end of the JSON.
  120562. */
  120563. position: number;
  120564. }
  120565. /**
  120566. * Defines the specular data enclosed in the file.
  120567. * This corresponds to the version 1 of the data.
  120568. */
  120569. export interface EnvironmentTextureSpecularInfoV1 {
  120570. /**
  120571. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  120572. */
  120573. specularDataPosition?: number;
  120574. /**
  120575. * This contains all the images data needed to reconstruct the cubemap.
  120576. */
  120577. mipmaps: Array<BufferImageData>;
  120578. /**
  120579. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  120580. */
  120581. lodGenerationScale: number;
  120582. }
  120583. /**
  120584. * Sets of helpers addressing the serialization and deserialization of environment texture
  120585. * stored in a BabylonJS env file.
  120586. * Those files are usually stored as .env files.
  120587. */
  120588. export class EnvironmentTextureTools {
  120589. /**
  120590. * Magic number identifying the env file.
  120591. */
  120592. private static _MagicBytes;
  120593. /**
  120594. * Gets the environment info from an env file.
  120595. * @param data The array buffer containing the .env bytes.
  120596. * @returns the environment file info (the json header) if successfully parsed.
  120597. */
  120598. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  120599. /**
  120600. * Creates an environment texture from a loaded cube texture.
  120601. * @param texture defines the cube texture to convert in env file
  120602. * @return a promise containing the environment data if succesfull.
  120603. */
  120604. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  120605. /**
  120606. * Creates a JSON representation of the spherical data.
  120607. * @param texture defines the texture containing the polynomials
  120608. * @return the JSON representation of the spherical info
  120609. */
  120610. private static _CreateEnvTextureIrradiance;
  120611. /**
  120612. * Creates the ArrayBufferViews used for initializing environment texture image data.
  120613. * @param data the image data
  120614. * @param info parameters that determine what views will be created for accessing the underlying buffer
  120615. * @return the views described by info providing access to the underlying buffer
  120616. */
  120617. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  120618. /**
  120619. * Uploads the texture info contained in the env file to the GPU.
  120620. * @param texture defines the internal texture to upload to
  120621. * @param data defines the data to load
  120622. * @param info defines the texture info retrieved through the GetEnvInfo method
  120623. * @returns a promise
  120624. */
  120625. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  120626. private static _OnImageReadyAsync;
  120627. /**
  120628. * Uploads the levels of image data to the GPU.
  120629. * @param texture defines the internal texture to upload to
  120630. * @param imageData defines the array buffer views of image data [mipmap][face]
  120631. * @returns a promise
  120632. */
  120633. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  120634. /**
  120635. * Uploads spherical polynomials information to the texture.
  120636. * @param texture defines the texture we are trying to upload the information to
  120637. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  120638. */
  120639. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  120640. /** @hidden */
  120641. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120642. }
  120643. }
  120644. declare module BABYLON {
  120645. /**
  120646. * Contains position and normal vectors for a vertex
  120647. */
  120648. export class PositionNormalVertex {
  120649. /** the position of the vertex (defaut: 0,0,0) */
  120650. position: Vector3;
  120651. /** the normal of the vertex (defaut: 0,1,0) */
  120652. normal: Vector3;
  120653. /**
  120654. * Creates a PositionNormalVertex
  120655. * @param position the position of the vertex (defaut: 0,0,0)
  120656. * @param normal the normal of the vertex (defaut: 0,1,0)
  120657. */
  120658. constructor(
  120659. /** the position of the vertex (defaut: 0,0,0) */
  120660. position?: Vector3,
  120661. /** the normal of the vertex (defaut: 0,1,0) */
  120662. normal?: Vector3);
  120663. /**
  120664. * Clones the PositionNormalVertex
  120665. * @returns the cloned PositionNormalVertex
  120666. */
  120667. clone(): PositionNormalVertex;
  120668. }
  120669. /**
  120670. * Contains position, normal and uv vectors for a vertex
  120671. */
  120672. export class PositionNormalTextureVertex {
  120673. /** the position of the vertex (defaut: 0,0,0) */
  120674. position: Vector3;
  120675. /** the normal of the vertex (defaut: 0,1,0) */
  120676. normal: Vector3;
  120677. /** the uv of the vertex (default: 0,0) */
  120678. uv: Vector2;
  120679. /**
  120680. * Creates a PositionNormalTextureVertex
  120681. * @param position the position of the vertex (defaut: 0,0,0)
  120682. * @param normal the normal of the vertex (defaut: 0,1,0)
  120683. * @param uv the uv of the vertex (default: 0,0)
  120684. */
  120685. constructor(
  120686. /** the position of the vertex (defaut: 0,0,0) */
  120687. position?: Vector3,
  120688. /** the normal of the vertex (defaut: 0,1,0) */
  120689. normal?: Vector3,
  120690. /** the uv of the vertex (default: 0,0) */
  120691. uv?: Vector2);
  120692. /**
  120693. * Clones the PositionNormalTextureVertex
  120694. * @returns the cloned PositionNormalTextureVertex
  120695. */
  120696. clone(): PositionNormalTextureVertex;
  120697. }
  120698. }
  120699. declare module BABYLON {
  120700. /** @hidden */
  120701. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  120702. private _genericAttributeLocation;
  120703. private _varyingLocationCount;
  120704. private _varyingLocationMap;
  120705. private _replacements;
  120706. private _textureCount;
  120707. private _uniforms;
  120708. lineProcessor(line: string): string;
  120709. attributeProcessor(attribute: string): string;
  120710. varyingProcessor(varying: string, isFragment: boolean): string;
  120711. uniformProcessor(uniform: string): string;
  120712. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  120713. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120714. }
  120715. }
  120716. declare module BABYLON {
  120717. /**
  120718. * Container for accessors for natively-stored mesh data buffers.
  120719. */
  120720. class NativeDataBuffer extends DataBuffer {
  120721. /**
  120722. * Accessor value used to identify/retrieve a natively-stored index buffer.
  120723. */
  120724. nativeIndexBuffer?: any;
  120725. /**
  120726. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  120727. */
  120728. nativeVertexBuffer?: any;
  120729. }
  120730. /** @hidden */
  120731. class NativeTexture extends InternalTexture {
  120732. getInternalTexture(): InternalTexture;
  120733. getViewCount(): number;
  120734. }
  120735. /** @hidden */
  120736. export class NativeEngine extends Engine {
  120737. private readonly _native;
  120738. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  120739. private readonly INVALID_HANDLE;
  120740. getHardwareScalingLevel(): number;
  120741. constructor();
  120742. /**
  120743. * Can be used to override the current requestAnimationFrame requester.
  120744. * @hidden
  120745. */
  120746. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120747. /**
  120748. * Override default engine behavior.
  120749. * @param color
  120750. * @param backBuffer
  120751. * @param depth
  120752. * @param stencil
  120753. */
  120754. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120755. /**
  120756. * Gets host document
  120757. * @returns the host document object
  120758. */
  120759. getHostDocument(): Nullable<Document>;
  120760. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120761. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  120762. createVertexBuffer(data: DataArray): NativeDataBuffer;
  120763. recordVertexArrayObject(vertexBuffers: {
  120764. [key: string]: VertexBuffer;
  120765. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120766. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120767. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120768. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120769. /**
  120770. * Draw a list of indexed primitives
  120771. * @param fillMode defines the primitive to use
  120772. * @param indexStart defines the starting index
  120773. * @param indexCount defines the number of index to draw
  120774. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120775. */
  120776. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120777. /**
  120778. * Draw a list of unindexed primitives
  120779. * @param fillMode defines the primitive to use
  120780. * @param verticesStart defines the index of first vertex to draw
  120781. * @param verticesCount defines the count of vertices to draw
  120782. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120783. */
  120784. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120785. createPipelineContext(): IPipelineContext;
  120786. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  120787. /** @hidden */
  120788. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  120789. /** @hidden */
  120790. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  120791. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120792. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120793. protected _setProgram(program: WebGLProgram): void;
  120794. _releaseEffect(effect: Effect): void;
  120795. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  120796. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  120797. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  120798. bindSamplers(effect: Effect): void;
  120799. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  120800. getRenderWidth(useScreen?: boolean): number;
  120801. getRenderHeight(useScreen?: boolean): number;
  120802. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  120803. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120804. /**
  120805. * Set the z offset to apply to current rendering
  120806. * @param value defines the offset to apply
  120807. */
  120808. setZOffset(value: number): void;
  120809. /**
  120810. * Gets the current value of the zOffset
  120811. * @returns the current zOffset state
  120812. */
  120813. getZOffset(): number;
  120814. /**
  120815. * Enable or disable depth buffering
  120816. * @param enable defines the state to set
  120817. */
  120818. setDepthBuffer(enable: boolean): void;
  120819. /**
  120820. * Gets a boolean indicating if depth writing is enabled
  120821. * @returns the current depth writing state
  120822. */
  120823. getDepthWrite(): boolean;
  120824. /**
  120825. * Enable or disable depth writing
  120826. * @param enable defines the state to set
  120827. */
  120828. setDepthWrite(enable: boolean): void;
  120829. /**
  120830. * Enable or disable color writing
  120831. * @param enable defines the state to set
  120832. */
  120833. setColorWrite(enable: boolean): void;
  120834. /**
  120835. * Gets a boolean indicating if color writing is enabled
  120836. * @returns the current color writing state
  120837. */
  120838. getColorWrite(): boolean;
  120839. /**
  120840. * Sets alpha constants used by some alpha blending modes
  120841. * @param r defines the red component
  120842. * @param g defines the green component
  120843. * @param b defines the blue component
  120844. * @param a defines the alpha component
  120845. */
  120846. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  120847. /**
  120848. * Sets the current alpha mode
  120849. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  120850. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120851. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120852. */
  120853. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120854. /**
  120855. * Gets the current alpha mode
  120856. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120857. * @returns the current alpha mode
  120858. */
  120859. getAlphaMode(): number;
  120860. setInt(uniform: WebGLUniformLocation, int: number): void;
  120861. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  120862. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  120863. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  120864. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  120865. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  120866. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  120867. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  120868. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  120869. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  120870. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  120871. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  120872. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  120873. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  120874. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120875. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  120876. setFloat(uniform: WebGLUniformLocation, value: number): void;
  120877. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  120878. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120879. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120880. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  120881. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  120882. wipeCaches(bruteForce?: boolean): void;
  120883. _createTexture(): WebGLTexture;
  120884. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  120885. /**
  120886. * Usually called from Texture.ts.
  120887. * Passed information to create a WebGLTexture
  120888. * @param urlArg defines a value which contains one of the following:
  120889. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120890. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120891. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120892. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120893. * @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)
  120894. * @param scene needed for loading to the correct scene
  120895. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120896. * @param onLoad optional callback to be called upon successful completion
  120897. * @param onError optional callback to be called upon failure
  120898. * @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
  120899. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120900. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120901. * @param forcedExtension defines the extension to use to pick the right loader
  120902. * @param mimeType defines an optional mime type
  120903. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120904. */
  120905. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, mimeType?: string): InternalTexture;
  120906. /**
  120907. * Creates a cube texture
  120908. * @param rootUrl defines the url where the files to load is located
  120909. * @param scene defines the current scene
  120910. * @param files defines the list of files to load (1 per face)
  120911. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  120912. * @param onLoad defines an optional callback raised when the texture is loaded
  120913. * @param onError defines an optional callback raised if there is an issue to load the texture
  120914. * @param format defines the format of the data
  120915. * @param forcedExtension defines the extension to use to pick the right loader
  120916. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  120917. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  120918. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  120919. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  120920. * @returns the cube texture as an InternalTexture
  120921. */
  120922. 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;
  120923. private _getSamplingFilter;
  120924. private static _GetNativeTextureFormat;
  120925. createRenderTargetTexture(size: number | {
  120926. width: number;
  120927. height: number;
  120928. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  120929. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120930. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120931. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120932. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  120933. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  120934. /**
  120935. * Updates a dynamic vertex buffer.
  120936. * @param vertexBuffer the vertex buffer to update
  120937. * @param data the data used to update the vertex buffer
  120938. * @param byteOffset the byte offset of the data (optional)
  120939. * @param byteLength the byte length of the data (optional)
  120940. */
  120941. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  120942. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  120943. private _updateAnisotropicLevel;
  120944. private _getAddressMode;
  120945. /** @hidden */
  120946. _bindTexture(channel: number, texture: InternalTexture): void;
  120947. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  120948. releaseEffects(): void;
  120949. /** @hidden */
  120950. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120951. /** @hidden */
  120952. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120953. /** @hidden */
  120954. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120955. /** @hidden */
  120956. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120957. }
  120958. }
  120959. declare module BABYLON {
  120960. /**
  120961. * Gather the list of clipboard event types as constants.
  120962. */
  120963. export class ClipboardEventTypes {
  120964. /**
  120965. * The clipboard event is fired when a copy command is active (pressed).
  120966. */
  120967. static readonly COPY: number;
  120968. /**
  120969. * The clipboard event is fired when a cut command is active (pressed).
  120970. */
  120971. static readonly CUT: number;
  120972. /**
  120973. * The clipboard event is fired when a paste command is active (pressed).
  120974. */
  120975. static readonly PASTE: number;
  120976. }
  120977. /**
  120978. * This class is used to store clipboard related info for the onClipboardObservable event.
  120979. */
  120980. export class ClipboardInfo {
  120981. /**
  120982. * Defines the type of event (BABYLON.ClipboardEventTypes)
  120983. */
  120984. type: number;
  120985. /**
  120986. * Defines the related dom event
  120987. */
  120988. event: ClipboardEvent;
  120989. /**
  120990. *Creates an instance of ClipboardInfo.
  120991. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  120992. * @param event Defines the related dom event
  120993. */
  120994. constructor(
  120995. /**
  120996. * Defines the type of event (BABYLON.ClipboardEventTypes)
  120997. */
  120998. type: number,
  120999. /**
  121000. * Defines the related dom event
  121001. */
  121002. event: ClipboardEvent);
  121003. /**
  121004. * Get the clipboard event's type from the keycode.
  121005. * @param keyCode Defines the keyCode for the current keyboard event.
  121006. * @return {number}
  121007. */
  121008. static GetTypeFromCharacter(keyCode: number): number;
  121009. }
  121010. }
  121011. declare module BABYLON {
  121012. /**
  121013. * Google Daydream controller
  121014. */
  121015. export class DaydreamController extends WebVRController {
  121016. /**
  121017. * Base Url for the controller model.
  121018. */
  121019. static MODEL_BASE_URL: string;
  121020. /**
  121021. * File name for the controller model.
  121022. */
  121023. static MODEL_FILENAME: string;
  121024. /**
  121025. * Gamepad Id prefix used to identify Daydream Controller.
  121026. */
  121027. static readonly GAMEPAD_ID_PREFIX: string;
  121028. /**
  121029. * Creates a new DaydreamController from a gamepad
  121030. * @param vrGamepad the gamepad that the controller should be created from
  121031. */
  121032. constructor(vrGamepad: any);
  121033. /**
  121034. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121035. * @param scene scene in which to add meshes
  121036. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121037. */
  121038. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121039. /**
  121040. * Called once for each button that changed state since the last frame
  121041. * @param buttonIdx Which button index changed
  121042. * @param state New state of the button
  121043. * @param changes Which properties on the state changed since last frame
  121044. */
  121045. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121046. }
  121047. }
  121048. declare module BABYLON {
  121049. /**
  121050. * Gear VR Controller
  121051. */
  121052. export class GearVRController extends WebVRController {
  121053. /**
  121054. * Base Url for the controller model.
  121055. */
  121056. static MODEL_BASE_URL: string;
  121057. /**
  121058. * File name for the controller model.
  121059. */
  121060. static MODEL_FILENAME: string;
  121061. /**
  121062. * Gamepad Id prefix used to identify this controller.
  121063. */
  121064. static readonly GAMEPAD_ID_PREFIX: string;
  121065. private readonly _buttonIndexToObservableNameMap;
  121066. /**
  121067. * Creates a new GearVRController from a gamepad
  121068. * @param vrGamepad the gamepad that the controller should be created from
  121069. */
  121070. constructor(vrGamepad: any);
  121071. /**
  121072. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121073. * @param scene scene in which to add meshes
  121074. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121075. */
  121076. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121077. /**
  121078. * Called once for each button that changed state since the last frame
  121079. * @param buttonIdx Which button index changed
  121080. * @param state New state of the button
  121081. * @param changes Which properties on the state changed since last frame
  121082. */
  121083. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121084. }
  121085. }
  121086. declare module BABYLON {
  121087. /**
  121088. * Generic Controller
  121089. */
  121090. export class GenericController extends WebVRController {
  121091. /**
  121092. * Base Url for the controller model.
  121093. */
  121094. static readonly MODEL_BASE_URL: string;
  121095. /**
  121096. * File name for the controller model.
  121097. */
  121098. static readonly MODEL_FILENAME: string;
  121099. /**
  121100. * Creates a new GenericController from a gamepad
  121101. * @param vrGamepad the gamepad that the controller should be created from
  121102. */
  121103. constructor(vrGamepad: any);
  121104. /**
  121105. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121106. * @param scene scene in which to add meshes
  121107. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121108. */
  121109. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121110. /**
  121111. * Called once for each button that changed state since the last frame
  121112. * @param buttonIdx Which button index changed
  121113. * @param state New state of the button
  121114. * @param changes Which properties on the state changed since last frame
  121115. */
  121116. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121117. }
  121118. }
  121119. declare module BABYLON {
  121120. /**
  121121. * Oculus Touch Controller
  121122. */
  121123. export class OculusTouchController extends WebVRController {
  121124. /**
  121125. * Base Url for the controller model.
  121126. */
  121127. static MODEL_BASE_URL: string;
  121128. /**
  121129. * File name for the left controller model.
  121130. */
  121131. static MODEL_LEFT_FILENAME: string;
  121132. /**
  121133. * File name for the right controller model.
  121134. */
  121135. static MODEL_RIGHT_FILENAME: string;
  121136. /**
  121137. * Base Url for the Quest controller model.
  121138. */
  121139. static QUEST_MODEL_BASE_URL: string;
  121140. /**
  121141. * @hidden
  121142. * If the controllers are running on a device that needs the updated Quest controller models
  121143. */
  121144. static _IsQuest: boolean;
  121145. /**
  121146. * Fired when the secondary trigger on this controller is modified
  121147. */
  121148. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  121149. /**
  121150. * Fired when the thumb rest on this controller is modified
  121151. */
  121152. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  121153. /**
  121154. * Creates a new OculusTouchController from a gamepad
  121155. * @param vrGamepad the gamepad that the controller should be created from
  121156. */
  121157. constructor(vrGamepad: any);
  121158. /**
  121159. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121160. * @param scene scene in which to add meshes
  121161. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121162. */
  121163. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121164. /**
  121165. * Fired when the A button on this controller is modified
  121166. */
  121167. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121168. /**
  121169. * Fired when the B button on this controller is modified
  121170. */
  121171. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121172. /**
  121173. * Fired when the X button on this controller is modified
  121174. */
  121175. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121176. /**
  121177. * Fired when the Y button on this controller is modified
  121178. */
  121179. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121180. /**
  121181. * Called once for each button that changed state since the last frame
  121182. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  121183. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  121184. * 2) secondary trigger (same)
  121185. * 3) A (right) X (left), touch, pressed = value
  121186. * 4) B / Y
  121187. * 5) thumb rest
  121188. * @param buttonIdx Which button index changed
  121189. * @param state New state of the button
  121190. * @param changes Which properties on the state changed since last frame
  121191. */
  121192. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121193. }
  121194. }
  121195. declare module BABYLON {
  121196. /**
  121197. * Vive Controller
  121198. */
  121199. export class ViveController extends WebVRController {
  121200. /**
  121201. * Base Url for the controller model.
  121202. */
  121203. static MODEL_BASE_URL: string;
  121204. /**
  121205. * File name for the controller model.
  121206. */
  121207. static MODEL_FILENAME: string;
  121208. /**
  121209. * Creates a new ViveController from a gamepad
  121210. * @param vrGamepad the gamepad that the controller should be created from
  121211. */
  121212. constructor(vrGamepad: any);
  121213. /**
  121214. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121215. * @param scene scene in which to add meshes
  121216. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121217. */
  121218. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121219. /**
  121220. * Fired when the left button on this controller is modified
  121221. */
  121222. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121223. /**
  121224. * Fired when the right button on this controller is modified
  121225. */
  121226. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121227. /**
  121228. * Fired when the menu button on this controller is modified
  121229. */
  121230. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121231. /**
  121232. * Called once for each button that changed state since the last frame
  121233. * Vive mapping:
  121234. * 0: touchpad
  121235. * 1: trigger
  121236. * 2: left AND right buttons
  121237. * 3: menu button
  121238. * @param buttonIdx Which button index changed
  121239. * @param state New state of the button
  121240. * @param changes Which properties on the state changed since last frame
  121241. */
  121242. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121243. }
  121244. }
  121245. declare module BABYLON {
  121246. /**
  121247. * Defines the WindowsMotionController object that the state of the windows motion controller
  121248. */
  121249. export class WindowsMotionController extends WebVRController {
  121250. /**
  121251. * The base url used to load the left and right controller models
  121252. */
  121253. static MODEL_BASE_URL: string;
  121254. /**
  121255. * The name of the left controller model file
  121256. */
  121257. static MODEL_LEFT_FILENAME: string;
  121258. /**
  121259. * The name of the right controller model file
  121260. */
  121261. static MODEL_RIGHT_FILENAME: string;
  121262. /**
  121263. * The controller name prefix for this controller type
  121264. */
  121265. static readonly GAMEPAD_ID_PREFIX: string;
  121266. /**
  121267. * The controller id pattern for this controller type
  121268. */
  121269. private static readonly GAMEPAD_ID_PATTERN;
  121270. private _loadedMeshInfo;
  121271. protected readonly _mapping: {
  121272. buttons: string[];
  121273. buttonMeshNames: {
  121274. 'trigger': string;
  121275. 'menu': string;
  121276. 'grip': string;
  121277. 'thumbstick': string;
  121278. 'trackpad': string;
  121279. };
  121280. buttonObservableNames: {
  121281. 'trigger': string;
  121282. 'menu': string;
  121283. 'grip': string;
  121284. 'thumbstick': string;
  121285. 'trackpad': string;
  121286. };
  121287. axisMeshNames: string[];
  121288. pointingPoseMeshName: string;
  121289. };
  121290. /**
  121291. * Fired when the trackpad on this controller is clicked
  121292. */
  121293. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121294. /**
  121295. * Fired when the trackpad on this controller is modified
  121296. */
  121297. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121298. /**
  121299. * The current x and y values of this controller's trackpad
  121300. */
  121301. trackpad: StickValues;
  121302. /**
  121303. * Creates a new WindowsMotionController from a gamepad
  121304. * @param vrGamepad the gamepad that the controller should be created from
  121305. */
  121306. constructor(vrGamepad: any);
  121307. /**
  121308. * Fired when the trigger on this controller is modified
  121309. */
  121310. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121311. /**
  121312. * Fired when the menu button on this controller is modified
  121313. */
  121314. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121315. /**
  121316. * Fired when the grip button on this controller is modified
  121317. */
  121318. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121319. /**
  121320. * Fired when the thumbstick button on this controller is modified
  121321. */
  121322. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121323. /**
  121324. * Fired when the touchpad button on this controller is modified
  121325. */
  121326. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121327. /**
  121328. * Fired when the touchpad values on this controller are modified
  121329. */
  121330. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  121331. protected _updateTrackpad(): void;
  121332. /**
  121333. * Called once per frame by the engine.
  121334. */
  121335. update(): void;
  121336. /**
  121337. * Called once for each button that changed state since the last frame
  121338. * @param buttonIdx Which button index changed
  121339. * @param state New state of the button
  121340. * @param changes Which properties on the state changed since last frame
  121341. */
  121342. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121343. /**
  121344. * Moves the buttons on the controller mesh based on their current state
  121345. * @param buttonName the name of the button to move
  121346. * @param buttonValue the value of the button which determines the buttons new position
  121347. */
  121348. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  121349. /**
  121350. * Moves the axis on the controller mesh based on its current state
  121351. * @param axis the index of the axis
  121352. * @param axisValue the value of the axis which determines the meshes new position
  121353. * @hidden
  121354. */
  121355. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  121356. /**
  121357. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121358. * @param scene scene in which to add meshes
  121359. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121360. */
  121361. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  121362. /**
  121363. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  121364. * can be transformed by button presses and axes values, based on this._mapping.
  121365. *
  121366. * @param scene scene in which the meshes exist
  121367. * @param meshes list of meshes that make up the controller model to process
  121368. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  121369. */
  121370. private processModel;
  121371. private createMeshInfo;
  121372. /**
  121373. * Gets the ray of the controller in the direction the controller is pointing
  121374. * @param length the length the resulting ray should be
  121375. * @returns a ray in the direction the controller is pointing
  121376. */
  121377. getForwardRay(length?: number): Ray;
  121378. /**
  121379. * Disposes of the controller
  121380. */
  121381. dispose(): void;
  121382. }
  121383. /**
  121384. * This class represents a new windows motion controller in XR.
  121385. */
  121386. export class XRWindowsMotionController extends WindowsMotionController {
  121387. /**
  121388. * Changing the original WIndowsMotionController mapping to fir the new mapping
  121389. */
  121390. protected readonly _mapping: {
  121391. buttons: string[];
  121392. buttonMeshNames: {
  121393. 'trigger': string;
  121394. 'menu': string;
  121395. 'grip': string;
  121396. 'thumbstick': string;
  121397. 'trackpad': string;
  121398. };
  121399. buttonObservableNames: {
  121400. 'trigger': string;
  121401. 'menu': string;
  121402. 'grip': string;
  121403. 'thumbstick': string;
  121404. 'trackpad': string;
  121405. };
  121406. axisMeshNames: string[];
  121407. pointingPoseMeshName: string;
  121408. };
  121409. /**
  121410. * Construct a new XR-Based windows motion controller
  121411. *
  121412. * @param gamepadInfo the gamepad object from the browser
  121413. */
  121414. constructor(gamepadInfo: any);
  121415. /**
  121416. * holds the thumbstick values (X,Y)
  121417. */
  121418. thumbstickValues: StickValues;
  121419. /**
  121420. * Fired when the thumbstick on this controller is clicked
  121421. */
  121422. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  121423. /**
  121424. * Fired when the thumbstick on this controller is modified
  121425. */
  121426. onThumbstickValuesChangedObservable: Observable<StickValues>;
  121427. /**
  121428. * Fired when the touchpad button on this controller is modified
  121429. */
  121430. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121431. /**
  121432. * Fired when the touchpad values on this controller are modified
  121433. */
  121434. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121435. /**
  121436. * Fired when the thumbstick button on this controller is modified
  121437. * here to prevent breaking changes
  121438. */
  121439. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121440. /**
  121441. * updating the thumbstick(!) and not the trackpad.
  121442. * This is named this way due to the difference between WebVR and XR and to avoid
  121443. * changing the parent class.
  121444. */
  121445. protected _updateTrackpad(): void;
  121446. /**
  121447. * Disposes the class with joy
  121448. */
  121449. dispose(): void;
  121450. }
  121451. }
  121452. declare module BABYLON {
  121453. /**
  121454. * Class containing static functions to help procedurally build meshes
  121455. */
  121456. export class PolyhedronBuilder {
  121457. /**
  121458. * Creates a polyhedron mesh
  121459. * * 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
  121460. * * The parameter `size` (positive float, default 1) sets the polygon size
  121461. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121462. * * 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`
  121463. * * 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
  121464. * * 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)`)
  121465. * * 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
  121466. * * 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
  121467. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121468. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121469. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121470. * @param name defines the name of the mesh
  121471. * @param options defines the options used to create the mesh
  121472. * @param scene defines the hosting scene
  121473. * @returns the polyhedron mesh
  121474. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121475. */
  121476. static CreatePolyhedron(name: string, options: {
  121477. type?: number;
  121478. size?: number;
  121479. sizeX?: number;
  121480. sizeY?: number;
  121481. sizeZ?: number;
  121482. custom?: any;
  121483. faceUV?: Vector4[];
  121484. faceColors?: Color4[];
  121485. flat?: boolean;
  121486. updatable?: boolean;
  121487. sideOrientation?: number;
  121488. frontUVs?: Vector4;
  121489. backUVs?: Vector4;
  121490. }, scene?: Nullable<Scene>): Mesh;
  121491. }
  121492. }
  121493. declare module BABYLON {
  121494. /**
  121495. * Gizmo that enables scaling a mesh along 3 axis
  121496. */
  121497. export class ScaleGizmo extends Gizmo {
  121498. /**
  121499. * Internal gizmo used for interactions on the x axis
  121500. */
  121501. xGizmo: AxisScaleGizmo;
  121502. /**
  121503. * Internal gizmo used for interactions on the y axis
  121504. */
  121505. yGizmo: AxisScaleGizmo;
  121506. /**
  121507. * Internal gizmo used for interactions on the z axis
  121508. */
  121509. zGizmo: AxisScaleGizmo;
  121510. /**
  121511. * Internal gizmo used to scale all axis equally
  121512. */
  121513. uniformScaleGizmo: AxisScaleGizmo;
  121514. private _meshAttached;
  121515. private _updateGizmoRotationToMatchAttachedMesh;
  121516. private _snapDistance;
  121517. private _scaleRatio;
  121518. private _uniformScalingMesh;
  121519. private _octahedron;
  121520. private _sensitivity;
  121521. /** Fires an event when any of it's sub gizmos are dragged */
  121522. onDragStartObservable: Observable<unknown>;
  121523. /** Fires an event when any of it's sub gizmos are released from dragging */
  121524. onDragEndObservable: Observable<unknown>;
  121525. get attachedMesh(): Nullable<AbstractMesh>;
  121526. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121527. /**
  121528. * Creates a ScaleGizmo
  121529. * @param gizmoLayer The utility layer the gizmo will be added to
  121530. */
  121531. constructor(gizmoLayer?: UtilityLayerRenderer);
  121532. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121533. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121534. /**
  121535. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121536. */
  121537. set snapDistance(value: number);
  121538. get snapDistance(): number;
  121539. /**
  121540. * Ratio for the scale of the gizmo (Default: 1)
  121541. */
  121542. set scaleRatio(value: number);
  121543. get scaleRatio(): number;
  121544. /**
  121545. * Sensitivity factor for dragging (Default: 1)
  121546. */
  121547. set sensitivity(value: number);
  121548. get sensitivity(): number;
  121549. /**
  121550. * Disposes of the gizmo
  121551. */
  121552. dispose(): void;
  121553. }
  121554. }
  121555. declare module BABYLON {
  121556. /**
  121557. * Single axis scale gizmo
  121558. */
  121559. export class AxisScaleGizmo extends Gizmo {
  121560. /**
  121561. * Drag behavior responsible for the gizmos dragging interactions
  121562. */
  121563. dragBehavior: PointerDragBehavior;
  121564. private _pointerObserver;
  121565. /**
  121566. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121567. */
  121568. snapDistance: number;
  121569. /**
  121570. * Event that fires each time the gizmo snaps to a new location.
  121571. * * snapDistance is the the change in distance
  121572. */
  121573. onSnapObservable: Observable<{
  121574. snapDistance: number;
  121575. }>;
  121576. /**
  121577. * If the scaling operation should be done on all axis (default: false)
  121578. */
  121579. uniformScaling: boolean;
  121580. /**
  121581. * Custom sensitivity value for the drag strength
  121582. */
  121583. sensitivity: number;
  121584. private _isEnabled;
  121585. private _parent;
  121586. private _arrow;
  121587. private _coloredMaterial;
  121588. private _hoverMaterial;
  121589. /**
  121590. * Creates an AxisScaleGizmo
  121591. * @param gizmoLayer The utility layer the gizmo will be added to
  121592. * @param dragAxis The axis which the gizmo will be able to scale on
  121593. * @param color The color of the gizmo
  121594. */
  121595. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  121596. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121597. /**
  121598. * If the gizmo is enabled
  121599. */
  121600. set isEnabled(value: boolean);
  121601. get isEnabled(): boolean;
  121602. /**
  121603. * Disposes of the gizmo
  121604. */
  121605. dispose(): void;
  121606. /**
  121607. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  121608. * @param mesh The mesh to replace the default mesh of the gizmo
  121609. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  121610. */
  121611. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  121612. }
  121613. }
  121614. declare module BABYLON {
  121615. /**
  121616. * Bounding box gizmo
  121617. */
  121618. export class BoundingBoxGizmo extends Gizmo {
  121619. private _lineBoundingBox;
  121620. private _rotateSpheresParent;
  121621. private _scaleBoxesParent;
  121622. private _boundingDimensions;
  121623. private _renderObserver;
  121624. private _pointerObserver;
  121625. private _scaleDragSpeed;
  121626. private _tmpQuaternion;
  121627. private _tmpVector;
  121628. private _tmpRotationMatrix;
  121629. /**
  121630. * 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)
  121631. */
  121632. ignoreChildren: boolean;
  121633. /**
  121634. * 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)
  121635. */
  121636. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  121637. /**
  121638. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  121639. */
  121640. rotationSphereSize: number;
  121641. /**
  121642. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  121643. */
  121644. scaleBoxSize: number;
  121645. /**
  121646. * 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)
  121647. */
  121648. fixedDragMeshScreenSize: boolean;
  121649. /**
  121650. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  121651. */
  121652. fixedDragMeshScreenSizeDistanceFactor: number;
  121653. /**
  121654. * Fired when a rotation sphere or scale box is dragged
  121655. */
  121656. onDragStartObservable: Observable<{}>;
  121657. /**
  121658. * Fired when a scale box is dragged
  121659. */
  121660. onScaleBoxDragObservable: Observable<{}>;
  121661. /**
  121662. * Fired when a scale box drag is ended
  121663. */
  121664. onScaleBoxDragEndObservable: Observable<{}>;
  121665. /**
  121666. * Fired when a rotation sphere is dragged
  121667. */
  121668. onRotationSphereDragObservable: Observable<{}>;
  121669. /**
  121670. * Fired when a rotation sphere drag is ended
  121671. */
  121672. onRotationSphereDragEndObservable: Observable<{}>;
  121673. /**
  121674. * 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)
  121675. */
  121676. scalePivot: Nullable<Vector3>;
  121677. /**
  121678. * Mesh used as a pivot to rotate the attached mesh
  121679. */
  121680. private _anchorMesh;
  121681. private _existingMeshScale;
  121682. private _dragMesh;
  121683. private pointerDragBehavior;
  121684. private coloredMaterial;
  121685. private hoverColoredMaterial;
  121686. /**
  121687. * Sets the color of the bounding box gizmo
  121688. * @param color the color to set
  121689. */
  121690. setColor(color: Color3): void;
  121691. /**
  121692. * Creates an BoundingBoxGizmo
  121693. * @param gizmoLayer The utility layer the gizmo will be added to
  121694. * @param color The color of the gizmo
  121695. */
  121696. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  121697. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121698. private _selectNode;
  121699. /**
  121700. * Updates the bounding box information for the Gizmo
  121701. */
  121702. updateBoundingBox(): void;
  121703. private _updateRotationSpheres;
  121704. private _updateScaleBoxes;
  121705. /**
  121706. * Enables rotation on the specified axis and disables rotation on the others
  121707. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  121708. */
  121709. setEnabledRotationAxis(axis: string): void;
  121710. /**
  121711. * Enables/disables scaling
  121712. * @param enable if scaling should be enabled
  121713. */
  121714. setEnabledScaling(enable: boolean): void;
  121715. private _updateDummy;
  121716. /**
  121717. * Enables a pointer drag behavior on the bounding box of the gizmo
  121718. */
  121719. enableDragBehavior(): void;
  121720. /**
  121721. * Disposes of the gizmo
  121722. */
  121723. dispose(): void;
  121724. /**
  121725. * 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)
  121726. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  121727. * @returns the bounding box mesh with the passed in mesh as a child
  121728. */
  121729. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  121730. /**
  121731. * CustomMeshes are not supported by this gizmo
  121732. * @param mesh The mesh to replace the default mesh of the gizmo
  121733. */
  121734. setCustomMesh(mesh: Mesh): void;
  121735. }
  121736. }
  121737. declare module BABYLON {
  121738. /**
  121739. * Single plane rotation gizmo
  121740. */
  121741. export class PlaneRotationGizmo extends Gizmo {
  121742. /**
  121743. * Drag behavior responsible for the gizmos dragging interactions
  121744. */
  121745. dragBehavior: PointerDragBehavior;
  121746. private _pointerObserver;
  121747. /**
  121748. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  121749. */
  121750. snapDistance: number;
  121751. /**
  121752. * Event that fires each time the gizmo snaps to a new location.
  121753. * * snapDistance is the the change in distance
  121754. */
  121755. onSnapObservable: Observable<{
  121756. snapDistance: number;
  121757. }>;
  121758. private _isEnabled;
  121759. private _parent;
  121760. /**
  121761. * Creates a PlaneRotationGizmo
  121762. * @param gizmoLayer The utility layer the gizmo will be added to
  121763. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  121764. * @param color The color of the gizmo
  121765. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121766. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121767. */
  121768. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  121769. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121770. /**
  121771. * If the gizmo is enabled
  121772. */
  121773. set isEnabled(value: boolean);
  121774. get isEnabled(): boolean;
  121775. /**
  121776. * Disposes of the gizmo
  121777. */
  121778. dispose(): void;
  121779. }
  121780. }
  121781. declare module BABYLON {
  121782. /**
  121783. * Gizmo that enables rotating a mesh along 3 axis
  121784. */
  121785. export class RotationGizmo extends Gizmo {
  121786. /**
  121787. * Internal gizmo used for interactions on the x axis
  121788. */
  121789. xGizmo: PlaneRotationGizmo;
  121790. /**
  121791. * Internal gizmo used for interactions on the y axis
  121792. */
  121793. yGizmo: PlaneRotationGizmo;
  121794. /**
  121795. * Internal gizmo used for interactions on the z axis
  121796. */
  121797. zGizmo: PlaneRotationGizmo;
  121798. /** Fires an event when any of it's sub gizmos are dragged */
  121799. onDragStartObservable: Observable<unknown>;
  121800. /** Fires an event when any of it's sub gizmos are released from dragging */
  121801. onDragEndObservable: Observable<unknown>;
  121802. private _meshAttached;
  121803. get attachedMesh(): Nullable<AbstractMesh>;
  121804. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121805. /**
  121806. * Creates a RotationGizmo
  121807. * @param gizmoLayer The utility layer the gizmo will be added to
  121808. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121809. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121810. */
  121811. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  121812. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121813. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121814. /**
  121815. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121816. */
  121817. set snapDistance(value: number);
  121818. get snapDistance(): number;
  121819. /**
  121820. * Ratio for the scale of the gizmo (Default: 1)
  121821. */
  121822. set scaleRatio(value: number);
  121823. get scaleRatio(): number;
  121824. /**
  121825. * Disposes of the gizmo
  121826. */
  121827. dispose(): void;
  121828. /**
  121829. * CustomMeshes are not supported by this gizmo
  121830. * @param mesh The mesh to replace the default mesh of the gizmo
  121831. */
  121832. setCustomMesh(mesh: Mesh): void;
  121833. }
  121834. }
  121835. declare module BABYLON {
  121836. /**
  121837. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  121838. */
  121839. export class GizmoManager implements IDisposable {
  121840. private scene;
  121841. /**
  121842. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  121843. */
  121844. gizmos: {
  121845. positionGizmo: Nullable<PositionGizmo>;
  121846. rotationGizmo: Nullable<RotationGizmo>;
  121847. scaleGizmo: Nullable<ScaleGizmo>;
  121848. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  121849. };
  121850. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  121851. clearGizmoOnEmptyPointerEvent: boolean;
  121852. /** Fires an event when the manager is attached to a mesh */
  121853. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  121854. private _gizmosEnabled;
  121855. private _pointerObserver;
  121856. private _attachedMesh;
  121857. private _boundingBoxColor;
  121858. private _defaultUtilityLayer;
  121859. private _defaultKeepDepthUtilityLayer;
  121860. /**
  121861. * When bounding box gizmo is enabled, this can be used to track drag/end events
  121862. */
  121863. boundingBoxDragBehavior: SixDofDragBehavior;
  121864. /**
  121865. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  121866. */
  121867. attachableMeshes: Nullable<Array<AbstractMesh>>;
  121868. /**
  121869. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  121870. */
  121871. usePointerToAttachGizmos: boolean;
  121872. /**
  121873. * Utility layer that the bounding box gizmo belongs to
  121874. */
  121875. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  121876. /**
  121877. * Utility layer that all gizmos besides bounding box belong to
  121878. */
  121879. get utilityLayer(): UtilityLayerRenderer;
  121880. /**
  121881. * Instatiates a gizmo manager
  121882. * @param scene the scene to overlay the gizmos on top of
  121883. */
  121884. constructor(scene: Scene);
  121885. /**
  121886. * Attaches a set of gizmos to the specified mesh
  121887. * @param mesh The mesh the gizmo's should be attached to
  121888. */
  121889. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  121890. /**
  121891. * If the position gizmo is enabled
  121892. */
  121893. set positionGizmoEnabled(value: boolean);
  121894. get positionGizmoEnabled(): boolean;
  121895. /**
  121896. * If the rotation gizmo is enabled
  121897. */
  121898. set rotationGizmoEnabled(value: boolean);
  121899. get rotationGizmoEnabled(): boolean;
  121900. /**
  121901. * If the scale gizmo is enabled
  121902. */
  121903. set scaleGizmoEnabled(value: boolean);
  121904. get scaleGizmoEnabled(): boolean;
  121905. /**
  121906. * If the boundingBox gizmo is enabled
  121907. */
  121908. set boundingBoxGizmoEnabled(value: boolean);
  121909. get boundingBoxGizmoEnabled(): boolean;
  121910. /**
  121911. * Disposes of the gizmo manager
  121912. */
  121913. dispose(): void;
  121914. }
  121915. }
  121916. declare module BABYLON {
  121917. /**
  121918. * A directional light is defined by a direction (what a surprise!).
  121919. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  121920. * 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.
  121921. * Documentation: https://doc.babylonjs.com/babylon101/lights
  121922. */
  121923. export class DirectionalLight extends ShadowLight {
  121924. private _shadowFrustumSize;
  121925. /**
  121926. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  121927. */
  121928. get shadowFrustumSize(): number;
  121929. /**
  121930. * Specifies a fix frustum size for the shadow generation.
  121931. */
  121932. set shadowFrustumSize(value: number);
  121933. private _shadowOrthoScale;
  121934. /**
  121935. * Gets the shadow projection scale against the optimal computed one.
  121936. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121937. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121938. */
  121939. get shadowOrthoScale(): number;
  121940. /**
  121941. * Sets the shadow projection scale against the optimal computed one.
  121942. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  121943. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  121944. */
  121945. set shadowOrthoScale(value: number);
  121946. /**
  121947. * Automatically compute the projection matrix to best fit (including all the casters)
  121948. * on each frame.
  121949. */
  121950. autoUpdateExtends: boolean;
  121951. /**
  121952. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  121953. * on each frame. autoUpdateExtends must be set to true for this to work
  121954. */
  121955. autoCalcShadowZBounds: boolean;
  121956. private _orthoLeft;
  121957. private _orthoRight;
  121958. private _orthoTop;
  121959. private _orthoBottom;
  121960. /**
  121961. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  121962. * The directional light is emitted from everywhere in the given direction.
  121963. * It can cast shadows.
  121964. * Documentation : https://doc.babylonjs.com/babylon101/lights
  121965. * @param name The friendly name of the light
  121966. * @param direction The direction of the light
  121967. * @param scene The scene the light belongs to
  121968. */
  121969. constructor(name: string, direction: Vector3, scene: Scene);
  121970. /**
  121971. * Returns the string "DirectionalLight".
  121972. * @return The class name
  121973. */
  121974. getClassName(): string;
  121975. /**
  121976. * Returns the integer 1.
  121977. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  121978. */
  121979. getTypeID(): number;
  121980. /**
  121981. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  121982. * Returns the DirectionalLight Shadow projection matrix.
  121983. */
  121984. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121985. /**
  121986. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  121987. * Returns the DirectionalLight Shadow projection matrix.
  121988. */
  121989. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  121990. /**
  121991. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  121992. * Returns the DirectionalLight Shadow projection matrix.
  121993. */
  121994. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  121995. protected _buildUniformLayout(): void;
  121996. /**
  121997. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  121998. * @param effect The effect to update
  121999. * @param lightIndex The index of the light in the effect to update
  122000. * @returns The directional light
  122001. */
  122002. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  122003. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  122004. /**
  122005. * Gets the minZ used for shadow according to both the scene and the light.
  122006. *
  122007. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122008. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122009. * @param activeCamera The camera we are returning the min for
  122010. * @returns the depth min z
  122011. */
  122012. getDepthMinZ(activeCamera: Camera): number;
  122013. /**
  122014. * Gets the maxZ used for shadow according to both the scene and the light.
  122015. *
  122016. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122017. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122018. * @param activeCamera The camera we are returning the max for
  122019. * @returns the depth max z
  122020. */
  122021. getDepthMaxZ(activeCamera: Camera): number;
  122022. /**
  122023. * Prepares the list of defines specific to the light type.
  122024. * @param defines the list of defines
  122025. * @param lightIndex defines the index of the light for the effect
  122026. */
  122027. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122028. }
  122029. }
  122030. declare module BABYLON {
  122031. /**
  122032. * Class containing static functions to help procedurally build meshes
  122033. */
  122034. export class HemisphereBuilder {
  122035. /**
  122036. * Creates a hemisphere mesh
  122037. * @param name defines the name of the mesh
  122038. * @param options defines the options used to create the mesh
  122039. * @param scene defines the hosting scene
  122040. * @returns the hemisphere mesh
  122041. */
  122042. static CreateHemisphere(name: string, options: {
  122043. segments?: number;
  122044. diameter?: number;
  122045. sideOrientation?: number;
  122046. }, scene: any): Mesh;
  122047. }
  122048. }
  122049. declare module BABYLON {
  122050. /**
  122051. * A spot light is defined by a position, a direction, an angle, and an exponent.
  122052. * These values define a cone of light starting from the position, emitting toward the direction.
  122053. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  122054. * and the exponent defines the speed of the decay of the light with distance (reach).
  122055. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122056. */
  122057. export class SpotLight extends ShadowLight {
  122058. private _angle;
  122059. private _innerAngle;
  122060. private _cosHalfAngle;
  122061. private _lightAngleScale;
  122062. private _lightAngleOffset;
  122063. /**
  122064. * Gets the cone angle of the spot light in Radians.
  122065. */
  122066. get angle(): number;
  122067. /**
  122068. * Sets the cone angle of the spot light in Radians.
  122069. */
  122070. set angle(value: number);
  122071. /**
  122072. * Only used in gltf falloff mode, this defines the angle where
  122073. * the directional falloff will start before cutting at angle which could be seen
  122074. * as outer angle.
  122075. */
  122076. get innerAngle(): number;
  122077. /**
  122078. * Only used in gltf falloff mode, this defines the angle where
  122079. * the directional falloff will start before cutting at angle which could be seen
  122080. * as outer angle.
  122081. */
  122082. set innerAngle(value: number);
  122083. private _shadowAngleScale;
  122084. /**
  122085. * Allows scaling the angle of the light for shadow generation only.
  122086. */
  122087. get shadowAngleScale(): number;
  122088. /**
  122089. * Allows scaling the angle of the light for shadow generation only.
  122090. */
  122091. set shadowAngleScale(value: number);
  122092. /**
  122093. * The light decay speed with the distance from the emission spot.
  122094. */
  122095. exponent: number;
  122096. private _projectionTextureMatrix;
  122097. /**
  122098. * Allows reading the projecton texture
  122099. */
  122100. get projectionTextureMatrix(): Matrix;
  122101. protected _projectionTextureLightNear: number;
  122102. /**
  122103. * Gets the near clip of the Spotlight for texture projection.
  122104. */
  122105. get projectionTextureLightNear(): number;
  122106. /**
  122107. * Sets the near clip of the Spotlight for texture projection.
  122108. */
  122109. set projectionTextureLightNear(value: number);
  122110. protected _projectionTextureLightFar: number;
  122111. /**
  122112. * Gets the far clip of the Spotlight for texture projection.
  122113. */
  122114. get projectionTextureLightFar(): number;
  122115. /**
  122116. * Sets the far clip of the Spotlight for texture projection.
  122117. */
  122118. set projectionTextureLightFar(value: number);
  122119. protected _projectionTextureUpDirection: Vector3;
  122120. /**
  122121. * Gets the Up vector of the Spotlight for texture projection.
  122122. */
  122123. get projectionTextureUpDirection(): Vector3;
  122124. /**
  122125. * Sets the Up vector of the Spotlight for texture projection.
  122126. */
  122127. set projectionTextureUpDirection(value: Vector3);
  122128. private _projectionTexture;
  122129. /**
  122130. * Gets the projection texture of the light.
  122131. */
  122132. get projectionTexture(): Nullable<BaseTexture>;
  122133. /**
  122134. * Sets the projection texture of the light.
  122135. */
  122136. set projectionTexture(value: Nullable<BaseTexture>);
  122137. private _projectionTextureViewLightDirty;
  122138. private _projectionTextureProjectionLightDirty;
  122139. private _projectionTextureDirty;
  122140. private _projectionTextureViewTargetVector;
  122141. private _projectionTextureViewLightMatrix;
  122142. private _projectionTextureProjectionLightMatrix;
  122143. private _projectionTextureScalingMatrix;
  122144. /**
  122145. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  122146. * It can cast shadows.
  122147. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122148. * @param name The light friendly name
  122149. * @param position The position of the spot light in the scene
  122150. * @param direction The direction of the light in the scene
  122151. * @param angle The cone angle of the light in Radians
  122152. * @param exponent The light decay speed with the distance from the emission spot
  122153. * @param scene The scene the lights belongs to
  122154. */
  122155. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  122156. /**
  122157. * Returns the string "SpotLight".
  122158. * @returns the class name
  122159. */
  122160. getClassName(): string;
  122161. /**
  122162. * Returns the integer 2.
  122163. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122164. */
  122165. getTypeID(): number;
  122166. /**
  122167. * Overrides the direction setter to recompute the projection texture view light Matrix.
  122168. */
  122169. protected _setDirection(value: Vector3): void;
  122170. /**
  122171. * Overrides the position setter to recompute the projection texture view light Matrix.
  122172. */
  122173. protected _setPosition(value: Vector3): void;
  122174. /**
  122175. * 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.
  122176. * Returns the SpotLight.
  122177. */
  122178. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122179. protected _computeProjectionTextureViewLightMatrix(): void;
  122180. protected _computeProjectionTextureProjectionLightMatrix(): void;
  122181. /**
  122182. * Main function for light texture projection matrix computing.
  122183. */
  122184. protected _computeProjectionTextureMatrix(): void;
  122185. protected _buildUniformLayout(): void;
  122186. private _computeAngleValues;
  122187. /**
  122188. * Sets the passed Effect "effect" with the Light textures.
  122189. * @param effect The effect to update
  122190. * @param lightIndex The index of the light in the effect to update
  122191. * @returns The light
  122192. */
  122193. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  122194. /**
  122195. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  122196. * @param effect The effect to update
  122197. * @param lightIndex The index of the light in the effect to update
  122198. * @returns The spot light
  122199. */
  122200. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  122201. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  122202. /**
  122203. * Disposes the light and the associated resources.
  122204. */
  122205. dispose(): void;
  122206. /**
  122207. * Prepares the list of defines specific to the light type.
  122208. * @param defines the list of defines
  122209. * @param lightIndex defines the index of the light for the effect
  122210. */
  122211. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122212. }
  122213. }
  122214. declare module BABYLON {
  122215. /**
  122216. * Gizmo that enables viewing a light
  122217. */
  122218. export class LightGizmo extends Gizmo {
  122219. private _lightMesh;
  122220. private _material;
  122221. private _cachedPosition;
  122222. private _cachedForward;
  122223. private _attachedMeshParent;
  122224. /**
  122225. * Creates a LightGizmo
  122226. * @param gizmoLayer The utility layer the gizmo will be added to
  122227. */
  122228. constructor(gizmoLayer?: UtilityLayerRenderer);
  122229. private _light;
  122230. /**
  122231. * The light that the gizmo is attached to
  122232. */
  122233. set light(light: Nullable<Light>);
  122234. get light(): Nullable<Light>;
  122235. /**
  122236. * Gets the material used to render the light gizmo
  122237. */
  122238. get material(): StandardMaterial;
  122239. /**
  122240. * @hidden
  122241. * Updates the gizmo to match the attached mesh's position/rotation
  122242. */
  122243. protected _update(): void;
  122244. private static _Scale;
  122245. /**
  122246. * Creates the lines for a light mesh
  122247. */
  122248. private static _CreateLightLines;
  122249. /**
  122250. * Disposes of the light gizmo
  122251. */
  122252. dispose(): void;
  122253. private static _CreateHemisphericLightMesh;
  122254. private static _CreatePointLightMesh;
  122255. private static _CreateSpotLightMesh;
  122256. private static _CreateDirectionalLightMesh;
  122257. }
  122258. }
  122259. declare module BABYLON {
  122260. /** @hidden */
  122261. export var backgroundFragmentDeclaration: {
  122262. name: string;
  122263. shader: string;
  122264. };
  122265. }
  122266. declare module BABYLON {
  122267. /** @hidden */
  122268. export var backgroundUboDeclaration: {
  122269. name: string;
  122270. shader: string;
  122271. };
  122272. }
  122273. declare module BABYLON {
  122274. /** @hidden */
  122275. export var backgroundPixelShader: {
  122276. name: string;
  122277. shader: string;
  122278. };
  122279. }
  122280. declare module BABYLON {
  122281. /** @hidden */
  122282. export var backgroundVertexDeclaration: {
  122283. name: string;
  122284. shader: string;
  122285. };
  122286. }
  122287. declare module BABYLON {
  122288. /** @hidden */
  122289. export var backgroundVertexShader: {
  122290. name: string;
  122291. shader: string;
  122292. };
  122293. }
  122294. declare module BABYLON {
  122295. /**
  122296. * Background material used to create an efficient environement around your scene.
  122297. */
  122298. export class BackgroundMaterial extends PushMaterial {
  122299. /**
  122300. * Standard reflectance value at parallel view angle.
  122301. */
  122302. static StandardReflectance0: number;
  122303. /**
  122304. * Standard reflectance value at grazing angle.
  122305. */
  122306. static StandardReflectance90: number;
  122307. protected _primaryColor: Color3;
  122308. /**
  122309. * Key light Color (multiply against the environement texture)
  122310. */
  122311. primaryColor: Color3;
  122312. protected __perceptualColor: Nullable<Color3>;
  122313. /**
  122314. * Experimental Internal Use Only.
  122315. *
  122316. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  122317. * This acts as a helper to set the primary color to a more "human friendly" value.
  122318. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  122319. * output color as close as possible from the chosen value.
  122320. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  122321. * part of lighting setup.)
  122322. */
  122323. get _perceptualColor(): Nullable<Color3>;
  122324. set _perceptualColor(value: Nullable<Color3>);
  122325. protected _primaryColorShadowLevel: float;
  122326. /**
  122327. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  122328. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  122329. */
  122330. get primaryColorShadowLevel(): float;
  122331. set primaryColorShadowLevel(value: float);
  122332. protected _primaryColorHighlightLevel: float;
  122333. /**
  122334. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  122335. * The primary color is used at the level chosen to define what the white area would look.
  122336. */
  122337. get primaryColorHighlightLevel(): float;
  122338. set primaryColorHighlightLevel(value: float);
  122339. protected _reflectionTexture: Nullable<BaseTexture>;
  122340. /**
  122341. * Reflection Texture used in the material.
  122342. * Should be author in a specific way for the best result (refer to the documentation).
  122343. */
  122344. reflectionTexture: Nullable<BaseTexture>;
  122345. protected _reflectionBlur: float;
  122346. /**
  122347. * Reflection Texture level of blur.
  122348. *
  122349. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  122350. * texture twice.
  122351. */
  122352. reflectionBlur: float;
  122353. protected _diffuseTexture: Nullable<BaseTexture>;
  122354. /**
  122355. * Diffuse Texture used in the material.
  122356. * Should be author in a specific way for the best result (refer to the documentation).
  122357. */
  122358. diffuseTexture: Nullable<BaseTexture>;
  122359. protected _shadowLights: Nullable<IShadowLight[]>;
  122360. /**
  122361. * Specify the list of lights casting shadow on the material.
  122362. * All scene shadow lights will be included if null.
  122363. */
  122364. shadowLights: Nullable<IShadowLight[]>;
  122365. protected _shadowLevel: float;
  122366. /**
  122367. * Helps adjusting the shadow to a softer level if required.
  122368. * 0 means black shadows and 1 means no shadows.
  122369. */
  122370. shadowLevel: float;
  122371. protected _sceneCenter: Vector3;
  122372. /**
  122373. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  122374. * It is usually zero but might be interesting to modify according to your setup.
  122375. */
  122376. sceneCenter: Vector3;
  122377. protected _opacityFresnel: boolean;
  122378. /**
  122379. * This helps specifying that the material is falling off to the sky box at grazing angle.
  122380. * This helps ensuring a nice transition when the camera goes under the ground.
  122381. */
  122382. opacityFresnel: boolean;
  122383. protected _reflectionFresnel: boolean;
  122384. /**
  122385. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  122386. * This helps adding a mirror texture on the ground.
  122387. */
  122388. reflectionFresnel: boolean;
  122389. protected _reflectionFalloffDistance: number;
  122390. /**
  122391. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  122392. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  122393. */
  122394. reflectionFalloffDistance: number;
  122395. protected _reflectionAmount: number;
  122396. /**
  122397. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  122398. */
  122399. reflectionAmount: number;
  122400. protected _reflectionReflectance0: number;
  122401. /**
  122402. * This specifies the weight of the reflection at grazing angle.
  122403. */
  122404. reflectionReflectance0: number;
  122405. protected _reflectionReflectance90: number;
  122406. /**
  122407. * This specifies the weight of the reflection at a perpendicular point of view.
  122408. */
  122409. reflectionReflectance90: number;
  122410. /**
  122411. * Sets the reflection reflectance fresnel values according to the default standard
  122412. * empirically know to work well :-)
  122413. */
  122414. set reflectionStandardFresnelWeight(value: number);
  122415. protected _useRGBColor: boolean;
  122416. /**
  122417. * Helps to directly use the maps channels instead of their level.
  122418. */
  122419. useRGBColor: boolean;
  122420. protected _enableNoise: boolean;
  122421. /**
  122422. * This helps reducing the banding effect that could occur on the background.
  122423. */
  122424. enableNoise: boolean;
  122425. /**
  122426. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122427. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  122428. * Recommended to be keep at 1.0 except for special cases.
  122429. */
  122430. get fovMultiplier(): number;
  122431. set fovMultiplier(value: number);
  122432. private _fovMultiplier;
  122433. /**
  122434. * Enable the FOV adjustment feature controlled by fovMultiplier.
  122435. */
  122436. useEquirectangularFOV: boolean;
  122437. private _maxSimultaneousLights;
  122438. /**
  122439. * Number of Simultaneous lights allowed on the material.
  122440. */
  122441. maxSimultaneousLights: int;
  122442. /**
  122443. * Default configuration related to image processing available in the Background Material.
  122444. */
  122445. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122446. /**
  122447. * Keep track of the image processing observer to allow dispose and replace.
  122448. */
  122449. private _imageProcessingObserver;
  122450. /**
  122451. * Attaches a new image processing configuration to the PBR Material.
  122452. * @param configuration (if null the scene configuration will be use)
  122453. */
  122454. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122455. /**
  122456. * Gets the image processing configuration used either in this material.
  122457. */
  122458. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  122459. /**
  122460. * Sets the Default image processing configuration used either in the this material.
  122461. *
  122462. * If sets to null, the scene one is in use.
  122463. */
  122464. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  122465. /**
  122466. * Gets wether the color curves effect is enabled.
  122467. */
  122468. get cameraColorCurvesEnabled(): boolean;
  122469. /**
  122470. * Sets wether the color curves effect is enabled.
  122471. */
  122472. set cameraColorCurvesEnabled(value: boolean);
  122473. /**
  122474. * Gets wether the color grading effect is enabled.
  122475. */
  122476. get cameraColorGradingEnabled(): boolean;
  122477. /**
  122478. * Gets wether the color grading effect is enabled.
  122479. */
  122480. set cameraColorGradingEnabled(value: boolean);
  122481. /**
  122482. * Gets wether tonemapping is enabled or not.
  122483. */
  122484. get cameraToneMappingEnabled(): boolean;
  122485. /**
  122486. * Sets wether tonemapping is enabled or not
  122487. */
  122488. set cameraToneMappingEnabled(value: boolean);
  122489. /**
  122490. * The camera exposure used on this material.
  122491. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122492. * This corresponds to a photographic exposure.
  122493. */
  122494. get cameraExposure(): float;
  122495. /**
  122496. * The camera exposure used on this material.
  122497. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122498. * This corresponds to a photographic exposure.
  122499. */
  122500. set cameraExposure(value: float);
  122501. /**
  122502. * Gets The camera contrast used on this material.
  122503. */
  122504. get cameraContrast(): float;
  122505. /**
  122506. * Sets The camera contrast used on this material.
  122507. */
  122508. set cameraContrast(value: float);
  122509. /**
  122510. * Gets the Color Grading 2D Lookup Texture.
  122511. */
  122512. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  122513. /**
  122514. * Sets the Color Grading 2D Lookup Texture.
  122515. */
  122516. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  122517. /**
  122518. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122519. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122520. * 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;
  122521. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122522. */
  122523. get cameraColorCurves(): Nullable<ColorCurves>;
  122524. /**
  122525. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122526. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122527. * 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;
  122528. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122529. */
  122530. set cameraColorCurves(value: Nullable<ColorCurves>);
  122531. /**
  122532. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  122533. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  122534. */
  122535. switchToBGR: boolean;
  122536. private _renderTargets;
  122537. private _reflectionControls;
  122538. private _white;
  122539. private _primaryShadowColor;
  122540. private _primaryHighlightColor;
  122541. /**
  122542. * Instantiates a Background Material in the given scene
  122543. * @param name The friendly name of the material
  122544. * @param scene The scene to add the material to
  122545. */
  122546. constructor(name: string, scene: Scene);
  122547. /**
  122548. * Gets a boolean indicating that current material needs to register RTT
  122549. */
  122550. get hasRenderTargetTextures(): boolean;
  122551. /**
  122552. * The entire material has been created in order to prevent overdraw.
  122553. * @returns false
  122554. */
  122555. needAlphaTesting(): boolean;
  122556. /**
  122557. * The entire material has been created in order to prevent overdraw.
  122558. * @returns true if blending is enable
  122559. */
  122560. needAlphaBlending(): boolean;
  122561. /**
  122562. * Checks wether the material is ready to be rendered for a given mesh.
  122563. * @param mesh The mesh to render
  122564. * @param subMesh The submesh to check against
  122565. * @param useInstances Specify wether or not the material is used with instances
  122566. * @returns true if all the dependencies are ready (Textures, Effects...)
  122567. */
  122568. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122569. /**
  122570. * Compute the primary color according to the chosen perceptual color.
  122571. */
  122572. private _computePrimaryColorFromPerceptualColor;
  122573. /**
  122574. * Compute the highlights and shadow colors according to their chosen levels.
  122575. */
  122576. private _computePrimaryColors;
  122577. /**
  122578. * Build the uniform buffer used in the material.
  122579. */
  122580. buildUniformLayout(): void;
  122581. /**
  122582. * Unbind the material.
  122583. */
  122584. unbind(): void;
  122585. /**
  122586. * Bind only the world matrix to the material.
  122587. * @param world The world matrix to bind.
  122588. */
  122589. bindOnlyWorldMatrix(world: Matrix): void;
  122590. /**
  122591. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  122592. * @param world The world matrix to bind.
  122593. * @param subMesh The submesh to bind for.
  122594. */
  122595. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122596. /**
  122597. * Checks to see if a texture is used in the material.
  122598. * @param texture - Base texture to use.
  122599. * @returns - Boolean specifying if a texture is used in the material.
  122600. */
  122601. hasTexture(texture: BaseTexture): boolean;
  122602. /**
  122603. * Dispose the material.
  122604. * @param forceDisposeEffect Force disposal of the associated effect.
  122605. * @param forceDisposeTextures Force disposal of the associated textures.
  122606. */
  122607. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122608. /**
  122609. * Clones the material.
  122610. * @param name The cloned name.
  122611. * @returns The cloned material.
  122612. */
  122613. clone(name: string): BackgroundMaterial;
  122614. /**
  122615. * Serializes the current material to its JSON representation.
  122616. * @returns The JSON representation.
  122617. */
  122618. serialize(): any;
  122619. /**
  122620. * Gets the class name of the material
  122621. * @returns "BackgroundMaterial"
  122622. */
  122623. getClassName(): string;
  122624. /**
  122625. * Parse a JSON input to create back a background material.
  122626. * @param source The JSON data to parse
  122627. * @param scene The scene to create the parsed material in
  122628. * @param rootUrl The root url of the assets the material depends upon
  122629. * @returns the instantiated BackgroundMaterial.
  122630. */
  122631. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  122632. }
  122633. }
  122634. declare module BABYLON {
  122635. /**
  122636. * Represents the different options available during the creation of
  122637. * a Environment helper.
  122638. *
  122639. * This can control the default ground, skybox and image processing setup of your scene.
  122640. */
  122641. export interface IEnvironmentHelperOptions {
  122642. /**
  122643. * Specifies whether or not to create a ground.
  122644. * True by default.
  122645. */
  122646. createGround: boolean;
  122647. /**
  122648. * Specifies the ground size.
  122649. * 15 by default.
  122650. */
  122651. groundSize: number;
  122652. /**
  122653. * The texture used on the ground for the main color.
  122654. * Comes from the BabylonJS CDN by default.
  122655. *
  122656. * Remarks: Can be either a texture or a url.
  122657. */
  122658. groundTexture: string | BaseTexture;
  122659. /**
  122660. * The color mixed in the ground texture by default.
  122661. * BabylonJS clearColor by default.
  122662. */
  122663. groundColor: Color3;
  122664. /**
  122665. * Specifies the ground opacity.
  122666. * 1 by default.
  122667. */
  122668. groundOpacity: number;
  122669. /**
  122670. * Enables the ground to receive shadows.
  122671. * True by default.
  122672. */
  122673. enableGroundShadow: boolean;
  122674. /**
  122675. * Helps preventing the shadow to be fully black on the ground.
  122676. * 0.5 by default.
  122677. */
  122678. groundShadowLevel: number;
  122679. /**
  122680. * Creates a mirror texture attach to the ground.
  122681. * false by default.
  122682. */
  122683. enableGroundMirror: boolean;
  122684. /**
  122685. * Specifies the ground mirror size ratio.
  122686. * 0.3 by default as the default kernel is 64.
  122687. */
  122688. groundMirrorSizeRatio: number;
  122689. /**
  122690. * Specifies the ground mirror blur kernel size.
  122691. * 64 by default.
  122692. */
  122693. groundMirrorBlurKernel: number;
  122694. /**
  122695. * Specifies the ground mirror visibility amount.
  122696. * 1 by default
  122697. */
  122698. groundMirrorAmount: number;
  122699. /**
  122700. * Specifies the ground mirror reflectance weight.
  122701. * This uses the standard weight of the background material to setup the fresnel effect
  122702. * of the mirror.
  122703. * 1 by default.
  122704. */
  122705. groundMirrorFresnelWeight: number;
  122706. /**
  122707. * Specifies the ground mirror Falloff distance.
  122708. * This can helps reducing the size of the reflection.
  122709. * 0 by Default.
  122710. */
  122711. groundMirrorFallOffDistance: number;
  122712. /**
  122713. * Specifies the ground mirror texture type.
  122714. * Unsigned Int by Default.
  122715. */
  122716. groundMirrorTextureType: number;
  122717. /**
  122718. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  122719. * the shown objects.
  122720. */
  122721. groundYBias: number;
  122722. /**
  122723. * Specifies whether or not to create a skybox.
  122724. * True by default.
  122725. */
  122726. createSkybox: boolean;
  122727. /**
  122728. * Specifies the skybox size.
  122729. * 20 by default.
  122730. */
  122731. skyboxSize: number;
  122732. /**
  122733. * The texture used on the skybox for the main color.
  122734. * Comes from the BabylonJS CDN by default.
  122735. *
  122736. * Remarks: Can be either a texture or a url.
  122737. */
  122738. skyboxTexture: string | BaseTexture;
  122739. /**
  122740. * The color mixed in the skybox texture by default.
  122741. * BabylonJS clearColor by default.
  122742. */
  122743. skyboxColor: Color3;
  122744. /**
  122745. * The background rotation around the Y axis of the scene.
  122746. * This helps aligning the key lights of your scene with the background.
  122747. * 0 by default.
  122748. */
  122749. backgroundYRotation: number;
  122750. /**
  122751. * Compute automatically the size of the elements to best fit with the scene.
  122752. */
  122753. sizeAuto: boolean;
  122754. /**
  122755. * Default position of the rootMesh if autoSize is not true.
  122756. */
  122757. rootPosition: Vector3;
  122758. /**
  122759. * Sets up the image processing in the scene.
  122760. * true by default.
  122761. */
  122762. setupImageProcessing: boolean;
  122763. /**
  122764. * The texture used as your environment texture in the scene.
  122765. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  122766. *
  122767. * Remarks: Can be either a texture or a url.
  122768. */
  122769. environmentTexture: string | BaseTexture;
  122770. /**
  122771. * The value of the exposure to apply to the scene.
  122772. * 0.6 by default if setupImageProcessing is true.
  122773. */
  122774. cameraExposure: number;
  122775. /**
  122776. * The value of the contrast to apply to the scene.
  122777. * 1.6 by default if setupImageProcessing is true.
  122778. */
  122779. cameraContrast: number;
  122780. /**
  122781. * Specifies whether or not tonemapping should be enabled in the scene.
  122782. * true by default if setupImageProcessing is true.
  122783. */
  122784. toneMappingEnabled: boolean;
  122785. }
  122786. /**
  122787. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  122788. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  122789. * It also helps with the default setup of your imageProcessing configuration.
  122790. */
  122791. export class EnvironmentHelper {
  122792. /**
  122793. * Default ground texture URL.
  122794. */
  122795. private static _groundTextureCDNUrl;
  122796. /**
  122797. * Default skybox texture URL.
  122798. */
  122799. private static _skyboxTextureCDNUrl;
  122800. /**
  122801. * Default environment texture URL.
  122802. */
  122803. private static _environmentTextureCDNUrl;
  122804. /**
  122805. * Creates the default options for the helper.
  122806. */
  122807. private static _getDefaultOptions;
  122808. private _rootMesh;
  122809. /**
  122810. * Gets the root mesh created by the helper.
  122811. */
  122812. get rootMesh(): Mesh;
  122813. private _skybox;
  122814. /**
  122815. * Gets the skybox created by the helper.
  122816. */
  122817. get skybox(): Nullable<Mesh>;
  122818. private _skyboxTexture;
  122819. /**
  122820. * Gets the skybox texture created by the helper.
  122821. */
  122822. get skyboxTexture(): Nullable<BaseTexture>;
  122823. private _skyboxMaterial;
  122824. /**
  122825. * Gets the skybox material created by the helper.
  122826. */
  122827. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  122828. private _ground;
  122829. /**
  122830. * Gets the ground mesh created by the helper.
  122831. */
  122832. get ground(): Nullable<Mesh>;
  122833. private _groundTexture;
  122834. /**
  122835. * Gets the ground texture created by the helper.
  122836. */
  122837. get groundTexture(): Nullable<BaseTexture>;
  122838. private _groundMirror;
  122839. /**
  122840. * Gets the ground mirror created by the helper.
  122841. */
  122842. get groundMirror(): Nullable<MirrorTexture>;
  122843. /**
  122844. * Gets the ground mirror render list to helps pushing the meshes
  122845. * you wish in the ground reflection.
  122846. */
  122847. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  122848. private _groundMaterial;
  122849. /**
  122850. * Gets the ground material created by the helper.
  122851. */
  122852. get groundMaterial(): Nullable<BackgroundMaterial>;
  122853. /**
  122854. * Stores the creation options.
  122855. */
  122856. private readonly _scene;
  122857. private _options;
  122858. /**
  122859. * This observable will be notified with any error during the creation of the environment,
  122860. * mainly texture creation errors.
  122861. */
  122862. onErrorObservable: Observable<{
  122863. message?: string;
  122864. exception?: any;
  122865. }>;
  122866. /**
  122867. * constructor
  122868. * @param options Defines the options we want to customize the helper
  122869. * @param scene The scene to add the material to
  122870. */
  122871. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  122872. /**
  122873. * Updates the background according to the new options
  122874. * @param options
  122875. */
  122876. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  122877. /**
  122878. * Sets the primary color of all the available elements.
  122879. * @param color the main color to affect to the ground and the background
  122880. */
  122881. setMainColor(color: Color3): void;
  122882. /**
  122883. * Setup the image processing according to the specified options.
  122884. */
  122885. private _setupImageProcessing;
  122886. /**
  122887. * Setup the environment texture according to the specified options.
  122888. */
  122889. private _setupEnvironmentTexture;
  122890. /**
  122891. * Setup the background according to the specified options.
  122892. */
  122893. private _setupBackground;
  122894. /**
  122895. * Get the scene sizes according to the setup.
  122896. */
  122897. private _getSceneSize;
  122898. /**
  122899. * Setup the ground according to the specified options.
  122900. */
  122901. private _setupGround;
  122902. /**
  122903. * Setup the ground material according to the specified options.
  122904. */
  122905. private _setupGroundMaterial;
  122906. /**
  122907. * Setup the ground diffuse texture according to the specified options.
  122908. */
  122909. private _setupGroundDiffuseTexture;
  122910. /**
  122911. * Setup the ground mirror texture according to the specified options.
  122912. */
  122913. private _setupGroundMirrorTexture;
  122914. /**
  122915. * Setup the ground to receive the mirror texture.
  122916. */
  122917. private _setupMirrorInGroundMaterial;
  122918. /**
  122919. * Setup the skybox according to the specified options.
  122920. */
  122921. private _setupSkybox;
  122922. /**
  122923. * Setup the skybox material according to the specified options.
  122924. */
  122925. private _setupSkyboxMaterial;
  122926. /**
  122927. * Setup the skybox reflection texture according to the specified options.
  122928. */
  122929. private _setupSkyboxReflectionTexture;
  122930. private _errorHandler;
  122931. /**
  122932. * Dispose all the elements created by the Helper.
  122933. */
  122934. dispose(): void;
  122935. }
  122936. }
  122937. declare module BABYLON {
  122938. /**
  122939. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  122940. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  122941. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  122942. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  122943. */
  122944. export class PhotoDome extends TransformNode {
  122945. /**
  122946. * Define the image as a Monoscopic panoramic 360 image.
  122947. */
  122948. static readonly MODE_MONOSCOPIC: number;
  122949. /**
  122950. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  122951. */
  122952. static readonly MODE_TOPBOTTOM: number;
  122953. /**
  122954. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  122955. */
  122956. static readonly MODE_SIDEBYSIDE: number;
  122957. private _useDirectMapping;
  122958. /**
  122959. * The texture being displayed on the sphere
  122960. */
  122961. protected _photoTexture: Texture;
  122962. /**
  122963. * Gets or sets the texture being displayed on the sphere
  122964. */
  122965. get photoTexture(): Texture;
  122966. set photoTexture(value: Texture);
  122967. /**
  122968. * Observable raised when an error occured while loading the 360 image
  122969. */
  122970. onLoadErrorObservable: Observable<string>;
  122971. /**
  122972. * The skybox material
  122973. */
  122974. protected _material: BackgroundMaterial;
  122975. /**
  122976. * The surface used for the skybox
  122977. */
  122978. protected _mesh: Mesh;
  122979. /**
  122980. * Gets the mesh used for the skybox.
  122981. */
  122982. get mesh(): Mesh;
  122983. /**
  122984. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122985. * Also see the options.resolution property.
  122986. */
  122987. get fovMultiplier(): number;
  122988. set fovMultiplier(value: number);
  122989. private _imageMode;
  122990. /**
  122991. * Gets or set the current video mode for the video. It can be:
  122992. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  122993. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  122994. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  122995. */
  122996. get imageMode(): number;
  122997. set imageMode(value: number);
  122998. /**
  122999. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  123000. * @param name Element's name, child elements will append suffixes for their own names.
  123001. * @param urlsOfPhoto defines the url of the photo to display
  123002. * @param options defines an object containing optional or exposed sub element properties
  123003. * @param onError defines a callback called when an error occured while loading the texture
  123004. */
  123005. constructor(name: string, urlOfPhoto: string, options: {
  123006. resolution?: number;
  123007. size?: number;
  123008. useDirectMapping?: boolean;
  123009. faceForward?: boolean;
  123010. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  123011. private _onBeforeCameraRenderObserver;
  123012. private _changeImageMode;
  123013. /**
  123014. * Releases resources associated with this node.
  123015. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123016. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123017. */
  123018. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123019. }
  123020. }
  123021. declare module BABYLON {
  123022. /**
  123023. * Class used to host RGBD texture specific utilities
  123024. */
  123025. export class RGBDTextureTools {
  123026. /**
  123027. * Expand the RGBD Texture from RGBD to Half Float if possible.
  123028. * @param texture the texture to expand.
  123029. */
  123030. static ExpandRGBDTexture(texture: Texture): void;
  123031. }
  123032. }
  123033. declare module BABYLON {
  123034. /**
  123035. * Class used to host texture specific utilities
  123036. */
  123037. export class BRDFTextureTools {
  123038. /**
  123039. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  123040. * @param scene defines the hosting scene
  123041. * @returns the environment BRDF texture
  123042. */
  123043. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  123044. private static _environmentBRDFBase64Texture;
  123045. }
  123046. }
  123047. declare module BABYLON {
  123048. /**
  123049. * @hidden
  123050. */
  123051. export interface IMaterialClearCoatDefines {
  123052. CLEARCOAT: boolean;
  123053. CLEARCOAT_DEFAULTIOR: boolean;
  123054. CLEARCOAT_TEXTURE: boolean;
  123055. CLEARCOAT_TEXTUREDIRECTUV: number;
  123056. CLEARCOAT_BUMP: boolean;
  123057. CLEARCOAT_BUMPDIRECTUV: number;
  123058. CLEARCOAT_TINT: boolean;
  123059. CLEARCOAT_TINT_TEXTURE: boolean;
  123060. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123061. /** @hidden */
  123062. _areTexturesDirty: boolean;
  123063. }
  123064. /**
  123065. * Define the code related to the clear coat parameters of the pbr material.
  123066. */
  123067. export class PBRClearCoatConfiguration {
  123068. /**
  123069. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123070. * The default fits with a polyurethane material.
  123071. */
  123072. private static readonly _DefaultIndexOfRefraction;
  123073. private _isEnabled;
  123074. /**
  123075. * Defines if the clear coat is enabled in the material.
  123076. */
  123077. isEnabled: boolean;
  123078. /**
  123079. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  123080. */
  123081. intensity: number;
  123082. /**
  123083. * Defines the clear coat layer roughness.
  123084. */
  123085. roughness: number;
  123086. private _indexOfRefraction;
  123087. /**
  123088. * Defines the index of refraction of the clear coat.
  123089. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123090. * The default fits with a polyurethane material.
  123091. * Changing the default value is more performance intensive.
  123092. */
  123093. indexOfRefraction: number;
  123094. private _texture;
  123095. /**
  123096. * Stores the clear coat values in a texture.
  123097. */
  123098. texture: Nullable<BaseTexture>;
  123099. private _bumpTexture;
  123100. /**
  123101. * Define the clear coat specific bump texture.
  123102. */
  123103. bumpTexture: Nullable<BaseTexture>;
  123104. private _isTintEnabled;
  123105. /**
  123106. * Defines if the clear coat tint is enabled in the material.
  123107. */
  123108. isTintEnabled: boolean;
  123109. /**
  123110. * Defines the clear coat tint of the material.
  123111. * This is only use if tint is enabled
  123112. */
  123113. tintColor: Color3;
  123114. /**
  123115. * Defines the distance at which the tint color should be found in the
  123116. * clear coat media.
  123117. * This is only use if tint is enabled
  123118. */
  123119. tintColorAtDistance: number;
  123120. /**
  123121. * Defines the clear coat layer thickness.
  123122. * This is only use if tint is enabled
  123123. */
  123124. tintThickness: number;
  123125. private _tintTexture;
  123126. /**
  123127. * Stores the clear tint values in a texture.
  123128. * rgb is tint
  123129. * a is a thickness factor
  123130. */
  123131. tintTexture: Nullable<BaseTexture>;
  123132. /** @hidden */
  123133. private _internalMarkAllSubMeshesAsTexturesDirty;
  123134. /** @hidden */
  123135. _markAllSubMeshesAsTexturesDirty(): void;
  123136. /**
  123137. * Instantiate a new istance of clear coat configuration.
  123138. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123139. */
  123140. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123141. /**
  123142. * Gets wehter the submesh is ready to be used or not.
  123143. * @param defines the list of "defines" to update.
  123144. * @param scene defines the scene the material belongs to.
  123145. * @param engine defines the engine the material belongs to.
  123146. * @param disableBumpMap defines wether the material disables bump or not.
  123147. * @returns - boolean indicating that the submesh is ready or not.
  123148. */
  123149. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  123150. /**
  123151. * Checks to see if a texture is used in the material.
  123152. * @param defines the list of "defines" to update.
  123153. * @param scene defines the scene to the material belongs to.
  123154. */
  123155. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  123156. /**
  123157. * Binds the material data.
  123158. * @param uniformBuffer defines the Uniform buffer to fill in.
  123159. * @param scene defines the scene the material belongs to.
  123160. * @param engine defines the engine the material belongs to.
  123161. * @param disableBumpMap defines wether the material disables bump or not.
  123162. * @param isFrozen defines wether the material is frozen or not.
  123163. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123164. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123165. */
  123166. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  123167. /**
  123168. * Checks to see if a texture is used in the material.
  123169. * @param texture - Base texture to use.
  123170. * @returns - Boolean specifying if a texture is used in the material.
  123171. */
  123172. hasTexture(texture: BaseTexture): boolean;
  123173. /**
  123174. * Returns an array of the actively used textures.
  123175. * @param activeTextures Array of BaseTextures
  123176. */
  123177. getActiveTextures(activeTextures: BaseTexture[]): void;
  123178. /**
  123179. * Returns the animatable textures.
  123180. * @param animatables Array of animatable textures.
  123181. */
  123182. getAnimatables(animatables: IAnimatable[]): void;
  123183. /**
  123184. * Disposes the resources of the material.
  123185. * @param forceDisposeTextures - Forces the disposal of all textures.
  123186. */
  123187. dispose(forceDisposeTextures?: boolean): void;
  123188. /**
  123189. * Get the current class name of the texture useful for serialization or dynamic coding.
  123190. * @returns "PBRClearCoatConfiguration"
  123191. */
  123192. getClassName(): string;
  123193. /**
  123194. * Add fallbacks to the effect fallbacks list.
  123195. * @param defines defines the Base texture to use.
  123196. * @param fallbacks defines the current fallback list.
  123197. * @param currentRank defines the current fallback rank.
  123198. * @returns the new fallback rank.
  123199. */
  123200. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123201. /**
  123202. * Add the required uniforms to the current list.
  123203. * @param uniforms defines the current uniform list.
  123204. */
  123205. static AddUniforms(uniforms: string[]): void;
  123206. /**
  123207. * Add the required samplers to the current list.
  123208. * @param samplers defines the current sampler list.
  123209. */
  123210. static AddSamplers(samplers: string[]): void;
  123211. /**
  123212. * Add the required uniforms to the current buffer.
  123213. * @param uniformBuffer defines the current uniform buffer.
  123214. */
  123215. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123216. /**
  123217. * Makes a duplicate of the current configuration into another one.
  123218. * @param clearCoatConfiguration define the config where to copy the info
  123219. */
  123220. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  123221. /**
  123222. * Serializes this clear coat configuration.
  123223. * @returns - An object with the serialized config.
  123224. */
  123225. serialize(): any;
  123226. /**
  123227. * Parses a anisotropy Configuration from a serialized object.
  123228. * @param source - Serialized object.
  123229. * @param scene Defines the scene we are parsing for
  123230. * @param rootUrl Defines the rootUrl to load from
  123231. */
  123232. parse(source: any, scene: Scene, rootUrl: string): void;
  123233. }
  123234. }
  123235. declare module BABYLON {
  123236. /**
  123237. * @hidden
  123238. */
  123239. export interface IMaterialAnisotropicDefines {
  123240. ANISOTROPIC: boolean;
  123241. ANISOTROPIC_TEXTURE: boolean;
  123242. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123243. MAINUV1: boolean;
  123244. _areTexturesDirty: boolean;
  123245. _needUVs: boolean;
  123246. }
  123247. /**
  123248. * Define the code related to the anisotropic parameters of the pbr material.
  123249. */
  123250. export class PBRAnisotropicConfiguration {
  123251. private _isEnabled;
  123252. /**
  123253. * Defines if the anisotropy is enabled in the material.
  123254. */
  123255. isEnabled: boolean;
  123256. /**
  123257. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  123258. */
  123259. intensity: number;
  123260. /**
  123261. * Defines if the effect is along the tangents, bitangents or in between.
  123262. * By default, the effect is "strectching" the highlights along the tangents.
  123263. */
  123264. direction: Vector2;
  123265. private _texture;
  123266. /**
  123267. * Stores the anisotropy values in a texture.
  123268. * rg is direction (like normal from -1 to 1)
  123269. * b is a intensity
  123270. */
  123271. texture: Nullable<BaseTexture>;
  123272. /** @hidden */
  123273. private _internalMarkAllSubMeshesAsTexturesDirty;
  123274. /** @hidden */
  123275. _markAllSubMeshesAsTexturesDirty(): void;
  123276. /**
  123277. * Instantiate a new istance of anisotropy configuration.
  123278. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123279. */
  123280. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123281. /**
  123282. * Specifies that the submesh is ready to be used.
  123283. * @param defines the list of "defines" to update.
  123284. * @param scene defines the scene the material belongs to.
  123285. * @returns - boolean indicating that the submesh is ready or not.
  123286. */
  123287. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  123288. /**
  123289. * Checks to see if a texture is used in the material.
  123290. * @param defines the list of "defines" to update.
  123291. * @param mesh the mesh we are preparing the defines for.
  123292. * @param scene defines the scene the material belongs to.
  123293. */
  123294. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  123295. /**
  123296. * Binds the material data.
  123297. * @param uniformBuffer defines the Uniform buffer to fill in.
  123298. * @param scene defines the scene the material belongs to.
  123299. * @param isFrozen defines wether the material is frozen or not.
  123300. */
  123301. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123302. /**
  123303. * Checks to see if a texture is used in the material.
  123304. * @param texture - Base texture to use.
  123305. * @returns - Boolean specifying if a texture is used in the material.
  123306. */
  123307. hasTexture(texture: BaseTexture): boolean;
  123308. /**
  123309. * Returns an array of the actively used textures.
  123310. * @param activeTextures Array of BaseTextures
  123311. */
  123312. getActiveTextures(activeTextures: BaseTexture[]): void;
  123313. /**
  123314. * Returns the animatable textures.
  123315. * @param animatables Array of animatable textures.
  123316. */
  123317. getAnimatables(animatables: IAnimatable[]): void;
  123318. /**
  123319. * Disposes the resources of the material.
  123320. * @param forceDisposeTextures - Forces the disposal of all textures.
  123321. */
  123322. dispose(forceDisposeTextures?: boolean): void;
  123323. /**
  123324. * Get the current class name of the texture useful for serialization or dynamic coding.
  123325. * @returns "PBRAnisotropicConfiguration"
  123326. */
  123327. getClassName(): string;
  123328. /**
  123329. * Add fallbacks to the effect fallbacks list.
  123330. * @param defines defines the Base texture to use.
  123331. * @param fallbacks defines the current fallback list.
  123332. * @param currentRank defines the current fallback rank.
  123333. * @returns the new fallback rank.
  123334. */
  123335. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123336. /**
  123337. * Add the required uniforms to the current list.
  123338. * @param uniforms defines the current uniform list.
  123339. */
  123340. static AddUniforms(uniforms: string[]): void;
  123341. /**
  123342. * Add the required uniforms to the current buffer.
  123343. * @param uniformBuffer defines the current uniform buffer.
  123344. */
  123345. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123346. /**
  123347. * Add the required samplers to the current list.
  123348. * @param samplers defines the current sampler list.
  123349. */
  123350. static AddSamplers(samplers: string[]): void;
  123351. /**
  123352. * Makes a duplicate of the current configuration into another one.
  123353. * @param anisotropicConfiguration define the config where to copy the info
  123354. */
  123355. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  123356. /**
  123357. * Serializes this anisotropy configuration.
  123358. * @returns - An object with the serialized config.
  123359. */
  123360. serialize(): any;
  123361. /**
  123362. * Parses a anisotropy Configuration from a serialized object.
  123363. * @param source - Serialized object.
  123364. * @param scene Defines the scene we are parsing for
  123365. * @param rootUrl Defines the rootUrl to load from
  123366. */
  123367. parse(source: any, scene: Scene, rootUrl: string): void;
  123368. }
  123369. }
  123370. declare module BABYLON {
  123371. /**
  123372. * @hidden
  123373. */
  123374. export interface IMaterialBRDFDefines {
  123375. BRDF_V_HEIGHT_CORRELATED: boolean;
  123376. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123377. SPHERICAL_HARMONICS: boolean;
  123378. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  123379. /** @hidden */
  123380. _areMiscDirty: boolean;
  123381. }
  123382. /**
  123383. * Define the code related to the BRDF parameters of the pbr material.
  123384. */
  123385. export class PBRBRDFConfiguration {
  123386. /**
  123387. * Default value used for the energy conservation.
  123388. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123389. */
  123390. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  123391. /**
  123392. * Default value used for the Smith Visibility Height Correlated mode.
  123393. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123394. */
  123395. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  123396. /**
  123397. * Default value used for the IBL diffuse part.
  123398. * This can help switching back to the polynomials mode globally which is a tiny bit
  123399. * less GPU intensive at the drawback of a lower quality.
  123400. */
  123401. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  123402. /**
  123403. * Default value used for activating energy conservation for the specular workflow.
  123404. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123405. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123406. */
  123407. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  123408. private _useEnergyConservation;
  123409. /**
  123410. * Defines if the material uses energy conservation.
  123411. */
  123412. useEnergyConservation: boolean;
  123413. private _useSmithVisibilityHeightCorrelated;
  123414. /**
  123415. * LEGACY Mode set to false
  123416. * Defines if the material uses height smith correlated visibility term.
  123417. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  123418. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  123419. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  123420. * Not relying on height correlated will also disable energy conservation.
  123421. */
  123422. useSmithVisibilityHeightCorrelated: boolean;
  123423. private _useSphericalHarmonics;
  123424. /**
  123425. * LEGACY Mode set to false
  123426. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  123427. * diffuse part of the IBL.
  123428. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  123429. * to the ground truth.
  123430. */
  123431. useSphericalHarmonics: boolean;
  123432. private _useSpecularGlossinessInputEnergyConservation;
  123433. /**
  123434. * Defines if the material uses energy conservation, when the specular workflow is active.
  123435. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123436. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123437. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  123438. */
  123439. useSpecularGlossinessInputEnergyConservation: boolean;
  123440. /** @hidden */
  123441. private _internalMarkAllSubMeshesAsMiscDirty;
  123442. /** @hidden */
  123443. _markAllSubMeshesAsMiscDirty(): void;
  123444. /**
  123445. * Instantiate a new istance of clear coat configuration.
  123446. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  123447. */
  123448. constructor(markAllSubMeshesAsMiscDirty: () => void);
  123449. /**
  123450. * Checks to see if a texture is used in the material.
  123451. * @param defines the list of "defines" to update.
  123452. */
  123453. prepareDefines(defines: IMaterialBRDFDefines): void;
  123454. /**
  123455. * Get the current class name of the texture useful for serialization or dynamic coding.
  123456. * @returns "PBRClearCoatConfiguration"
  123457. */
  123458. getClassName(): string;
  123459. /**
  123460. * Makes a duplicate of the current configuration into another one.
  123461. * @param brdfConfiguration define the config where to copy the info
  123462. */
  123463. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  123464. /**
  123465. * Serializes this BRDF configuration.
  123466. * @returns - An object with the serialized config.
  123467. */
  123468. serialize(): any;
  123469. /**
  123470. * Parses a anisotropy Configuration from a serialized object.
  123471. * @param source - Serialized object.
  123472. * @param scene Defines the scene we are parsing for
  123473. * @param rootUrl Defines the rootUrl to load from
  123474. */
  123475. parse(source: any, scene: Scene, rootUrl: string): void;
  123476. }
  123477. }
  123478. declare module BABYLON {
  123479. /**
  123480. * @hidden
  123481. */
  123482. export interface IMaterialSheenDefines {
  123483. SHEEN: boolean;
  123484. SHEEN_TEXTURE: boolean;
  123485. SHEEN_TEXTUREDIRECTUV: number;
  123486. SHEEN_LINKWITHALBEDO: boolean;
  123487. /** @hidden */
  123488. _areTexturesDirty: boolean;
  123489. }
  123490. /**
  123491. * Define the code related to the Sheen parameters of the pbr material.
  123492. */
  123493. export class PBRSheenConfiguration {
  123494. private _isEnabled;
  123495. /**
  123496. * Defines if the material uses sheen.
  123497. */
  123498. isEnabled: boolean;
  123499. private _linkSheenWithAlbedo;
  123500. /**
  123501. * Defines if the sheen is linked to the sheen color.
  123502. */
  123503. linkSheenWithAlbedo: boolean;
  123504. /**
  123505. * Defines the sheen intensity.
  123506. */
  123507. intensity: number;
  123508. /**
  123509. * Defines the sheen color.
  123510. */
  123511. color: Color3;
  123512. private _texture;
  123513. /**
  123514. * Stores the sheen tint values in a texture.
  123515. * rgb is tint
  123516. * a is a intensity
  123517. */
  123518. texture: Nullable<BaseTexture>;
  123519. /** @hidden */
  123520. private _internalMarkAllSubMeshesAsTexturesDirty;
  123521. /** @hidden */
  123522. _markAllSubMeshesAsTexturesDirty(): void;
  123523. /**
  123524. * Instantiate a new istance of clear coat configuration.
  123525. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123526. */
  123527. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123528. /**
  123529. * Specifies that the submesh is ready to be used.
  123530. * @param defines the list of "defines" to update.
  123531. * @param scene defines the scene the material belongs to.
  123532. * @returns - boolean indicating that the submesh is ready or not.
  123533. */
  123534. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  123535. /**
  123536. * Checks to see if a texture is used in the material.
  123537. * @param defines the list of "defines" to update.
  123538. * @param scene defines the scene the material belongs to.
  123539. */
  123540. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  123541. /**
  123542. * Binds the material data.
  123543. * @param uniformBuffer defines the Uniform buffer to fill in.
  123544. * @param scene defines the scene the material belongs to.
  123545. * @param isFrozen defines wether the material is frozen or not.
  123546. */
  123547. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123548. /**
  123549. * Checks to see if a texture is used in the material.
  123550. * @param texture - Base texture to use.
  123551. * @returns - Boolean specifying if a texture is used in the material.
  123552. */
  123553. hasTexture(texture: BaseTexture): boolean;
  123554. /**
  123555. * Returns an array of the actively used textures.
  123556. * @param activeTextures Array of BaseTextures
  123557. */
  123558. getActiveTextures(activeTextures: BaseTexture[]): void;
  123559. /**
  123560. * Returns the animatable textures.
  123561. * @param animatables Array of animatable textures.
  123562. */
  123563. getAnimatables(animatables: IAnimatable[]): void;
  123564. /**
  123565. * Disposes the resources of the material.
  123566. * @param forceDisposeTextures - Forces the disposal of all textures.
  123567. */
  123568. dispose(forceDisposeTextures?: boolean): void;
  123569. /**
  123570. * Get the current class name of the texture useful for serialization or dynamic coding.
  123571. * @returns "PBRSheenConfiguration"
  123572. */
  123573. getClassName(): string;
  123574. /**
  123575. * Add fallbacks to the effect fallbacks list.
  123576. * @param defines defines the Base texture to use.
  123577. * @param fallbacks defines the current fallback list.
  123578. * @param currentRank defines the current fallback rank.
  123579. * @returns the new fallback rank.
  123580. */
  123581. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123582. /**
  123583. * Add the required uniforms to the current list.
  123584. * @param uniforms defines the current uniform list.
  123585. */
  123586. static AddUniforms(uniforms: string[]): void;
  123587. /**
  123588. * Add the required uniforms to the current buffer.
  123589. * @param uniformBuffer defines the current uniform buffer.
  123590. */
  123591. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123592. /**
  123593. * Add the required samplers to the current list.
  123594. * @param samplers defines the current sampler list.
  123595. */
  123596. static AddSamplers(samplers: string[]): void;
  123597. /**
  123598. * Makes a duplicate of the current configuration into another one.
  123599. * @param sheenConfiguration define the config where to copy the info
  123600. */
  123601. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  123602. /**
  123603. * Serializes this BRDF configuration.
  123604. * @returns - An object with the serialized config.
  123605. */
  123606. serialize(): any;
  123607. /**
  123608. * Parses a anisotropy Configuration from a serialized object.
  123609. * @param source - Serialized object.
  123610. * @param scene Defines the scene we are parsing for
  123611. * @param rootUrl Defines the rootUrl to load from
  123612. */
  123613. parse(source: any, scene: Scene, rootUrl: string): void;
  123614. }
  123615. }
  123616. declare module BABYLON {
  123617. /**
  123618. * @hidden
  123619. */
  123620. export interface IMaterialSubSurfaceDefines {
  123621. SUBSURFACE: boolean;
  123622. SS_REFRACTION: boolean;
  123623. SS_TRANSLUCENCY: boolean;
  123624. SS_SCATERRING: boolean;
  123625. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123626. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123627. SS_REFRACTIONMAP_3D: boolean;
  123628. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123629. SS_LODINREFRACTIONALPHA: boolean;
  123630. SS_GAMMAREFRACTION: boolean;
  123631. SS_RGBDREFRACTION: boolean;
  123632. SS_LINEARSPECULARREFRACTION: boolean;
  123633. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123634. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123635. /** @hidden */
  123636. _areTexturesDirty: boolean;
  123637. }
  123638. /**
  123639. * Define the code related to the sub surface parameters of the pbr material.
  123640. */
  123641. export class PBRSubSurfaceConfiguration {
  123642. private _isRefractionEnabled;
  123643. /**
  123644. * Defines if the refraction is enabled in the material.
  123645. */
  123646. isRefractionEnabled: boolean;
  123647. private _isTranslucencyEnabled;
  123648. /**
  123649. * Defines if the translucency is enabled in the material.
  123650. */
  123651. isTranslucencyEnabled: boolean;
  123652. private _isScatteringEnabled;
  123653. /**
  123654. * Defines the refraction intensity of the material.
  123655. * The refraction when enabled replaces the Diffuse part of the material.
  123656. * The intensity helps transitionning between diffuse and refraction.
  123657. */
  123658. refractionIntensity: number;
  123659. /**
  123660. * Defines the translucency intensity of the material.
  123661. * When translucency has been enabled, this defines how much of the "translucency"
  123662. * is addded to the diffuse part of the material.
  123663. */
  123664. translucencyIntensity: number;
  123665. /**
  123666. * Defines the scattering intensity of the material.
  123667. * When scattering has been enabled, this defines how much of the "scattered light"
  123668. * is addded to the diffuse part of the material.
  123669. */
  123670. scatteringIntensity: number;
  123671. private _thicknessTexture;
  123672. /**
  123673. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  123674. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  123675. * 0 would mean minimumThickness
  123676. * 1 would mean maximumThickness
  123677. * The other channels might be use as a mask to vary the different effects intensity.
  123678. */
  123679. thicknessTexture: Nullable<BaseTexture>;
  123680. private _refractionTexture;
  123681. /**
  123682. * Defines the texture to use for refraction.
  123683. */
  123684. refractionTexture: Nullable<BaseTexture>;
  123685. private _indexOfRefraction;
  123686. /**
  123687. * Defines the index of refraction used in the material.
  123688. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  123689. */
  123690. indexOfRefraction: number;
  123691. private _invertRefractionY;
  123692. /**
  123693. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  123694. */
  123695. invertRefractionY: boolean;
  123696. private _linkRefractionWithTransparency;
  123697. /**
  123698. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  123699. * Materials half opaque for instance using refraction could benefit from this control.
  123700. */
  123701. linkRefractionWithTransparency: boolean;
  123702. /**
  123703. * Defines the minimum thickness stored in the thickness map.
  123704. * If no thickness map is defined, this value will be used to simulate thickness.
  123705. */
  123706. minimumThickness: number;
  123707. /**
  123708. * Defines the maximum thickness stored in the thickness map.
  123709. */
  123710. maximumThickness: number;
  123711. /**
  123712. * Defines the volume tint of the material.
  123713. * This is used for both translucency and scattering.
  123714. */
  123715. tintColor: Color3;
  123716. /**
  123717. * Defines the distance at which the tint color should be found in the media.
  123718. * This is used for refraction only.
  123719. */
  123720. tintColorAtDistance: number;
  123721. /**
  123722. * Defines how far each channel transmit through the media.
  123723. * It is defined as a color to simplify it selection.
  123724. */
  123725. diffusionDistance: Color3;
  123726. private _useMaskFromThicknessTexture;
  123727. /**
  123728. * Stores the intensity of the different subsurface effects in the thickness texture.
  123729. * * the green channel is the translucency intensity.
  123730. * * the blue channel is the scattering intensity.
  123731. * * the alpha channel is the refraction intensity.
  123732. */
  123733. useMaskFromThicknessTexture: boolean;
  123734. /** @hidden */
  123735. private _internalMarkAllSubMeshesAsTexturesDirty;
  123736. /** @hidden */
  123737. _markAllSubMeshesAsTexturesDirty(): void;
  123738. /**
  123739. * Instantiate a new istance of sub surface configuration.
  123740. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123741. */
  123742. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123743. /**
  123744. * Gets wehter the submesh is ready to be used or not.
  123745. * @param defines the list of "defines" to update.
  123746. * @param scene defines the scene the material belongs to.
  123747. * @returns - boolean indicating that the submesh is ready or not.
  123748. */
  123749. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  123750. /**
  123751. * Checks to see if a texture is used in the material.
  123752. * @param defines the list of "defines" to update.
  123753. * @param scene defines the scene to the material belongs to.
  123754. */
  123755. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  123756. /**
  123757. * Binds the material data.
  123758. * @param uniformBuffer defines the Uniform buffer to fill in.
  123759. * @param scene defines the scene the material belongs to.
  123760. * @param engine defines the engine the material belongs to.
  123761. * @param isFrozen defines wether the material is frozen or not.
  123762. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  123763. */
  123764. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  123765. /**
  123766. * Unbinds the material from the mesh.
  123767. * @param activeEffect defines the effect that should be unbound from.
  123768. * @returns true if unbound, otherwise false
  123769. */
  123770. unbind(activeEffect: Effect): boolean;
  123771. /**
  123772. * Returns the texture used for refraction or null if none is used.
  123773. * @param scene defines the scene the material belongs to.
  123774. * @returns - Refraction texture if present. If no refraction texture and refraction
  123775. * is linked with transparency, returns environment texture. Otherwise, returns null.
  123776. */
  123777. private _getRefractionTexture;
  123778. /**
  123779. * Returns true if alpha blending should be disabled.
  123780. */
  123781. get disableAlphaBlending(): boolean;
  123782. /**
  123783. * Fills the list of render target textures.
  123784. * @param renderTargets the list of render targets to update
  123785. */
  123786. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  123787. /**
  123788. * Checks to see if a texture is used in the material.
  123789. * @param texture - Base texture to use.
  123790. * @returns - Boolean specifying if a texture is used in the material.
  123791. */
  123792. hasTexture(texture: BaseTexture): boolean;
  123793. /**
  123794. * Gets a boolean indicating that current material needs to register RTT
  123795. * @returns true if this uses a render target otherwise false.
  123796. */
  123797. hasRenderTargetTextures(): boolean;
  123798. /**
  123799. * Returns an array of the actively used textures.
  123800. * @param activeTextures Array of BaseTextures
  123801. */
  123802. getActiveTextures(activeTextures: BaseTexture[]): void;
  123803. /**
  123804. * Returns the animatable textures.
  123805. * @param animatables Array of animatable textures.
  123806. */
  123807. getAnimatables(animatables: IAnimatable[]): void;
  123808. /**
  123809. * Disposes the resources of the material.
  123810. * @param forceDisposeTextures - Forces the disposal of all textures.
  123811. */
  123812. dispose(forceDisposeTextures?: boolean): void;
  123813. /**
  123814. * Get the current class name of the texture useful for serialization or dynamic coding.
  123815. * @returns "PBRSubSurfaceConfiguration"
  123816. */
  123817. getClassName(): string;
  123818. /**
  123819. * Add fallbacks to the effect fallbacks list.
  123820. * @param defines defines the Base texture to use.
  123821. * @param fallbacks defines the current fallback list.
  123822. * @param currentRank defines the current fallback rank.
  123823. * @returns the new fallback rank.
  123824. */
  123825. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123826. /**
  123827. * Add the required uniforms to the current list.
  123828. * @param uniforms defines the current uniform list.
  123829. */
  123830. static AddUniforms(uniforms: string[]): void;
  123831. /**
  123832. * Add the required samplers to the current list.
  123833. * @param samplers defines the current sampler list.
  123834. */
  123835. static AddSamplers(samplers: string[]): void;
  123836. /**
  123837. * Add the required uniforms to the current buffer.
  123838. * @param uniformBuffer defines the current uniform buffer.
  123839. */
  123840. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123841. /**
  123842. * Makes a duplicate of the current configuration into another one.
  123843. * @param configuration define the config where to copy the info
  123844. */
  123845. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  123846. /**
  123847. * Serializes this Sub Surface configuration.
  123848. * @returns - An object with the serialized config.
  123849. */
  123850. serialize(): any;
  123851. /**
  123852. * Parses a anisotropy Configuration from a serialized object.
  123853. * @param source - Serialized object.
  123854. * @param scene Defines the scene we are parsing for
  123855. * @param rootUrl Defines the rootUrl to load from
  123856. */
  123857. parse(source: any, scene: Scene, rootUrl: string): void;
  123858. }
  123859. }
  123860. declare module BABYLON {
  123861. /** @hidden */
  123862. export var pbrFragmentDeclaration: {
  123863. name: string;
  123864. shader: string;
  123865. };
  123866. }
  123867. declare module BABYLON {
  123868. /** @hidden */
  123869. export var pbrUboDeclaration: {
  123870. name: string;
  123871. shader: string;
  123872. };
  123873. }
  123874. declare module BABYLON {
  123875. /** @hidden */
  123876. export var pbrFragmentExtraDeclaration: {
  123877. name: string;
  123878. shader: string;
  123879. };
  123880. }
  123881. declare module BABYLON {
  123882. /** @hidden */
  123883. export var pbrFragmentSamplersDeclaration: {
  123884. name: string;
  123885. shader: string;
  123886. };
  123887. }
  123888. declare module BABYLON {
  123889. /** @hidden */
  123890. export var pbrHelperFunctions: {
  123891. name: string;
  123892. shader: string;
  123893. };
  123894. }
  123895. declare module BABYLON {
  123896. /** @hidden */
  123897. export var harmonicsFunctions: {
  123898. name: string;
  123899. shader: string;
  123900. };
  123901. }
  123902. declare module BABYLON {
  123903. /** @hidden */
  123904. export var pbrDirectLightingSetupFunctions: {
  123905. name: string;
  123906. shader: string;
  123907. };
  123908. }
  123909. declare module BABYLON {
  123910. /** @hidden */
  123911. export var pbrDirectLightingFalloffFunctions: {
  123912. name: string;
  123913. shader: string;
  123914. };
  123915. }
  123916. declare module BABYLON {
  123917. /** @hidden */
  123918. export var pbrBRDFFunctions: {
  123919. name: string;
  123920. shader: string;
  123921. };
  123922. }
  123923. declare module BABYLON {
  123924. /** @hidden */
  123925. export var pbrDirectLightingFunctions: {
  123926. name: string;
  123927. shader: string;
  123928. };
  123929. }
  123930. declare module BABYLON {
  123931. /** @hidden */
  123932. export var pbrIBLFunctions: {
  123933. name: string;
  123934. shader: string;
  123935. };
  123936. }
  123937. declare module BABYLON {
  123938. /** @hidden */
  123939. export var pbrDebug: {
  123940. name: string;
  123941. shader: string;
  123942. };
  123943. }
  123944. declare module BABYLON {
  123945. /** @hidden */
  123946. export var pbrPixelShader: {
  123947. name: string;
  123948. shader: string;
  123949. };
  123950. }
  123951. declare module BABYLON {
  123952. /** @hidden */
  123953. export var pbrVertexDeclaration: {
  123954. name: string;
  123955. shader: string;
  123956. };
  123957. }
  123958. declare module BABYLON {
  123959. /** @hidden */
  123960. export var pbrVertexShader: {
  123961. name: string;
  123962. shader: string;
  123963. };
  123964. }
  123965. declare module BABYLON {
  123966. /**
  123967. * Manages the defines for the PBR Material.
  123968. * @hidden
  123969. */
  123970. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  123971. PBR: boolean;
  123972. MAINUV1: boolean;
  123973. MAINUV2: boolean;
  123974. UV1: boolean;
  123975. UV2: boolean;
  123976. ALBEDO: boolean;
  123977. GAMMAALBEDO: boolean;
  123978. ALBEDODIRECTUV: number;
  123979. VERTEXCOLOR: boolean;
  123980. AMBIENT: boolean;
  123981. AMBIENTDIRECTUV: number;
  123982. AMBIENTINGRAYSCALE: boolean;
  123983. OPACITY: boolean;
  123984. VERTEXALPHA: boolean;
  123985. OPACITYDIRECTUV: number;
  123986. OPACITYRGB: boolean;
  123987. ALPHATEST: boolean;
  123988. DEPTHPREPASS: boolean;
  123989. ALPHABLEND: boolean;
  123990. ALPHAFROMALBEDO: boolean;
  123991. ALPHATESTVALUE: string;
  123992. SPECULAROVERALPHA: boolean;
  123993. RADIANCEOVERALPHA: boolean;
  123994. ALPHAFRESNEL: boolean;
  123995. LINEARALPHAFRESNEL: boolean;
  123996. PREMULTIPLYALPHA: boolean;
  123997. EMISSIVE: boolean;
  123998. EMISSIVEDIRECTUV: number;
  123999. REFLECTIVITY: boolean;
  124000. REFLECTIVITYDIRECTUV: number;
  124001. SPECULARTERM: boolean;
  124002. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  124003. MICROSURFACEAUTOMATIC: boolean;
  124004. LODBASEDMICROSFURACE: boolean;
  124005. MICROSURFACEMAP: boolean;
  124006. MICROSURFACEMAPDIRECTUV: number;
  124007. METALLICWORKFLOW: boolean;
  124008. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  124009. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  124010. METALLNESSSTOREINMETALMAPBLUE: boolean;
  124011. AOSTOREINMETALMAPRED: boolean;
  124012. METALLICF0FACTORFROMMETALLICMAP: boolean;
  124013. ENVIRONMENTBRDF: boolean;
  124014. ENVIRONMENTBRDF_RGBD: boolean;
  124015. NORMAL: boolean;
  124016. TANGENT: boolean;
  124017. BUMP: boolean;
  124018. BUMPDIRECTUV: number;
  124019. OBJECTSPACE_NORMALMAP: boolean;
  124020. PARALLAX: boolean;
  124021. PARALLAXOCCLUSION: boolean;
  124022. NORMALXYSCALE: boolean;
  124023. LIGHTMAP: boolean;
  124024. LIGHTMAPDIRECTUV: number;
  124025. USELIGHTMAPASSHADOWMAP: boolean;
  124026. GAMMALIGHTMAP: boolean;
  124027. RGBDLIGHTMAP: boolean;
  124028. REFLECTION: boolean;
  124029. REFLECTIONMAP_3D: boolean;
  124030. REFLECTIONMAP_SPHERICAL: boolean;
  124031. REFLECTIONMAP_PLANAR: boolean;
  124032. REFLECTIONMAP_CUBIC: boolean;
  124033. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  124034. REFLECTIONMAP_PROJECTION: boolean;
  124035. REFLECTIONMAP_SKYBOX: boolean;
  124036. REFLECTIONMAP_EXPLICIT: boolean;
  124037. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  124038. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  124039. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  124040. INVERTCUBICMAP: boolean;
  124041. USESPHERICALFROMREFLECTIONMAP: boolean;
  124042. USEIRRADIANCEMAP: boolean;
  124043. SPHERICAL_HARMONICS: boolean;
  124044. USESPHERICALINVERTEX: boolean;
  124045. REFLECTIONMAP_OPPOSITEZ: boolean;
  124046. LODINREFLECTIONALPHA: boolean;
  124047. GAMMAREFLECTION: boolean;
  124048. RGBDREFLECTION: boolean;
  124049. LINEARSPECULARREFLECTION: boolean;
  124050. RADIANCEOCCLUSION: boolean;
  124051. HORIZONOCCLUSION: boolean;
  124052. INSTANCES: boolean;
  124053. NUM_BONE_INFLUENCERS: number;
  124054. BonesPerMesh: number;
  124055. BONETEXTURE: boolean;
  124056. NONUNIFORMSCALING: boolean;
  124057. MORPHTARGETS: boolean;
  124058. MORPHTARGETS_NORMAL: boolean;
  124059. MORPHTARGETS_TANGENT: boolean;
  124060. MORPHTARGETS_UV: boolean;
  124061. NUM_MORPH_INFLUENCERS: number;
  124062. IMAGEPROCESSING: boolean;
  124063. VIGNETTE: boolean;
  124064. VIGNETTEBLENDMODEMULTIPLY: boolean;
  124065. VIGNETTEBLENDMODEOPAQUE: boolean;
  124066. TONEMAPPING: boolean;
  124067. TONEMAPPING_ACES: boolean;
  124068. CONTRAST: boolean;
  124069. COLORCURVES: boolean;
  124070. COLORGRADING: boolean;
  124071. COLORGRADING3D: boolean;
  124072. SAMPLER3DGREENDEPTH: boolean;
  124073. SAMPLER3DBGRMAP: boolean;
  124074. IMAGEPROCESSINGPOSTPROCESS: boolean;
  124075. EXPOSURE: boolean;
  124076. MULTIVIEW: boolean;
  124077. USEPHYSICALLIGHTFALLOFF: boolean;
  124078. USEGLTFLIGHTFALLOFF: boolean;
  124079. TWOSIDEDLIGHTING: boolean;
  124080. SHADOWFLOAT: boolean;
  124081. CLIPPLANE: boolean;
  124082. CLIPPLANE2: boolean;
  124083. CLIPPLANE3: boolean;
  124084. CLIPPLANE4: boolean;
  124085. CLIPPLANE5: boolean;
  124086. CLIPPLANE6: boolean;
  124087. POINTSIZE: boolean;
  124088. FOG: boolean;
  124089. LOGARITHMICDEPTH: boolean;
  124090. FORCENORMALFORWARD: boolean;
  124091. SPECULARAA: boolean;
  124092. CLEARCOAT: boolean;
  124093. CLEARCOAT_DEFAULTIOR: boolean;
  124094. CLEARCOAT_TEXTURE: boolean;
  124095. CLEARCOAT_TEXTUREDIRECTUV: number;
  124096. CLEARCOAT_BUMP: boolean;
  124097. CLEARCOAT_BUMPDIRECTUV: number;
  124098. CLEARCOAT_TINT: boolean;
  124099. CLEARCOAT_TINT_TEXTURE: boolean;
  124100. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124101. ANISOTROPIC: boolean;
  124102. ANISOTROPIC_TEXTURE: boolean;
  124103. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124104. BRDF_V_HEIGHT_CORRELATED: boolean;
  124105. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124106. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124107. SHEEN: boolean;
  124108. SHEEN_TEXTURE: boolean;
  124109. SHEEN_TEXTUREDIRECTUV: number;
  124110. SHEEN_LINKWITHALBEDO: boolean;
  124111. SUBSURFACE: boolean;
  124112. SS_REFRACTION: boolean;
  124113. SS_TRANSLUCENCY: boolean;
  124114. SS_SCATERRING: boolean;
  124115. SS_THICKNESSANDMASK_TEXTURE: boolean;
  124116. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  124117. SS_REFRACTIONMAP_3D: boolean;
  124118. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  124119. SS_LODINREFRACTIONALPHA: boolean;
  124120. SS_GAMMAREFRACTION: boolean;
  124121. SS_RGBDREFRACTION: boolean;
  124122. SS_LINEARSPECULARREFRACTION: boolean;
  124123. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  124124. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  124125. UNLIT: boolean;
  124126. DEBUGMODE: number;
  124127. /**
  124128. * Initializes the PBR Material defines.
  124129. */
  124130. constructor();
  124131. /**
  124132. * Resets the PBR Material defines.
  124133. */
  124134. reset(): void;
  124135. }
  124136. /**
  124137. * The Physically based material base class of BJS.
  124138. *
  124139. * This offers the main features of a standard PBR material.
  124140. * For more information, please refer to the documentation :
  124141. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124142. */
  124143. export abstract class PBRBaseMaterial extends PushMaterial {
  124144. /**
  124145. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124146. */
  124147. static readonly PBRMATERIAL_OPAQUE: number;
  124148. /**
  124149. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124150. */
  124151. static readonly PBRMATERIAL_ALPHATEST: number;
  124152. /**
  124153. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124154. */
  124155. static readonly PBRMATERIAL_ALPHABLEND: number;
  124156. /**
  124157. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124158. * They are also discarded below the alpha cutoff threshold to improve performances.
  124159. */
  124160. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124161. /**
  124162. * Defines the default value of how much AO map is occluding the analytical lights
  124163. * (point spot...).
  124164. */
  124165. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124166. /**
  124167. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  124168. */
  124169. static readonly LIGHTFALLOFF_PHYSICAL: number;
  124170. /**
  124171. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  124172. * to enhance interoperability with other engines.
  124173. */
  124174. static readonly LIGHTFALLOFF_GLTF: number;
  124175. /**
  124176. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  124177. * to enhance interoperability with other materials.
  124178. */
  124179. static readonly LIGHTFALLOFF_STANDARD: number;
  124180. /**
  124181. * Intensity of the direct lights e.g. the four lights available in your scene.
  124182. * This impacts both the direct diffuse and specular highlights.
  124183. */
  124184. protected _directIntensity: number;
  124185. /**
  124186. * Intensity of the emissive part of the material.
  124187. * This helps controlling the emissive effect without modifying the emissive color.
  124188. */
  124189. protected _emissiveIntensity: number;
  124190. /**
  124191. * Intensity of the environment e.g. how much the environment will light the object
  124192. * either through harmonics for rough material or through the refelction for shiny ones.
  124193. */
  124194. protected _environmentIntensity: number;
  124195. /**
  124196. * This is a special control allowing the reduction of the specular highlights coming from the
  124197. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124198. */
  124199. protected _specularIntensity: number;
  124200. /**
  124201. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  124202. */
  124203. private _lightingInfos;
  124204. /**
  124205. * Debug Control allowing disabling the bump map on this material.
  124206. */
  124207. protected _disableBumpMap: boolean;
  124208. /**
  124209. * AKA Diffuse Texture in standard nomenclature.
  124210. */
  124211. protected _albedoTexture: Nullable<BaseTexture>;
  124212. /**
  124213. * AKA Occlusion Texture in other nomenclature.
  124214. */
  124215. protected _ambientTexture: Nullable<BaseTexture>;
  124216. /**
  124217. * AKA Occlusion Texture Intensity in other nomenclature.
  124218. */
  124219. protected _ambientTextureStrength: number;
  124220. /**
  124221. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124222. * 1 means it completely occludes it
  124223. * 0 mean it has no impact
  124224. */
  124225. protected _ambientTextureImpactOnAnalyticalLights: number;
  124226. /**
  124227. * Stores the alpha values in a texture.
  124228. */
  124229. protected _opacityTexture: Nullable<BaseTexture>;
  124230. /**
  124231. * Stores the reflection values in a texture.
  124232. */
  124233. protected _reflectionTexture: Nullable<BaseTexture>;
  124234. /**
  124235. * Stores the emissive values in a texture.
  124236. */
  124237. protected _emissiveTexture: Nullable<BaseTexture>;
  124238. /**
  124239. * AKA Specular texture in other nomenclature.
  124240. */
  124241. protected _reflectivityTexture: Nullable<BaseTexture>;
  124242. /**
  124243. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124244. */
  124245. protected _metallicTexture: Nullable<BaseTexture>;
  124246. /**
  124247. * Specifies the metallic scalar of the metallic/roughness workflow.
  124248. * Can also be used to scale the metalness values of the metallic texture.
  124249. */
  124250. protected _metallic: Nullable<number>;
  124251. /**
  124252. * Specifies the roughness scalar of the metallic/roughness workflow.
  124253. * Can also be used to scale the roughness values of the metallic texture.
  124254. */
  124255. protected _roughness: Nullable<number>;
  124256. /**
  124257. * Specifies the an F0 factor to help configuring the material F0.
  124258. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124259. * to 0.5 the previously hard coded value stays the same.
  124260. * Can also be used to scale the F0 values of the metallic texture.
  124261. */
  124262. protected _metallicF0Factor: number;
  124263. /**
  124264. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124265. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124266. * your expectation as it multiplies with the texture data.
  124267. */
  124268. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  124269. /**
  124270. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124271. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124272. */
  124273. protected _microSurfaceTexture: Nullable<BaseTexture>;
  124274. /**
  124275. * Stores surface normal data used to displace a mesh in a texture.
  124276. */
  124277. protected _bumpTexture: Nullable<BaseTexture>;
  124278. /**
  124279. * Stores the pre-calculated light information of a mesh in a texture.
  124280. */
  124281. protected _lightmapTexture: Nullable<BaseTexture>;
  124282. /**
  124283. * The color of a material in ambient lighting.
  124284. */
  124285. protected _ambientColor: Color3;
  124286. /**
  124287. * AKA Diffuse Color in other nomenclature.
  124288. */
  124289. protected _albedoColor: Color3;
  124290. /**
  124291. * AKA Specular Color in other nomenclature.
  124292. */
  124293. protected _reflectivityColor: Color3;
  124294. /**
  124295. * The color applied when light is reflected from a material.
  124296. */
  124297. protected _reflectionColor: Color3;
  124298. /**
  124299. * The color applied when light is emitted from a material.
  124300. */
  124301. protected _emissiveColor: Color3;
  124302. /**
  124303. * AKA Glossiness in other nomenclature.
  124304. */
  124305. protected _microSurface: number;
  124306. /**
  124307. * Specifies that the material will use the light map as a show map.
  124308. */
  124309. protected _useLightmapAsShadowmap: boolean;
  124310. /**
  124311. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124312. * makes the reflect vector face the model (under horizon).
  124313. */
  124314. protected _useHorizonOcclusion: boolean;
  124315. /**
  124316. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124317. * too much the area relying on ambient texture to define their ambient occlusion.
  124318. */
  124319. protected _useRadianceOcclusion: boolean;
  124320. /**
  124321. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124322. */
  124323. protected _useAlphaFromAlbedoTexture: boolean;
  124324. /**
  124325. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  124326. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124327. */
  124328. protected _useSpecularOverAlpha: boolean;
  124329. /**
  124330. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124331. */
  124332. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124333. /**
  124334. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124335. */
  124336. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  124337. /**
  124338. * Specifies if the metallic texture contains the roughness information in its green channel.
  124339. */
  124340. protected _useRoughnessFromMetallicTextureGreen: boolean;
  124341. /**
  124342. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124343. */
  124344. protected _useMetallnessFromMetallicTextureBlue: boolean;
  124345. /**
  124346. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124347. */
  124348. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  124349. /**
  124350. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124351. */
  124352. protected _useAmbientInGrayScale: boolean;
  124353. /**
  124354. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124355. * The material will try to infer what glossiness each pixel should be.
  124356. */
  124357. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  124358. /**
  124359. * Defines the falloff type used in this material.
  124360. * It by default is Physical.
  124361. */
  124362. protected _lightFalloff: number;
  124363. /**
  124364. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124365. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124366. */
  124367. protected _useRadianceOverAlpha: boolean;
  124368. /**
  124369. * Allows using an object space normal map (instead of tangent space).
  124370. */
  124371. protected _useObjectSpaceNormalMap: boolean;
  124372. /**
  124373. * Allows using the bump map in parallax mode.
  124374. */
  124375. protected _useParallax: boolean;
  124376. /**
  124377. * Allows using the bump map in parallax occlusion mode.
  124378. */
  124379. protected _useParallaxOcclusion: boolean;
  124380. /**
  124381. * Controls the scale bias of the parallax mode.
  124382. */
  124383. protected _parallaxScaleBias: number;
  124384. /**
  124385. * If sets to true, disables all the lights affecting the material.
  124386. */
  124387. protected _disableLighting: boolean;
  124388. /**
  124389. * Number of Simultaneous lights allowed on the material.
  124390. */
  124391. protected _maxSimultaneousLights: number;
  124392. /**
  124393. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124394. */
  124395. protected _invertNormalMapX: boolean;
  124396. /**
  124397. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124398. */
  124399. protected _invertNormalMapY: boolean;
  124400. /**
  124401. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124402. */
  124403. protected _twoSidedLighting: boolean;
  124404. /**
  124405. * Defines the alpha limits in alpha test mode.
  124406. */
  124407. protected _alphaCutOff: number;
  124408. /**
  124409. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124410. */
  124411. protected _forceAlphaTest: boolean;
  124412. /**
  124413. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124414. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124415. */
  124416. protected _useAlphaFresnel: boolean;
  124417. /**
  124418. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124419. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124420. */
  124421. protected _useLinearAlphaFresnel: boolean;
  124422. /**
  124423. * The transparency mode of the material.
  124424. */
  124425. protected _transparencyMode: Nullable<number>;
  124426. /**
  124427. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  124428. * from cos thetav and roughness:
  124429. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  124430. */
  124431. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  124432. /**
  124433. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124434. */
  124435. protected _forceIrradianceInFragment: boolean;
  124436. /**
  124437. * Force normal to face away from face.
  124438. */
  124439. protected _forceNormalForward: boolean;
  124440. /**
  124441. * Enables specular anti aliasing in the PBR shader.
  124442. * It will both interacts on the Geometry for analytical and IBL lighting.
  124443. * It also prefilter the roughness map based on the bump values.
  124444. */
  124445. protected _enableSpecularAntiAliasing: boolean;
  124446. /**
  124447. * Default configuration related to image processing available in the PBR Material.
  124448. */
  124449. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124450. /**
  124451. * Keep track of the image processing observer to allow dispose and replace.
  124452. */
  124453. private _imageProcessingObserver;
  124454. /**
  124455. * Attaches a new image processing configuration to the PBR Material.
  124456. * @param configuration
  124457. */
  124458. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  124459. /**
  124460. * Stores the available render targets.
  124461. */
  124462. private _renderTargets;
  124463. /**
  124464. * Sets the global ambient color for the material used in lighting calculations.
  124465. */
  124466. private _globalAmbientColor;
  124467. /**
  124468. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  124469. */
  124470. private _useLogarithmicDepth;
  124471. /**
  124472. * If set to true, no lighting calculations will be applied.
  124473. */
  124474. private _unlit;
  124475. private _debugMode;
  124476. /**
  124477. * @hidden
  124478. * This is reserved for the inspector.
  124479. * Defines the material debug mode.
  124480. * It helps seeing only some components of the material while troubleshooting.
  124481. */
  124482. debugMode: number;
  124483. /**
  124484. * @hidden
  124485. * This is reserved for the inspector.
  124486. * Specify from where on screen the debug mode should start.
  124487. * The value goes from -1 (full screen) to 1 (not visible)
  124488. * It helps with side by side comparison against the final render
  124489. * This defaults to -1
  124490. */
  124491. private debugLimit;
  124492. /**
  124493. * @hidden
  124494. * This is reserved for the inspector.
  124495. * As the default viewing range might not be enough (if the ambient is really small for instance)
  124496. * You can use the factor to better multiply the final value.
  124497. */
  124498. private debugFactor;
  124499. /**
  124500. * Defines the clear coat layer parameters for the material.
  124501. */
  124502. readonly clearCoat: PBRClearCoatConfiguration;
  124503. /**
  124504. * Defines the anisotropic parameters for the material.
  124505. */
  124506. readonly anisotropy: PBRAnisotropicConfiguration;
  124507. /**
  124508. * Defines the BRDF parameters for the material.
  124509. */
  124510. readonly brdf: PBRBRDFConfiguration;
  124511. /**
  124512. * Defines the Sheen parameters for the material.
  124513. */
  124514. readonly sheen: PBRSheenConfiguration;
  124515. /**
  124516. * Defines the SubSurface parameters for the material.
  124517. */
  124518. readonly subSurface: PBRSubSurfaceConfiguration;
  124519. /**
  124520. * Custom callback helping to override the default shader used in the material.
  124521. */
  124522. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  124523. protected _rebuildInParallel: boolean;
  124524. /**
  124525. * Instantiates a new PBRMaterial instance.
  124526. *
  124527. * @param name The material name
  124528. * @param scene The scene the material will be use in.
  124529. */
  124530. constructor(name: string, scene: Scene);
  124531. /**
  124532. * Gets a boolean indicating that current material needs to register RTT
  124533. */
  124534. get hasRenderTargetTextures(): boolean;
  124535. /**
  124536. * Gets the name of the material class.
  124537. */
  124538. getClassName(): string;
  124539. /**
  124540. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124541. */
  124542. get useLogarithmicDepth(): boolean;
  124543. /**
  124544. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124545. */
  124546. set useLogarithmicDepth(value: boolean);
  124547. /**
  124548. * Gets the current transparency mode.
  124549. */
  124550. get transparencyMode(): Nullable<number>;
  124551. /**
  124552. * Sets the transparency mode of the material.
  124553. *
  124554. * | Value | Type | Description |
  124555. * | ----- | ----------------------------------- | ----------- |
  124556. * | 0 | OPAQUE | |
  124557. * | 1 | ALPHATEST | |
  124558. * | 2 | ALPHABLEND | |
  124559. * | 3 | ALPHATESTANDBLEND | |
  124560. *
  124561. */
  124562. set transparencyMode(value: Nullable<number>);
  124563. /**
  124564. * Returns true if alpha blending should be disabled.
  124565. */
  124566. private get _disableAlphaBlending();
  124567. /**
  124568. * Specifies whether or not this material should be rendered in alpha blend mode.
  124569. */
  124570. needAlphaBlending(): boolean;
  124571. /**
  124572. * Specifies if the mesh will require alpha blending.
  124573. * @param mesh - BJS mesh.
  124574. */
  124575. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  124576. /**
  124577. * Specifies whether or not this material should be rendered in alpha test mode.
  124578. */
  124579. needAlphaTesting(): boolean;
  124580. /**
  124581. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  124582. */
  124583. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  124584. /**
  124585. * Gets the texture used for the alpha test.
  124586. */
  124587. getAlphaTestTexture(): Nullable<BaseTexture>;
  124588. /**
  124589. * Specifies that the submesh is ready to be used.
  124590. * @param mesh - BJS mesh.
  124591. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  124592. * @param useInstances - Specifies that instances should be used.
  124593. * @returns - boolean indicating that the submesh is ready or not.
  124594. */
  124595. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124596. /**
  124597. * Specifies if the material uses metallic roughness workflow.
  124598. * @returns boolean specifiying if the material uses metallic roughness workflow.
  124599. */
  124600. isMetallicWorkflow(): boolean;
  124601. private _prepareEffect;
  124602. private _prepareDefines;
  124603. /**
  124604. * Force shader compilation
  124605. */
  124606. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  124607. /**
  124608. * Initializes the uniform buffer layout for the shader.
  124609. */
  124610. buildUniformLayout(): void;
  124611. /**
  124612. * Unbinds the material from the mesh
  124613. */
  124614. unbind(): void;
  124615. /**
  124616. * Binds the submesh data.
  124617. * @param world - The world matrix.
  124618. * @param mesh - The BJS mesh.
  124619. * @param subMesh - A submesh of the BJS mesh.
  124620. */
  124621. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124622. /**
  124623. * Returns the animatable textures.
  124624. * @returns - Array of animatable textures.
  124625. */
  124626. getAnimatables(): IAnimatable[];
  124627. /**
  124628. * Returns the texture used for reflections.
  124629. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  124630. */
  124631. private _getReflectionTexture;
  124632. /**
  124633. * Returns an array of the actively used textures.
  124634. * @returns - Array of BaseTextures
  124635. */
  124636. getActiveTextures(): BaseTexture[];
  124637. /**
  124638. * Checks to see if a texture is used in the material.
  124639. * @param texture - Base texture to use.
  124640. * @returns - Boolean specifying if a texture is used in the material.
  124641. */
  124642. hasTexture(texture: BaseTexture): boolean;
  124643. /**
  124644. * Disposes the resources of the material.
  124645. * @param forceDisposeEffect - Forces the disposal of effects.
  124646. * @param forceDisposeTextures - Forces the disposal of all textures.
  124647. */
  124648. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124649. }
  124650. }
  124651. declare module BABYLON {
  124652. /**
  124653. * The Physically based material of BJS.
  124654. *
  124655. * This offers the main features of a standard PBR material.
  124656. * For more information, please refer to the documentation :
  124657. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124658. */
  124659. export class PBRMaterial extends PBRBaseMaterial {
  124660. /**
  124661. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124662. */
  124663. static readonly PBRMATERIAL_OPAQUE: number;
  124664. /**
  124665. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124666. */
  124667. static readonly PBRMATERIAL_ALPHATEST: number;
  124668. /**
  124669. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124670. */
  124671. static readonly PBRMATERIAL_ALPHABLEND: number;
  124672. /**
  124673. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124674. * They are also discarded below the alpha cutoff threshold to improve performances.
  124675. */
  124676. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124677. /**
  124678. * Defines the default value of how much AO map is occluding the analytical lights
  124679. * (point spot...).
  124680. */
  124681. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124682. /**
  124683. * Intensity of the direct lights e.g. the four lights available in your scene.
  124684. * This impacts both the direct diffuse and specular highlights.
  124685. */
  124686. directIntensity: number;
  124687. /**
  124688. * Intensity of the emissive part of the material.
  124689. * This helps controlling the emissive effect without modifying the emissive color.
  124690. */
  124691. emissiveIntensity: number;
  124692. /**
  124693. * Intensity of the environment e.g. how much the environment will light the object
  124694. * either through harmonics for rough material or through the refelction for shiny ones.
  124695. */
  124696. environmentIntensity: number;
  124697. /**
  124698. * This is a special control allowing the reduction of the specular highlights coming from the
  124699. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124700. */
  124701. specularIntensity: number;
  124702. /**
  124703. * Debug Control allowing disabling the bump map on this material.
  124704. */
  124705. disableBumpMap: boolean;
  124706. /**
  124707. * AKA Diffuse Texture in standard nomenclature.
  124708. */
  124709. albedoTexture: BaseTexture;
  124710. /**
  124711. * AKA Occlusion Texture in other nomenclature.
  124712. */
  124713. ambientTexture: BaseTexture;
  124714. /**
  124715. * AKA Occlusion Texture Intensity in other nomenclature.
  124716. */
  124717. ambientTextureStrength: number;
  124718. /**
  124719. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124720. * 1 means it completely occludes it
  124721. * 0 mean it has no impact
  124722. */
  124723. ambientTextureImpactOnAnalyticalLights: number;
  124724. /**
  124725. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  124726. */
  124727. opacityTexture: BaseTexture;
  124728. /**
  124729. * Stores the reflection values in a texture.
  124730. */
  124731. reflectionTexture: Nullable<BaseTexture>;
  124732. /**
  124733. * Stores the emissive values in a texture.
  124734. */
  124735. emissiveTexture: BaseTexture;
  124736. /**
  124737. * AKA Specular texture in other nomenclature.
  124738. */
  124739. reflectivityTexture: BaseTexture;
  124740. /**
  124741. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124742. */
  124743. metallicTexture: BaseTexture;
  124744. /**
  124745. * Specifies the metallic scalar of the metallic/roughness workflow.
  124746. * Can also be used to scale the metalness values of the metallic texture.
  124747. */
  124748. metallic: Nullable<number>;
  124749. /**
  124750. * Specifies the roughness scalar of the metallic/roughness workflow.
  124751. * Can also be used to scale the roughness values of the metallic texture.
  124752. */
  124753. roughness: Nullable<number>;
  124754. /**
  124755. * Specifies the an F0 factor to help configuring the material F0.
  124756. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124757. * to 0.5 the previously hard coded value stays the same.
  124758. * Can also be used to scale the F0 values of the metallic texture.
  124759. */
  124760. metallicF0Factor: number;
  124761. /**
  124762. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124763. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124764. * your expectation as it multiplies with the texture data.
  124765. */
  124766. useMetallicF0FactorFromMetallicTexture: boolean;
  124767. /**
  124768. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124769. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124770. */
  124771. microSurfaceTexture: BaseTexture;
  124772. /**
  124773. * Stores surface normal data used to displace a mesh in a texture.
  124774. */
  124775. bumpTexture: BaseTexture;
  124776. /**
  124777. * Stores the pre-calculated light information of a mesh in a texture.
  124778. */
  124779. lightmapTexture: BaseTexture;
  124780. /**
  124781. * Stores the refracted light information in a texture.
  124782. */
  124783. get refractionTexture(): Nullable<BaseTexture>;
  124784. set refractionTexture(value: Nullable<BaseTexture>);
  124785. /**
  124786. * The color of a material in ambient lighting.
  124787. */
  124788. ambientColor: Color3;
  124789. /**
  124790. * AKA Diffuse Color in other nomenclature.
  124791. */
  124792. albedoColor: Color3;
  124793. /**
  124794. * AKA Specular Color in other nomenclature.
  124795. */
  124796. reflectivityColor: Color3;
  124797. /**
  124798. * The color reflected from the material.
  124799. */
  124800. reflectionColor: Color3;
  124801. /**
  124802. * The color emitted from the material.
  124803. */
  124804. emissiveColor: Color3;
  124805. /**
  124806. * AKA Glossiness in other nomenclature.
  124807. */
  124808. microSurface: number;
  124809. /**
  124810. * source material index of refraction (IOR)' / 'destination material IOR.
  124811. */
  124812. get indexOfRefraction(): number;
  124813. set indexOfRefraction(value: number);
  124814. /**
  124815. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  124816. */
  124817. get invertRefractionY(): boolean;
  124818. set invertRefractionY(value: boolean);
  124819. /**
  124820. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  124821. * Materials half opaque for instance using refraction could benefit from this control.
  124822. */
  124823. get linkRefractionWithTransparency(): boolean;
  124824. set linkRefractionWithTransparency(value: boolean);
  124825. /**
  124826. * If true, the light map contains occlusion information instead of lighting info.
  124827. */
  124828. useLightmapAsShadowmap: boolean;
  124829. /**
  124830. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124831. */
  124832. useAlphaFromAlbedoTexture: boolean;
  124833. /**
  124834. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124835. */
  124836. forceAlphaTest: boolean;
  124837. /**
  124838. * Defines the alpha limits in alpha test mode.
  124839. */
  124840. alphaCutOff: number;
  124841. /**
  124842. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  124843. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124844. */
  124845. useSpecularOverAlpha: boolean;
  124846. /**
  124847. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124848. */
  124849. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124850. /**
  124851. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124852. */
  124853. useRoughnessFromMetallicTextureAlpha: boolean;
  124854. /**
  124855. * Specifies if the metallic texture contains the roughness information in its green channel.
  124856. */
  124857. useRoughnessFromMetallicTextureGreen: boolean;
  124858. /**
  124859. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124860. */
  124861. useMetallnessFromMetallicTextureBlue: boolean;
  124862. /**
  124863. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124864. */
  124865. useAmbientOcclusionFromMetallicTextureRed: boolean;
  124866. /**
  124867. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124868. */
  124869. useAmbientInGrayScale: boolean;
  124870. /**
  124871. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124872. * The material will try to infer what glossiness each pixel should be.
  124873. */
  124874. useAutoMicroSurfaceFromReflectivityMap: boolean;
  124875. /**
  124876. * BJS is using an harcoded light falloff based on a manually sets up range.
  124877. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124878. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124879. */
  124880. get usePhysicalLightFalloff(): boolean;
  124881. /**
  124882. * BJS is using an harcoded light falloff based on a manually sets up range.
  124883. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  124884. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  124885. */
  124886. set usePhysicalLightFalloff(value: boolean);
  124887. /**
  124888. * In order to support the falloff compatibility with gltf, a special mode has been added
  124889. * to reproduce the gltf light falloff.
  124890. */
  124891. get useGLTFLightFalloff(): boolean;
  124892. /**
  124893. * In order to support the falloff compatibility with gltf, a special mode has been added
  124894. * to reproduce the gltf light falloff.
  124895. */
  124896. set useGLTFLightFalloff(value: boolean);
  124897. /**
  124898. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124899. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124900. */
  124901. useRadianceOverAlpha: boolean;
  124902. /**
  124903. * Allows using an object space normal map (instead of tangent space).
  124904. */
  124905. useObjectSpaceNormalMap: boolean;
  124906. /**
  124907. * Allows using the bump map in parallax mode.
  124908. */
  124909. useParallax: boolean;
  124910. /**
  124911. * Allows using the bump map in parallax occlusion mode.
  124912. */
  124913. useParallaxOcclusion: boolean;
  124914. /**
  124915. * Controls the scale bias of the parallax mode.
  124916. */
  124917. parallaxScaleBias: number;
  124918. /**
  124919. * If sets to true, disables all the lights affecting the material.
  124920. */
  124921. disableLighting: boolean;
  124922. /**
  124923. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124924. */
  124925. forceIrradianceInFragment: boolean;
  124926. /**
  124927. * Number of Simultaneous lights allowed on the material.
  124928. */
  124929. maxSimultaneousLights: number;
  124930. /**
  124931. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  124932. */
  124933. invertNormalMapX: boolean;
  124934. /**
  124935. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  124936. */
  124937. invertNormalMapY: boolean;
  124938. /**
  124939. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124940. */
  124941. twoSidedLighting: boolean;
  124942. /**
  124943. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124944. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124945. */
  124946. useAlphaFresnel: boolean;
  124947. /**
  124948. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124949. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124950. */
  124951. useLinearAlphaFresnel: boolean;
  124952. /**
  124953. * Let user defines the brdf lookup texture used for IBL.
  124954. * A default 8bit version is embedded but you could point at :
  124955. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  124956. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  124957. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  124958. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  124959. */
  124960. environmentBRDFTexture: Nullable<BaseTexture>;
  124961. /**
  124962. * Force normal to face away from face.
  124963. */
  124964. forceNormalForward: boolean;
  124965. /**
  124966. * Enables specular anti aliasing in the PBR shader.
  124967. * It will both interacts on the Geometry for analytical and IBL lighting.
  124968. * It also prefilter the roughness map based on the bump values.
  124969. */
  124970. enableSpecularAntiAliasing: boolean;
  124971. /**
  124972. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124973. * makes the reflect vector face the model (under horizon).
  124974. */
  124975. useHorizonOcclusion: boolean;
  124976. /**
  124977. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124978. * too much the area relying on ambient texture to define their ambient occlusion.
  124979. */
  124980. useRadianceOcclusion: boolean;
  124981. /**
  124982. * If set to true, no lighting calculations will be applied.
  124983. */
  124984. unlit: boolean;
  124985. /**
  124986. * Gets the image processing configuration used either in this material.
  124987. */
  124988. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  124989. /**
  124990. * Sets the Default image processing configuration used either in the this material.
  124991. *
  124992. * If sets to null, the scene one is in use.
  124993. */
  124994. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  124995. /**
  124996. * Gets wether the color curves effect is enabled.
  124997. */
  124998. get cameraColorCurvesEnabled(): boolean;
  124999. /**
  125000. * Sets wether the color curves effect is enabled.
  125001. */
  125002. set cameraColorCurvesEnabled(value: boolean);
  125003. /**
  125004. * Gets wether the color grading effect is enabled.
  125005. */
  125006. get cameraColorGradingEnabled(): boolean;
  125007. /**
  125008. * Gets wether the color grading effect is enabled.
  125009. */
  125010. set cameraColorGradingEnabled(value: boolean);
  125011. /**
  125012. * Gets wether tonemapping is enabled or not.
  125013. */
  125014. get cameraToneMappingEnabled(): boolean;
  125015. /**
  125016. * Sets wether tonemapping is enabled or not
  125017. */
  125018. set cameraToneMappingEnabled(value: boolean);
  125019. /**
  125020. * The camera exposure used on this material.
  125021. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125022. * This corresponds to a photographic exposure.
  125023. */
  125024. get cameraExposure(): number;
  125025. /**
  125026. * The camera exposure used on this material.
  125027. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125028. * This corresponds to a photographic exposure.
  125029. */
  125030. set cameraExposure(value: number);
  125031. /**
  125032. * Gets The camera contrast used on this material.
  125033. */
  125034. get cameraContrast(): number;
  125035. /**
  125036. * Sets The camera contrast used on this material.
  125037. */
  125038. set cameraContrast(value: number);
  125039. /**
  125040. * Gets the Color Grading 2D Lookup Texture.
  125041. */
  125042. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  125043. /**
  125044. * Sets the Color Grading 2D Lookup Texture.
  125045. */
  125046. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  125047. /**
  125048. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125049. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125050. * 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;
  125051. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125052. */
  125053. get cameraColorCurves(): Nullable<ColorCurves>;
  125054. /**
  125055. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125056. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125057. * 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;
  125058. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125059. */
  125060. set cameraColorCurves(value: Nullable<ColorCurves>);
  125061. /**
  125062. * Instantiates a new PBRMaterial instance.
  125063. *
  125064. * @param name The material name
  125065. * @param scene The scene the material will be use in.
  125066. */
  125067. constructor(name: string, scene: Scene);
  125068. /**
  125069. * Returns the name of this material class.
  125070. */
  125071. getClassName(): string;
  125072. /**
  125073. * Makes a duplicate of the current material.
  125074. * @param name - name to use for the new material.
  125075. */
  125076. clone(name: string): PBRMaterial;
  125077. /**
  125078. * Serializes this PBR Material.
  125079. * @returns - An object with the serialized material.
  125080. */
  125081. serialize(): any;
  125082. /**
  125083. * Parses a PBR Material from a serialized object.
  125084. * @param source - Serialized object.
  125085. * @param scene - BJS scene instance.
  125086. * @param rootUrl - url for the scene object
  125087. * @returns - PBRMaterial
  125088. */
  125089. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  125090. }
  125091. }
  125092. declare module BABYLON {
  125093. /**
  125094. * Direct draw surface info
  125095. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  125096. */
  125097. export interface DDSInfo {
  125098. /**
  125099. * Width of the texture
  125100. */
  125101. width: number;
  125102. /**
  125103. * Width of the texture
  125104. */
  125105. height: number;
  125106. /**
  125107. * Number of Mipmaps for the texture
  125108. * @see https://en.wikipedia.org/wiki/Mipmap
  125109. */
  125110. mipmapCount: number;
  125111. /**
  125112. * If the textures format is a known fourCC format
  125113. * @see https://www.fourcc.org/
  125114. */
  125115. isFourCC: boolean;
  125116. /**
  125117. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  125118. */
  125119. isRGB: boolean;
  125120. /**
  125121. * If the texture is a lumincance format
  125122. */
  125123. isLuminance: boolean;
  125124. /**
  125125. * If this is a cube texture
  125126. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  125127. */
  125128. isCube: boolean;
  125129. /**
  125130. * If the texture is a compressed format eg. FOURCC_DXT1
  125131. */
  125132. isCompressed: boolean;
  125133. /**
  125134. * The dxgiFormat of the texture
  125135. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  125136. */
  125137. dxgiFormat: number;
  125138. /**
  125139. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  125140. */
  125141. textureType: number;
  125142. /**
  125143. * Sphericle polynomial created for the dds texture
  125144. */
  125145. sphericalPolynomial?: SphericalPolynomial;
  125146. }
  125147. /**
  125148. * Class used to provide DDS decompression tools
  125149. */
  125150. export class DDSTools {
  125151. /**
  125152. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  125153. */
  125154. static StoreLODInAlphaChannel: boolean;
  125155. /**
  125156. * Gets DDS information from an array buffer
  125157. * @param data defines the array buffer view to read data from
  125158. * @returns the DDS information
  125159. */
  125160. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  125161. private static _FloatView;
  125162. private static _Int32View;
  125163. private static _ToHalfFloat;
  125164. private static _FromHalfFloat;
  125165. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  125166. private static _GetHalfFloatRGBAArrayBuffer;
  125167. private static _GetFloatRGBAArrayBuffer;
  125168. private static _GetFloatAsUIntRGBAArrayBuffer;
  125169. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  125170. private static _GetRGBAArrayBuffer;
  125171. private static _ExtractLongWordOrder;
  125172. private static _GetRGBArrayBuffer;
  125173. private static _GetLuminanceArrayBuffer;
  125174. /**
  125175. * Uploads DDS Levels to a Babylon Texture
  125176. * @hidden
  125177. */
  125178. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  125179. }
  125180. interface ThinEngine {
  125181. /**
  125182. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  125183. * @param rootUrl defines the url where the file to load is located
  125184. * @param scene defines the current scene
  125185. * @param lodScale defines scale to apply to the mip map selection
  125186. * @param lodOffset defines offset to apply to the mip map selection
  125187. * @param onLoad defines an optional callback raised when the texture is loaded
  125188. * @param onError defines an optional callback raised if there is an issue to load the texture
  125189. * @param format defines the format of the data
  125190. * @param forcedExtension defines the extension to use to pick the right loader
  125191. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  125192. * @returns the cube texture as an InternalTexture
  125193. */
  125194. 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;
  125195. }
  125196. }
  125197. declare module BABYLON {
  125198. /**
  125199. * Implementation of the DDS Texture Loader.
  125200. * @hidden
  125201. */
  125202. export class _DDSTextureLoader implements IInternalTextureLoader {
  125203. /**
  125204. * Defines wether the loader supports cascade loading the different faces.
  125205. */
  125206. readonly supportCascades: boolean;
  125207. /**
  125208. * This returns if the loader support the current file information.
  125209. * @param extension defines the file extension of the file being loaded
  125210. * @returns true if the loader can load the specified file
  125211. */
  125212. canLoad(extension: string): boolean;
  125213. /**
  125214. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125215. * @param data contains the texture data
  125216. * @param texture defines the BabylonJS internal texture
  125217. * @param createPolynomials will be true if polynomials have been requested
  125218. * @param onLoad defines the callback to trigger once the texture is ready
  125219. * @param onError defines the callback to trigger in case of error
  125220. */
  125221. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125222. /**
  125223. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125224. * @param data contains the texture data
  125225. * @param texture defines the BabylonJS internal texture
  125226. * @param callback defines the method to call once ready to upload
  125227. */
  125228. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125229. }
  125230. }
  125231. declare module BABYLON {
  125232. /**
  125233. * Implementation of the ENV Texture Loader.
  125234. * @hidden
  125235. */
  125236. export class _ENVTextureLoader implements IInternalTextureLoader {
  125237. /**
  125238. * Defines wether the loader supports cascade loading the different faces.
  125239. */
  125240. readonly supportCascades: boolean;
  125241. /**
  125242. * This returns if the loader support the current file information.
  125243. * @param extension defines the file extension of the file being loaded
  125244. * @returns true if the loader can load the specified file
  125245. */
  125246. canLoad(extension: string): boolean;
  125247. /**
  125248. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125249. * @param data contains the texture data
  125250. * @param texture defines the BabylonJS internal texture
  125251. * @param createPolynomials will be true if polynomials have been requested
  125252. * @param onLoad defines the callback to trigger once the texture is ready
  125253. * @param onError defines the callback to trigger in case of error
  125254. */
  125255. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125256. /**
  125257. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125258. * @param data contains the texture data
  125259. * @param texture defines the BabylonJS internal texture
  125260. * @param callback defines the method to call once ready to upload
  125261. */
  125262. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125263. }
  125264. }
  125265. declare module BABYLON {
  125266. /**
  125267. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  125268. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  125269. */
  125270. export class KhronosTextureContainer {
  125271. /** contents of the KTX container file */
  125272. data: ArrayBufferView;
  125273. private static HEADER_LEN;
  125274. private static COMPRESSED_2D;
  125275. private static COMPRESSED_3D;
  125276. private static TEX_2D;
  125277. private static TEX_3D;
  125278. /**
  125279. * Gets the openGL type
  125280. */
  125281. glType: number;
  125282. /**
  125283. * Gets the openGL type size
  125284. */
  125285. glTypeSize: number;
  125286. /**
  125287. * Gets the openGL format
  125288. */
  125289. glFormat: number;
  125290. /**
  125291. * Gets the openGL internal format
  125292. */
  125293. glInternalFormat: number;
  125294. /**
  125295. * Gets the base internal format
  125296. */
  125297. glBaseInternalFormat: number;
  125298. /**
  125299. * Gets image width in pixel
  125300. */
  125301. pixelWidth: number;
  125302. /**
  125303. * Gets image height in pixel
  125304. */
  125305. pixelHeight: number;
  125306. /**
  125307. * Gets image depth in pixels
  125308. */
  125309. pixelDepth: number;
  125310. /**
  125311. * Gets the number of array elements
  125312. */
  125313. numberOfArrayElements: number;
  125314. /**
  125315. * Gets the number of faces
  125316. */
  125317. numberOfFaces: number;
  125318. /**
  125319. * Gets the number of mipmap levels
  125320. */
  125321. numberOfMipmapLevels: number;
  125322. /**
  125323. * Gets the bytes of key value data
  125324. */
  125325. bytesOfKeyValueData: number;
  125326. /**
  125327. * Gets the load type
  125328. */
  125329. loadType: number;
  125330. /**
  125331. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  125332. */
  125333. isInvalid: boolean;
  125334. /**
  125335. * Creates a new KhronosTextureContainer
  125336. * @param data contents of the KTX container file
  125337. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  125338. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  125339. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  125340. */
  125341. constructor(
  125342. /** contents of the KTX container file */
  125343. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  125344. /**
  125345. * Uploads KTX content to a Babylon Texture.
  125346. * It is assumed that the texture has already been created & is currently bound
  125347. * @hidden
  125348. */
  125349. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  125350. private _upload2DCompressedLevels;
  125351. /**
  125352. * Checks if the given data starts with a KTX file identifier.
  125353. * @param data the data to check
  125354. * @returns true if the data is a KTX file or false otherwise
  125355. */
  125356. static IsValid(data: ArrayBufferView): boolean;
  125357. }
  125358. }
  125359. declare module BABYLON {
  125360. /**
  125361. * Class for loading KTX2 files
  125362. * !!! Experimental Extension Subject to Changes !!!
  125363. * @hidden
  125364. */
  125365. export class KhronosTextureContainer2 {
  125366. private static _ModulePromise;
  125367. private static _TranscodeFormat;
  125368. constructor(engine: ThinEngine);
  125369. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  125370. private _determineTranscodeFormat;
  125371. /**
  125372. * Checks if the given data starts with a KTX2 file identifier.
  125373. * @param data the data to check
  125374. * @returns true if the data is a KTX2 file or false otherwise
  125375. */
  125376. static IsValid(data: ArrayBufferView): boolean;
  125377. }
  125378. }
  125379. declare module BABYLON {
  125380. /**
  125381. * Implementation of the KTX Texture Loader.
  125382. * @hidden
  125383. */
  125384. export class _KTXTextureLoader implements IInternalTextureLoader {
  125385. /**
  125386. * Defines wether the loader supports cascade loading the different faces.
  125387. */
  125388. readonly supportCascades: boolean;
  125389. /**
  125390. * This returns if the loader support the current file information.
  125391. * @param extension defines the file extension of the file being loaded
  125392. * @returns true if the loader can load the specified file
  125393. */
  125394. canLoad(extension: string): boolean;
  125395. /**
  125396. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  125397. * @param data contains the texture data
  125398. * @param texture defines the BabylonJS internal texture
  125399. * @param createPolynomials will be true if polynomials have been requested
  125400. * @param onLoad defines the callback to trigger once the texture is ready
  125401. * @param onError defines the callback to trigger in case of error
  125402. */
  125403. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125404. /**
  125405. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  125406. * @param data contains the texture data
  125407. * @param texture defines the BabylonJS internal texture
  125408. * @param callback defines the method to call once ready to upload
  125409. */
  125410. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  125411. }
  125412. }
  125413. declare module BABYLON {
  125414. /** @hidden */
  125415. export var _forceSceneHelpersToBundle: boolean;
  125416. interface Scene {
  125417. /**
  125418. * Creates a default light for the scene.
  125419. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  125420. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  125421. */
  125422. createDefaultLight(replace?: boolean): void;
  125423. /**
  125424. * Creates a default camera for the scene.
  125425. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  125426. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125427. * @param replace has default false, when true replaces the active camera in the scene
  125428. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  125429. */
  125430. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125431. /**
  125432. * Creates a default camera and a default light.
  125433. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  125434. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125435. * @param replace has the default false, when true replaces the active camera/light in the scene
  125436. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  125437. */
  125438. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125439. /**
  125440. * Creates a new sky box
  125441. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  125442. * @param environmentTexture defines the texture to use as environment texture
  125443. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  125444. * @param scale defines the overall scale of the skybox
  125445. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  125446. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  125447. * @returns a new mesh holding the sky box
  125448. */
  125449. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  125450. /**
  125451. * Creates a new environment
  125452. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  125453. * @param options defines the options you can use to configure the environment
  125454. * @returns the new EnvironmentHelper
  125455. */
  125456. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  125457. /**
  125458. * Creates a new VREXperienceHelper
  125459. * @see http://doc.babylonjs.com/how_to/webvr_helper
  125460. * @param webVROptions defines the options used to create the new VREXperienceHelper
  125461. * @returns a new VREXperienceHelper
  125462. */
  125463. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  125464. /**
  125465. * Creates a new WebXRDefaultExperience
  125466. * @see http://doc.babylonjs.com/how_to/webxr
  125467. * @param options experience options
  125468. * @returns a promise for a new WebXRDefaultExperience
  125469. */
  125470. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125471. }
  125472. }
  125473. declare module BABYLON {
  125474. /**
  125475. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  125476. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  125477. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  125478. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  125479. */
  125480. export class VideoDome extends TransformNode {
  125481. /**
  125482. * Define the video source as a Monoscopic panoramic 360 video.
  125483. */
  125484. static readonly MODE_MONOSCOPIC: number;
  125485. /**
  125486. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125487. */
  125488. static readonly MODE_TOPBOTTOM: number;
  125489. /**
  125490. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125491. */
  125492. static readonly MODE_SIDEBYSIDE: number;
  125493. private _halfDome;
  125494. private _useDirectMapping;
  125495. /**
  125496. * The video texture being displayed on the sphere
  125497. */
  125498. protected _videoTexture: VideoTexture;
  125499. /**
  125500. * Gets the video texture being displayed on the sphere
  125501. */
  125502. get videoTexture(): VideoTexture;
  125503. /**
  125504. * The skybox material
  125505. */
  125506. protected _material: BackgroundMaterial;
  125507. /**
  125508. * The surface used for the skybox
  125509. */
  125510. protected _mesh: Mesh;
  125511. /**
  125512. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  125513. */
  125514. private _halfDomeMask;
  125515. /**
  125516. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125517. * Also see the options.resolution property.
  125518. */
  125519. get fovMultiplier(): number;
  125520. set fovMultiplier(value: number);
  125521. private _videoMode;
  125522. /**
  125523. * Gets or set the current video mode for the video. It can be:
  125524. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  125525. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125526. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125527. */
  125528. get videoMode(): number;
  125529. set videoMode(value: number);
  125530. /**
  125531. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  125532. *
  125533. */
  125534. get halfDome(): boolean;
  125535. /**
  125536. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  125537. */
  125538. set halfDome(enabled: boolean);
  125539. /**
  125540. * Oberserver used in Stereoscopic VR Mode.
  125541. */
  125542. private _onBeforeCameraRenderObserver;
  125543. /**
  125544. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  125545. * @param name Element's name, child elements will append suffixes for their own names.
  125546. * @param urlsOrVideo defines the url(s) or the video element to use
  125547. * @param options An object containing optional or exposed sub element properties
  125548. */
  125549. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  125550. resolution?: number;
  125551. clickToPlay?: boolean;
  125552. autoPlay?: boolean;
  125553. loop?: boolean;
  125554. size?: number;
  125555. poster?: string;
  125556. faceForward?: boolean;
  125557. useDirectMapping?: boolean;
  125558. halfDomeMode?: boolean;
  125559. }, scene: Scene);
  125560. private _changeVideoMode;
  125561. /**
  125562. * Releases resources associated with this node.
  125563. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  125564. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  125565. */
  125566. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  125567. }
  125568. }
  125569. declare module BABYLON {
  125570. /**
  125571. * This class can be used to get instrumentation data from a Babylon engine
  125572. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125573. */
  125574. export class EngineInstrumentation implements IDisposable {
  125575. /**
  125576. * Define the instrumented engine.
  125577. */
  125578. engine: Engine;
  125579. private _captureGPUFrameTime;
  125580. private _gpuFrameTimeToken;
  125581. private _gpuFrameTime;
  125582. private _captureShaderCompilationTime;
  125583. private _shaderCompilationTime;
  125584. private _onBeginFrameObserver;
  125585. private _onEndFrameObserver;
  125586. private _onBeforeShaderCompilationObserver;
  125587. private _onAfterShaderCompilationObserver;
  125588. /**
  125589. * Gets the perf counter used for GPU frame time
  125590. */
  125591. get gpuFrameTimeCounter(): PerfCounter;
  125592. /**
  125593. * Gets the GPU frame time capture status
  125594. */
  125595. get captureGPUFrameTime(): boolean;
  125596. /**
  125597. * Enable or disable the GPU frame time capture
  125598. */
  125599. set captureGPUFrameTime(value: boolean);
  125600. /**
  125601. * Gets the perf counter used for shader compilation time
  125602. */
  125603. get shaderCompilationTimeCounter(): PerfCounter;
  125604. /**
  125605. * Gets the shader compilation time capture status
  125606. */
  125607. get captureShaderCompilationTime(): boolean;
  125608. /**
  125609. * Enable or disable the shader compilation time capture
  125610. */
  125611. set captureShaderCompilationTime(value: boolean);
  125612. /**
  125613. * Instantiates a new engine instrumentation.
  125614. * This class can be used to get instrumentation data from a Babylon engine
  125615. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125616. * @param engine Defines the engine to instrument
  125617. */
  125618. constructor(
  125619. /**
  125620. * Define the instrumented engine.
  125621. */
  125622. engine: Engine);
  125623. /**
  125624. * Dispose and release associated resources.
  125625. */
  125626. dispose(): void;
  125627. }
  125628. }
  125629. declare module BABYLON {
  125630. /**
  125631. * This class can be used to get instrumentation data from a Babylon engine
  125632. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125633. */
  125634. export class SceneInstrumentation implements IDisposable {
  125635. /**
  125636. * Defines the scene to instrument
  125637. */
  125638. scene: Scene;
  125639. private _captureActiveMeshesEvaluationTime;
  125640. private _activeMeshesEvaluationTime;
  125641. private _captureRenderTargetsRenderTime;
  125642. private _renderTargetsRenderTime;
  125643. private _captureFrameTime;
  125644. private _frameTime;
  125645. private _captureRenderTime;
  125646. private _renderTime;
  125647. private _captureInterFrameTime;
  125648. private _interFrameTime;
  125649. private _captureParticlesRenderTime;
  125650. private _particlesRenderTime;
  125651. private _captureSpritesRenderTime;
  125652. private _spritesRenderTime;
  125653. private _capturePhysicsTime;
  125654. private _physicsTime;
  125655. private _captureAnimationsTime;
  125656. private _animationsTime;
  125657. private _captureCameraRenderTime;
  125658. private _cameraRenderTime;
  125659. private _onBeforeActiveMeshesEvaluationObserver;
  125660. private _onAfterActiveMeshesEvaluationObserver;
  125661. private _onBeforeRenderTargetsRenderObserver;
  125662. private _onAfterRenderTargetsRenderObserver;
  125663. private _onAfterRenderObserver;
  125664. private _onBeforeDrawPhaseObserver;
  125665. private _onAfterDrawPhaseObserver;
  125666. private _onBeforeAnimationsObserver;
  125667. private _onBeforeParticlesRenderingObserver;
  125668. private _onAfterParticlesRenderingObserver;
  125669. private _onBeforeSpritesRenderingObserver;
  125670. private _onAfterSpritesRenderingObserver;
  125671. private _onBeforePhysicsObserver;
  125672. private _onAfterPhysicsObserver;
  125673. private _onAfterAnimationsObserver;
  125674. private _onBeforeCameraRenderObserver;
  125675. private _onAfterCameraRenderObserver;
  125676. /**
  125677. * Gets the perf counter used for active meshes evaluation time
  125678. */
  125679. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  125680. /**
  125681. * Gets the active meshes evaluation time capture status
  125682. */
  125683. get captureActiveMeshesEvaluationTime(): boolean;
  125684. /**
  125685. * Enable or disable the active meshes evaluation time capture
  125686. */
  125687. set captureActiveMeshesEvaluationTime(value: boolean);
  125688. /**
  125689. * Gets the perf counter used for render targets render time
  125690. */
  125691. get renderTargetsRenderTimeCounter(): PerfCounter;
  125692. /**
  125693. * Gets the render targets render time capture status
  125694. */
  125695. get captureRenderTargetsRenderTime(): boolean;
  125696. /**
  125697. * Enable or disable the render targets render time capture
  125698. */
  125699. set captureRenderTargetsRenderTime(value: boolean);
  125700. /**
  125701. * Gets the perf counter used for particles render time
  125702. */
  125703. get particlesRenderTimeCounter(): PerfCounter;
  125704. /**
  125705. * Gets the particles render time capture status
  125706. */
  125707. get captureParticlesRenderTime(): boolean;
  125708. /**
  125709. * Enable or disable the particles render time capture
  125710. */
  125711. set captureParticlesRenderTime(value: boolean);
  125712. /**
  125713. * Gets the perf counter used for sprites render time
  125714. */
  125715. get spritesRenderTimeCounter(): PerfCounter;
  125716. /**
  125717. * Gets the sprites render time capture status
  125718. */
  125719. get captureSpritesRenderTime(): boolean;
  125720. /**
  125721. * Enable or disable the sprites render time capture
  125722. */
  125723. set captureSpritesRenderTime(value: boolean);
  125724. /**
  125725. * Gets the perf counter used for physics time
  125726. */
  125727. get physicsTimeCounter(): PerfCounter;
  125728. /**
  125729. * Gets the physics time capture status
  125730. */
  125731. get capturePhysicsTime(): boolean;
  125732. /**
  125733. * Enable or disable the physics time capture
  125734. */
  125735. set capturePhysicsTime(value: boolean);
  125736. /**
  125737. * Gets the perf counter used for animations time
  125738. */
  125739. get animationsTimeCounter(): PerfCounter;
  125740. /**
  125741. * Gets the animations time capture status
  125742. */
  125743. get captureAnimationsTime(): boolean;
  125744. /**
  125745. * Enable or disable the animations time capture
  125746. */
  125747. set captureAnimationsTime(value: boolean);
  125748. /**
  125749. * Gets the perf counter used for frame time capture
  125750. */
  125751. get frameTimeCounter(): PerfCounter;
  125752. /**
  125753. * Gets the frame time capture status
  125754. */
  125755. get captureFrameTime(): boolean;
  125756. /**
  125757. * Enable or disable the frame time capture
  125758. */
  125759. set captureFrameTime(value: boolean);
  125760. /**
  125761. * Gets the perf counter used for inter-frames time capture
  125762. */
  125763. get interFrameTimeCounter(): PerfCounter;
  125764. /**
  125765. * Gets the inter-frames time capture status
  125766. */
  125767. get captureInterFrameTime(): boolean;
  125768. /**
  125769. * Enable or disable the inter-frames time capture
  125770. */
  125771. set captureInterFrameTime(value: boolean);
  125772. /**
  125773. * Gets the perf counter used for render time capture
  125774. */
  125775. get renderTimeCounter(): PerfCounter;
  125776. /**
  125777. * Gets the render time capture status
  125778. */
  125779. get captureRenderTime(): boolean;
  125780. /**
  125781. * Enable or disable the render time capture
  125782. */
  125783. set captureRenderTime(value: boolean);
  125784. /**
  125785. * Gets the perf counter used for camera render time capture
  125786. */
  125787. get cameraRenderTimeCounter(): PerfCounter;
  125788. /**
  125789. * Gets the camera render time capture status
  125790. */
  125791. get captureCameraRenderTime(): boolean;
  125792. /**
  125793. * Enable or disable the camera render time capture
  125794. */
  125795. set captureCameraRenderTime(value: boolean);
  125796. /**
  125797. * Gets the perf counter used for draw calls
  125798. */
  125799. get drawCallsCounter(): PerfCounter;
  125800. /**
  125801. * Instantiates a new scene instrumentation.
  125802. * This class can be used to get instrumentation data from a Babylon engine
  125803. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125804. * @param scene Defines the scene to instrument
  125805. */
  125806. constructor(
  125807. /**
  125808. * Defines the scene to instrument
  125809. */
  125810. scene: Scene);
  125811. /**
  125812. * Dispose and release associated resources.
  125813. */
  125814. dispose(): void;
  125815. }
  125816. }
  125817. declare module BABYLON {
  125818. /** @hidden */
  125819. export var glowMapGenerationPixelShader: {
  125820. name: string;
  125821. shader: string;
  125822. };
  125823. }
  125824. declare module BABYLON {
  125825. /** @hidden */
  125826. export var glowMapGenerationVertexShader: {
  125827. name: string;
  125828. shader: string;
  125829. };
  125830. }
  125831. declare module BABYLON {
  125832. /**
  125833. * Effect layer options. This helps customizing the behaviour
  125834. * of the effect layer.
  125835. */
  125836. export interface IEffectLayerOptions {
  125837. /**
  125838. * Multiplication factor apply to the canvas size to compute the render target size
  125839. * used to generated the objects (the smaller the faster).
  125840. */
  125841. mainTextureRatio: number;
  125842. /**
  125843. * Enforces a fixed size texture to ensure effect stability across devices.
  125844. */
  125845. mainTextureFixedSize?: number;
  125846. /**
  125847. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  125848. */
  125849. alphaBlendingMode: number;
  125850. /**
  125851. * The camera attached to the layer.
  125852. */
  125853. camera: Nullable<Camera>;
  125854. /**
  125855. * The rendering group to draw the layer in.
  125856. */
  125857. renderingGroupId: number;
  125858. }
  125859. /**
  125860. * The effect layer Helps adding post process effect blended with the main pass.
  125861. *
  125862. * This can be for instance use to generate glow or higlight effects on the scene.
  125863. *
  125864. * The effect layer class can not be used directly and is intented to inherited from to be
  125865. * customized per effects.
  125866. */
  125867. export abstract class EffectLayer {
  125868. private _vertexBuffers;
  125869. private _indexBuffer;
  125870. private _cachedDefines;
  125871. private _effectLayerMapGenerationEffect;
  125872. private _effectLayerOptions;
  125873. private _mergeEffect;
  125874. protected _scene: Scene;
  125875. protected _engine: Engine;
  125876. protected _maxSize: number;
  125877. protected _mainTextureDesiredSize: ISize;
  125878. protected _mainTexture: RenderTargetTexture;
  125879. protected _shouldRender: boolean;
  125880. protected _postProcesses: PostProcess[];
  125881. protected _textures: BaseTexture[];
  125882. protected _emissiveTextureAndColor: {
  125883. texture: Nullable<BaseTexture>;
  125884. color: Color4;
  125885. };
  125886. /**
  125887. * The name of the layer
  125888. */
  125889. name: string;
  125890. /**
  125891. * The clear color of the texture used to generate the glow map.
  125892. */
  125893. neutralColor: Color4;
  125894. /**
  125895. * Specifies whether the highlight layer is enabled or not.
  125896. */
  125897. isEnabled: boolean;
  125898. /**
  125899. * Gets the camera attached to the layer.
  125900. */
  125901. get camera(): Nullable<Camera>;
  125902. /**
  125903. * Gets the rendering group id the layer should render in.
  125904. */
  125905. get renderingGroupId(): number;
  125906. set renderingGroupId(renderingGroupId: number);
  125907. /**
  125908. * An event triggered when the effect layer has been disposed.
  125909. */
  125910. onDisposeObservable: Observable<EffectLayer>;
  125911. /**
  125912. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  125913. */
  125914. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  125915. /**
  125916. * An event triggered when the generated texture is being merged in the scene.
  125917. */
  125918. onBeforeComposeObservable: Observable<EffectLayer>;
  125919. /**
  125920. * An event triggered when the mesh is rendered into the effect render target.
  125921. */
  125922. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  125923. /**
  125924. * An event triggered after the mesh has been rendered into the effect render target.
  125925. */
  125926. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  125927. /**
  125928. * An event triggered when the generated texture has been merged in the scene.
  125929. */
  125930. onAfterComposeObservable: Observable<EffectLayer>;
  125931. /**
  125932. * An event triggered when the efffect layer changes its size.
  125933. */
  125934. onSizeChangedObservable: Observable<EffectLayer>;
  125935. /** @hidden */
  125936. static _SceneComponentInitialization: (scene: Scene) => void;
  125937. /**
  125938. * Instantiates a new effect Layer and references it in the scene.
  125939. * @param name The name of the layer
  125940. * @param scene The scene to use the layer in
  125941. */
  125942. constructor(
  125943. /** The Friendly of the effect in the scene */
  125944. name: string, scene: Scene);
  125945. /**
  125946. * Get the effect name of the layer.
  125947. * @return The effect name
  125948. */
  125949. abstract getEffectName(): string;
  125950. /**
  125951. * Checks for the readiness of the element composing the layer.
  125952. * @param subMesh the mesh to check for
  125953. * @param useInstances specify whether or not to use instances to render the mesh
  125954. * @return true if ready otherwise, false
  125955. */
  125956. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  125957. /**
  125958. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  125959. * @returns true if the effect requires stencil during the main canvas render pass.
  125960. */
  125961. abstract needStencil(): boolean;
  125962. /**
  125963. * Create the merge effect. This is the shader use to blit the information back
  125964. * to the main canvas at the end of the scene rendering.
  125965. * @returns The effect containing the shader used to merge the effect on the main canvas
  125966. */
  125967. protected abstract _createMergeEffect(): Effect;
  125968. /**
  125969. * Creates the render target textures and post processes used in the effect layer.
  125970. */
  125971. protected abstract _createTextureAndPostProcesses(): void;
  125972. /**
  125973. * Implementation specific of rendering the generating effect on the main canvas.
  125974. * @param effect The effect used to render through
  125975. */
  125976. protected abstract _internalRender(effect: Effect): void;
  125977. /**
  125978. * Sets the required values for both the emissive texture and and the main color.
  125979. */
  125980. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  125981. /**
  125982. * Free any resources and references associated to a mesh.
  125983. * Internal use
  125984. * @param mesh The mesh to free.
  125985. */
  125986. abstract _disposeMesh(mesh: Mesh): void;
  125987. /**
  125988. * Serializes this layer (Glow or Highlight for example)
  125989. * @returns a serialized layer object
  125990. */
  125991. abstract serialize?(): any;
  125992. /**
  125993. * Initializes the effect layer with the required options.
  125994. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  125995. */
  125996. protected _init(options: Partial<IEffectLayerOptions>): void;
  125997. /**
  125998. * Generates the index buffer of the full screen quad blending to the main canvas.
  125999. */
  126000. private _generateIndexBuffer;
  126001. /**
  126002. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  126003. */
  126004. private _generateVertexBuffer;
  126005. /**
  126006. * Sets the main texture desired size which is the closest power of two
  126007. * of the engine canvas size.
  126008. */
  126009. private _setMainTextureSize;
  126010. /**
  126011. * Creates the main texture for the effect layer.
  126012. */
  126013. protected _createMainTexture(): void;
  126014. /**
  126015. * Adds specific effects defines.
  126016. * @param defines The defines to add specifics to.
  126017. */
  126018. protected _addCustomEffectDefines(defines: string[]): void;
  126019. /**
  126020. * Checks for the readiness of the element composing the layer.
  126021. * @param subMesh the mesh to check for
  126022. * @param useInstances specify whether or not to use instances to render the mesh
  126023. * @param emissiveTexture the associated emissive texture used to generate the glow
  126024. * @return true if ready otherwise, false
  126025. */
  126026. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  126027. /**
  126028. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  126029. */
  126030. render(): void;
  126031. /**
  126032. * Determine if a given mesh will be used in the current effect.
  126033. * @param mesh mesh to test
  126034. * @returns true if the mesh will be used
  126035. */
  126036. hasMesh(mesh: AbstractMesh): boolean;
  126037. /**
  126038. * Returns true if the layer contains information to display, otherwise false.
  126039. * @returns true if the glow layer should be rendered
  126040. */
  126041. shouldRender(): boolean;
  126042. /**
  126043. * Returns true if the mesh should render, otherwise false.
  126044. * @param mesh The mesh to render
  126045. * @returns true if it should render otherwise false
  126046. */
  126047. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  126048. /**
  126049. * Returns true if the mesh can be rendered, otherwise false.
  126050. * @param mesh The mesh to render
  126051. * @param material The material used on the mesh
  126052. * @returns true if it can be rendered otherwise false
  126053. */
  126054. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126055. /**
  126056. * Returns true if the mesh should render, otherwise false.
  126057. * @param mesh The mesh to render
  126058. * @returns true if it should render otherwise false
  126059. */
  126060. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  126061. /**
  126062. * Renders the submesh passed in parameter to the generation map.
  126063. */
  126064. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  126065. /**
  126066. * Defines whether the current material of the mesh should be use to render the effect.
  126067. * @param mesh defines the current mesh to render
  126068. */
  126069. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126070. /**
  126071. * Rebuild the required buffers.
  126072. * @hidden Internal use only.
  126073. */
  126074. _rebuild(): void;
  126075. /**
  126076. * Dispose only the render target textures and post process.
  126077. */
  126078. private _disposeTextureAndPostProcesses;
  126079. /**
  126080. * Dispose the highlight layer and free resources.
  126081. */
  126082. dispose(): void;
  126083. /**
  126084. * Gets the class name of the effect layer
  126085. * @returns the string with the class name of the effect layer
  126086. */
  126087. getClassName(): string;
  126088. /**
  126089. * Creates an effect layer from parsed effect layer data
  126090. * @param parsedEffectLayer defines effect layer data
  126091. * @param scene defines the current scene
  126092. * @param rootUrl defines the root URL containing the effect layer information
  126093. * @returns a parsed effect Layer
  126094. */
  126095. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  126096. }
  126097. }
  126098. declare module BABYLON {
  126099. interface AbstractScene {
  126100. /**
  126101. * The list of effect layers (highlights/glow) added to the scene
  126102. * @see http://doc.babylonjs.com/how_to/highlight_layer
  126103. * @see http://doc.babylonjs.com/how_to/glow_layer
  126104. */
  126105. effectLayers: Array<EffectLayer>;
  126106. /**
  126107. * Removes the given effect layer from this scene.
  126108. * @param toRemove defines the effect layer to remove
  126109. * @returns the index of the removed effect layer
  126110. */
  126111. removeEffectLayer(toRemove: EffectLayer): number;
  126112. /**
  126113. * Adds the given effect layer to this scene
  126114. * @param newEffectLayer defines the effect layer to add
  126115. */
  126116. addEffectLayer(newEffectLayer: EffectLayer): void;
  126117. }
  126118. /**
  126119. * Defines the layer scene component responsible to manage any effect layers
  126120. * in a given scene.
  126121. */
  126122. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  126123. /**
  126124. * The component name helpfull to identify the component in the list of scene components.
  126125. */
  126126. readonly name: string;
  126127. /**
  126128. * The scene the component belongs to.
  126129. */
  126130. scene: Scene;
  126131. private _engine;
  126132. private _renderEffects;
  126133. private _needStencil;
  126134. private _previousStencilState;
  126135. /**
  126136. * Creates a new instance of the component for the given scene
  126137. * @param scene Defines the scene to register the component in
  126138. */
  126139. constructor(scene: Scene);
  126140. /**
  126141. * Registers the component in a given scene
  126142. */
  126143. register(): void;
  126144. /**
  126145. * Rebuilds the elements related to this component in case of
  126146. * context lost for instance.
  126147. */
  126148. rebuild(): void;
  126149. /**
  126150. * Serializes the component data to the specified json object
  126151. * @param serializationObject The object to serialize to
  126152. */
  126153. serialize(serializationObject: any): void;
  126154. /**
  126155. * Adds all the elements from the container to the scene
  126156. * @param container the container holding the elements
  126157. */
  126158. addFromContainer(container: AbstractScene): void;
  126159. /**
  126160. * Removes all the elements in the container from the scene
  126161. * @param container contains the elements to remove
  126162. * @param dispose if the removed element should be disposed (default: false)
  126163. */
  126164. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126165. /**
  126166. * Disposes the component and the associated ressources.
  126167. */
  126168. dispose(): void;
  126169. private _isReadyForMesh;
  126170. private _renderMainTexture;
  126171. private _setStencil;
  126172. private _setStencilBack;
  126173. private _draw;
  126174. private _drawCamera;
  126175. private _drawRenderingGroup;
  126176. }
  126177. }
  126178. declare module BABYLON {
  126179. /** @hidden */
  126180. export var glowMapMergePixelShader: {
  126181. name: string;
  126182. shader: string;
  126183. };
  126184. }
  126185. declare module BABYLON {
  126186. /** @hidden */
  126187. export var glowMapMergeVertexShader: {
  126188. name: string;
  126189. shader: string;
  126190. };
  126191. }
  126192. declare module BABYLON {
  126193. interface AbstractScene {
  126194. /**
  126195. * Return a the first highlight layer of the scene with a given name.
  126196. * @param name The name of the highlight layer to look for.
  126197. * @return The highlight layer if found otherwise null.
  126198. */
  126199. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  126200. }
  126201. /**
  126202. * Glow layer options. This helps customizing the behaviour
  126203. * of the glow layer.
  126204. */
  126205. export interface IGlowLayerOptions {
  126206. /**
  126207. * Multiplication factor apply to the canvas size to compute the render target size
  126208. * used to generated the glowing objects (the smaller the faster).
  126209. */
  126210. mainTextureRatio: number;
  126211. /**
  126212. * Enforces a fixed size texture to ensure resize independant blur.
  126213. */
  126214. mainTextureFixedSize?: number;
  126215. /**
  126216. * How big is the kernel of the blur texture.
  126217. */
  126218. blurKernelSize: number;
  126219. /**
  126220. * The camera attached to the layer.
  126221. */
  126222. camera: Nullable<Camera>;
  126223. /**
  126224. * Enable MSAA by chosing the number of samples.
  126225. */
  126226. mainTextureSamples?: number;
  126227. /**
  126228. * The rendering group to draw the layer in.
  126229. */
  126230. renderingGroupId: number;
  126231. }
  126232. /**
  126233. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  126234. *
  126235. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  126236. *
  126237. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  126238. */
  126239. export class GlowLayer extends EffectLayer {
  126240. /**
  126241. * Effect Name of the layer.
  126242. */
  126243. static readonly EffectName: string;
  126244. /**
  126245. * The default blur kernel size used for the glow.
  126246. */
  126247. static DefaultBlurKernelSize: number;
  126248. /**
  126249. * The default texture size ratio used for the glow.
  126250. */
  126251. static DefaultTextureRatio: number;
  126252. /**
  126253. * Sets the kernel size of the blur.
  126254. */
  126255. set blurKernelSize(value: number);
  126256. /**
  126257. * Gets the kernel size of the blur.
  126258. */
  126259. get blurKernelSize(): number;
  126260. /**
  126261. * Sets the glow intensity.
  126262. */
  126263. set intensity(value: number);
  126264. /**
  126265. * Gets the glow intensity.
  126266. */
  126267. get intensity(): number;
  126268. private _options;
  126269. private _intensity;
  126270. private _horizontalBlurPostprocess1;
  126271. private _verticalBlurPostprocess1;
  126272. private _horizontalBlurPostprocess2;
  126273. private _verticalBlurPostprocess2;
  126274. private _blurTexture1;
  126275. private _blurTexture2;
  126276. private _postProcesses1;
  126277. private _postProcesses2;
  126278. private _includedOnlyMeshes;
  126279. private _excludedMeshes;
  126280. private _meshesUsingTheirOwnMaterials;
  126281. /**
  126282. * Callback used to let the user override the color selection on a per mesh basis
  126283. */
  126284. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  126285. /**
  126286. * Callback used to let the user override the texture selection on a per mesh basis
  126287. */
  126288. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  126289. /**
  126290. * Instantiates a new glow Layer and references it to the scene.
  126291. * @param name The name of the layer
  126292. * @param scene The scene to use the layer in
  126293. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  126294. */
  126295. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  126296. /**
  126297. * Get the effect name of the layer.
  126298. * @return The effect name
  126299. */
  126300. getEffectName(): string;
  126301. /**
  126302. * Create the merge effect. This is the shader use to blit the information back
  126303. * to the main canvas at the end of the scene rendering.
  126304. */
  126305. protected _createMergeEffect(): Effect;
  126306. /**
  126307. * Creates the render target textures and post processes used in the glow layer.
  126308. */
  126309. protected _createTextureAndPostProcesses(): void;
  126310. /**
  126311. * Checks for the readiness of the element composing the layer.
  126312. * @param subMesh the mesh to check for
  126313. * @param useInstances specify wether or not to use instances to render the mesh
  126314. * @param emissiveTexture the associated emissive texture used to generate the glow
  126315. * @return true if ready otherwise, false
  126316. */
  126317. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126318. /**
  126319. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126320. */
  126321. needStencil(): boolean;
  126322. /**
  126323. * Returns true if the mesh can be rendered, otherwise false.
  126324. * @param mesh The mesh to render
  126325. * @param material The material used on the mesh
  126326. * @returns true if it can be rendered otherwise false
  126327. */
  126328. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126329. /**
  126330. * Implementation specific of rendering the generating effect on the main canvas.
  126331. * @param effect The effect used to render through
  126332. */
  126333. protected _internalRender(effect: Effect): void;
  126334. /**
  126335. * Sets the required values for both the emissive texture and and the main color.
  126336. */
  126337. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126338. /**
  126339. * Returns true if the mesh should render, otherwise false.
  126340. * @param mesh The mesh to render
  126341. * @returns true if it should render otherwise false
  126342. */
  126343. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126344. /**
  126345. * Adds specific effects defines.
  126346. * @param defines The defines to add specifics to.
  126347. */
  126348. protected _addCustomEffectDefines(defines: string[]): void;
  126349. /**
  126350. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  126351. * @param mesh The mesh to exclude from the glow layer
  126352. */
  126353. addExcludedMesh(mesh: Mesh): void;
  126354. /**
  126355. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  126356. * @param mesh The mesh to remove
  126357. */
  126358. removeExcludedMesh(mesh: Mesh): void;
  126359. /**
  126360. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  126361. * @param mesh The mesh to include in the glow layer
  126362. */
  126363. addIncludedOnlyMesh(mesh: Mesh): void;
  126364. /**
  126365. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  126366. * @param mesh The mesh to remove
  126367. */
  126368. removeIncludedOnlyMesh(mesh: Mesh): void;
  126369. /**
  126370. * Determine if a given mesh will be used in the glow layer
  126371. * @param mesh The mesh to test
  126372. * @returns true if the mesh will be highlighted by the current glow layer
  126373. */
  126374. hasMesh(mesh: AbstractMesh): boolean;
  126375. /**
  126376. * Defines whether the current material of the mesh should be use to render the effect.
  126377. * @param mesh defines the current mesh to render
  126378. */
  126379. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126380. /**
  126381. * Add a mesh to be rendered through its own material and not with emissive only.
  126382. * @param mesh The mesh for which we need to use its material
  126383. */
  126384. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  126385. /**
  126386. * Remove a mesh from being rendered through its own material and not with emissive only.
  126387. * @param mesh The mesh for which we need to not use its material
  126388. */
  126389. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  126390. /**
  126391. * Free any resources and references associated to a mesh.
  126392. * Internal use
  126393. * @param mesh The mesh to free.
  126394. * @hidden
  126395. */
  126396. _disposeMesh(mesh: Mesh): void;
  126397. /**
  126398. * Gets the class name of the effect layer
  126399. * @returns the string with the class name of the effect layer
  126400. */
  126401. getClassName(): string;
  126402. /**
  126403. * Serializes this glow layer
  126404. * @returns a serialized glow layer object
  126405. */
  126406. serialize(): any;
  126407. /**
  126408. * Creates a Glow Layer from parsed glow layer data
  126409. * @param parsedGlowLayer defines glow layer data
  126410. * @param scene defines the current scene
  126411. * @param rootUrl defines the root URL containing the glow layer information
  126412. * @returns a parsed Glow Layer
  126413. */
  126414. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  126415. }
  126416. }
  126417. declare module BABYLON {
  126418. /** @hidden */
  126419. export var glowBlurPostProcessPixelShader: {
  126420. name: string;
  126421. shader: string;
  126422. };
  126423. }
  126424. declare module BABYLON {
  126425. interface AbstractScene {
  126426. /**
  126427. * Return a the first highlight layer of the scene with a given name.
  126428. * @param name The name of the highlight layer to look for.
  126429. * @return The highlight layer if found otherwise null.
  126430. */
  126431. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  126432. }
  126433. /**
  126434. * Highlight layer options. This helps customizing the behaviour
  126435. * of the highlight layer.
  126436. */
  126437. export interface IHighlightLayerOptions {
  126438. /**
  126439. * Multiplication factor apply to the canvas size to compute the render target size
  126440. * used to generated the glowing objects (the smaller the faster).
  126441. */
  126442. mainTextureRatio: number;
  126443. /**
  126444. * Enforces a fixed size texture to ensure resize independant blur.
  126445. */
  126446. mainTextureFixedSize?: number;
  126447. /**
  126448. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  126449. * of the picture to blur (the smaller the faster).
  126450. */
  126451. blurTextureSizeRatio: number;
  126452. /**
  126453. * How big in texel of the blur texture is the vertical blur.
  126454. */
  126455. blurVerticalSize: number;
  126456. /**
  126457. * How big in texel of the blur texture is the horizontal blur.
  126458. */
  126459. blurHorizontalSize: number;
  126460. /**
  126461. * Alpha blending mode used to apply the blur. Default is combine.
  126462. */
  126463. alphaBlendingMode: number;
  126464. /**
  126465. * The camera attached to the layer.
  126466. */
  126467. camera: Nullable<Camera>;
  126468. /**
  126469. * Should we display highlight as a solid stroke?
  126470. */
  126471. isStroke?: boolean;
  126472. /**
  126473. * The rendering group to draw the layer in.
  126474. */
  126475. renderingGroupId: number;
  126476. }
  126477. /**
  126478. * The highlight layer Helps adding a glow effect around a mesh.
  126479. *
  126480. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  126481. * glowy meshes to your scene.
  126482. *
  126483. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  126484. */
  126485. export class HighlightLayer extends EffectLayer {
  126486. name: string;
  126487. /**
  126488. * Effect Name of the highlight layer.
  126489. */
  126490. static readonly EffectName: string;
  126491. /**
  126492. * The neutral color used during the preparation of the glow effect.
  126493. * This is black by default as the blend operation is a blend operation.
  126494. */
  126495. static NeutralColor: Color4;
  126496. /**
  126497. * Stencil value used for glowing meshes.
  126498. */
  126499. static GlowingMeshStencilReference: number;
  126500. /**
  126501. * Stencil value used for the other meshes in the scene.
  126502. */
  126503. static NormalMeshStencilReference: number;
  126504. /**
  126505. * Specifies whether or not the inner glow is ACTIVE in the layer.
  126506. */
  126507. innerGlow: boolean;
  126508. /**
  126509. * Specifies whether or not the outer glow is ACTIVE in the layer.
  126510. */
  126511. outerGlow: boolean;
  126512. /**
  126513. * Specifies the horizontal size of the blur.
  126514. */
  126515. set blurHorizontalSize(value: number);
  126516. /**
  126517. * Specifies the vertical size of the blur.
  126518. */
  126519. set blurVerticalSize(value: number);
  126520. /**
  126521. * Gets the horizontal size of the blur.
  126522. */
  126523. get blurHorizontalSize(): number;
  126524. /**
  126525. * Gets the vertical size of the blur.
  126526. */
  126527. get blurVerticalSize(): number;
  126528. /**
  126529. * An event triggered when the highlight layer is being blurred.
  126530. */
  126531. onBeforeBlurObservable: Observable<HighlightLayer>;
  126532. /**
  126533. * An event triggered when the highlight layer has been blurred.
  126534. */
  126535. onAfterBlurObservable: Observable<HighlightLayer>;
  126536. private _instanceGlowingMeshStencilReference;
  126537. private _options;
  126538. private _downSamplePostprocess;
  126539. private _horizontalBlurPostprocess;
  126540. private _verticalBlurPostprocess;
  126541. private _blurTexture;
  126542. private _meshes;
  126543. private _excludedMeshes;
  126544. /**
  126545. * Instantiates a new highlight Layer and references it to the scene..
  126546. * @param name The name of the layer
  126547. * @param scene The scene to use the layer in
  126548. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  126549. */
  126550. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  126551. /**
  126552. * Get the effect name of the layer.
  126553. * @return The effect name
  126554. */
  126555. getEffectName(): string;
  126556. /**
  126557. * Create the merge effect. This is the shader use to blit the information back
  126558. * to the main canvas at the end of the scene rendering.
  126559. */
  126560. protected _createMergeEffect(): Effect;
  126561. /**
  126562. * Creates the render target textures and post processes used in the highlight layer.
  126563. */
  126564. protected _createTextureAndPostProcesses(): void;
  126565. /**
  126566. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  126567. */
  126568. needStencil(): boolean;
  126569. /**
  126570. * Checks for the readiness of the element composing the layer.
  126571. * @param subMesh the mesh to check for
  126572. * @param useInstances specify wether or not to use instances to render the mesh
  126573. * @param emissiveTexture the associated emissive texture used to generate the glow
  126574. * @return true if ready otherwise, false
  126575. */
  126576. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126577. /**
  126578. * Implementation specific of rendering the generating effect on the main canvas.
  126579. * @param effect The effect used to render through
  126580. */
  126581. protected _internalRender(effect: Effect): void;
  126582. /**
  126583. * Returns true if the layer contains information to display, otherwise false.
  126584. */
  126585. shouldRender(): boolean;
  126586. /**
  126587. * Returns true if the mesh should render, otherwise false.
  126588. * @param mesh The mesh to render
  126589. * @returns true if it should render otherwise false
  126590. */
  126591. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126592. /**
  126593. * Sets the required values for both the emissive texture and and the main color.
  126594. */
  126595. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126596. /**
  126597. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  126598. * @param mesh The mesh to exclude from the highlight layer
  126599. */
  126600. addExcludedMesh(mesh: Mesh): void;
  126601. /**
  126602. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  126603. * @param mesh The mesh to highlight
  126604. */
  126605. removeExcludedMesh(mesh: Mesh): void;
  126606. /**
  126607. * Determine if a given mesh will be highlighted by the current HighlightLayer
  126608. * @param mesh mesh to test
  126609. * @returns true if the mesh will be highlighted by the current HighlightLayer
  126610. */
  126611. hasMesh(mesh: AbstractMesh): boolean;
  126612. /**
  126613. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  126614. * @param mesh The mesh to highlight
  126615. * @param color The color of the highlight
  126616. * @param glowEmissiveOnly Extract the glow from the emissive texture
  126617. */
  126618. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  126619. /**
  126620. * Remove a mesh from the highlight layer in order to make it stop glowing.
  126621. * @param mesh The mesh to highlight
  126622. */
  126623. removeMesh(mesh: Mesh): void;
  126624. /**
  126625. * Remove all the meshes currently referenced in the highlight layer
  126626. */
  126627. removeAllMeshes(): void;
  126628. /**
  126629. * Force the stencil to the normal expected value for none glowing parts
  126630. */
  126631. private _defaultStencilReference;
  126632. /**
  126633. * Free any resources and references associated to a mesh.
  126634. * Internal use
  126635. * @param mesh The mesh to free.
  126636. * @hidden
  126637. */
  126638. _disposeMesh(mesh: Mesh): void;
  126639. /**
  126640. * Dispose the highlight layer and free resources.
  126641. */
  126642. dispose(): void;
  126643. /**
  126644. * Gets the class name of the effect layer
  126645. * @returns the string with the class name of the effect layer
  126646. */
  126647. getClassName(): string;
  126648. /**
  126649. * Serializes this Highlight layer
  126650. * @returns a serialized Highlight layer object
  126651. */
  126652. serialize(): any;
  126653. /**
  126654. * Creates a Highlight layer from parsed Highlight layer data
  126655. * @param parsedHightlightLayer defines the Highlight layer data
  126656. * @param scene defines the current scene
  126657. * @param rootUrl defines the root URL containing the Highlight layer information
  126658. * @returns a parsed Highlight layer
  126659. */
  126660. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  126661. }
  126662. }
  126663. declare module BABYLON {
  126664. interface AbstractScene {
  126665. /**
  126666. * The list of layers (background and foreground) of the scene
  126667. */
  126668. layers: Array<Layer>;
  126669. }
  126670. /**
  126671. * Defines the layer scene component responsible to manage any layers
  126672. * in a given scene.
  126673. */
  126674. export class LayerSceneComponent implements ISceneComponent {
  126675. /**
  126676. * The component name helpfull to identify the component in the list of scene components.
  126677. */
  126678. readonly name: string;
  126679. /**
  126680. * The scene the component belongs to.
  126681. */
  126682. scene: Scene;
  126683. private _engine;
  126684. /**
  126685. * Creates a new instance of the component for the given scene
  126686. * @param scene Defines the scene to register the component in
  126687. */
  126688. constructor(scene: Scene);
  126689. /**
  126690. * Registers the component in a given scene
  126691. */
  126692. register(): void;
  126693. /**
  126694. * Rebuilds the elements related to this component in case of
  126695. * context lost for instance.
  126696. */
  126697. rebuild(): void;
  126698. /**
  126699. * Disposes the component and the associated ressources.
  126700. */
  126701. dispose(): void;
  126702. private _draw;
  126703. private _drawCameraPredicate;
  126704. private _drawCameraBackground;
  126705. private _drawCameraForeground;
  126706. private _drawRenderTargetPredicate;
  126707. private _drawRenderTargetBackground;
  126708. private _drawRenderTargetForeground;
  126709. /**
  126710. * Adds all the elements from the container to the scene
  126711. * @param container the container holding the elements
  126712. */
  126713. addFromContainer(container: AbstractScene): void;
  126714. /**
  126715. * Removes all the elements in the container from the scene
  126716. * @param container contains the elements to remove
  126717. * @param dispose if the removed element should be disposed (default: false)
  126718. */
  126719. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126720. }
  126721. }
  126722. declare module BABYLON {
  126723. /** @hidden */
  126724. export var layerPixelShader: {
  126725. name: string;
  126726. shader: string;
  126727. };
  126728. }
  126729. declare module BABYLON {
  126730. /** @hidden */
  126731. export var layerVertexShader: {
  126732. name: string;
  126733. shader: string;
  126734. };
  126735. }
  126736. declare module BABYLON {
  126737. /**
  126738. * This represents a full screen 2d layer.
  126739. * This can be useful to display a picture in the background of your scene for instance.
  126740. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126741. */
  126742. export class Layer {
  126743. /**
  126744. * Define the name of the layer.
  126745. */
  126746. name: string;
  126747. /**
  126748. * Define the texture the layer should display.
  126749. */
  126750. texture: Nullable<Texture>;
  126751. /**
  126752. * Is the layer in background or foreground.
  126753. */
  126754. isBackground: boolean;
  126755. /**
  126756. * Define the color of the layer (instead of texture).
  126757. */
  126758. color: Color4;
  126759. /**
  126760. * Define the scale of the layer in order to zoom in out of the texture.
  126761. */
  126762. scale: Vector2;
  126763. /**
  126764. * Define an offset for the layer in order to shift the texture.
  126765. */
  126766. offset: Vector2;
  126767. /**
  126768. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  126769. */
  126770. alphaBlendingMode: number;
  126771. /**
  126772. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  126773. * Alpha test will not mix with the background color in case of transparency.
  126774. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  126775. */
  126776. alphaTest: boolean;
  126777. /**
  126778. * Define a mask to restrict the layer to only some of the scene cameras.
  126779. */
  126780. layerMask: number;
  126781. /**
  126782. * Define the list of render target the layer is visible into.
  126783. */
  126784. renderTargetTextures: RenderTargetTexture[];
  126785. /**
  126786. * Define if the layer is only used in renderTarget or if it also
  126787. * renders in the main frame buffer of the canvas.
  126788. */
  126789. renderOnlyInRenderTargetTextures: boolean;
  126790. private _scene;
  126791. private _vertexBuffers;
  126792. private _indexBuffer;
  126793. private _effect;
  126794. private _previousDefines;
  126795. /**
  126796. * An event triggered when the layer is disposed.
  126797. */
  126798. onDisposeObservable: Observable<Layer>;
  126799. private _onDisposeObserver;
  126800. /**
  126801. * Back compatibility with callback before the onDisposeObservable existed.
  126802. * The set callback will be triggered when the layer has been disposed.
  126803. */
  126804. set onDispose(callback: () => void);
  126805. /**
  126806. * An event triggered before rendering the scene
  126807. */
  126808. onBeforeRenderObservable: Observable<Layer>;
  126809. private _onBeforeRenderObserver;
  126810. /**
  126811. * Back compatibility with callback before the onBeforeRenderObservable existed.
  126812. * The set callback will be triggered just before rendering the layer.
  126813. */
  126814. set onBeforeRender(callback: () => void);
  126815. /**
  126816. * An event triggered after rendering the scene
  126817. */
  126818. onAfterRenderObservable: Observable<Layer>;
  126819. private _onAfterRenderObserver;
  126820. /**
  126821. * Back compatibility with callback before the onAfterRenderObservable existed.
  126822. * The set callback will be triggered just after rendering the layer.
  126823. */
  126824. set onAfterRender(callback: () => void);
  126825. /**
  126826. * Instantiates a new layer.
  126827. * This represents a full screen 2d layer.
  126828. * This can be useful to display a picture in the background of your scene for instance.
  126829. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126830. * @param name Define the name of the layer in the scene
  126831. * @param imgUrl Define the url of the texture to display in the layer
  126832. * @param scene Define the scene the layer belongs to
  126833. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  126834. * @param color Defines a color for the layer
  126835. */
  126836. constructor(
  126837. /**
  126838. * Define the name of the layer.
  126839. */
  126840. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  126841. private _createIndexBuffer;
  126842. /** @hidden */
  126843. _rebuild(): void;
  126844. /**
  126845. * Renders the layer in the scene.
  126846. */
  126847. render(): void;
  126848. /**
  126849. * Disposes and releases the associated ressources.
  126850. */
  126851. dispose(): void;
  126852. }
  126853. }
  126854. declare module BABYLON {
  126855. /** @hidden */
  126856. export var lensFlarePixelShader: {
  126857. name: string;
  126858. shader: string;
  126859. };
  126860. }
  126861. declare module BABYLON {
  126862. /** @hidden */
  126863. export var lensFlareVertexShader: {
  126864. name: string;
  126865. shader: string;
  126866. };
  126867. }
  126868. declare module BABYLON {
  126869. /**
  126870. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126871. * It is usually composed of several `lensFlare`.
  126872. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126873. */
  126874. export class LensFlareSystem {
  126875. /**
  126876. * Define the name of the lens flare system
  126877. */
  126878. name: string;
  126879. /**
  126880. * List of lens flares used in this system.
  126881. */
  126882. lensFlares: LensFlare[];
  126883. /**
  126884. * Define a limit from the border the lens flare can be visible.
  126885. */
  126886. borderLimit: number;
  126887. /**
  126888. * Define a viewport border we do not want to see the lens flare in.
  126889. */
  126890. viewportBorder: number;
  126891. /**
  126892. * Define a predicate which could limit the list of meshes able to occlude the effect.
  126893. */
  126894. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  126895. /**
  126896. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  126897. */
  126898. layerMask: number;
  126899. /**
  126900. * Define the id of the lens flare system in the scene.
  126901. * (equal to name by default)
  126902. */
  126903. id: string;
  126904. private _scene;
  126905. private _emitter;
  126906. private _vertexBuffers;
  126907. private _indexBuffer;
  126908. private _effect;
  126909. private _positionX;
  126910. private _positionY;
  126911. private _isEnabled;
  126912. /** @hidden */
  126913. static _SceneComponentInitialization: (scene: Scene) => void;
  126914. /**
  126915. * Instantiates a lens flare system.
  126916. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  126917. * It is usually composed of several `lensFlare`.
  126918. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126919. * @param name Define the name of the lens flare system in the scene
  126920. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  126921. * @param scene Define the scene the lens flare system belongs to
  126922. */
  126923. constructor(
  126924. /**
  126925. * Define the name of the lens flare system
  126926. */
  126927. name: string, emitter: any, scene: Scene);
  126928. /**
  126929. * Define if the lens flare system is enabled.
  126930. */
  126931. get isEnabled(): boolean;
  126932. set isEnabled(value: boolean);
  126933. /**
  126934. * Get the scene the effects belongs to.
  126935. * @returns the scene holding the lens flare system
  126936. */
  126937. getScene(): Scene;
  126938. /**
  126939. * Get the emitter of the lens flare system.
  126940. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  126941. * @returns the emitter of the lens flare system
  126942. */
  126943. getEmitter(): any;
  126944. /**
  126945. * Set the emitter of the lens flare system.
  126946. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  126947. * @param newEmitter Define the new emitter of the system
  126948. */
  126949. setEmitter(newEmitter: any): void;
  126950. /**
  126951. * Get the lens flare system emitter position.
  126952. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  126953. * @returns the position
  126954. */
  126955. getEmitterPosition(): Vector3;
  126956. /**
  126957. * @hidden
  126958. */
  126959. computeEffectivePosition(globalViewport: Viewport): boolean;
  126960. /** @hidden */
  126961. _isVisible(): boolean;
  126962. /**
  126963. * @hidden
  126964. */
  126965. render(): boolean;
  126966. /**
  126967. * Dispose and release the lens flare with its associated resources.
  126968. */
  126969. dispose(): void;
  126970. /**
  126971. * Parse a lens flare system from a JSON repressentation
  126972. * @param parsedLensFlareSystem Define the JSON to parse
  126973. * @param scene Define the scene the parsed system should be instantiated in
  126974. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  126975. * @returns the parsed system
  126976. */
  126977. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  126978. /**
  126979. * Serialize the current Lens Flare System into a JSON representation.
  126980. * @returns the serialized JSON
  126981. */
  126982. serialize(): any;
  126983. }
  126984. }
  126985. declare module BABYLON {
  126986. /**
  126987. * This represents one of the lens effect in a `lensFlareSystem`.
  126988. * It controls one of the indiviual texture used in the effect.
  126989. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  126990. */
  126991. export class LensFlare {
  126992. /**
  126993. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  126994. */
  126995. size: number;
  126996. /**
  126997. * 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.
  126998. */
  126999. position: number;
  127000. /**
  127001. * Define the lens color.
  127002. */
  127003. color: Color3;
  127004. /**
  127005. * Define the lens texture.
  127006. */
  127007. texture: Nullable<Texture>;
  127008. /**
  127009. * Define the alpha mode to render this particular lens.
  127010. */
  127011. alphaMode: number;
  127012. private _system;
  127013. /**
  127014. * Creates a new Lens Flare.
  127015. * This represents one of the lens effect in a `lensFlareSystem`.
  127016. * It controls one of the indiviual texture used in the effect.
  127017. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127018. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  127019. * @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.
  127020. * @param color Define the lens color
  127021. * @param imgUrl Define the lens texture url
  127022. * @param system Define the `lensFlareSystem` this flare is part of
  127023. * @returns The newly created Lens Flare
  127024. */
  127025. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  127026. /**
  127027. * Instantiates a new Lens Flare.
  127028. * This represents one of the lens effect in a `lensFlareSystem`.
  127029. * It controls one of the indiviual texture used in the effect.
  127030. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127031. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  127032. * @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.
  127033. * @param color Define the lens color
  127034. * @param imgUrl Define the lens texture url
  127035. * @param system Define the `lensFlareSystem` this flare is part of
  127036. */
  127037. constructor(
  127038. /**
  127039. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127040. */
  127041. size: number,
  127042. /**
  127043. * 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.
  127044. */
  127045. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  127046. /**
  127047. * Dispose and release the lens flare with its associated resources.
  127048. */
  127049. dispose(): void;
  127050. }
  127051. }
  127052. declare module BABYLON {
  127053. interface AbstractScene {
  127054. /**
  127055. * The list of lens flare system added to the scene
  127056. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127057. */
  127058. lensFlareSystems: Array<LensFlareSystem>;
  127059. /**
  127060. * Removes the given lens flare system from this scene.
  127061. * @param toRemove The lens flare system to remove
  127062. * @returns The index of the removed lens flare system
  127063. */
  127064. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  127065. /**
  127066. * Adds the given lens flare system to this scene
  127067. * @param newLensFlareSystem The lens flare system to add
  127068. */
  127069. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  127070. /**
  127071. * Gets a lens flare system using its name
  127072. * @param name defines the name to look for
  127073. * @returns the lens flare system or null if not found
  127074. */
  127075. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  127076. /**
  127077. * Gets a lens flare system using its id
  127078. * @param id defines the id to look for
  127079. * @returns the lens flare system or null if not found
  127080. */
  127081. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  127082. }
  127083. /**
  127084. * Defines the lens flare scene component responsible to manage any lens flares
  127085. * in a given scene.
  127086. */
  127087. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  127088. /**
  127089. * The component name helpfull to identify the component in the list of scene components.
  127090. */
  127091. readonly name: string;
  127092. /**
  127093. * The scene the component belongs to.
  127094. */
  127095. scene: Scene;
  127096. /**
  127097. * Creates a new instance of the component for the given scene
  127098. * @param scene Defines the scene to register the component in
  127099. */
  127100. constructor(scene: Scene);
  127101. /**
  127102. * Registers the component in a given scene
  127103. */
  127104. register(): void;
  127105. /**
  127106. * Rebuilds the elements related to this component in case of
  127107. * context lost for instance.
  127108. */
  127109. rebuild(): void;
  127110. /**
  127111. * Adds all the elements from the container to the scene
  127112. * @param container the container holding the elements
  127113. */
  127114. addFromContainer(container: AbstractScene): void;
  127115. /**
  127116. * Removes all the elements in the container from the scene
  127117. * @param container contains the elements to remove
  127118. * @param dispose if the removed element should be disposed (default: false)
  127119. */
  127120. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127121. /**
  127122. * Serializes the component data to the specified json object
  127123. * @param serializationObject The object to serialize to
  127124. */
  127125. serialize(serializationObject: any): void;
  127126. /**
  127127. * Disposes the component and the associated ressources.
  127128. */
  127129. dispose(): void;
  127130. private _draw;
  127131. }
  127132. }
  127133. declare module BABYLON {
  127134. /** @hidden */
  127135. export var depthPixelShader: {
  127136. name: string;
  127137. shader: string;
  127138. };
  127139. }
  127140. declare module BABYLON {
  127141. /** @hidden */
  127142. export var depthVertexShader: {
  127143. name: string;
  127144. shader: string;
  127145. };
  127146. }
  127147. declare module BABYLON {
  127148. /**
  127149. * This represents a depth renderer in Babylon.
  127150. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127151. */
  127152. export class DepthRenderer {
  127153. private _scene;
  127154. private _depthMap;
  127155. private _effect;
  127156. private readonly _storeNonLinearDepth;
  127157. private readonly _clearColor;
  127158. /** Get if the depth renderer is using packed depth or not */
  127159. readonly isPacked: boolean;
  127160. private _cachedDefines;
  127161. private _camera;
  127162. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  127163. enabled: boolean;
  127164. /**
  127165. * Specifiess that the depth renderer will only be used within
  127166. * the camera it is created for.
  127167. * This can help forcing its rendering during the camera processing.
  127168. */
  127169. useOnlyInActiveCamera: boolean;
  127170. /** @hidden */
  127171. static _SceneComponentInitialization: (scene: Scene) => void;
  127172. /**
  127173. * Instantiates a depth renderer
  127174. * @param scene The scene the renderer belongs to
  127175. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127176. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127177. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127178. */
  127179. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127180. /**
  127181. * Creates the depth rendering effect and checks if the effect is ready.
  127182. * @param subMesh The submesh to be used to render the depth map of
  127183. * @param useInstances If multiple world instances should be used
  127184. * @returns if the depth renderer is ready to render the depth map
  127185. */
  127186. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127187. /**
  127188. * Gets the texture which the depth map will be written to.
  127189. * @returns The depth map texture
  127190. */
  127191. getDepthMap(): RenderTargetTexture;
  127192. /**
  127193. * Disposes of the depth renderer.
  127194. */
  127195. dispose(): void;
  127196. }
  127197. }
  127198. declare module BABYLON {
  127199. /** @hidden */
  127200. export var minmaxReduxPixelShader: {
  127201. name: string;
  127202. shader: string;
  127203. };
  127204. }
  127205. declare module BABYLON {
  127206. /**
  127207. * This class computes a min/max reduction from a texture: it means it computes the minimum
  127208. * and maximum values from all values of the texture.
  127209. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  127210. * The source values are read from the red channel of the texture.
  127211. */
  127212. export class MinMaxReducer {
  127213. /**
  127214. * Observable triggered when the computation has been performed
  127215. */
  127216. onAfterReductionPerformed: Observable<{
  127217. min: number;
  127218. max: number;
  127219. }>;
  127220. protected _camera: Camera;
  127221. protected _sourceTexture: Nullable<RenderTargetTexture>;
  127222. protected _reductionSteps: Nullable<Array<PostProcess>>;
  127223. protected _postProcessManager: PostProcessManager;
  127224. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  127225. protected _forceFullscreenViewport: boolean;
  127226. /**
  127227. * Creates a min/max reducer
  127228. * @param camera The camera to use for the post processes
  127229. */
  127230. constructor(camera: Camera);
  127231. /**
  127232. * Gets the texture used to read the values from.
  127233. */
  127234. get sourceTexture(): Nullable<RenderTargetTexture>;
  127235. /**
  127236. * Sets the source texture to read the values from.
  127237. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  127238. * because in such textures '1' value must not be taken into account to compute the maximum
  127239. * as this value is used to clear the texture.
  127240. * Note that the computation is not activated by calling this function, you must call activate() for that!
  127241. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  127242. * @param depthRedux Indicates if the texture is a depth texture or not
  127243. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  127244. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127245. */
  127246. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127247. /**
  127248. * Defines the refresh rate of the computation.
  127249. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127250. */
  127251. get refreshRate(): number;
  127252. set refreshRate(value: number);
  127253. protected _activated: boolean;
  127254. /**
  127255. * Gets the activation status of the reducer
  127256. */
  127257. get activated(): boolean;
  127258. /**
  127259. * Activates the reduction computation.
  127260. * When activated, the observers registered in onAfterReductionPerformed are
  127261. * called after the compuation is performed
  127262. */
  127263. activate(): void;
  127264. /**
  127265. * Deactivates the reduction computation.
  127266. */
  127267. deactivate(): void;
  127268. /**
  127269. * Disposes the min/max reducer
  127270. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  127271. */
  127272. dispose(disposeAll?: boolean): void;
  127273. }
  127274. }
  127275. declare module BABYLON {
  127276. /**
  127277. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  127278. */
  127279. export class DepthReducer extends MinMaxReducer {
  127280. private _depthRenderer;
  127281. private _depthRendererId;
  127282. /**
  127283. * Gets the depth renderer used for the computation.
  127284. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  127285. */
  127286. get depthRenderer(): Nullable<DepthRenderer>;
  127287. /**
  127288. * Creates a depth reducer
  127289. * @param camera The camera used to render the depth texture
  127290. */
  127291. constructor(camera: Camera);
  127292. /**
  127293. * Sets the depth renderer to use to generate the depth map
  127294. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  127295. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  127296. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127297. */
  127298. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  127299. /** @hidden */
  127300. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127301. /**
  127302. * Activates the reduction computation.
  127303. * When activated, the observers registered in onAfterReductionPerformed are
  127304. * called after the compuation is performed
  127305. */
  127306. activate(): void;
  127307. /**
  127308. * Deactivates the reduction computation.
  127309. */
  127310. deactivate(): void;
  127311. /**
  127312. * Disposes the depth reducer
  127313. * @param disposeAll true to dispose all the resources. You should always call this function with true as the parameter (or without any parameter as it is the default one). This flag is meant to be used internally.
  127314. */
  127315. dispose(disposeAll?: boolean): void;
  127316. }
  127317. }
  127318. declare module BABYLON {
  127319. /**
  127320. * A CSM implementation allowing casting shadows on large scenes.
  127321. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127322. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  127323. */
  127324. export class CascadedShadowGenerator extends ShadowGenerator {
  127325. private static readonly frustumCornersNDCSpace;
  127326. /**
  127327. * Name of the CSM class
  127328. */
  127329. static CLASSNAME: string;
  127330. /**
  127331. * Defines the default number of cascades used by the CSM.
  127332. */
  127333. static readonly DEFAULT_CASCADES_COUNT: number;
  127334. /**
  127335. * Defines the minimum number of cascades used by the CSM.
  127336. */
  127337. static readonly MIN_CASCADES_COUNT: number;
  127338. /**
  127339. * Defines the maximum number of cascades used by the CSM.
  127340. */
  127341. static readonly MAX_CASCADES_COUNT: number;
  127342. protected _validateFilter(filter: number): number;
  127343. /**
  127344. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  127345. */
  127346. penumbraDarkness: number;
  127347. private _numCascades;
  127348. /**
  127349. * Gets or set the number of cascades used by the CSM.
  127350. */
  127351. get numCascades(): number;
  127352. set numCascades(value: number);
  127353. /**
  127354. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  127355. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  127356. */
  127357. stabilizeCascades: boolean;
  127358. private _freezeShadowCastersBoundingInfo;
  127359. private _freezeShadowCastersBoundingInfoObservable;
  127360. /**
  127361. * Enables or disables the shadow casters bounding info computation.
  127362. * If your shadow casters don't move, you can disable this feature.
  127363. * If it is enabled, the bounding box computation is done every frame.
  127364. */
  127365. get freezeShadowCastersBoundingInfo(): boolean;
  127366. set freezeShadowCastersBoundingInfo(freeze: boolean);
  127367. private _scbiMin;
  127368. private _scbiMax;
  127369. protected _computeShadowCastersBoundingInfo(): void;
  127370. protected _shadowCastersBoundingInfo: BoundingInfo;
  127371. /**
  127372. * Gets or sets the shadow casters bounding info.
  127373. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  127374. * so that the system won't overwrite the bounds you provide
  127375. */
  127376. get shadowCastersBoundingInfo(): BoundingInfo;
  127377. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  127378. protected _breaksAreDirty: boolean;
  127379. protected _minDistance: number;
  127380. protected _maxDistance: number;
  127381. /**
  127382. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  127383. *
  127384. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  127385. * If you don't know these values, simply leave them to their defaults and don't call this function.
  127386. * @param min minimal distance for the breaks (default to 0.)
  127387. * @param max maximal distance for the breaks (default to 1.)
  127388. */
  127389. setMinMaxDistance(min: number, max: number): void;
  127390. /** Gets the minimal distance used in the cascade break computation */
  127391. get minDistance(): number;
  127392. /** Gets the maximal distance used in the cascade break computation */
  127393. get maxDistance(): number;
  127394. /**
  127395. * Gets the class name of that object
  127396. * @returns "CascadedShadowGenerator"
  127397. */
  127398. getClassName(): string;
  127399. private _cascadeMinExtents;
  127400. private _cascadeMaxExtents;
  127401. /**
  127402. * Gets a cascade minimum extents
  127403. * @param cascadeIndex index of the cascade
  127404. * @returns the minimum cascade extents
  127405. */
  127406. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  127407. /**
  127408. * Gets a cascade maximum extents
  127409. * @param cascadeIndex index of the cascade
  127410. * @returns the maximum cascade extents
  127411. */
  127412. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  127413. private _cascades;
  127414. private _currentLayer;
  127415. private _viewSpaceFrustumsZ;
  127416. private _viewMatrices;
  127417. private _projectionMatrices;
  127418. private _transformMatrices;
  127419. private _transformMatricesAsArray;
  127420. private _frustumLengths;
  127421. private _lightSizeUVCorrection;
  127422. private _depthCorrection;
  127423. private _frustumCornersWorldSpace;
  127424. private _frustumCenter;
  127425. private _shadowCameraPos;
  127426. private _shadowMaxZ;
  127427. /**
  127428. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  127429. * It defaults to camera.maxZ
  127430. */
  127431. get shadowMaxZ(): number;
  127432. /**
  127433. * Sets the shadow max z distance.
  127434. */
  127435. set shadowMaxZ(value: number);
  127436. protected _debug: boolean;
  127437. /**
  127438. * Gets or sets the debug flag.
  127439. * When enabled, the cascades are materialized by different colors on the screen.
  127440. */
  127441. get debug(): boolean;
  127442. set debug(dbg: boolean);
  127443. private _depthClamp;
  127444. /**
  127445. * Gets or sets the depth clamping value.
  127446. *
  127447. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  127448. * to account for the shadow casters far away.
  127449. *
  127450. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  127451. */
  127452. get depthClamp(): boolean;
  127453. set depthClamp(value: boolean);
  127454. private _cascadeBlendPercentage;
  127455. /**
  127456. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  127457. * It defaults to 0.1 (10% blending).
  127458. */
  127459. get cascadeBlendPercentage(): number;
  127460. set cascadeBlendPercentage(value: number);
  127461. private _lambda;
  127462. /**
  127463. * Gets or set the lambda parameter.
  127464. * This parameter is used to split the camera frustum and create the cascades.
  127465. * It's a value between 0. and 1.: If 0, the split is a uniform split of the frustum, if 1 it is a logarithmic split.
  127466. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  127467. */
  127468. get lambda(): number;
  127469. set lambda(value: number);
  127470. /**
  127471. * Gets the view matrix corresponding to a given cascade
  127472. * @param cascadeNum cascade to retrieve the view matrix from
  127473. * @returns the cascade view matrix
  127474. */
  127475. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  127476. /**
  127477. * Gets the projection matrix corresponding to a given cascade
  127478. * @param cascadeNum cascade to retrieve the projection matrix from
  127479. * @returns the cascade projection matrix
  127480. */
  127481. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  127482. /**
  127483. * Gets the transformation matrix corresponding to a given cascade
  127484. * @param cascadeNum cascade to retrieve the transformation matrix from
  127485. * @returns the cascade transformation matrix
  127486. */
  127487. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  127488. private _depthRenderer;
  127489. /**
  127490. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  127491. *
  127492. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  127493. *
  127494. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  127495. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  127496. * @param depthRenderer The depth renderer to use when autoCalcDepthBounds is enabled. If you pass null or don't call this function at all, a depth renderer will be automatically created
  127497. */
  127498. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  127499. private _depthReducer;
  127500. private _autoCalcDepthBounds;
  127501. /**
  127502. * Gets or sets the autoCalcDepthBounds property.
  127503. *
  127504. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  127505. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  127506. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  127507. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  127508. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  127509. */
  127510. get autoCalcDepthBounds(): boolean;
  127511. set autoCalcDepthBounds(value: boolean);
  127512. /**
  127513. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  127514. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127515. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  127516. * for setting the refresh rate on the renderer yourself!
  127517. */
  127518. get autoCalcDepthBoundsRefreshRate(): number;
  127519. set autoCalcDepthBoundsRefreshRate(value: number);
  127520. /**
  127521. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  127522. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  127523. * you change the camera near/far planes!
  127524. */
  127525. splitFrustum(): void;
  127526. private _splitFrustum;
  127527. private _computeMatrices;
  127528. private _computeFrustumInWorldSpace;
  127529. private _computeCascadeFrustum;
  127530. /** @hidden */
  127531. static _SceneComponentInitialization: (scene: Scene) => void;
  127532. /**
  127533. * Creates a Cascaded Shadow Generator object.
  127534. * A ShadowGenerator is the required tool to use the shadows.
  127535. * Each directional light casting shadows needs to use its own ShadowGenerator.
  127536. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127537. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  127538. * @param light The directional light object generating the shadows.
  127539. * @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.
  127540. */
  127541. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  127542. protected _initializeGenerator(): void;
  127543. protected _createTargetRenderTexture(): void;
  127544. protected _initializeShadowMap(): void;
  127545. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  127546. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  127547. /**
  127548. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  127549. * @param defines Defines of the material we want to update
  127550. * @param lightIndex Index of the light in the enabled light list of the material
  127551. */
  127552. prepareDefines(defines: any, lightIndex: number): void;
  127553. /**
  127554. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  127555. * defined in the generator but impacting the effect).
  127556. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  127557. * @param effect The effect we are binfing the information for
  127558. */
  127559. bindShadowLight(lightIndex: string, effect: Effect): void;
  127560. /**
  127561. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  127562. * (eq to view projection * shadow projection matrices)
  127563. * @returns The transform matrix used to create the shadow map
  127564. */
  127565. getTransformMatrix(): Matrix;
  127566. /**
  127567. * Disposes the ShadowGenerator.
  127568. * Returns nothing.
  127569. */
  127570. dispose(): void;
  127571. /**
  127572. * Serializes the shadow generator setup to a json object.
  127573. * @returns The serialized JSON object
  127574. */
  127575. serialize(): any;
  127576. /**
  127577. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  127578. * @param parsedShadowGenerator The JSON object to parse
  127579. * @param scene The scene to create the shadow map for
  127580. * @returns The parsed shadow generator
  127581. */
  127582. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  127583. }
  127584. }
  127585. declare module BABYLON {
  127586. /**
  127587. * Defines the shadow generator component responsible to manage any shadow generators
  127588. * in a given scene.
  127589. */
  127590. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  127591. /**
  127592. * The component name helpfull to identify the component in the list of scene components.
  127593. */
  127594. readonly name: string;
  127595. /**
  127596. * The scene the component belongs to.
  127597. */
  127598. scene: Scene;
  127599. /**
  127600. * Creates a new instance of the component for the given scene
  127601. * @param scene Defines the scene to register the component in
  127602. */
  127603. constructor(scene: Scene);
  127604. /**
  127605. * Registers the component in a given scene
  127606. */
  127607. register(): void;
  127608. /**
  127609. * Rebuilds the elements related to this component in case of
  127610. * context lost for instance.
  127611. */
  127612. rebuild(): void;
  127613. /**
  127614. * Serializes the component data to the specified json object
  127615. * @param serializationObject The object to serialize to
  127616. */
  127617. serialize(serializationObject: any): void;
  127618. /**
  127619. * Adds all the elements from the container to the scene
  127620. * @param container the container holding the elements
  127621. */
  127622. addFromContainer(container: AbstractScene): void;
  127623. /**
  127624. * Removes all the elements in the container from the scene
  127625. * @param container contains the elements to remove
  127626. * @param dispose if the removed element should be disposed (default: false)
  127627. */
  127628. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127629. /**
  127630. * Rebuilds the elements related to this component in case of
  127631. * context lost for instance.
  127632. */
  127633. dispose(): void;
  127634. private _gatherRenderTargets;
  127635. }
  127636. }
  127637. declare module BABYLON {
  127638. /**
  127639. * A point light is a light defined by an unique point in world space.
  127640. * The light is emitted in every direction from this point.
  127641. * A good example of a point light is a standard light bulb.
  127642. * Documentation: https://doc.babylonjs.com/babylon101/lights
  127643. */
  127644. export class PointLight extends ShadowLight {
  127645. private _shadowAngle;
  127646. /**
  127647. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127648. * This specifies what angle the shadow will use to be created.
  127649. *
  127650. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127651. */
  127652. get shadowAngle(): number;
  127653. /**
  127654. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127655. * This specifies what angle the shadow will use to be created.
  127656. *
  127657. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127658. */
  127659. set shadowAngle(value: number);
  127660. /**
  127661. * Gets the direction if it has been set.
  127662. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127663. */
  127664. get direction(): Vector3;
  127665. /**
  127666. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127667. */
  127668. set direction(value: Vector3);
  127669. /**
  127670. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  127671. * A PointLight emits the light in every direction.
  127672. * It can cast shadows.
  127673. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  127674. * ```javascript
  127675. * var pointLight = new PointLight("pl", camera.position, scene);
  127676. * ```
  127677. * Documentation : https://doc.babylonjs.com/babylon101/lights
  127678. * @param name The light friendly name
  127679. * @param position The position of the point light in the scene
  127680. * @param scene The scene the lights belongs to
  127681. */
  127682. constructor(name: string, position: Vector3, scene: Scene);
  127683. /**
  127684. * Returns the string "PointLight"
  127685. * @returns the class name
  127686. */
  127687. getClassName(): string;
  127688. /**
  127689. * Returns the integer 0.
  127690. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  127691. */
  127692. getTypeID(): number;
  127693. /**
  127694. * Specifies wether or not the shadowmap should be a cube texture.
  127695. * @returns true if the shadowmap needs to be a cube texture.
  127696. */
  127697. needCube(): boolean;
  127698. /**
  127699. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  127700. * @param faceIndex The index of the face we are computed the direction to generate shadow
  127701. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  127702. */
  127703. getShadowDirection(faceIndex?: number): Vector3;
  127704. /**
  127705. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  127706. * - fov = PI / 2
  127707. * - aspect ratio : 1.0
  127708. * - z-near and far equal to the active camera minZ and maxZ.
  127709. * Returns the PointLight.
  127710. */
  127711. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  127712. protected _buildUniformLayout(): void;
  127713. /**
  127714. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  127715. * @param effect The effect to update
  127716. * @param lightIndex The index of the light in the effect to update
  127717. * @returns The point light
  127718. */
  127719. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  127720. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  127721. /**
  127722. * Prepares the list of defines specific to the light type.
  127723. * @param defines the list of defines
  127724. * @param lightIndex defines the index of the light for the effect
  127725. */
  127726. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  127727. }
  127728. }
  127729. declare module BABYLON {
  127730. /**
  127731. * Header information of HDR texture files.
  127732. */
  127733. export interface HDRInfo {
  127734. /**
  127735. * The height of the texture in pixels.
  127736. */
  127737. height: number;
  127738. /**
  127739. * The width of the texture in pixels.
  127740. */
  127741. width: number;
  127742. /**
  127743. * The index of the beginning of the data in the binary file.
  127744. */
  127745. dataPosition: number;
  127746. }
  127747. /**
  127748. * This groups tools to convert HDR texture to native colors array.
  127749. */
  127750. export class HDRTools {
  127751. private static Ldexp;
  127752. private static Rgbe2float;
  127753. private static readStringLine;
  127754. /**
  127755. * Reads header information from an RGBE texture stored in a native array.
  127756. * More information on this format are available here:
  127757. * https://en.wikipedia.org/wiki/RGBE_image_format
  127758. *
  127759. * @param uint8array The binary file stored in native array.
  127760. * @return The header information.
  127761. */
  127762. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  127763. /**
  127764. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  127765. * This RGBE texture needs to store the information as a panorama.
  127766. *
  127767. * More information on this format are available here:
  127768. * https://en.wikipedia.org/wiki/RGBE_image_format
  127769. *
  127770. * @param buffer The binary file stored in an array buffer.
  127771. * @param size The expected size of the extracted cubemap.
  127772. * @return The Cube Map information.
  127773. */
  127774. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  127775. /**
  127776. * Returns the pixels data extracted from an RGBE texture.
  127777. * This pixels will be stored left to right up to down in the R G B order in one array.
  127778. *
  127779. * More information on this format are available here:
  127780. * https://en.wikipedia.org/wiki/RGBE_image_format
  127781. *
  127782. * @param uint8array The binary file stored in an array buffer.
  127783. * @param hdrInfo The header information of the file.
  127784. * @return The pixels data in RGB right to left up to down order.
  127785. */
  127786. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  127787. private static RGBE_ReadPixels_RLE;
  127788. }
  127789. }
  127790. declare module BABYLON {
  127791. /**
  127792. * This represents a texture coming from an HDR input.
  127793. *
  127794. * The only supported format is currently panorama picture stored in RGBE format.
  127795. * Example of such files can be found on HDRLib: http://hdrlib.com/
  127796. */
  127797. export class HDRCubeTexture extends BaseTexture {
  127798. private static _facesMapping;
  127799. private _generateHarmonics;
  127800. private _noMipmap;
  127801. private _textureMatrix;
  127802. private _size;
  127803. private _onLoad;
  127804. private _onError;
  127805. /**
  127806. * The texture URL.
  127807. */
  127808. url: string;
  127809. /**
  127810. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  127811. */
  127812. coordinatesMode: number;
  127813. protected _isBlocking: boolean;
  127814. /**
  127815. * Sets wether or not the texture is blocking during loading.
  127816. */
  127817. set isBlocking(value: boolean);
  127818. /**
  127819. * Gets wether or not the texture is blocking during loading.
  127820. */
  127821. get isBlocking(): boolean;
  127822. protected _rotationY: number;
  127823. /**
  127824. * Sets texture matrix rotation angle around Y axis in radians.
  127825. */
  127826. set rotationY(value: number);
  127827. /**
  127828. * Gets texture matrix rotation angle around Y axis radians.
  127829. */
  127830. get rotationY(): number;
  127831. /**
  127832. * Gets or sets the center of the bounding box associated with the cube texture
  127833. * It must define where the camera used to render the texture was set
  127834. */
  127835. boundingBoxPosition: Vector3;
  127836. private _boundingBoxSize;
  127837. /**
  127838. * Gets or sets the size of the bounding box associated with the cube texture
  127839. * When defined, the cubemap will switch to local mode
  127840. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  127841. * @example https://www.babylonjs-playground.com/#RNASML
  127842. */
  127843. set boundingBoxSize(value: Vector3);
  127844. get boundingBoxSize(): Vector3;
  127845. /**
  127846. * Instantiates an HDRTexture from the following parameters.
  127847. *
  127848. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  127849. * @param scene The scene the texture will be used in
  127850. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  127851. * @param noMipmap Forces to not generate the mipmap if true
  127852. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  127853. * @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)
  127854. * @param reserved Reserved flag for internal use.
  127855. */
  127856. 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>);
  127857. /**
  127858. * Get the current class name of the texture useful for serialization or dynamic coding.
  127859. * @returns "HDRCubeTexture"
  127860. */
  127861. getClassName(): string;
  127862. /**
  127863. * Occurs when the file is raw .hdr file.
  127864. */
  127865. private loadTexture;
  127866. clone(): HDRCubeTexture;
  127867. delayLoad(): void;
  127868. /**
  127869. * Get the texture reflection matrix used to rotate/transform the reflection.
  127870. * @returns the reflection matrix
  127871. */
  127872. getReflectionTextureMatrix(): Matrix;
  127873. /**
  127874. * Set the texture reflection matrix used to rotate/transform the reflection.
  127875. * @param value Define the reflection matrix to set
  127876. */
  127877. setReflectionTextureMatrix(value: Matrix): void;
  127878. /**
  127879. * Parses a JSON representation of an HDR Texture in order to create the texture
  127880. * @param parsedTexture Define the JSON representation
  127881. * @param scene Define the scene the texture should be created in
  127882. * @param rootUrl Define the root url in case we need to load relative dependencies
  127883. * @returns the newly created texture after parsing
  127884. */
  127885. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  127886. serialize(): any;
  127887. }
  127888. }
  127889. declare module BABYLON {
  127890. /**
  127891. * Class used to control physics engine
  127892. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  127893. */
  127894. export class PhysicsEngine implements IPhysicsEngine {
  127895. private _physicsPlugin;
  127896. /**
  127897. * Global value used to control the smallest number supported by the simulation
  127898. */
  127899. static Epsilon: number;
  127900. private _impostors;
  127901. private _joints;
  127902. private _subTimeStep;
  127903. /**
  127904. * Gets the gravity vector used by the simulation
  127905. */
  127906. gravity: Vector3;
  127907. /**
  127908. * Factory used to create the default physics plugin.
  127909. * @returns The default physics plugin
  127910. */
  127911. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  127912. /**
  127913. * Creates a new Physics Engine
  127914. * @param gravity defines the gravity vector used by the simulation
  127915. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  127916. */
  127917. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  127918. /**
  127919. * Sets the gravity vector used by the simulation
  127920. * @param gravity defines the gravity vector to use
  127921. */
  127922. setGravity(gravity: Vector3): void;
  127923. /**
  127924. * Set the time step of the physics engine.
  127925. * Default is 1/60.
  127926. * To slow it down, enter 1/600 for example.
  127927. * To speed it up, 1/30
  127928. * @param newTimeStep defines the new timestep to apply to this world.
  127929. */
  127930. setTimeStep(newTimeStep?: number): void;
  127931. /**
  127932. * Get the time step of the physics engine.
  127933. * @returns the current time step
  127934. */
  127935. getTimeStep(): number;
  127936. /**
  127937. * Set the sub time step of the physics engine.
  127938. * Default is 0 meaning there is no sub steps
  127939. * To increase physics resolution precision, set a small value (like 1 ms)
  127940. * @param subTimeStep defines the new sub timestep used for physics resolution.
  127941. */
  127942. setSubTimeStep(subTimeStep?: number): void;
  127943. /**
  127944. * Get the sub time step of the physics engine.
  127945. * @returns the current sub time step
  127946. */
  127947. getSubTimeStep(): number;
  127948. /**
  127949. * Release all resources
  127950. */
  127951. dispose(): void;
  127952. /**
  127953. * Gets the name of the current physics plugin
  127954. * @returns the name of the plugin
  127955. */
  127956. getPhysicsPluginName(): string;
  127957. /**
  127958. * Adding a new impostor for the impostor tracking.
  127959. * This will be done by the impostor itself.
  127960. * @param impostor the impostor to add
  127961. */
  127962. addImpostor(impostor: PhysicsImpostor): void;
  127963. /**
  127964. * Remove an impostor from the engine.
  127965. * This impostor and its mesh will not longer be updated by the physics engine.
  127966. * @param impostor the impostor to remove
  127967. */
  127968. removeImpostor(impostor: PhysicsImpostor): void;
  127969. /**
  127970. * Add a joint to the physics engine
  127971. * @param mainImpostor defines the main impostor to which the joint is added.
  127972. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  127973. * @param joint defines the joint that will connect both impostors.
  127974. */
  127975. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  127976. /**
  127977. * Removes a joint from the simulation
  127978. * @param mainImpostor defines the impostor used with the joint
  127979. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  127980. * @param joint defines the joint to remove
  127981. */
  127982. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  127983. /**
  127984. * Called by the scene. No need to call it.
  127985. * @param delta defines the timespam between frames
  127986. */
  127987. _step(delta: number): void;
  127988. /**
  127989. * Gets the current plugin used to run the simulation
  127990. * @returns current plugin
  127991. */
  127992. getPhysicsPlugin(): IPhysicsEnginePlugin;
  127993. /**
  127994. * Gets the list of physic impostors
  127995. * @returns an array of PhysicsImpostor
  127996. */
  127997. getImpostors(): Array<PhysicsImpostor>;
  127998. /**
  127999. * Gets the impostor for a physics enabled object
  128000. * @param object defines the object impersonated by the impostor
  128001. * @returns the PhysicsImpostor or null if not found
  128002. */
  128003. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  128004. /**
  128005. * Gets the impostor for a physics body object
  128006. * @param body defines physics body used by the impostor
  128007. * @returns the PhysicsImpostor or null if not found
  128008. */
  128009. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  128010. /**
  128011. * Does a raycast in the physics world
  128012. * @param from when should the ray start?
  128013. * @param to when should the ray end?
  128014. * @returns PhysicsRaycastResult
  128015. */
  128016. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128017. }
  128018. }
  128019. declare module BABYLON {
  128020. /** @hidden */
  128021. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  128022. private _useDeltaForWorldStep;
  128023. world: any;
  128024. name: string;
  128025. private _physicsMaterials;
  128026. private _fixedTimeStep;
  128027. private _cannonRaycastResult;
  128028. private _raycastResult;
  128029. private _physicsBodysToRemoveAfterStep;
  128030. BJSCANNON: any;
  128031. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  128032. setGravity(gravity: Vector3): void;
  128033. setTimeStep(timeStep: number): void;
  128034. getTimeStep(): number;
  128035. executeStep(delta: number): void;
  128036. private _removeMarkedPhysicsBodiesFromWorld;
  128037. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128038. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128039. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128040. private _processChildMeshes;
  128041. removePhysicsBody(impostor: PhysicsImpostor): void;
  128042. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128043. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128044. private _addMaterial;
  128045. private _checkWithEpsilon;
  128046. private _createShape;
  128047. private _createHeightmap;
  128048. private _minus90X;
  128049. private _plus90X;
  128050. private _tmpPosition;
  128051. private _tmpDeltaPosition;
  128052. private _tmpUnityRotation;
  128053. private _updatePhysicsBodyTransformation;
  128054. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128055. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128056. isSupported(): boolean;
  128057. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128058. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128059. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128060. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128061. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128062. getBodyMass(impostor: PhysicsImpostor): number;
  128063. getBodyFriction(impostor: PhysicsImpostor): number;
  128064. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128065. getBodyRestitution(impostor: PhysicsImpostor): number;
  128066. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128067. sleepBody(impostor: PhysicsImpostor): void;
  128068. wakeUpBody(impostor: PhysicsImpostor): void;
  128069. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  128070. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128071. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128072. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128073. getRadius(impostor: PhysicsImpostor): number;
  128074. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128075. dispose(): void;
  128076. private _extendNamespace;
  128077. /**
  128078. * Does a raycast in the physics world
  128079. * @param from when should the ray start?
  128080. * @param to when should the ray end?
  128081. * @returns PhysicsRaycastResult
  128082. */
  128083. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128084. }
  128085. }
  128086. declare module BABYLON {
  128087. /** @hidden */
  128088. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  128089. world: any;
  128090. name: string;
  128091. BJSOIMO: any;
  128092. private _raycastResult;
  128093. constructor(iterations?: number, oimoInjection?: any);
  128094. setGravity(gravity: Vector3): void;
  128095. setTimeStep(timeStep: number): void;
  128096. getTimeStep(): number;
  128097. private _tmpImpostorsArray;
  128098. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128099. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128100. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128101. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128102. private _tmpPositionVector;
  128103. removePhysicsBody(impostor: PhysicsImpostor): void;
  128104. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128105. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128106. isSupported(): boolean;
  128107. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128108. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128109. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128110. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128111. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128112. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128113. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128114. getBodyMass(impostor: PhysicsImpostor): number;
  128115. getBodyFriction(impostor: PhysicsImpostor): number;
  128116. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128117. getBodyRestitution(impostor: PhysicsImpostor): number;
  128118. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128119. sleepBody(impostor: PhysicsImpostor): void;
  128120. wakeUpBody(impostor: PhysicsImpostor): void;
  128121. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128122. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  128123. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  128124. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128125. getRadius(impostor: PhysicsImpostor): number;
  128126. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128127. dispose(): void;
  128128. /**
  128129. * Does a raycast in the physics world
  128130. * @param from when should the ray start?
  128131. * @param to when should the ray end?
  128132. * @returns PhysicsRaycastResult
  128133. */
  128134. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128135. }
  128136. }
  128137. declare module BABYLON {
  128138. /**
  128139. * Class containing static functions to help procedurally build meshes
  128140. */
  128141. export class RibbonBuilder {
  128142. /**
  128143. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128144. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  128145. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  128146. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  128147. * * 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
  128148. * * 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
  128149. * * 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
  128150. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128151. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128152. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128153. * * 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
  128154. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  128155. * * 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
  128156. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  128157. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128158. * @param name defines the name of the mesh
  128159. * @param options defines the options used to create the mesh
  128160. * @param scene defines the hosting scene
  128161. * @returns the ribbon mesh
  128162. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  128163. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128164. */
  128165. static CreateRibbon(name: string, options: {
  128166. pathArray: Vector3[][];
  128167. closeArray?: boolean;
  128168. closePath?: boolean;
  128169. offset?: number;
  128170. updatable?: boolean;
  128171. sideOrientation?: number;
  128172. frontUVs?: Vector4;
  128173. backUVs?: Vector4;
  128174. instance?: Mesh;
  128175. invertUV?: boolean;
  128176. uvs?: Vector2[];
  128177. colors?: Color4[];
  128178. }, scene?: Nullable<Scene>): Mesh;
  128179. }
  128180. }
  128181. declare module BABYLON {
  128182. /**
  128183. * Class containing static functions to help procedurally build meshes
  128184. */
  128185. export class ShapeBuilder {
  128186. /**
  128187. * 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.
  128188. * * 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.
  128189. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128190. * * 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.
  128191. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  128192. * * 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
  128193. * * 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
  128194. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  128195. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128196. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128197. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  128198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128199. * @param name defines the name of the mesh
  128200. * @param options defines the options used to create the mesh
  128201. * @param scene defines the hosting scene
  128202. * @returns the extruded shape mesh
  128203. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128204. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128205. */
  128206. static ExtrudeShape(name: string, options: {
  128207. shape: Vector3[];
  128208. path: Vector3[];
  128209. scale?: number;
  128210. rotation?: number;
  128211. cap?: number;
  128212. updatable?: boolean;
  128213. sideOrientation?: number;
  128214. frontUVs?: Vector4;
  128215. backUVs?: Vector4;
  128216. instance?: Mesh;
  128217. invertUV?: boolean;
  128218. }, scene?: Nullable<Scene>): Mesh;
  128219. /**
  128220. * Creates an custom extruded shape mesh.
  128221. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  128222. * * 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.
  128223. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128224. * * 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
  128225. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  128226. * * 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
  128227. * * It must returns a float value that will be the scale value applied to the shape on each path point
  128228. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  128229. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  128230. * * 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
  128231. * * 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
  128232. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  128233. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128234. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128235. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128237. * @param name defines the name of the mesh
  128238. * @param options defines the options used to create the mesh
  128239. * @param scene defines the hosting scene
  128240. * @returns the custom extruded shape mesh
  128241. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  128242. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128243. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128244. */
  128245. static ExtrudeShapeCustom(name: string, options: {
  128246. shape: Vector3[];
  128247. path: Vector3[];
  128248. scaleFunction?: any;
  128249. rotationFunction?: any;
  128250. ribbonCloseArray?: boolean;
  128251. ribbonClosePath?: boolean;
  128252. cap?: number;
  128253. updatable?: boolean;
  128254. sideOrientation?: number;
  128255. frontUVs?: Vector4;
  128256. backUVs?: Vector4;
  128257. instance?: Mesh;
  128258. invertUV?: boolean;
  128259. }, scene?: Nullable<Scene>): Mesh;
  128260. private static _ExtrudeShapeGeneric;
  128261. }
  128262. }
  128263. declare module BABYLON {
  128264. /**
  128265. * AmmoJS Physics plugin
  128266. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  128267. * @see https://github.com/kripken/ammo.js/
  128268. */
  128269. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  128270. private _useDeltaForWorldStep;
  128271. /**
  128272. * Reference to the Ammo library
  128273. */
  128274. bjsAMMO: any;
  128275. /**
  128276. * Created ammoJS world which physics bodies are added to
  128277. */
  128278. world: any;
  128279. /**
  128280. * Name of the plugin
  128281. */
  128282. name: string;
  128283. private _timeStep;
  128284. private _fixedTimeStep;
  128285. private _maxSteps;
  128286. private _tmpQuaternion;
  128287. private _tmpAmmoTransform;
  128288. private _tmpAmmoQuaternion;
  128289. private _tmpAmmoConcreteContactResultCallback;
  128290. private _collisionConfiguration;
  128291. private _dispatcher;
  128292. private _overlappingPairCache;
  128293. private _solver;
  128294. private _softBodySolver;
  128295. private _tmpAmmoVectorA;
  128296. private _tmpAmmoVectorB;
  128297. private _tmpAmmoVectorC;
  128298. private _tmpAmmoVectorD;
  128299. private _tmpContactCallbackResult;
  128300. private _tmpAmmoVectorRCA;
  128301. private _tmpAmmoVectorRCB;
  128302. private _raycastResult;
  128303. private static readonly DISABLE_COLLISION_FLAG;
  128304. private static readonly KINEMATIC_FLAG;
  128305. private static readonly DISABLE_DEACTIVATION_FLAG;
  128306. /**
  128307. * Initializes the ammoJS plugin
  128308. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  128309. * @param ammoInjection can be used to inject your own ammo reference
  128310. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  128311. */
  128312. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  128313. /**
  128314. * Sets the gravity of the physics world (m/(s^2))
  128315. * @param gravity Gravity to set
  128316. */
  128317. setGravity(gravity: Vector3): void;
  128318. /**
  128319. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  128320. * @param timeStep timestep to use in seconds
  128321. */
  128322. setTimeStep(timeStep: number): void;
  128323. /**
  128324. * 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)
  128325. * @param fixedTimeStep fixedTimeStep to use in seconds
  128326. */
  128327. setFixedTimeStep(fixedTimeStep: number): void;
  128328. /**
  128329. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  128330. * @param maxSteps the maximum number of steps by the physics engine per frame
  128331. */
  128332. setMaxSteps(maxSteps: number): void;
  128333. /**
  128334. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  128335. * @returns the current timestep in seconds
  128336. */
  128337. getTimeStep(): number;
  128338. /**
  128339. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  128340. */
  128341. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  128342. private _isImpostorInContact;
  128343. private _isImpostorPairInContact;
  128344. private _stepSimulation;
  128345. /**
  128346. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  128347. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  128348. * After the step the babylon meshes are set to the position of the physics imposters
  128349. * @param delta amount of time to step forward
  128350. * @param impostors array of imposters to update before/after the step
  128351. */
  128352. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128353. /**
  128354. * Update babylon mesh to match physics world object
  128355. * @param impostor imposter to match
  128356. */
  128357. private _afterSoftStep;
  128358. /**
  128359. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128360. * @param impostor imposter to match
  128361. */
  128362. private _ropeStep;
  128363. /**
  128364. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128365. * @param impostor imposter to match
  128366. */
  128367. private _softbodyOrClothStep;
  128368. private _tmpVector;
  128369. private _tmpMatrix;
  128370. /**
  128371. * Applies an impulse on the imposter
  128372. * @param impostor imposter to apply impulse to
  128373. * @param force amount of force to be applied to the imposter
  128374. * @param contactPoint the location to apply the impulse on the imposter
  128375. */
  128376. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128377. /**
  128378. * Applies a force on the imposter
  128379. * @param impostor imposter to apply force
  128380. * @param force amount of force to be applied to the imposter
  128381. * @param contactPoint the location to apply the force on the imposter
  128382. */
  128383. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128384. /**
  128385. * Creates a physics body using the plugin
  128386. * @param impostor the imposter to create the physics body on
  128387. */
  128388. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128389. /**
  128390. * Removes the physics body from the imposter and disposes of the body's memory
  128391. * @param impostor imposter to remove the physics body from
  128392. */
  128393. removePhysicsBody(impostor: PhysicsImpostor): void;
  128394. /**
  128395. * Generates a joint
  128396. * @param impostorJoint the imposter joint to create the joint with
  128397. */
  128398. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128399. /**
  128400. * Removes a joint
  128401. * @param impostorJoint the imposter joint to remove the joint from
  128402. */
  128403. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128404. private _addMeshVerts;
  128405. /**
  128406. * Initialise the soft body vertices to match its object's (mesh) vertices
  128407. * Softbody vertices (nodes) are in world space and to match this
  128408. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  128409. * @param impostor to create the softbody for
  128410. */
  128411. private _softVertexData;
  128412. /**
  128413. * Create an impostor's soft body
  128414. * @param impostor to create the softbody for
  128415. */
  128416. private _createSoftbody;
  128417. /**
  128418. * Create cloth for an impostor
  128419. * @param impostor to create the softbody for
  128420. */
  128421. private _createCloth;
  128422. /**
  128423. * Create rope for an impostor
  128424. * @param impostor to create the softbody for
  128425. */
  128426. private _createRope;
  128427. /**
  128428. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  128429. * @param impostor to create the custom physics shape for
  128430. */
  128431. private _createCustom;
  128432. private _addHullVerts;
  128433. private _createShape;
  128434. /**
  128435. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  128436. * @param impostor imposter containing the physics body and babylon object
  128437. */
  128438. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128439. /**
  128440. * Sets the babylon object's position/rotation from the physics body's position/rotation
  128441. * @param impostor imposter containing the physics body and babylon object
  128442. * @param newPosition new position
  128443. * @param newRotation new rotation
  128444. */
  128445. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128446. /**
  128447. * If this plugin is supported
  128448. * @returns true if its supported
  128449. */
  128450. isSupported(): boolean;
  128451. /**
  128452. * Sets the linear velocity of the physics body
  128453. * @param impostor imposter to set the velocity on
  128454. * @param velocity velocity to set
  128455. */
  128456. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128457. /**
  128458. * Sets the angular velocity of the physics body
  128459. * @param impostor imposter to set the velocity on
  128460. * @param velocity velocity to set
  128461. */
  128462. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128463. /**
  128464. * gets the linear velocity
  128465. * @param impostor imposter to get linear velocity from
  128466. * @returns linear velocity
  128467. */
  128468. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128469. /**
  128470. * gets the angular velocity
  128471. * @param impostor imposter to get angular velocity from
  128472. * @returns angular velocity
  128473. */
  128474. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128475. /**
  128476. * Sets the mass of physics body
  128477. * @param impostor imposter to set the mass on
  128478. * @param mass mass to set
  128479. */
  128480. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128481. /**
  128482. * Gets the mass of the physics body
  128483. * @param impostor imposter to get the mass from
  128484. * @returns mass
  128485. */
  128486. getBodyMass(impostor: PhysicsImpostor): number;
  128487. /**
  128488. * Gets friction of the impostor
  128489. * @param impostor impostor to get friction from
  128490. * @returns friction value
  128491. */
  128492. getBodyFriction(impostor: PhysicsImpostor): number;
  128493. /**
  128494. * Sets friction of the impostor
  128495. * @param impostor impostor to set friction on
  128496. * @param friction friction value
  128497. */
  128498. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128499. /**
  128500. * Gets restitution of the impostor
  128501. * @param impostor impostor to get restitution from
  128502. * @returns restitution value
  128503. */
  128504. getBodyRestitution(impostor: PhysicsImpostor): number;
  128505. /**
  128506. * Sets resitution of the impostor
  128507. * @param impostor impostor to set resitution on
  128508. * @param restitution resitution value
  128509. */
  128510. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128511. /**
  128512. * Gets pressure inside the impostor
  128513. * @param impostor impostor to get pressure from
  128514. * @returns pressure value
  128515. */
  128516. getBodyPressure(impostor: PhysicsImpostor): number;
  128517. /**
  128518. * Sets pressure inside a soft body impostor
  128519. * Cloth and rope must remain 0 pressure
  128520. * @param impostor impostor to set pressure on
  128521. * @param pressure pressure value
  128522. */
  128523. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  128524. /**
  128525. * Gets stiffness of the impostor
  128526. * @param impostor impostor to get stiffness from
  128527. * @returns pressure value
  128528. */
  128529. getBodyStiffness(impostor: PhysicsImpostor): number;
  128530. /**
  128531. * Sets stiffness of the impostor
  128532. * @param impostor impostor to set stiffness on
  128533. * @param stiffness stiffness value from 0 to 1
  128534. */
  128535. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  128536. /**
  128537. * Gets velocityIterations of the impostor
  128538. * @param impostor impostor to get velocity iterations from
  128539. * @returns velocityIterations value
  128540. */
  128541. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  128542. /**
  128543. * Sets velocityIterations of the impostor
  128544. * @param impostor impostor to set velocity iterations on
  128545. * @param velocityIterations velocityIterations value
  128546. */
  128547. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  128548. /**
  128549. * Gets positionIterations of the impostor
  128550. * @param impostor impostor to get position iterations from
  128551. * @returns positionIterations value
  128552. */
  128553. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  128554. /**
  128555. * Sets positionIterations of the impostor
  128556. * @param impostor impostor to set position on
  128557. * @param positionIterations positionIterations value
  128558. */
  128559. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  128560. /**
  128561. * Append an anchor to a cloth object
  128562. * @param impostor is the cloth impostor to add anchor to
  128563. * @param otherImpostor is the rigid impostor to anchor to
  128564. * @param width ratio across width from 0 to 1
  128565. * @param height ratio up height from 0 to 1
  128566. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  128567. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128568. */
  128569. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128570. /**
  128571. * Append an hook to a rope object
  128572. * @param impostor is the rope impostor to add hook to
  128573. * @param otherImpostor is the rigid impostor to hook to
  128574. * @param length ratio along the rope from 0 to 1
  128575. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  128576. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128577. */
  128578. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128579. /**
  128580. * Sleeps the physics body and stops it from being active
  128581. * @param impostor impostor to sleep
  128582. */
  128583. sleepBody(impostor: PhysicsImpostor): void;
  128584. /**
  128585. * Activates the physics body
  128586. * @param impostor impostor to activate
  128587. */
  128588. wakeUpBody(impostor: PhysicsImpostor): void;
  128589. /**
  128590. * Updates the distance parameters of the joint
  128591. * @param joint joint to update
  128592. * @param maxDistance maximum distance of the joint
  128593. * @param minDistance minimum distance of the joint
  128594. */
  128595. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128596. /**
  128597. * Sets a motor on the joint
  128598. * @param joint joint to set motor on
  128599. * @param speed speed of the motor
  128600. * @param maxForce maximum force of the motor
  128601. * @param motorIndex index of the motor
  128602. */
  128603. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128604. /**
  128605. * Sets the motors limit
  128606. * @param joint joint to set limit on
  128607. * @param upperLimit upper limit
  128608. * @param lowerLimit lower limit
  128609. */
  128610. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128611. /**
  128612. * Syncs the position and rotation of a mesh with the impostor
  128613. * @param mesh mesh to sync
  128614. * @param impostor impostor to update the mesh with
  128615. */
  128616. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128617. /**
  128618. * Gets the radius of the impostor
  128619. * @param impostor impostor to get radius from
  128620. * @returns the radius
  128621. */
  128622. getRadius(impostor: PhysicsImpostor): number;
  128623. /**
  128624. * Gets the box size of the impostor
  128625. * @param impostor impostor to get box size from
  128626. * @param result the resulting box size
  128627. */
  128628. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128629. /**
  128630. * Disposes of the impostor
  128631. */
  128632. dispose(): void;
  128633. /**
  128634. * Does a raycast in the physics world
  128635. * @param from when should the ray start?
  128636. * @param to when should the ray end?
  128637. * @returns PhysicsRaycastResult
  128638. */
  128639. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128640. }
  128641. }
  128642. declare module BABYLON {
  128643. interface AbstractScene {
  128644. /**
  128645. * The list of reflection probes added to the scene
  128646. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128647. */
  128648. reflectionProbes: Array<ReflectionProbe>;
  128649. /**
  128650. * Removes the given reflection probe from this scene.
  128651. * @param toRemove The reflection probe to remove
  128652. * @returns The index of the removed reflection probe
  128653. */
  128654. removeReflectionProbe(toRemove: ReflectionProbe): number;
  128655. /**
  128656. * Adds the given reflection probe to this scene.
  128657. * @param newReflectionProbe The reflection probe to add
  128658. */
  128659. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  128660. }
  128661. /**
  128662. * Class used to generate realtime reflection / refraction cube textures
  128663. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128664. */
  128665. export class ReflectionProbe {
  128666. /** defines the name of the probe */
  128667. name: string;
  128668. private _scene;
  128669. private _renderTargetTexture;
  128670. private _projectionMatrix;
  128671. private _viewMatrix;
  128672. private _target;
  128673. private _add;
  128674. private _attachedMesh;
  128675. private _invertYAxis;
  128676. /** Gets or sets probe position (center of the cube map) */
  128677. position: Vector3;
  128678. /**
  128679. * Creates a new reflection probe
  128680. * @param name defines the name of the probe
  128681. * @param size defines the texture resolution (for each face)
  128682. * @param scene defines the hosting scene
  128683. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  128684. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  128685. */
  128686. constructor(
  128687. /** defines the name of the probe */
  128688. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  128689. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  128690. get samples(): number;
  128691. set samples(value: number);
  128692. /** Gets or sets the refresh rate to use (on every frame by default) */
  128693. get refreshRate(): number;
  128694. set refreshRate(value: number);
  128695. /**
  128696. * Gets the hosting scene
  128697. * @returns a Scene
  128698. */
  128699. getScene(): Scene;
  128700. /** Gets the internal CubeTexture used to render to */
  128701. get cubeTexture(): RenderTargetTexture;
  128702. /** Gets the list of meshes to render */
  128703. get renderList(): Nullable<AbstractMesh[]>;
  128704. /**
  128705. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  128706. * @param mesh defines the mesh to attach to
  128707. */
  128708. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  128709. /**
  128710. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  128711. * @param renderingGroupId The rendering group id corresponding to its index
  128712. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128713. */
  128714. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  128715. /**
  128716. * Clean all associated resources
  128717. */
  128718. dispose(): void;
  128719. /**
  128720. * Converts the reflection probe information to a readable string for debug purpose.
  128721. * @param fullDetails Supports for multiple levels of logging within scene loading
  128722. * @returns the human readable reflection probe info
  128723. */
  128724. toString(fullDetails?: boolean): string;
  128725. /**
  128726. * Get the class name of the relfection probe.
  128727. * @returns "ReflectionProbe"
  128728. */
  128729. getClassName(): string;
  128730. /**
  128731. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  128732. * @returns The JSON representation of the texture
  128733. */
  128734. serialize(): any;
  128735. /**
  128736. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  128737. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  128738. * @param scene Define the scene the parsed reflection probe should be instantiated in
  128739. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  128740. * @returns The parsed reflection probe if successful
  128741. */
  128742. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  128743. }
  128744. }
  128745. declare module BABYLON {
  128746. /** @hidden */
  128747. export var _BabylonLoaderRegistered: boolean;
  128748. /**
  128749. * Helps setting up some configuration for the babylon file loader.
  128750. */
  128751. export class BabylonFileLoaderConfiguration {
  128752. /**
  128753. * The loader does not allow injecting custom physix engine into the plugins.
  128754. * Unfortunately in ES6, we need to manually inject them into the plugin.
  128755. * So you could set this variable to your engine import to make it work.
  128756. */
  128757. static LoaderInjectedPhysicsEngine: any;
  128758. }
  128759. }
  128760. declare module BABYLON {
  128761. /**
  128762. * The Physically based simple base material of BJS.
  128763. *
  128764. * This enables better naming and convention enforcements on top of the pbrMaterial.
  128765. * It is used as the base class for both the specGloss and metalRough conventions.
  128766. */
  128767. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  128768. /**
  128769. * Number of Simultaneous lights allowed on the material.
  128770. */
  128771. maxSimultaneousLights: number;
  128772. /**
  128773. * If sets to true, disables all the lights affecting the material.
  128774. */
  128775. disableLighting: boolean;
  128776. /**
  128777. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  128778. */
  128779. environmentTexture: BaseTexture;
  128780. /**
  128781. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128782. */
  128783. invertNormalMapX: boolean;
  128784. /**
  128785. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128786. */
  128787. invertNormalMapY: boolean;
  128788. /**
  128789. * Normal map used in the model.
  128790. */
  128791. normalTexture: BaseTexture;
  128792. /**
  128793. * Emissivie color used to self-illuminate the model.
  128794. */
  128795. emissiveColor: Color3;
  128796. /**
  128797. * Emissivie texture used to self-illuminate the model.
  128798. */
  128799. emissiveTexture: BaseTexture;
  128800. /**
  128801. * Occlusion Channel Strenght.
  128802. */
  128803. occlusionStrength: number;
  128804. /**
  128805. * Occlusion Texture of the material (adding extra occlusion effects).
  128806. */
  128807. occlusionTexture: BaseTexture;
  128808. /**
  128809. * Defines the alpha limits in alpha test mode.
  128810. */
  128811. alphaCutOff: number;
  128812. /**
  128813. * Gets the current double sided mode.
  128814. */
  128815. get doubleSided(): boolean;
  128816. /**
  128817. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128818. */
  128819. set doubleSided(value: boolean);
  128820. /**
  128821. * Stores the pre-calculated light information of a mesh in a texture.
  128822. */
  128823. lightmapTexture: BaseTexture;
  128824. /**
  128825. * If true, the light map contains occlusion information instead of lighting info.
  128826. */
  128827. useLightmapAsShadowmap: boolean;
  128828. /**
  128829. * Instantiates a new PBRMaterial instance.
  128830. *
  128831. * @param name The material name
  128832. * @param scene The scene the material will be use in.
  128833. */
  128834. constructor(name: string, scene: Scene);
  128835. getClassName(): string;
  128836. }
  128837. }
  128838. declare module BABYLON {
  128839. /**
  128840. * The PBR material of BJS following the metal roughness convention.
  128841. *
  128842. * This fits to the PBR convention in the GLTF definition:
  128843. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  128844. */
  128845. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  128846. /**
  128847. * The base color has two different interpretations depending on the value of metalness.
  128848. * When the material is a metal, the base color is the specific measured reflectance value
  128849. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  128850. * of the material.
  128851. */
  128852. baseColor: Color3;
  128853. /**
  128854. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  128855. * well as opacity information in the alpha channel.
  128856. */
  128857. baseTexture: BaseTexture;
  128858. /**
  128859. * Specifies the metallic scalar value of the material.
  128860. * Can also be used to scale the metalness values of the metallic texture.
  128861. */
  128862. metallic: number;
  128863. /**
  128864. * Specifies the roughness scalar value of the material.
  128865. * Can also be used to scale the roughness values of the metallic texture.
  128866. */
  128867. roughness: number;
  128868. /**
  128869. * Texture containing both the metallic value in the B channel and the
  128870. * roughness value in the G channel to keep better precision.
  128871. */
  128872. metallicRoughnessTexture: BaseTexture;
  128873. /**
  128874. * Instantiates a new PBRMetalRoughnessMaterial instance.
  128875. *
  128876. * @param name The material name
  128877. * @param scene The scene the material will be use in.
  128878. */
  128879. constructor(name: string, scene: Scene);
  128880. /**
  128881. * Return the currrent class name of the material.
  128882. */
  128883. getClassName(): string;
  128884. /**
  128885. * Makes a duplicate of the current material.
  128886. * @param name - name to use for the new material.
  128887. */
  128888. clone(name: string): PBRMetallicRoughnessMaterial;
  128889. /**
  128890. * Serialize the material to a parsable JSON object.
  128891. */
  128892. serialize(): any;
  128893. /**
  128894. * Parses a JSON object correponding to the serialize function.
  128895. */
  128896. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  128897. }
  128898. }
  128899. declare module BABYLON {
  128900. /**
  128901. * The PBR material of BJS following the specular glossiness convention.
  128902. *
  128903. * This fits to the PBR convention in the GLTF definition:
  128904. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  128905. */
  128906. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  128907. /**
  128908. * Specifies the diffuse color of the material.
  128909. */
  128910. diffuseColor: Color3;
  128911. /**
  128912. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  128913. * channel.
  128914. */
  128915. diffuseTexture: BaseTexture;
  128916. /**
  128917. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  128918. */
  128919. specularColor: Color3;
  128920. /**
  128921. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  128922. */
  128923. glossiness: number;
  128924. /**
  128925. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  128926. */
  128927. specularGlossinessTexture: BaseTexture;
  128928. /**
  128929. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  128930. *
  128931. * @param name The material name
  128932. * @param scene The scene the material will be use in.
  128933. */
  128934. constructor(name: string, scene: Scene);
  128935. /**
  128936. * Return the currrent class name of the material.
  128937. */
  128938. getClassName(): string;
  128939. /**
  128940. * Makes a duplicate of the current material.
  128941. * @param name - name to use for the new material.
  128942. */
  128943. clone(name: string): PBRSpecularGlossinessMaterial;
  128944. /**
  128945. * Serialize the material to a parsable JSON object.
  128946. */
  128947. serialize(): any;
  128948. /**
  128949. * Parses a JSON object correponding to the serialize function.
  128950. */
  128951. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  128952. }
  128953. }
  128954. declare module BABYLON {
  128955. /**
  128956. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  128957. * It can help converting any input color in a desired output one. This can then be used to create effects
  128958. * from sepia, black and white to sixties or futuristic rendering...
  128959. *
  128960. * The only supported format is currently 3dl.
  128961. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  128962. */
  128963. export class ColorGradingTexture extends BaseTexture {
  128964. /**
  128965. * The current texture matrix. (will always be identity in color grading texture)
  128966. */
  128967. private _textureMatrix;
  128968. /**
  128969. * The texture URL.
  128970. */
  128971. url: string;
  128972. /**
  128973. * Empty line regex stored for GC.
  128974. */
  128975. private static _noneEmptyLineRegex;
  128976. private _engine;
  128977. /**
  128978. * Instantiates a ColorGradingTexture from the following parameters.
  128979. *
  128980. * @param url The location of the color gradind data (currently only supporting 3dl)
  128981. * @param scene The scene the texture will be used in
  128982. */
  128983. constructor(url: string, scene: Scene);
  128984. /**
  128985. * Returns the texture matrix used in most of the material.
  128986. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  128987. */
  128988. getTextureMatrix(): Matrix;
  128989. /**
  128990. * Occurs when the file being loaded is a .3dl LUT file.
  128991. */
  128992. private load3dlTexture;
  128993. /**
  128994. * Starts the loading process of the texture.
  128995. */
  128996. private loadTexture;
  128997. /**
  128998. * Clones the color gradind texture.
  128999. */
  129000. clone(): ColorGradingTexture;
  129001. /**
  129002. * Called during delayed load for textures.
  129003. */
  129004. delayLoad(): void;
  129005. /**
  129006. * Parses a color grading texture serialized by Babylon.
  129007. * @param parsedTexture The texture information being parsedTexture
  129008. * @param scene The scene to load the texture in
  129009. * @param rootUrl The root url of the data assets to load
  129010. * @return A color gradind texture
  129011. */
  129012. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  129013. /**
  129014. * Serializes the LUT texture to json format.
  129015. */
  129016. serialize(): any;
  129017. }
  129018. }
  129019. declare module BABYLON {
  129020. /**
  129021. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  129022. */
  129023. export class EquiRectangularCubeTexture extends BaseTexture {
  129024. /** The six faces of the cube. */
  129025. private static _FacesMapping;
  129026. private _noMipmap;
  129027. private _onLoad;
  129028. private _onError;
  129029. /** The size of the cubemap. */
  129030. private _size;
  129031. /** The buffer of the image. */
  129032. private _buffer;
  129033. /** The width of the input image. */
  129034. private _width;
  129035. /** The height of the input image. */
  129036. private _height;
  129037. /** The URL to the image. */
  129038. url: string;
  129039. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  129040. coordinatesMode: number;
  129041. /**
  129042. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  129043. * @param url The location of the image
  129044. * @param scene The scene the texture will be used in
  129045. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129046. * @param noMipmap Forces to not generate the mipmap if true
  129047. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129048. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129049. * @param onLoad — defines a callback called when texture is loaded
  129050. * @param onError — defines a callback called if there is an error
  129051. */
  129052. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  129053. /**
  129054. * Load the image data, by putting the image on a canvas and extracting its buffer.
  129055. */
  129056. private loadImage;
  129057. /**
  129058. * Convert the image buffer into a cubemap and create a CubeTexture.
  129059. */
  129060. private loadTexture;
  129061. /**
  129062. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  129063. * @param buffer The ArrayBuffer that should be converted.
  129064. * @returns The buffer as Float32Array.
  129065. */
  129066. private getFloat32ArrayFromArrayBuffer;
  129067. /**
  129068. * Get the current class name of the texture useful for serialization or dynamic coding.
  129069. * @returns "EquiRectangularCubeTexture"
  129070. */
  129071. getClassName(): string;
  129072. /**
  129073. * Create a clone of the current EquiRectangularCubeTexture and return it.
  129074. * @returns A clone of the current EquiRectangularCubeTexture.
  129075. */
  129076. clone(): EquiRectangularCubeTexture;
  129077. }
  129078. }
  129079. declare module BABYLON {
  129080. /**
  129081. * Based on jsTGALoader - Javascript loader for TGA file
  129082. * By Vincent Thibault
  129083. * @see http://blog.robrowser.com/javascript-tga-loader.html
  129084. */
  129085. export class TGATools {
  129086. private static _TYPE_INDEXED;
  129087. private static _TYPE_RGB;
  129088. private static _TYPE_GREY;
  129089. private static _TYPE_RLE_INDEXED;
  129090. private static _TYPE_RLE_RGB;
  129091. private static _TYPE_RLE_GREY;
  129092. private static _ORIGIN_MASK;
  129093. private static _ORIGIN_SHIFT;
  129094. private static _ORIGIN_BL;
  129095. private static _ORIGIN_BR;
  129096. private static _ORIGIN_UL;
  129097. private static _ORIGIN_UR;
  129098. /**
  129099. * Gets the header of a TGA file
  129100. * @param data defines the TGA data
  129101. * @returns the header
  129102. */
  129103. static GetTGAHeader(data: Uint8Array): any;
  129104. /**
  129105. * Uploads TGA content to a Babylon Texture
  129106. * @hidden
  129107. */
  129108. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  129109. /** @hidden */
  129110. 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;
  129111. /** @hidden */
  129112. 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;
  129113. /** @hidden */
  129114. 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;
  129115. /** @hidden */
  129116. 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;
  129117. /** @hidden */
  129118. 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;
  129119. /** @hidden */
  129120. 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;
  129121. }
  129122. }
  129123. declare module BABYLON {
  129124. /**
  129125. * Implementation of the TGA Texture Loader.
  129126. * @hidden
  129127. */
  129128. export class _TGATextureLoader implements IInternalTextureLoader {
  129129. /**
  129130. * Defines wether the loader supports cascade loading the different faces.
  129131. */
  129132. readonly supportCascades: boolean;
  129133. /**
  129134. * This returns if the loader support the current file information.
  129135. * @param extension defines the file extension of the file being loaded
  129136. * @returns true if the loader can load the specified file
  129137. */
  129138. canLoad(extension: string): boolean;
  129139. /**
  129140. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129141. * @param data contains the texture data
  129142. * @param texture defines the BabylonJS internal texture
  129143. * @param createPolynomials will be true if polynomials have been requested
  129144. * @param onLoad defines the callback to trigger once the texture is ready
  129145. * @param onError defines the callback to trigger in case of error
  129146. */
  129147. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129148. /**
  129149. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129150. * @param data contains the texture data
  129151. * @param texture defines the BabylonJS internal texture
  129152. * @param callback defines the method to call once ready to upload
  129153. */
  129154. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129155. }
  129156. }
  129157. declare module BABYLON {
  129158. /**
  129159. * Info about the .basis files
  129160. */
  129161. class BasisFileInfo {
  129162. /**
  129163. * If the file has alpha
  129164. */
  129165. hasAlpha: boolean;
  129166. /**
  129167. * Info about each image of the basis file
  129168. */
  129169. images: Array<{
  129170. levels: Array<{
  129171. width: number;
  129172. height: number;
  129173. transcodedPixels: ArrayBufferView;
  129174. }>;
  129175. }>;
  129176. }
  129177. /**
  129178. * Result of transcoding a basis file
  129179. */
  129180. class TranscodeResult {
  129181. /**
  129182. * Info about the .basis file
  129183. */
  129184. fileInfo: BasisFileInfo;
  129185. /**
  129186. * Format to use when loading the file
  129187. */
  129188. format: number;
  129189. }
  129190. /**
  129191. * Configuration options for the Basis transcoder
  129192. */
  129193. export class BasisTranscodeConfiguration {
  129194. /**
  129195. * Supported compression formats used to determine the supported output format of the transcoder
  129196. */
  129197. supportedCompressionFormats?: {
  129198. /**
  129199. * etc1 compression format
  129200. */
  129201. etc1?: boolean;
  129202. /**
  129203. * s3tc compression format
  129204. */
  129205. s3tc?: boolean;
  129206. /**
  129207. * pvrtc compression format
  129208. */
  129209. pvrtc?: boolean;
  129210. /**
  129211. * etc2 compression format
  129212. */
  129213. etc2?: boolean;
  129214. };
  129215. /**
  129216. * If mipmap levels should be loaded for transcoded images (Default: true)
  129217. */
  129218. loadMipmapLevels?: boolean;
  129219. /**
  129220. * Index of a single image to load (Default: all images)
  129221. */
  129222. loadSingleImage?: number;
  129223. }
  129224. /**
  129225. * Used to load .Basis files
  129226. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  129227. */
  129228. export class BasisTools {
  129229. private static _IgnoreSupportedFormats;
  129230. /**
  129231. * URL to use when loading the basis transcoder
  129232. */
  129233. static JSModuleURL: string;
  129234. /**
  129235. * URL to use when loading the wasm module for the transcoder
  129236. */
  129237. static WasmModuleURL: string;
  129238. /**
  129239. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  129240. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  129241. * @returns internal format corresponding to the Basis format
  129242. */
  129243. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  129244. private static _WorkerPromise;
  129245. private static _Worker;
  129246. private static _actionId;
  129247. private static _CreateWorkerAsync;
  129248. /**
  129249. * Transcodes a loaded image file to compressed pixel data
  129250. * @param data image data to transcode
  129251. * @param config configuration options for the transcoding
  129252. * @returns a promise resulting in the transcoded image
  129253. */
  129254. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  129255. /**
  129256. * Loads a texture from the transcode result
  129257. * @param texture texture load to
  129258. * @param transcodeResult the result of transcoding the basis file to load from
  129259. */
  129260. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  129261. }
  129262. }
  129263. declare module BABYLON {
  129264. /**
  129265. * Loader for .basis file format
  129266. */
  129267. export class _BasisTextureLoader implements IInternalTextureLoader {
  129268. /**
  129269. * Defines whether the loader supports cascade loading the different faces.
  129270. */
  129271. readonly supportCascades: boolean;
  129272. /**
  129273. * This returns if the loader support the current file information.
  129274. * @param extension defines the file extension of the file being loaded
  129275. * @returns true if the loader can load the specified file
  129276. */
  129277. canLoad(extension: string): boolean;
  129278. /**
  129279. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  129280. * @param data contains the texture data
  129281. * @param texture defines the BabylonJS internal texture
  129282. * @param createPolynomials will be true if polynomials have been requested
  129283. * @param onLoad defines the callback to trigger once the texture is ready
  129284. * @param onError defines the callback to trigger in case of error
  129285. */
  129286. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129287. /**
  129288. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  129289. * @param data contains the texture data
  129290. * @param texture defines the BabylonJS internal texture
  129291. * @param callback defines the method to call once ready to upload
  129292. */
  129293. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129294. }
  129295. }
  129296. declare module BABYLON {
  129297. /**
  129298. * 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.
  129299. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129300. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129301. */
  129302. export class CustomProceduralTexture extends ProceduralTexture {
  129303. private _animate;
  129304. private _time;
  129305. private _config;
  129306. private _texturePath;
  129307. /**
  129308. * Instantiates a new Custom Procedural Texture.
  129309. * 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.
  129310. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129311. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129312. * @param name Define the name of the texture
  129313. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  129314. * @param size Define the size of the texture to create
  129315. * @param scene Define the scene the texture belongs to
  129316. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  129317. * @param generateMipMaps Define if the texture should creates mip maps or not
  129318. */
  129319. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129320. private _loadJson;
  129321. /**
  129322. * Is the texture ready to be used ? (rendered at least once)
  129323. * @returns true if ready, otherwise, false.
  129324. */
  129325. isReady(): boolean;
  129326. /**
  129327. * Render the texture to its associated render target.
  129328. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  129329. */
  129330. render(useCameraPostProcess?: boolean): void;
  129331. /**
  129332. * Update the list of dependant textures samplers in the shader.
  129333. */
  129334. updateTextures(): void;
  129335. /**
  129336. * Update the uniform values of the procedural texture in the shader.
  129337. */
  129338. updateShaderUniforms(): void;
  129339. /**
  129340. * Define if the texture animates or not.
  129341. */
  129342. get animate(): boolean;
  129343. set animate(value: boolean);
  129344. }
  129345. }
  129346. declare module BABYLON {
  129347. /** @hidden */
  129348. export var noisePixelShader: {
  129349. name: string;
  129350. shader: string;
  129351. };
  129352. }
  129353. declare module BABYLON {
  129354. /**
  129355. * Class used to generate noise procedural textures
  129356. */
  129357. export class NoiseProceduralTexture extends ProceduralTexture {
  129358. private _time;
  129359. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  129360. brightness: number;
  129361. /** Defines the number of octaves to process */
  129362. octaves: number;
  129363. /** Defines the level of persistence (0.8 by default) */
  129364. persistence: number;
  129365. /** Gets or sets animation speed factor (default is 1) */
  129366. animationSpeedFactor: number;
  129367. /**
  129368. * Creates a new NoiseProceduralTexture
  129369. * @param name defines the name fo the texture
  129370. * @param size defines the size of the texture (default is 256)
  129371. * @param scene defines the hosting scene
  129372. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  129373. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  129374. */
  129375. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129376. private _updateShaderUniforms;
  129377. protected _getDefines(): string;
  129378. /** Generate the current state of the procedural texture */
  129379. render(useCameraPostProcess?: boolean): void;
  129380. /**
  129381. * Serializes this noise procedural texture
  129382. * @returns a serialized noise procedural texture object
  129383. */
  129384. serialize(): any;
  129385. /**
  129386. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  129387. * @param parsedTexture defines parsed texture data
  129388. * @param scene defines the current scene
  129389. * @param rootUrl defines the root URL containing noise procedural texture information
  129390. * @returns a parsed NoiseProceduralTexture
  129391. */
  129392. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  129393. }
  129394. }
  129395. declare module BABYLON {
  129396. /**
  129397. * Raw cube texture where the raw buffers are passed in
  129398. */
  129399. export class RawCubeTexture extends CubeTexture {
  129400. /**
  129401. * Creates a cube texture where the raw buffers are passed in.
  129402. * @param scene defines the scene the texture is attached to
  129403. * @param data defines the array of data to use to create each face
  129404. * @param size defines the size of the textures
  129405. * @param format defines the format of the data
  129406. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  129407. * @param generateMipMaps defines if the engine should generate the mip levels
  129408. * @param invertY defines if data must be stored with Y axis inverted
  129409. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129410. * @param compression defines the compression used (null by default)
  129411. */
  129412. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  129413. /**
  129414. * Updates the raw cube texture.
  129415. * @param data defines the data to store
  129416. * @param format defines the data format
  129417. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129418. * @param invertY defines if data must be stored with Y axis inverted
  129419. * @param compression defines the compression used (null by default)
  129420. * @param level defines which level of the texture to update
  129421. */
  129422. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  129423. /**
  129424. * Updates a raw cube texture with RGBD encoded data.
  129425. * @param data defines the array of data [mipmap][face] to use to create each face
  129426. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  129427. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129428. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129429. * @returns a promsie that resolves when the operation is complete
  129430. */
  129431. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  129432. /**
  129433. * Clones the raw cube texture.
  129434. * @return a new cube texture
  129435. */
  129436. clone(): CubeTexture;
  129437. /** @hidden */
  129438. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129439. }
  129440. }
  129441. declare module BABYLON {
  129442. /**
  129443. * Class used to store 3D textures containing user data
  129444. */
  129445. export class RawTexture3D extends Texture {
  129446. /** Gets or sets the texture format to use */
  129447. format: number;
  129448. private _engine;
  129449. /**
  129450. * Create a new RawTexture3D
  129451. * @param data defines the data of the texture
  129452. * @param width defines the width of the texture
  129453. * @param height defines the height of the texture
  129454. * @param depth defines the depth of the texture
  129455. * @param format defines the texture format to use
  129456. * @param scene defines the hosting scene
  129457. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129458. * @param invertY defines if texture must be stored with Y axis inverted
  129459. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129460. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129461. */
  129462. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129463. /** Gets or sets the texture format to use */
  129464. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129465. /**
  129466. * Update the texture with new data
  129467. * @param data defines the data to store in the texture
  129468. */
  129469. update(data: ArrayBufferView): void;
  129470. }
  129471. }
  129472. declare module BABYLON {
  129473. /**
  129474. * Class used to store 2D array textures containing user data
  129475. */
  129476. export class RawTexture2DArray extends Texture {
  129477. /** Gets or sets the texture format to use */
  129478. format: number;
  129479. private _engine;
  129480. /**
  129481. * Create a new RawTexture2DArray
  129482. * @param data defines the data of the texture
  129483. * @param width defines the width of the texture
  129484. * @param height defines the height of the texture
  129485. * @param depth defines the number of layers of the texture
  129486. * @param format defines the texture format to use
  129487. * @param scene defines the hosting scene
  129488. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129489. * @param invertY defines if texture must be stored with Y axis inverted
  129490. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129491. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129492. */
  129493. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129494. /** Gets or sets the texture format to use */
  129495. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129496. /**
  129497. * Update the texture with new data
  129498. * @param data defines the data to store in the texture
  129499. */
  129500. update(data: ArrayBufferView): void;
  129501. }
  129502. }
  129503. declare module BABYLON {
  129504. /**
  129505. * Creates a refraction texture used by refraction channel of the standard material.
  129506. * It is like a mirror but to see through a material.
  129507. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129508. */
  129509. export class RefractionTexture extends RenderTargetTexture {
  129510. /**
  129511. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  129512. * 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.
  129513. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129514. */
  129515. refractionPlane: Plane;
  129516. /**
  129517. * Define how deep under the surface we should see.
  129518. */
  129519. depth: number;
  129520. /**
  129521. * Creates a refraction texture used by refraction channel of the standard material.
  129522. * It is like a mirror but to see through a material.
  129523. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129524. * @param name Define the texture name
  129525. * @param size Define the size of the underlying texture
  129526. * @param scene Define the scene the refraction belongs to
  129527. * @param generateMipMaps Define if we need to generate mips level for the refraction
  129528. */
  129529. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  129530. /**
  129531. * Clone the refraction texture.
  129532. * @returns the cloned texture
  129533. */
  129534. clone(): RefractionTexture;
  129535. /**
  129536. * Serialize the texture to a JSON representation you could use in Parse later on
  129537. * @returns the serialized JSON representation
  129538. */
  129539. serialize(): any;
  129540. }
  129541. }
  129542. declare module BABYLON {
  129543. /**
  129544. * Defines the options related to the creation of an HtmlElementTexture
  129545. */
  129546. export interface IHtmlElementTextureOptions {
  129547. /**
  129548. * Defines wether mip maps should be created or not.
  129549. */
  129550. generateMipMaps?: boolean;
  129551. /**
  129552. * Defines the sampling mode of the texture.
  129553. */
  129554. samplingMode?: number;
  129555. /**
  129556. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  129557. */
  129558. engine: Nullable<ThinEngine>;
  129559. /**
  129560. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  129561. */
  129562. scene: Nullable<Scene>;
  129563. }
  129564. /**
  129565. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  129566. * To be as efficient as possible depending on your constraints nothing aside the first upload
  129567. * is automatically managed.
  129568. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  129569. * in your application.
  129570. *
  129571. * As the update is not automatic, you need to call them manually.
  129572. */
  129573. export class HtmlElementTexture extends BaseTexture {
  129574. /**
  129575. * The texture URL.
  129576. */
  129577. element: HTMLVideoElement | HTMLCanvasElement;
  129578. private static readonly DefaultOptions;
  129579. private _textureMatrix;
  129580. private _engine;
  129581. private _isVideo;
  129582. private _generateMipMaps;
  129583. private _samplingMode;
  129584. /**
  129585. * Instantiates a HtmlElementTexture from the following parameters.
  129586. *
  129587. * @param name Defines the name of the texture
  129588. * @param element Defines the video or canvas the texture is filled with
  129589. * @param options Defines the other none mandatory texture creation options
  129590. */
  129591. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  129592. private _createInternalTexture;
  129593. /**
  129594. * Returns the texture matrix used in most of the material.
  129595. */
  129596. getTextureMatrix(): Matrix;
  129597. /**
  129598. * Updates the content of the texture.
  129599. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  129600. */
  129601. update(invertY?: Nullable<boolean>): void;
  129602. }
  129603. }
  129604. declare module BABYLON {
  129605. /**
  129606. * Defines the basic options interface of a TexturePacker Frame
  129607. */
  129608. export interface ITexturePackerFrame {
  129609. /**
  129610. * The frame ID
  129611. */
  129612. id: number;
  129613. /**
  129614. * The frames Scale
  129615. */
  129616. scale: Vector2;
  129617. /**
  129618. * The Frames offset
  129619. */
  129620. offset: Vector2;
  129621. }
  129622. /**
  129623. * This is a support class for frame Data on texture packer sets.
  129624. */
  129625. export class TexturePackerFrame implements ITexturePackerFrame {
  129626. /**
  129627. * The frame ID
  129628. */
  129629. id: number;
  129630. /**
  129631. * The frames Scale
  129632. */
  129633. scale: Vector2;
  129634. /**
  129635. * The Frames offset
  129636. */
  129637. offset: Vector2;
  129638. /**
  129639. * Initializes a texture package frame.
  129640. * @param id The numerical frame identifier
  129641. * @param scale Scalar Vector2 for UV frame
  129642. * @param offset Vector2 for the frame position in UV units.
  129643. * @returns TexturePackerFrame
  129644. */
  129645. constructor(id: number, scale: Vector2, offset: Vector2);
  129646. }
  129647. }
  129648. declare module BABYLON {
  129649. /**
  129650. * Defines the basic options interface of a TexturePacker
  129651. */
  129652. export interface ITexturePackerOptions {
  129653. /**
  129654. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  129655. */
  129656. map?: string[];
  129657. /**
  129658. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129659. */
  129660. uvsIn?: string;
  129661. /**
  129662. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129663. */
  129664. uvsOut?: string;
  129665. /**
  129666. * number representing the layout style. Defaults to LAYOUT_STRIP
  129667. */
  129668. layout?: number;
  129669. /**
  129670. * number of columns if using custom column count layout(2). This defaults to 4.
  129671. */
  129672. colnum?: number;
  129673. /**
  129674. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  129675. */
  129676. updateInputMeshes?: boolean;
  129677. /**
  129678. * boolean flag to dispose all the source textures. Defaults to true.
  129679. */
  129680. disposeSources?: boolean;
  129681. /**
  129682. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  129683. */
  129684. fillBlanks?: boolean;
  129685. /**
  129686. * string value representing the context fill style color. Defaults to 'black'.
  129687. */
  129688. customFillColor?: string;
  129689. /**
  129690. * Width and Height Value of each Frame in the TexturePacker Sets
  129691. */
  129692. frameSize?: number;
  129693. /**
  129694. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  129695. */
  129696. paddingRatio?: number;
  129697. /**
  129698. * Number that declares the fill method for the padding gutter.
  129699. */
  129700. paddingMode?: number;
  129701. /**
  129702. * If in SUBUV_COLOR padding mode what color to use.
  129703. */
  129704. paddingColor?: Color3 | Color4;
  129705. }
  129706. /**
  129707. * Defines the basic interface of a TexturePacker JSON File
  129708. */
  129709. export interface ITexturePackerJSON {
  129710. /**
  129711. * The frame ID
  129712. */
  129713. name: string;
  129714. /**
  129715. * The base64 channel data
  129716. */
  129717. sets: any;
  129718. /**
  129719. * The options of the Packer
  129720. */
  129721. options: ITexturePackerOptions;
  129722. /**
  129723. * The frame data of the Packer
  129724. */
  129725. frames: Array<number>;
  129726. }
  129727. /**
  129728. * This is a support class that generates a series of packed texture sets.
  129729. * @see https://doc.babylonjs.com/babylon101/materials
  129730. */
  129731. export class TexturePacker {
  129732. /** Packer Layout Constant 0 */
  129733. static readonly LAYOUT_STRIP: number;
  129734. /** Packer Layout Constant 1 */
  129735. static readonly LAYOUT_POWER2: number;
  129736. /** Packer Layout Constant 2 */
  129737. static readonly LAYOUT_COLNUM: number;
  129738. /** Packer Layout Constant 0 */
  129739. static readonly SUBUV_WRAP: number;
  129740. /** Packer Layout Constant 1 */
  129741. static readonly SUBUV_EXTEND: number;
  129742. /** Packer Layout Constant 2 */
  129743. static readonly SUBUV_COLOR: number;
  129744. /** The Name of the Texture Package */
  129745. name: string;
  129746. /** The scene scope of the TexturePacker */
  129747. scene: Scene;
  129748. /** The Meshes to target */
  129749. meshes: AbstractMesh[];
  129750. /** Arguments passed with the Constructor */
  129751. options: ITexturePackerOptions;
  129752. /** The promise that is started upon initialization */
  129753. promise: Nullable<Promise<TexturePacker | string>>;
  129754. /** The Container object for the channel sets that are generated */
  129755. sets: object;
  129756. /** The Container array for the frames that are generated */
  129757. frames: TexturePackerFrame[];
  129758. /** The expected number of textures the system is parsing. */
  129759. private _expecting;
  129760. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  129761. private _paddingValue;
  129762. /**
  129763. * Initializes a texture package series from an array of meshes or a single mesh.
  129764. * @param name The name of the package
  129765. * @param meshes The target meshes to compose the package from
  129766. * @param options The arguments that texture packer should follow while building.
  129767. * @param scene The scene which the textures are scoped to.
  129768. * @returns TexturePacker
  129769. */
  129770. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  129771. /**
  129772. * Starts the package process
  129773. * @param resolve The promises resolution function
  129774. * @returns TexturePacker
  129775. */
  129776. private _createFrames;
  129777. /**
  129778. * Calculates the Size of the Channel Sets
  129779. * @returns Vector2
  129780. */
  129781. private _calculateSize;
  129782. /**
  129783. * Calculates the UV data for the frames.
  129784. * @param baseSize the base frameSize
  129785. * @param padding the base frame padding
  129786. * @param dtSize size of the Dynamic Texture for that channel
  129787. * @param dtUnits is 1/dtSize
  129788. * @param update flag to update the input meshes
  129789. */
  129790. private _calculateMeshUVFrames;
  129791. /**
  129792. * Calculates the frames Offset.
  129793. * @param index of the frame
  129794. * @returns Vector2
  129795. */
  129796. private _getFrameOffset;
  129797. /**
  129798. * Updates a Mesh to the frame data
  129799. * @param mesh that is the target
  129800. * @param frameID or the frame index
  129801. */
  129802. private _updateMeshUV;
  129803. /**
  129804. * Updates a Meshes materials to use the texture packer channels
  129805. * @param m is the mesh to target
  129806. * @param force all channels on the packer to be set.
  129807. */
  129808. private _updateTextureReferences;
  129809. /**
  129810. * Public method to set a Mesh to a frame
  129811. * @param m that is the target
  129812. * @param frameID or the frame index
  129813. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  129814. */
  129815. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  129816. /**
  129817. * Starts the async promise to compile the texture packer.
  129818. * @returns Promise<void>
  129819. */
  129820. processAsync(): Promise<void>;
  129821. /**
  129822. * Disposes all textures associated with this packer
  129823. */
  129824. dispose(): void;
  129825. /**
  129826. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  129827. * @param imageType is the image type to use.
  129828. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  129829. */
  129830. download(imageType?: string, quality?: number): void;
  129831. /**
  129832. * Public method to load a texturePacker JSON file.
  129833. * @param data of the JSON file in string format.
  129834. */
  129835. updateFromJSON(data: string): void;
  129836. }
  129837. }
  129838. declare module BABYLON {
  129839. /**
  129840. * Enum used to define the target of a block
  129841. */
  129842. export enum NodeMaterialBlockTargets {
  129843. /** Vertex shader */
  129844. Vertex = 1,
  129845. /** Fragment shader */
  129846. Fragment = 2,
  129847. /** Neutral */
  129848. Neutral = 4,
  129849. /** Vertex and Fragment */
  129850. VertexAndFragment = 3
  129851. }
  129852. }
  129853. declare module BABYLON {
  129854. /**
  129855. * Defines the kind of connection point for node based material
  129856. */
  129857. export enum NodeMaterialBlockConnectionPointTypes {
  129858. /** Float */
  129859. Float = 1,
  129860. /** Int */
  129861. Int = 2,
  129862. /** Vector2 */
  129863. Vector2 = 4,
  129864. /** Vector3 */
  129865. Vector3 = 8,
  129866. /** Vector4 */
  129867. Vector4 = 16,
  129868. /** Color3 */
  129869. Color3 = 32,
  129870. /** Color4 */
  129871. Color4 = 64,
  129872. /** Matrix */
  129873. Matrix = 128,
  129874. /** Detect type based on connection */
  129875. AutoDetect = 1024,
  129876. /** Output type that will be defined by input type */
  129877. BasedOnInput = 2048
  129878. }
  129879. }
  129880. declare module BABYLON {
  129881. /**
  129882. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  129883. */
  129884. export enum NodeMaterialBlockConnectionPointMode {
  129885. /** Value is an uniform */
  129886. Uniform = 0,
  129887. /** Value is a mesh attribute */
  129888. Attribute = 1,
  129889. /** Value is a varying between vertex and fragment shaders */
  129890. Varying = 2,
  129891. /** Mode is undefined */
  129892. Undefined = 3
  129893. }
  129894. }
  129895. declare module BABYLON {
  129896. /**
  129897. * Enum used to define system values e.g. values automatically provided by the system
  129898. */
  129899. export enum NodeMaterialSystemValues {
  129900. /** World */
  129901. World = 1,
  129902. /** View */
  129903. View = 2,
  129904. /** Projection */
  129905. Projection = 3,
  129906. /** ViewProjection */
  129907. ViewProjection = 4,
  129908. /** WorldView */
  129909. WorldView = 5,
  129910. /** WorldViewProjection */
  129911. WorldViewProjection = 6,
  129912. /** CameraPosition */
  129913. CameraPosition = 7,
  129914. /** Fog Color */
  129915. FogColor = 8,
  129916. /** Delta time */
  129917. DeltaTime = 9
  129918. }
  129919. }
  129920. declare module BABYLON {
  129921. /**
  129922. * Root class for all node material optimizers
  129923. */
  129924. export class NodeMaterialOptimizer {
  129925. /**
  129926. * Function used to optimize a NodeMaterial graph
  129927. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  129928. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  129929. */
  129930. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  129931. }
  129932. }
  129933. declare module BABYLON {
  129934. /**
  129935. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  129936. */
  129937. export class TransformBlock extends NodeMaterialBlock {
  129938. /**
  129939. * Defines the value to use to complement W value to transform it to a Vector4
  129940. */
  129941. complementW: number;
  129942. /**
  129943. * Defines the value to use to complement z value to transform it to a Vector4
  129944. */
  129945. complementZ: number;
  129946. /**
  129947. * Creates a new TransformBlock
  129948. * @param name defines the block name
  129949. */
  129950. constructor(name: string);
  129951. /**
  129952. * Gets the current class name
  129953. * @returns the class name
  129954. */
  129955. getClassName(): string;
  129956. /**
  129957. * Gets the vector input
  129958. */
  129959. get vector(): NodeMaterialConnectionPoint;
  129960. /**
  129961. * Gets the output component
  129962. */
  129963. get output(): NodeMaterialConnectionPoint;
  129964. /**
  129965. * Gets the matrix transform input
  129966. */
  129967. get transform(): NodeMaterialConnectionPoint;
  129968. protected _buildBlock(state: NodeMaterialBuildState): this;
  129969. serialize(): any;
  129970. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  129971. protected _dumpPropertiesCode(): string;
  129972. }
  129973. }
  129974. declare module BABYLON {
  129975. /**
  129976. * Block used to output the vertex position
  129977. */
  129978. export class VertexOutputBlock extends NodeMaterialBlock {
  129979. /**
  129980. * Creates a new VertexOutputBlock
  129981. * @param name defines the block name
  129982. */
  129983. constructor(name: string);
  129984. /**
  129985. * Gets the current class name
  129986. * @returns the class name
  129987. */
  129988. getClassName(): string;
  129989. /**
  129990. * Gets the vector input component
  129991. */
  129992. get vector(): NodeMaterialConnectionPoint;
  129993. protected _buildBlock(state: NodeMaterialBuildState): this;
  129994. }
  129995. }
  129996. declare module BABYLON {
  129997. /**
  129998. * Block used to output the final color
  129999. */
  130000. export class FragmentOutputBlock extends NodeMaterialBlock {
  130001. /**
  130002. * Create a new FragmentOutputBlock
  130003. * @param name defines the block name
  130004. */
  130005. constructor(name: string);
  130006. /**
  130007. * Gets the current class name
  130008. * @returns the class name
  130009. */
  130010. getClassName(): string;
  130011. /**
  130012. * Gets the rgba input component
  130013. */
  130014. get rgba(): NodeMaterialConnectionPoint;
  130015. /**
  130016. * Gets the rgb input component
  130017. */
  130018. get rgb(): NodeMaterialConnectionPoint;
  130019. /**
  130020. * Gets the a input component
  130021. */
  130022. get a(): NodeMaterialConnectionPoint;
  130023. protected _buildBlock(state: NodeMaterialBuildState): this;
  130024. }
  130025. }
  130026. declare module BABYLON {
  130027. /**
  130028. * Block used to read a reflection texture from a sampler
  130029. */
  130030. export class ReflectionTextureBlock extends NodeMaterialBlock {
  130031. private _define3DName;
  130032. private _defineCubicName;
  130033. private _defineExplicitName;
  130034. private _defineProjectionName;
  130035. private _defineLocalCubicName;
  130036. private _defineSphericalName;
  130037. private _definePlanarName;
  130038. private _defineEquirectangularName;
  130039. private _defineMirroredEquirectangularFixedName;
  130040. private _defineEquirectangularFixedName;
  130041. private _defineSkyboxName;
  130042. private _cubeSamplerName;
  130043. private _2DSamplerName;
  130044. private _positionUVWName;
  130045. private _directionWName;
  130046. private _reflectionCoordsName;
  130047. private _reflection2DCoordsName;
  130048. private _reflectionColorName;
  130049. private _reflectionMatrixName;
  130050. /**
  130051. * Gets or sets the texture associated with the node
  130052. */
  130053. texture: Nullable<BaseTexture>;
  130054. /**
  130055. * Create a new TextureBlock
  130056. * @param name defines the block name
  130057. */
  130058. constructor(name: string);
  130059. /**
  130060. * Gets the current class name
  130061. * @returns the class name
  130062. */
  130063. getClassName(): string;
  130064. /**
  130065. * Gets the world position input component
  130066. */
  130067. get position(): NodeMaterialConnectionPoint;
  130068. /**
  130069. * Gets the world position input component
  130070. */
  130071. get worldPosition(): NodeMaterialConnectionPoint;
  130072. /**
  130073. * Gets the world normal input component
  130074. */
  130075. get worldNormal(): NodeMaterialConnectionPoint;
  130076. /**
  130077. * Gets the world input component
  130078. */
  130079. get world(): NodeMaterialConnectionPoint;
  130080. /**
  130081. * Gets the camera (or eye) position component
  130082. */
  130083. get cameraPosition(): NodeMaterialConnectionPoint;
  130084. /**
  130085. * Gets the view input component
  130086. */
  130087. get view(): NodeMaterialConnectionPoint;
  130088. /**
  130089. * Gets the rgb output component
  130090. */
  130091. get rgb(): NodeMaterialConnectionPoint;
  130092. /**
  130093. * Gets the r output component
  130094. */
  130095. get r(): NodeMaterialConnectionPoint;
  130096. /**
  130097. * Gets the g output component
  130098. */
  130099. get g(): NodeMaterialConnectionPoint;
  130100. /**
  130101. * Gets the b output component
  130102. */
  130103. get b(): NodeMaterialConnectionPoint;
  130104. autoConfigure(material: NodeMaterial): void;
  130105. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130106. isReady(): boolean;
  130107. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130108. private _injectVertexCode;
  130109. private _writeOutput;
  130110. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130111. protected _dumpPropertiesCode(): string;
  130112. serialize(): any;
  130113. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130114. }
  130115. }
  130116. declare module BABYLON {
  130117. /**
  130118. * Interface used to configure the node material editor
  130119. */
  130120. export interface INodeMaterialEditorOptions {
  130121. /** Define the URl to load node editor script */
  130122. editorURL?: string;
  130123. }
  130124. /** @hidden */
  130125. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  130126. NORMAL: boolean;
  130127. TANGENT: boolean;
  130128. UV1: boolean;
  130129. /** BONES */
  130130. NUM_BONE_INFLUENCERS: number;
  130131. BonesPerMesh: number;
  130132. BONETEXTURE: boolean;
  130133. /** MORPH TARGETS */
  130134. MORPHTARGETS: boolean;
  130135. MORPHTARGETS_NORMAL: boolean;
  130136. MORPHTARGETS_TANGENT: boolean;
  130137. MORPHTARGETS_UV: boolean;
  130138. NUM_MORPH_INFLUENCERS: number;
  130139. /** IMAGE PROCESSING */
  130140. IMAGEPROCESSING: boolean;
  130141. VIGNETTE: boolean;
  130142. VIGNETTEBLENDMODEMULTIPLY: boolean;
  130143. VIGNETTEBLENDMODEOPAQUE: boolean;
  130144. TONEMAPPING: boolean;
  130145. TONEMAPPING_ACES: boolean;
  130146. CONTRAST: boolean;
  130147. EXPOSURE: boolean;
  130148. COLORCURVES: boolean;
  130149. COLORGRADING: boolean;
  130150. COLORGRADING3D: boolean;
  130151. SAMPLER3DGREENDEPTH: boolean;
  130152. SAMPLER3DBGRMAP: boolean;
  130153. IMAGEPROCESSINGPOSTPROCESS: boolean;
  130154. /** MISC. */
  130155. BUMPDIRECTUV: number;
  130156. constructor();
  130157. setValue(name: string, value: boolean): void;
  130158. }
  130159. /**
  130160. * Class used to configure NodeMaterial
  130161. */
  130162. export interface INodeMaterialOptions {
  130163. /**
  130164. * Defines if blocks should emit comments
  130165. */
  130166. emitComments: boolean;
  130167. }
  130168. /**
  130169. * Class used to create a node based material built by assembling shader blocks
  130170. */
  130171. export class NodeMaterial extends PushMaterial {
  130172. private static _BuildIdGenerator;
  130173. private _options;
  130174. private _vertexCompilationState;
  130175. private _fragmentCompilationState;
  130176. private _sharedData;
  130177. private _buildId;
  130178. private _buildWasSuccessful;
  130179. private _cachedWorldViewMatrix;
  130180. private _cachedWorldViewProjectionMatrix;
  130181. private _optimizers;
  130182. private _animationFrame;
  130183. /** Define the Url to load node editor script */
  130184. static EditorURL: string;
  130185. /** Define the Url to load snippets */
  130186. static SnippetUrl: string;
  130187. private BJSNODEMATERIALEDITOR;
  130188. /** Get the inspector from bundle or global */
  130189. private _getGlobalNodeMaterialEditor;
  130190. /**
  130191. * Gets or sets data used by visual editor
  130192. * @see https://nme.babylonjs.com
  130193. */
  130194. editorData: any;
  130195. /**
  130196. * 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)
  130197. */
  130198. ignoreAlpha: boolean;
  130199. /**
  130200. * Defines the maximum number of lights that can be used in the material
  130201. */
  130202. maxSimultaneousLights: number;
  130203. /**
  130204. * Observable raised when the material is built
  130205. */
  130206. onBuildObservable: Observable<NodeMaterial>;
  130207. /**
  130208. * Gets or sets the root nodes of the material vertex shader
  130209. */
  130210. _vertexOutputNodes: NodeMaterialBlock[];
  130211. /**
  130212. * Gets or sets the root nodes of the material fragment (pixel) shader
  130213. */
  130214. _fragmentOutputNodes: NodeMaterialBlock[];
  130215. /** Gets or sets options to control the node material overall behavior */
  130216. get options(): INodeMaterialOptions;
  130217. set options(options: INodeMaterialOptions);
  130218. /**
  130219. * Default configuration related to image processing available in the standard Material.
  130220. */
  130221. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130222. /**
  130223. * Gets the image processing configuration used either in this material.
  130224. */
  130225. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  130226. /**
  130227. * Sets the Default image processing configuration used either in the this material.
  130228. *
  130229. * If sets to null, the scene one is in use.
  130230. */
  130231. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  130232. /**
  130233. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  130234. */
  130235. attachedBlocks: NodeMaterialBlock[];
  130236. /**
  130237. * Create a new node based material
  130238. * @param name defines the material name
  130239. * @param scene defines the hosting scene
  130240. * @param options defines creation option
  130241. */
  130242. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  130243. /**
  130244. * Gets the current class name of the material e.g. "NodeMaterial"
  130245. * @returns the class name
  130246. */
  130247. getClassName(): string;
  130248. /**
  130249. * Keep track of the image processing observer to allow dispose and replace.
  130250. */
  130251. private _imageProcessingObserver;
  130252. /**
  130253. * Attaches a new image processing configuration to the Standard Material.
  130254. * @param configuration
  130255. */
  130256. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130257. /**
  130258. * Get a block by its name
  130259. * @param name defines the name of the block to retrieve
  130260. * @returns the required block or null if not found
  130261. */
  130262. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  130263. /**
  130264. * Get a block by its name
  130265. * @param predicate defines the predicate used to find the good candidate
  130266. * @returns the required block or null if not found
  130267. */
  130268. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  130269. /**
  130270. * Get an input block by its name
  130271. * @param predicate defines the predicate used to find the good candidate
  130272. * @returns the required input block or null if not found
  130273. */
  130274. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  130275. /**
  130276. * Gets the list of input blocks attached to this material
  130277. * @returns an array of InputBlocks
  130278. */
  130279. getInputBlocks(): InputBlock[];
  130280. /**
  130281. * Adds a new optimizer to the list of optimizers
  130282. * @param optimizer defines the optimizers to add
  130283. * @returns the current material
  130284. */
  130285. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130286. /**
  130287. * Remove an optimizer from the list of optimizers
  130288. * @param optimizer defines the optimizers to remove
  130289. * @returns the current material
  130290. */
  130291. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130292. /**
  130293. * Add a new block to the list of output nodes
  130294. * @param node defines the node to add
  130295. * @returns the current material
  130296. */
  130297. addOutputNode(node: NodeMaterialBlock): this;
  130298. /**
  130299. * Remove a block from the list of root nodes
  130300. * @param node defines the node to remove
  130301. * @returns the current material
  130302. */
  130303. removeOutputNode(node: NodeMaterialBlock): this;
  130304. private _addVertexOutputNode;
  130305. private _removeVertexOutputNode;
  130306. private _addFragmentOutputNode;
  130307. private _removeFragmentOutputNode;
  130308. /**
  130309. * Specifies if the material will require alpha blending
  130310. * @returns a boolean specifying if alpha blending is needed
  130311. */
  130312. needAlphaBlending(): boolean;
  130313. /**
  130314. * Specifies if this material should be rendered in alpha test mode
  130315. * @returns a boolean specifying if an alpha test is needed.
  130316. */
  130317. needAlphaTesting(): boolean;
  130318. private _initializeBlock;
  130319. private _resetDualBlocks;
  130320. /**
  130321. * Remove a block from the current node material
  130322. * @param block defines the block to remove
  130323. */
  130324. removeBlock(block: NodeMaterialBlock): void;
  130325. /**
  130326. * Build the material and generates the inner effect
  130327. * @param verbose defines if the build should log activity
  130328. */
  130329. build(verbose?: boolean): void;
  130330. /**
  130331. * Runs an otpimization phase to try to improve the shader code
  130332. */
  130333. optimize(): void;
  130334. private _prepareDefinesForAttributes;
  130335. /**
  130336. * Get if the submesh is ready to be used and all its information available.
  130337. * Child classes can use it to update shaders
  130338. * @param mesh defines the mesh to check
  130339. * @param subMesh defines which submesh to check
  130340. * @param useInstances specifies that instances should be used
  130341. * @returns a boolean indicating that the submesh is ready or not
  130342. */
  130343. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130344. /**
  130345. * Get a string representing the shaders built by the current node graph
  130346. */
  130347. get compiledShaders(): string;
  130348. /**
  130349. * Binds the world matrix to the material
  130350. * @param world defines the world transformation matrix
  130351. */
  130352. bindOnlyWorldMatrix(world: Matrix): void;
  130353. /**
  130354. * Binds the submesh to this material by preparing the effect and shader to draw
  130355. * @param world defines the world transformation matrix
  130356. * @param mesh defines the mesh containing the submesh
  130357. * @param subMesh defines the submesh to bind the material to
  130358. */
  130359. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130360. /**
  130361. * Gets the active textures from the material
  130362. * @returns an array of textures
  130363. */
  130364. getActiveTextures(): BaseTexture[];
  130365. /**
  130366. * Gets the list of texture blocks
  130367. * @returns an array of texture blocks
  130368. */
  130369. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  130370. /**
  130371. * Specifies if the material uses a texture
  130372. * @param texture defines the texture to check against the material
  130373. * @returns a boolean specifying if the material uses the texture
  130374. */
  130375. hasTexture(texture: BaseTexture): boolean;
  130376. /**
  130377. * Disposes the material
  130378. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  130379. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  130380. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  130381. */
  130382. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  130383. /** Creates the node editor window. */
  130384. private _createNodeEditor;
  130385. /**
  130386. * Launch the node material editor
  130387. * @param config Define the configuration of the editor
  130388. * @return a promise fulfilled when the node editor is visible
  130389. */
  130390. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  130391. /**
  130392. * Clear the current material
  130393. */
  130394. clear(): void;
  130395. /**
  130396. * Clear the current material and set it to a default state
  130397. */
  130398. setToDefault(): void;
  130399. /**
  130400. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  130401. * @param url defines the url to load from
  130402. * @returns a promise that will fullfil when the material is fully loaded
  130403. */
  130404. loadAsync(url: string): Promise<void>;
  130405. private _gatherBlocks;
  130406. /**
  130407. * Generate a string containing the code declaration required to create an equivalent of this material
  130408. * @returns a string
  130409. */
  130410. generateCode(): string;
  130411. /**
  130412. * Serializes this material in a JSON representation
  130413. * @returns the serialized material object
  130414. */
  130415. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  130416. private _restoreConnections;
  130417. /**
  130418. * Clear the current graph and load a new one from a serialization object
  130419. * @param source defines the JSON representation of the material
  130420. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130421. */
  130422. loadFromSerialization(source: any, rootUrl?: string): void;
  130423. /**
  130424. * Creates a node material from parsed material data
  130425. * @param source defines the JSON representation of the material
  130426. * @param scene defines the hosting scene
  130427. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130428. * @returns a new node material
  130429. */
  130430. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  130431. /**
  130432. * Creates a node material from a snippet saved in a remote file
  130433. * @param name defines the name of the material to create
  130434. * @param url defines the url to load from
  130435. * @param scene defines the hosting scene
  130436. * @returns a promise that will resolve to the new node material
  130437. */
  130438. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  130439. /**
  130440. * Creates a node material from a snippet saved by the node material editor
  130441. * @param snippetId defines the snippet to load
  130442. * @param scene defines the hosting scene
  130443. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130444. * @returns a promise that will resolve to the new node material
  130445. */
  130446. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  130447. /**
  130448. * Creates a new node material set to default basic configuration
  130449. * @param name defines the name of the material
  130450. * @param scene defines the hosting scene
  130451. * @returns a new NodeMaterial
  130452. */
  130453. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  130454. }
  130455. }
  130456. declare module BABYLON {
  130457. /**
  130458. * Block used to read a texture from a sampler
  130459. */
  130460. export class TextureBlock extends NodeMaterialBlock {
  130461. private _defineName;
  130462. private _linearDefineName;
  130463. private _tempTextureRead;
  130464. private _samplerName;
  130465. private _transformedUVName;
  130466. private _textureTransformName;
  130467. private _textureInfoName;
  130468. private _mainUVName;
  130469. private _mainUVDefineName;
  130470. /**
  130471. * Gets or sets the texture associated with the node
  130472. */
  130473. texture: Nullable<Texture>;
  130474. /**
  130475. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  130476. */
  130477. convertToGammaSpace: boolean;
  130478. /**
  130479. * Create a new TextureBlock
  130480. * @param name defines the block name
  130481. */
  130482. constructor(name: string);
  130483. /**
  130484. * Gets the current class name
  130485. * @returns the class name
  130486. */
  130487. getClassName(): string;
  130488. /**
  130489. * Gets the uv input component
  130490. */
  130491. get uv(): NodeMaterialConnectionPoint;
  130492. /**
  130493. * Gets the rgba output component
  130494. */
  130495. get rgba(): NodeMaterialConnectionPoint;
  130496. /**
  130497. * Gets the rgb output component
  130498. */
  130499. get rgb(): NodeMaterialConnectionPoint;
  130500. /**
  130501. * Gets the r output component
  130502. */
  130503. get r(): NodeMaterialConnectionPoint;
  130504. /**
  130505. * Gets the g output component
  130506. */
  130507. get g(): NodeMaterialConnectionPoint;
  130508. /**
  130509. * Gets the b output component
  130510. */
  130511. get b(): NodeMaterialConnectionPoint;
  130512. /**
  130513. * Gets the a output component
  130514. */
  130515. get a(): NodeMaterialConnectionPoint;
  130516. get target(): NodeMaterialBlockTargets;
  130517. autoConfigure(material: NodeMaterial): void;
  130518. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130519. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130520. isReady(): boolean;
  130521. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130522. private get _isMixed();
  130523. private _injectVertexCode;
  130524. private _writeTextureRead;
  130525. private _writeOutput;
  130526. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130527. protected _dumpPropertiesCode(): string;
  130528. serialize(): any;
  130529. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130530. }
  130531. }
  130532. declare module BABYLON {
  130533. /**
  130534. * Class used to store shared data between 2 NodeMaterialBuildState
  130535. */
  130536. export class NodeMaterialBuildStateSharedData {
  130537. /**
  130538. * Gets the list of emitted varyings
  130539. */
  130540. temps: string[];
  130541. /**
  130542. * Gets the list of emitted varyings
  130543. */
  130544. varyings: string[];
  130545. /**
  130546. * Gets the varying declaration string
  130547. */
  130548. varyingDeclaration: string;
  130549. /**
  130550. * Input blocks
  130551. */
  130552. inputBlocks: InputBlock[];
  130553. /**
  130554. * Input blocks
  130555. */
  130556. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  130557. /**
  130558. * Bindable blocks (Blocks that need to set data to the effect)
  130559. */
  130560. bindableBlocks: NodeMaterialBlock[];
  130561. /**
  130562. * List of blocks that can provide a compilation fallback
  130563. */
  130564. blocksWithFallbacks: NodeMaterialBlock[];
  130565. /**
  130566. * List of blocks that can provide a define update
  130567. */
  130568. blocksWithDefines: NodeMaterialBlock[];
  130569. /**
  130570. * List of blocks that can provide a repeatable content
  130571. */
  130572. repeatableContentBlocks: NodeMaterialBlock[];
  130573. /**
  130574. * List of blocks that can provide a dynamic list of uniforms
  130575. */
  130576. dynamicUniformBlocks: NodeMaterialBlock[];
  130577. /**
  130578. * List of blocks that can block the isReady function for the material
  130579. */
  130580. blockingBlocks: NodeMaterialBlock[];
  130581. /**
  130582. * Gets the list of animated inputs
  130583. */
  130584. animatedInputs: InputBlock[];
  130585. /**
  130586. * Build Id used to avoid multiple recompilations
  130587. */
  130588. buildId: number;
  130589. /** List of emitted variables */
  130590. variableNames: {
  130591. [key: string]: number;
  130592. };
  130593. /** List of emitted defines */
  130594. defineNames: {
  130595. [key: string]: number;
  130596. };
  130597. /** Should emit comments? */
  130598. emitComments: boolean;
  130599. /** Emit build activity */
  130600. verbose: boolean;
  130601. /** Gets or sets the hosting scene */
  130602. scene: Scene;
  130603. /**
  130604. * Gets the compilation hints emitted at compilation time
  130605. */
  130606. hints: {
  130607. needWorldViewMatrix: boolean;
  130608. needWorldViewProjectionMatrix: boolean;
  130609. needAlphaBlending: boolean;
  130610. needAlphaTesting: boolean;
  130611. };
  130612. /**
  130613. * List of compilation checks
  130614. */
  130615. checks: {
  130616. emitVertex: boolean;
  130617. emitFragment: boolean;
  130618. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  130619. };
  130620. /** Creates a new shared data */
  130621. constructor();
  130622. /**
  130623. * Emits console errors and exceptions if there is a failing check
  130624. */
  130625. emitErrors(): void;
  130626. }
  130627. }
  130628. declare module BABYLON {
  130629. /**
  130630. * Class used to store node based material build state
  130631. */
  130632. export class NodeMaterialBuildState {
  130633. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  130634. supportUniformBuffers: boolean;
  130635. /**
  130636. * Gets the list of emitted attributes
  130637. */
  130638. attributes: string[];
  130639. /**
  130640. * Gets the list of emitted uniforms
  130641. */
  130642. uniforms: string[];
  130643. /**
  130644. * Gets the list of emitted constants
  130645. */
  130646. constants: string[];
  130647. /**
  130648. * Gets the list of emitted samplers
  130649. */
  130650. samplers: string[];
  130651. /**
  130652. * Gets the list of emitted functions
  130653. */
  130654. functions: {
  130655. [key: string]: string;
  130656. };
  130657. /**
  130658. * Gets the list of emitted extensions
  130659. */
  130660. extensions: {
  130661. [key: string]: string;
  130662. };
  130663. /**
  130664. * Gets the target of the compilation state
  130665. */
  130666. target: NodeMaterialBlockTargets;
  130667. /**
  130668. * Gets the list of emitted counters
  130669. */
  130670. counters: {
  130671. [key: string]: number;
  130672. };
  130673. /**
  130674. * Shared data between multiple NodeMaterialBuildState instances
  130675. */
  130676. sharedData: NodeMaterialBuildStateSharedData;
  130677. /** @hidden */
  130678. _vertexState: NodeMaterialBuildState;
  130679. /** @hidden */
  130680. _attributeDeclaration: string;
  130681. /** @hidden */
  130682. _uniformDeclaration: string;
  130683. /** @hidden */
  130684. _constantDeclaration: string;
  130685. /** @hidden */
  130686. _samplerDeclaration: string;
  130687. /** @hidden */
  130688. _varyingTransfer: string;
  130689. private _repeatableContentAnchorIndex;
  130690. /** @hidden */
  130691. _builtCompilationString: string;
  130692. /**
  130693. * Gets the emitted compilation strings
  130694. */
  130695. compilationString: string;
  130696. /**
  130697. * Finalize the compilation strings
  130698. * @param state defines the current compilation state
  130699. */
  130700. finalize(state: NodeMaterialBuildState): void;
  130701. /** @hidden */
  130702. get _repeatableContentAnchor(): string;
  130703. /** @hidden */
  130704. _getFreeVariableName(prefix: string): string;
  130705. /** @hidden */
  130706. _getFreeDefineName(prefix: string): string;
  130707. /** @hidden */
  130708. _excludeVariableName(name: string): void;
  130709. /** @hidden */
  130710. _emit2DSampler(name: string): void;
  130711. /** @hidden */
  130712. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  130713. /** @hidden */
  130714. _emitExtension(name: string, extension: string): void;
  130715. /** @hidden */
  130716. _emitFunction(name: string, code: string, comments: string): void;
  130717. /** @hidden */
  130718. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  130719. replaceStrings?: {
  130720. search: RegExp;
  130721. replace: string;
  130722. }[];
  130723. repeatKey?: string;
  130724. }): string;
  130725. /** @hidden */
  130726. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  130727. repeatKey?: string;
  130728. removeAttributes?: boolean;
  130729. removeUniforms?: boolean;
  130730. removeVaryings?: boolean;
  130731. removeIfDef?: boolean;
  130732. replaceStrings?: {
  130733. search: RegExp;
  130734. replace: string;
  130735. }[];
  130736. }, storeKey?: string): void;
  130737. /** @hidden */
  130738. _registerTempVariable(name: string): boolean;
  130739. /** @hidden */
  130740. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  130741. /** @hidden */
  130742. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  130743. /** @hidden */
  130744. _emitFloat(value: number): string;
  130745. }
  130746. }
  130747. declare module BABYLON {
  130748. /**
  130749. * Defines a block that can be used inside a node based material
  130750. */
  130751. export class NodeMaterialBlock {
  130752. private _buildId;
  130753. private _buildTarget;
  130754. private _target;
  130755. private _isFinalMerger;
  130756. private _isInput;
  130757. protected _isUnique: boolean;
  130758. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  130759. inputsAreExclusive: boolean;
  130760. /** @hidden */
  130761. _codeVariableName: string;
  130762. /** @hidden */
  130763. _inputs: NodeMaterialConnectionPoint[];
  130764. /** @hidden */
  130765. _outputs: NodeMaterialConnectionPoint[];
  130766. /** @hidden */
  130767. _preparationId: number;
  130768. /**
  130769. * Gets or sets the name of the block
  130770. */
  130771. name: string;
  130772. /**
  130773. * Gets or sets the unique id of the node
  130774. */
  130775. uniqueId: number;
  130776. /**
  130777. * Gets or sets the comments associated with this block
  130778. */
  130779. comments: string;
  130780. /**
  130781. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  130782. */
  130783. get isUnique(): boolean;
  130784. /**
  130785. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  130786. */
  130787. get isFinalMerger(): boolean;
  130788. /**
  130789. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  130790. */
  130791. get isInput(): boolean;
  130792. /**
  130793. * Gets or sets the build Id
  130794. */
  130795. get buildId(): number;
  130796. set buildId(value: number);
  130797. /**
  130798. * Gets or sets the target of the block
  130799. */
  130800. get target(): NodeMaterialBlockTargets;
  130801. set target(value: NodeMaterialBlockTargets);
  130802. /**
  130803. * Gets the list of input points
  130804. */
  130805. get inputs(): NodeMaterialConnectionPoint[];
  130806. /** Gets the list of output points */
  130807. get outputs(): NodeMaterialConnectionPoint[];
  130808. /**
  130809. * Find an input by its name
  130810. * @param name defines the name of the input to look for
  130811. * @returns the input or null if not found
  130812. */
  130813. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130814. /**
  130815. * Find an output by its name
  130816. * @param name defines the name of the outputto look for
  130817. * @returns the output or null if not found
  130818. */
  130819. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  130820. /**
  130821. * Creates a new NodeMaterialBlock
  130822. * @param name defines the block name
  130823. * @param target defines the target of that block (Vertex by default)
  130824. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  130825. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  130826. */
  130827. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  130828. /**
  130829. * Initialize the block and prepare the context for build
  130830. * @param state defines the state that will be used for the build
  130831. */
  130832. initialize(state: NodeMaterialBuildState): void;
  130833. /**
  130834. * Bind data to effect. Will only be called for blocks with isBindable === true
  130835. * @param effect defines the effect to bind data to
  130836. * @param nodeMaterial defines the hosting NodeMaterial
  130837. * @param mesh defines the mesh that will be rendered
  130838. */
  130839. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130840. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  130841. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  130842. protected _writeFloat(value: number): string;
  130843. /**
  130844. * Gets the current class name e.g. "NodeMaterialBlock"
  130845. * @returns the class name
  130846. */
  130847. getClassName(): string;
  130848. /**
  130849. * Register a new input. Must be called inside a block constructor
  130850. * @param name defines the connection point name
  130851. * @param type defines the connection point type
  130852. * @param isOptional defines a boolean indicating that this input can be omitted
  130853. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130854. * @returns the current block
  130855. */
  130856. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  130857. /**
  130858. * Register a new output. Must be called inside a block constructor
  130859. * @param name defines the connection point name
  130860. * @param type defines the connection point type
  130861. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  130862. * @returns the current block
  130863. */
  130864. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  130865. /**
  130866. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  130867. * @param forOutput defines an optional connection point to check compatibility with
  130868. * @returns the first available input or null
  130869. */
  130870. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  130871. /**
  130872. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  130873. * @param forBlock defines an optional block to check compatibility with
  130874. * @returns the first available input or null
  130875. */
  130876. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  130877. /**
  130878. * Gets the sibling of the given output
  130879. * @param current defines the current output
  130880. * @returns the next output in the list or null
  130881. */
  130882. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  130883. /**
  130884. * Connect current block with another block
  130885. * @param other defines the block to connect with
  130886. * @param options define the various options to help pick the right connections
  130887. * @returns the current block
  130888. */
  130889. connectTo(other: NodeMaterialBlock, options?: {
  130890. input?: string;
  130891. output?: string;
  130892. outputSwizzle?: string;
  130893. }): this | undefined;
  130894. protected _buildBlock(state: NodeMaterialBuildState): void;
  130895. /**
  130896. * Add uniforms, samplers and uniform buffers at compilation time
  130897. * @param state defines the state to update
  130898. * @param nodeMaterial defines the node material requesting the update
  130899. * @param defines defines the material defines to update
  130900. * @param uniformBuffers defines the list of uniform buffer names
  130901. */
  130902. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  130903. /**
  130904. * Add potential fallbacks if shader compilation fails
  130905. * @param mesh defines the mesh to be rendered
  130906. * @param fallbacks defines the current prioritized list of fallbacks
  130907. */
  130908. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  130909. /**
  130910. * Initialize defines for shader compilation
  130911. * @param mesh defines the mesh to be rendered
  130912. * @param nodeMaterial defines the node material requesting the update
  130913. * @param defines defines the material defines to update
  130914. * @param useInstances specifies that instances should be used
  130915. */
  130916. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130917. /**
  130918. * Update defines for shader compilation
  130919. * @param mesh defines the mesh to be rendered
  130920. * @param nodeMaterial defines the node material requesting the update
  130921. * @param defines defines the material defines to update
  130922. * @param useInstances specifies that instances should be used
  130923. */
  130924. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130925. /**
  130926. * Lets the block try to connect some inputs automatically
  130927. * @param material defines the hosting NodeMaterial
  130928. */
  130929. autoConfigure(material: NodeMaterial): void;
  130930. /**
  130931. * Function called when a block is declared as repeatable content generator
  130932. * @param vertexShaderState defines the current compilation state for the vertex shader
  130933. * @param fragmentShaderState defines the current compilation state for the fragment shader
  130934. * @param mesh defines the mesh to be rendered
  130935. * @param defines defines the material defines to update
  130936. */
  130937. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  130938. /**
  130939. * Checks if the block is ready
  130940. * @param mesh defines the mesh to be rendered
  130941. * @param nodeMaterial defines the node material requesting the update
  130942. * @param defines defines the material defines to update
  130943. * @param useInstances specifies that instances should be used
  130944. * @returns true if the block is ready
  130945. */
  130946. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  130947. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  130948. private _processBuild;
  130949. /**
  130950. * Compile the current node and generate the shader code
  130951. * @param state defines the current compilation state (uniforms, samplers, current string)
  130952. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  130953. * @returns true if already built
  130954. */
  130955. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  130956. protected _inputRename(name: string): string;
  130957. protected _outputRename(name: string): string;
  130958. protected _dumpPropertiesCode(): string;
  130959. /** @hidden */
  130960. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  130961. /** @hidden */
  130962. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  130963. /**
  130964. * Clone the current block to a new identical block
  130965. * @param scene defines the hosting scene
  130966. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130967. * @returns a copy of the current block
  130968. */
  130969. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  130970. /**
  130971. * Serializes this block in a JSON representation
  130972. * @returns the serialized block object
  130973. */
  130974. serialize(): any;
  130975. /** @hidden */
  130976. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130977. /**
  130978. * Release resources
  130979. */
  130980. dispose(): void;
  130981. }
  130982. }
  130983. declare module BABYLON {
  130984. /**
  130985. * Enum defining the type of animations supported by InputBlock
  130986. */
  130987. export enum AnimatedInputBlockTypes {
  130988. /** No animation */
  130989. None = 0,
  130990. /** Time based animation. Will only work for floats */
  130991. Time = 1
  130992. }
  130993. }
  130994. declare module BABYLON {
  130995. /**
  130996. * Block used to expose an input value
  130997. */
  130998. export class InputBlock extends NodeMaterialBlock {
  130999. private _mode;
  131000. private _associatedVariableName;
  131001. private _storedValue;
  131002. private _valueCallback;
  131003. private _type;
  131004. private _animationType;
  131005. /** Gets or set a value used to limit the range of float values */
  131006. min: number;
  131007. /** Gets or set a value used to limit the range of float values */
  131008. max: number;
  131009. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  131010. isBoolean: boolean;
  131011. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  131012. matrixMode: number;
  131013. /** @hidden */
  131014. _systemValue: Nullable<NodeMaterialSystemValues>;
  131015. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  131016. visibleInInspector: boolean;
  131017. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  131018. isConstant: boolean;
  131019. /** Gets or sets the group to use to display this block in the Inspector */
  131020. groupInInspector: string;
  131021. /** Gets an observable raised when the value is changed */
  131022. onValueChangedObservable: Observable<InputBlock>;
  131023. /**
  131024. * Gets or sets the connection point type (default is float)
  131025. */
  131026. get type(): NodeMaterialBlockConnectionPointTypes;
  131027. /**
  131028. * Creates a new InputBlock
  131029. * @param name defines the block name
  131030. * @param target defines the target of that block (Vertex by default)
  131031. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  131032. */
  131033. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  131034. /**
  131035. * Gets the output component
  131036. */
  131037. get output(): NodeMaterialConnectionPoint;
  131038. /**
  131039. * Set the source of this connection point to a vertex attribute
  131040. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  131041. * @returns the current connection point
  131042. */
  131043. setAsAttribute(attributeName?: string): InputBlock;
  131044. /**
  131045. * Set the source of this connection point to a system value
  131046. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  131047. * @returns the current connection point
  131048. */
  131049. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  131050. /**
  131051. * Gets or sets the value of that point.
  131052. * Please note that this value will be ignored if valueCallback is defined
  131053. */
  131054. get value(): any;
  131055. set value(value: any);
  131056. /**
  131057. * Gets or sets a callback used to get the value of that point.
  131058. * Please note that setting this value will force the connection point to ignore the value property
  131059. */
  131060. get valueCallback(): () => any;
  131061. set valueCallback(value: () => any);
  131062. /**
  131063. * Gets or sets the associated variable name in the shader
  131064. */
  131065. get associatedVariableName(): string;
  131066. set associatedVariableName(value: string);
  131067. /** Gets or sets the type of animation applied to the input */
  131068. get animationType(): AnimatedInputBlockTypes;
  131069. set animationType(value: AnimatedInputBlockTypes);
  131070. /**
  131071. * Gets a boolean indicating that this connection point not defined yet
  131072. */
  131073. get isUndefined(): boolean;
  131074. /**
  131075. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  131076. * In this case the connection point name must be the name of the uniform to use.
  131077. * Can only be set on inputs
  131078. */
  131079. get isUniform(): boolean;
  131080. set isUniform(value: boolean);
  131081. /**
  131082. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  131083. * In this case the connection point name must be the name of the attribute to use
  131084. * Can only be set on inputs
  131085. */
  131086. get isAttribute(): boolean;
  131087. set isAttribute(value: boolean);
  131088. /**
  131089. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  131090. * Can only be set on exit points
  131091. */
  131092. get isVarying(): boolean;
  131093. set isVarying(value: boolean);
  131094. /**
  131095. * Gets a boolean indicating that the current connection point is a system value
  131096. */
  131097. get isSystemValue(): boolean;
  131098. /**
  131099. * Gets or sets the current well known value or null if not defined as a system value
  131100. */
  131101. get systemValue(): Nullable<NodeMaterialSystemValues>;
  131102. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  131103. /**
  131104. * Gets the current class name
  131105. * @returns the class name
  131106. */
  131107. getClassName(): string;
  131108. /**
  131109. * Animate the input if animationType !== None
  131110. * @param scene defines the rendering scene
  131111. */
  131112. animate(scene: Scene): void;
  131113. private _emitDefine;
  131114. initialize(state: NodeMaterialBuildState): void;
  131115. /**
  131116. * Set the input block to its default value (based on its type)
  131117. */
  131118. setDefaultValue(): void;
  131119. private _emitConstant;
  131120. private _emit;
  131121. /** @hidden */
  131122. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  131123. /** @hidden */
  131124. _transmit(effect: Effect, scene: Scene): void;
  131125. protected _buildBlock(state: NodeMaterialBuildState): void;
  131126. protected _dumpPropertiesCode(): string;
  131127. dispose(): void;
  131128. serialize(): any;
  131129. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131130. }
  131131. }
  131132. declare module BABYLON {
  131133. /**
  131134. * Enum used to define the compatibility state between two connection points
  131135. */
  131136. export enum NodeMaterialConnectionPointCompatibilityStates {
  131137. /** Points are compatibles */
  131138. Compatible = 0,
  131139. /** Points are incompatible because of their types */
  131140. TypeIncompatible = 1,
  131141. /** Points are incompatible because of their targets (vertex vs fragment) */
  131142. TargetIncompatible = 2
  131143. }
  131144. /**
  131145. * Defines the direction of a connection point
  131146. */
  131147. export enum NodeMaterialConnectionPointDirection {
  131148. /** Input */
  131149. Input = 0,
  131150. /** Output */
  131151. Output = 1
  131152. }
  131153. /**
  131154. * Defines a connection point for a block
  131155. */
  131156. export class NodeMaterialConnectionPoint {
  131157. /** @hidden */
  131158. _ownerBlock: NodeMaterialBlock;
  131159. /** @hidden */
  131160. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  131161. private _endpoints;
  131162. private _associatedVariableName;
  131163. private _direction;
  131164. /** @hidden */
  131165. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131166. /** @hidden */
  131167. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131168. private _type;
  131169. /** @hidden */
  131170. _enforceAssociatedVariableName: boolean;
  131171. /** Gets the direction of the point */
  131172. get direction(): NodeMaterialConnectionPointDirection;
  131173. /**
  131174. * Gets or sets the additional types supported by this connection point
  131175. */
  131176. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131177. /**
  131178. * Gets or sets the additional types excluded by this connection point
  131179. */
  131180. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131181. /**
  131182. * Observable triggered when this point is connected
  131183. */
  131184. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  131185. /**
  131186. * Gets or sets the associated variable name in the shader
  131187. */
  131188. get associatedVariableName(): string;
  131189. set associatedVariableName(value: string);
  131190. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  131191. get innerType(): NodeMaterialBlockConnectionPointTypes;
  131192. /**
  131193. * Gets or sets the connection point type (default is float)
  131194. */
  131195. get type(): NodeMaterialBlockConnectionPointTypes;
  131196. set type(value: NodeMaterialBlockConnectionPointTypes);
  131197. /**
  131198. * Gets or sets the connection point name
  131199. */
  131200. name: string;
  131201. /**
  131202. * Gets or sets a boolean indicating that this connection point can be omitted
  131203. */
  131204. isOptional: boolean;
  131205. /**
  131206. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  131207. */
  131208. define: string;
  131209. /** @hidden */
  131210. _prioritizeVertex: boolean;
  131211. private _target;
  131212. /** Gets or sets the target of that connection point */
  131213. get target(): NodeMaterialBlockTargets;
  131214. set target(value: NodeMaterialBlockTargets);
  131215. /**
  131216. * Gets a boolean indicating that the current point is connected
  131217. */
  131218. get isConnected(): boolean;
  131219. /**
  131220. * Gets a boolean indicating that the current point is connected to an input block
  131221. */
  131222. get isConnectedToInputBlock(): boolean;
  131223. /**
  131224. * Gets a the connected input block (if any)
  131225. */
  131226. get connectInputBlock(): Nullable<InputBlock>;
  131227. /** Get the other side of the connection (if any) */
  131228. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  131229. /** Get the block that owns this connection point */
  131230. get ownerBlock(): NodeMaterialBlock;
  131231. /** Get the block connected on the other side of this connection (if any) */
  131232. get sourceBlock(): Nullable<NodeMaterialBlock>;
  131233. /** Get the block connected on the endpoints of this connection (if any) */
  131234. get connectedBlocks(): Array<NodeMaterialBlock>;
  131235. /** Gets the list of connected endpoints */
  131236. get endpoints(): NodeMaterialConnectionPoint[];
  131237. /** Gets a boolean indicating if that output point is connected to at least one input */
  131238. get hasEndpoints(): boolean;
  131239. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  131240. get isConnectedInVertexShader(): boolean;
  131241. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  131242. get isConnectedInFragmentShader(): boolean;
  131243. /**
  131244. * Creates a new connection point
  131245. * @param name defines the connection point name
  131246. * @param ownerBlock defines the block hosting this connection point
  131247. * @param direction defines the direction of the connection point
  131248. */
  131249. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  131250. /**
  131251. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  131252. * @returns the class name
  131253. */
  131254. getClassName(): string;
  131255. /**
  131256. * Gets a boolean indicating if the current point can be connected to another point
  131257. * @param connectionPoint defines the other connection point
  131258. * @returns a boolean
  131259. */
  131260. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  131261. /**
  131262. * Gets a number indicating if the current point can be connected to another point
  131263. * @param connectionPoint defines the other connection point
  131264. * @returns a number defining the compatibility state
  131265. */
  131266. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  131267. /**
  131268. * Connect this point to another connection point
  131269. * @param connectionPoint defines the other connection point
  131270. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  131271. * @returns the current connection point
  131272. */
  131273. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  131274. /**
  131275. * Disconnect this point from one of his endpoint
  131276. * @param endpoint defines the other connection point
  131277. * @returns the current connection point
  131278. */
  131279. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  131280. /**
  131281. * Serializes this point in a JSON representation
  131282. * @returns the serialized point object
  131283. */
  131284. serialize(): any;
  131285. /**
  131286. * Release resources
  131287. */
  131288. dispose(): void;
  131289. }
  131290. }
  131291. declare module BABYLON {
  131292. /**
  131293. * Block used to add support for vertex skinning (bones)
  131294. */
  131295. export class BonesBlock extends NodeMaterialBlock {
  131296. /**
  131297. * Creates a new BonesBlock
  131298. * @param name defines the block name
  131299. */
  131300. constructor(name: string);
  131301. /**
  131302. * Initialize the block and prepare the context for build
  131303. * @param state defines the state that will be used for the build
  131304. */
  131305. initialize(state: NodeMaterialBuildState): void;
  131306. /**
  131307. * Gets the current class name
  131308. * @returns the class name
  131309. */
  131310. getClassName(): string;
  131311. /**
  131312. * Gets the matrix indices input component
  131313. */
  131314. get matricesIndices(): NodeMaterialConnectionPoint;
  131315. /**
  131316. * Gets the matrix weights input component
  131317. */
  131318. get matricesWeights(): NodeMaterialConnectionPoint;
  131319. /**
  131320. * Gets the extra matrix indices input component
  131321. */
  131322. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  131323. /**
  131324. * Gets the extra matrix weights input component
  131325. */
  131326. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  131327. /**
  131328. * Gets the world input component
  131329. */
  131330. get world(): NodeMaterialConnectionPoint;
  131331. /**
  131332. * Gets the output component
  131333. */
  131334. get output(): NodeMaterialConnectionPoint;
  131335. autoConfigure(material: NodeMaterial): void;
  131336. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131337. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131338. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131339. protected _buildBlock(state: NodeMaterialBuildState): this;
  131340. }
  131341. }
  131342. declare module BABYLON {
  131343. /**
  131344. * Block used to add support for instances
  131345. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  131346. */
  131347. export class InstancesBlock extends NodeMaterialBlock {
  131348. /**
  131349. * Creates a new InstancesBlock
  131350. * @param name defines the block name
  131351. */
  131352. constructor(name: string);
  131353. /**
  131354. * Gets the current class name
  131355. * @returns the class name
  131356. */
  131357. getClassName(): string;
  131358. /**
  131359. * Gets the first world row input component
  131360. */
  131361. get world0(): NodeMaterialConnectionPoint;
  131362. /**
  131363. * Gets the second world row input component
  131364. */
  131365. get world1(): NodeMaterialConnectionPoint;
  131366. /**
  131367. * Gets the third world row input component
  131368. */
  131369. get world2(): NodeMaterialConnectionPoint;
  131370. /**
  131371. * Gets the forth world row input component
  131372. */
  131373. get world3(): NodeMaterialConnectionPoint;
  131374. /**
  131375. * Gets the world input component
  131376. */
  131377. get world(): NodeMaterialConnectionPoint;
  131378. /**
  131379. * Gets the output component
  131380. */
  131381. get output(): NodeMaterialConnectionPoint;
  131382. /**
  131383. * Gets the isntanceID component
  131384. */
  131385. get instanceID(): NodeMaterialConnectionPoint;
  131386. autoConfigure(material: NodeMaterial): void;
  131387. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131388. protected _buildBlock(state: NodeMaterialBuildState): this;
  131389. }
  131390. }
  131391. declare module BABYLON {
  131392. /**
  131393. * Block used to add morph targets support to vertex shader
  131394. */
  131395. export class MorphTargetsBlock extends NodeMaterialBlock {
  131396. private _repeatableContentAnchor;
  131397. /**
  131398. * Create a new MorphTargetsBlock
  131399. * @param name defines the block name
  131400. */
  131401. constructor(name: string);
  131402. /**
  131403. * Gets the current class name
  131404. * @returns the class name
  131405. */
  131406. getClassName(): string;
  131407. /**
  131408. * Gets the position input component
  131409. */
  131410. get position(): NodeMaterialConnectionPoint;
  131411. /**
  131412. * Gets the normal input component
  131413. */
  131414. get normal(): NodeMaterialConnectionPoint;
  131415. /**
  131416. * Gets the tangent input component
  131417. */
  131418. get tangent(): NodeMaterialConnectionPoint;
  131419. /**
  131420. * Gets the tangent input component
  131421. */
  131422. get uv(): NodeMaterialConnectionPoint;
  131423. /**
  131424. * Gets the position output component
  131425. */
  131426. get positionOutput(): NodeMaterialConnectionPoint;
  131427. /**
  131428. * Gets the normal output component
  131429. */
  131430. get normalOutput(): NodeMaterialConnectionPoint;
  131431. /**
  131432. * Gets the tangent output component
  131433. */
  131434. get tangentOutput(): NodeMaterialConnectionPoint;
  131435. /**
  131436. * Gets the tangent output component
  131437. */
  131438. get uvOutput(): NodeMaterialConnectionPoint;
  131439. initialize(state: NodeMaterialBuildState): void;
  131440. autoConfigure(material: NodeMaterial): void;
  131441. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131442. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131443. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131444. protected _buildBlock(state: NodeMaterialBuildState): this;
  131445. }
  131446. }
  131447. declare module BABYLON {
  131448. /**
  131449. * Block used to get data information from a light
  131450. */
  131451. export class LightInformationBlock extends NodeMaterialBlock {
  131452. private _lightDataUniformName;
  131453. private _lightColorUniformName;
  131454. private _lightTypeDefineName;
  131455. /**
  131456. * Gets or sets the light associated with this block
  131457. */
  131458. light: Nullable<Light>;
  131459. /**
  131460. * Creates a new LightInformationBlock
  131461. * @param name defines the block name
  131462. */
  131463. constructor(name: string);
  131464. /**
  131465. * Gets the current class name
  131466. * @returns the class name
  131467. */
  131468. getClassName(): string;
  131469. /**
  131470. * Gets the world position input component
  131471. */
  131472. get worldPosition(): NodeMaterialConnectionPoint;
  131473. /**
  131474. * Gets the direction output component
  131475. */
  131476. get direction(): NodeMaterialConnectionPoint;
  131477. /**
  131478. * Gets the direction output component
  131479. */
  131480. get color(): NodeMaterialConnectionPoint;
  131481. /**
  131482. * Gets the direction output component
  131483. */
  131484. get intensity(): NodeMaterialConnectionPoint;
  131485. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131486. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131487. protected _buildBlock(state: NodeMaterialBuildState): this;
  131488. serialize(): any;
  131489. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131490. }
  131491. }
  131492. declare module BABYLON {
  131493. /**
  131494. * Block used to add image processing support to fragment shader
  131495. */
  131496. export class ImageProcessingBlock extends NodeMaterialBlock {
  131497. /**
  131498. * Create a new ImageProcessingBlock
  131499. * @param name defines the block name
  131500. */
  131501. constructor(name: string);
  131502. /**
  131503. * Gets the current class name
  131504. * @returns the class name
  131505. */
  131506. getClassName(): string;
  131507. /**
  131508. * Gets the color input component
  131509. */
  131510. get color(): NodeMaterialConnectionPoint;
  131511. /**
  131512. * Gets the output component
  131513. */
  131514. get output(): NodeMaterialConnectionPoint;
  131515. /**
  131516. * Initialize the block and prepare the context for build
  131517. * @param state defines the state that will be used for the build
  131518. */
  131519. initialize(state: NodeMaterialBuildState): void;
  131520. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  131521. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131522. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131523. protected _buildBlock(state: NodeMaterialBuildState): this;
  131524. }
  131525. }
  131526. declare module BABYLON {
  131527. /**
  131528. * Block used to pertub normals based on a normal map
  131529. */
  131530. export class PerturbNormalBlock extends NodeMaterialBlock {
  131531. private _tangentSpaceParameterName;
  131532. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  131533. invertX: boolean;
  131534. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  131535. invertY: boolean;
  131536. /**
  131537. * Create a new PerturbNormalBlock
  131538. * @param name defines the block name
  131539. */
  131540. constructor(name: string);
  131541. /**
  131542. * Gets the current class name
  131543. * @returns the class name
  131544. */
  131545. getClassName(): string;
  131546. /**
  131547. * Gets the world position input component
  131548. */
  131549. get worldPosition(): NodeMaterialConnectionPoint;
  131550. /**
  131551. * Gets the world normal input component
  131552. */
  131553. get worldNormal(): NodeMaterialConnectionPoint;
  131554. /**
  131555. * Gets the world tangent input component
  131556. */
  131557. get worldTangent(): NodeMaterialConnectionPoint;
  131558. /**
  131559. * Gets the uv input component
  131560. */
  131561. get uv(): NodeMaterialConnectionPoint;
  131562. /**
  131563. * Gets the normal map color input component
  131564. */
  131565. get normalMapColor(): NodeMaterialConnectionPoint;
  131566. /**
  131567. * Gets the strength input component
  131568. */
  131569. get strength(): NodeMaterialConnectionPoint;
  131570. /**
  131571. * Gets the output component
  131572. */
  131573. get output(): NodeMaterialConnectionPoint;
  131574. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131575. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131576. autoConfigure(material: NodeMaterial): void;
  131577. protected _buildBlock(state: NodeMaterialBuildState): this;
  131578. protected _dumpPropertiesCode(): string;
  131579. serialize(): any;
  131580. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131581. }
  131582. }
  131583. declare module BABYLON {
  131584. /**
  131585. * Block used to discard a pixel if a value is smaller than a cutoff
  131586. */
  131587. export class DiscardBlock extends NodeMaterialBlock {
  131588. /**
  131589. * Create a new DiscardBlock
  131590. * @param name defines the block name
  131591. */
  131592. constructor(name: string);
  131593. /**
  131594. * Gets the current class name
  131595. * @returns the class name
  131596. */
  131597. getClassName(): string;
  131598. /**
  131599. * Gets the color input component
  131600. */
  131601. get value(): NodeMaterialConnectionPoint;
  131602. /**
  131603. * Gets the cutoff input component
  131604. */
  131605. get cutoff(): NodeMaterialConnectionPoint;
  131606. protected _buildBlock(state: NodeMaterialBuildState): this;
  131607. }
  131608. }
  131609. declare module BABYLON {
  131610. /**
  131611. * Block used to test if the fragment shader is front facing
  131612. */
  131613. export class FrontFacingBlock extends NodeMaterialBlock {
  131614. /**
  131615. * Creates a new FrontFacingBlock
  131616. * @param name defines the block name
  131617. */
  131618. constructor(name: string);
  131619. /**
  131620. * Gets the current class name
  131621. * @returns the class name
  131622. */
  131623. getClassName(): string;
  131624. /**
  131625. * Gets the output component
  131626. */
  131627. get output(): NodeMaterialConnectionPoint;
  131628. protected _buildBlock(state: NodeMaterialBuildState): this;
  131629. }
  131630. }
  131631. declare module BABYLON {
  131632. /**
  131633. * Block used to get the derivative value on x and y of a given input
  131634. */
  131635. export class DerivativeBlock extends NodeMaterialBlock {
  131636. /**
  131637. * Create a new DerivativeBlock
  131638. * @param name defines the block name
  131639. */
  131640. constructor(name: string);
  131641. /**
  131642. * Gets the current class name
  131643. * @returns the class name
  131644. */
  131645. getClassName(): string;
  131646. /**
  131647. * Gets the input component
  131648. */
  131649. get input(): NodeMaterialConnectionPoint;
  131650. /**
  131651. * Gets the derivative output on x
  131652. */
  131653. get dx(): NodeMaterialConnectionPoint;
  131654. /**
  131655. * Gets the derivative output on y
  131656. */
  131657. get dy(): NodeMaterialConnectionPoint;
  131658. protected _buildBlock(state: NodeMaterialBuildState): this;
  131659. }
  131660. }
  131661. declare module BABYLON {
  131662. /**
  131663. * Block used to add support for scene fog
  131664. */
  131665. export class FogBlock extends NodeMaterialBlock {
  131666. private _fogDistanceName;
  131667. private _fogParameters;
  131668. /**
  131669. * Create a new FogBlock
  131670. * @param name defines the block name
  131671. */
  131672. constructor(name: string);
  131673. /**
  131674. * Gets the current class name
  131675. * @returns the class name
  131676. */
  131677. getClassName(): string;
  131678. /**
  131679. * Gets the world position input component
  131680. */
  131681. get worldPosition(): NodeMaterialConnectionPoint;
  131682. /**
  131683. * Gets the view input component
  131684. */
  131685. get view(): NodeMaterialConnectionPoint;
  131686. /**
  131687. * Gets the color input component
  131688. */
  131689. get input(): NodeMaterialConnectionPoint;
  131690. /**
  131691. * Gets the fog color input component
  131692. */
  131693. get fogColor(): NodeMaterialConnectionPoint;
  131694. /**
  131695. * Gets the output component
  131696. */
  131697. get output(): NodeMaterialConnectionPoint;
  131698. autoConfigure(material: NodeMaterial): void;
  131699. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131700. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131701. protected _buildBlock(state: NodeMaterialBuildState): this;
  131702. }
  131703. }
  131704. declare module BABYLON {
  131705. /**
  131706. * Block used to add light in the fragment shader
  131707. */
  131708. export class LightBlock extends NodeMaterialBlock {
  131709. private _lightId;
  131710. /**
  131711. * Gets or sets the light associated with this block
  131712. */
  131713. light: Nullable<Light>;
  131714. /**
  131715. * Create a new LightBlock
  131716. * @param name defines the block name
  131717. */
  131718. constructor(name: string);
  131719. /**
  131720. * Gets the current class name
  131721. * @returns the class name
  131722. */
  131723. getClassName(): string;
  131724. /**
  131725. * Gets the world position input component
  131726. */
  131727. get worldPosition(): NodeMaterialConnectionPoint;
  131728. /**
  131729. * Gets the world normal input component
  131730. */
  131731. get worldNormal(): NodeMaterialConnectionPoint;
  131732. /**
  131733. * Gets the camera (or eye) position component
  131734. */
  131735. get cameraPosition(): NodeMaterialConnectionPoint;
  131736. /**
  131737. * Gets the glossiness component
  131738. */
  131739. get glossiness(): NodeMaterialConnectionPoint;
  131740. /**
  131741. * Gets the glossinness power component
  131742. */
  131743. get glossPower(): NodeMaterialConnectionPoint;
  131744. /**
  131745. * Gets the diffuse color component
  131746. */
  131747. get diffuseColor(): NodeMaterialConnectionPoint;
  131748. /**
  131749. * Gets the specular color component
  131750. */
  131751. get specularColor(): NodeMaterialConnectionPoint;
  131752. /**
  131753. * Gets the diffuse output component
  131754. */
  131755. get diffuseOutput(): NodeMaterialConnectionPoint;
  131756. /**
  131757. * Gets the specular output component
  131758. */
  131759. get specularOutput(): NodeMaterialConnectionPoint;
  131760. /**
  131761. * Gets the shadow output component
  131762. */
  131763. get shadow(): NodeMaterialConnectionPoint;
  131764. autoConfigure(material: NodeMaterial): void;
  131765. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131766. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131767. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131768. private _injectVertexCode;
  131769. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131770. serialize(): any;
  131771. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131772. }
  131773. }
  131774. declare module BABYLON {
  131775. /**
  131776. * Block used to multiply 2 values
  131777. */
  131778. export class MultiplyBlock extends NodeMaterialBlock {
  131779. /**
  131780. * Creates a new MultiplyBlock
  131781. * @param name defines the block name
  131782. */
  131783. constructor(name: string);
  131784. /**
  131785. * Gets the current class name
  131786. * @returns the class name
  131787. */
  131788. getClassName(): string;
  131789. /**
  131790. * Gets the left operand input component
  131791. */
  131792. get left(): NodeMaterialConnectionPoint;
  131793. /**
  131794. * Gets the right operand input component
  131795. */
  131796. get right(): NodeMaterialConnectionPoint;
  131797. /**
  131798. * Gets the output component
  131799. */
  131800. get output(): NodeMaterialConnectionPoint;
  131801. protected _buildBlock(state: NodeMaterialBuildState): this;
  131802. }
  131803. }
  131804. declare module BABYLON {
  131805. /**
  131806. * Block used to add 2 vectors
  131807. */
  131808. export class AddBlock extends NodeMaterialBlock {
  131809. /**
  131810. * Creates a new AddBlock
  131811. * @param name defines the block name
  131812. */
  131813. constructor(name: string);
  131814. /**
  131815. * Gets the current class name
  131816. * @returns the class name
  131817. */
  131818. getClassName(): string;
  131819. /**
  131820. * Gets the left operand input component
  131821. */
  131822. get left(): NodeMaterialConnectionPoint;
  131823. /**
  131824. * Gets the right operand input component
  131825. */
  131826. get right(): NodeMaterialConnectionPoint;
  131827. /**
  131828. * Gets the output component
  131829. */
  131830. get output(): NodeMaterialConnectionPoint;
  131831. protected _buildBlock(state: NodeMaterialBuildState): this;
  131832. }
  131833. }
  131834. declare module BABYLON {
  131835. /**
  131836. * Block used to scale a vector by a float
  131837. */
  131838. export class ScaleBlock extends NodeMaterialBlock {
  131839. /**
  131840. * Creates a new ScaleBlock
  131841. * @param name defines the block name
  131842. */
  131843. constructor(name: string);
  131844. /**
  131845. * Gets the current class name
  131846. * @returns the class name
  131847. */
  131848. getClassName(): string;
  131849. /**
  131850. * Gets the input component
  131851. */
  131852. get input(): NodeMaterialConnectionPoint;
  131853. /**
  131854. * Gets the factor input component
  131855. */
  131856. get factor(): NodeMaterialConnectionPoint;
  131857. /**
  131858. * Gets the output component
  131859. */
  131860. get output(): NodeMaterialConnectionPoint;
  131861. protected _buildBlock(state: NodeMaterialBuildState): this;
  131862. }
  131863. }
  131864. declare module BABYLON {
  131865. /**
  131866. * Block used to clamp a float
  131867. */
  131868. export class ClampBlock extends NodeMaterialBlock {
  131869. /** Gets or sets the minimum range */
  131870. minimum: number;
  131871. /** Gets or sets the maximum range */
  131872. maximum: number;
  131873. /**
  131874. * Creates a new ClampBlock
  131875. * @param name defines the block name
  131876. */
  131877. constructor(name: string);
  131878. /**
  131879. * Gets the current class name
  131880. * @returns the class name
  131881. */
  131882. getClassName(): string;
  131883. /**
  131884. * Gets the value input component
  131885. */
  131886. get value(): NodeMaterialConnectionPoint;
  131887. /**
  131888. * Gets the output component
  131889. */
  131890. get output(): NodeMaterialConnectionPoint;
  131891. protected _buildBlock(state: NodeMaterialBuildState): this;
  131892. protected _dumpPropertiesCode(): string;
  131893. serialize(): any;
  131894. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131895. }
  131896. }
  131897. declare module BABYLON {
  131898. /**
  131899. * Block used to apply a cross product between 2 vectors
  131900. */
  131901. export class CrossBlock extends NodeMaterialBlock {
  131902. /**
  131903. * Creates a new CrossBlock
  131904. * @param name defines the block name
  131905. */
  131906. constructor(name: string);
  131907. /**
  131908. * Gets the current class name
  131909. * @returns the class name
  131910. */
  131911. getClassName(): string;
  131912. /**
  131913. * Gets the left operand input component
  131914. */
  131915. get left(): NodeMaterialConnectionPoint;
  131916. /**
  131917. * Gets the right operand input component
  131918. */
  131919. get right(): NodeMaterialConnectionPoint;
  131920. /**
  131921. * Gets the output component
  131922. */
  131923. get output(): NodeMaterialConnectionPoint;
  131924. protected _buildBlock(state: NodeMaterialBuildState): this;
  131925. }
  131926. }
  131927. declare module BABYLON {
  131928. /**
  131929. * Block used to apply a dot product between 2 vectors
  131930. */
  131931. export class DotBlock extends NodeMaterialBlock {
  131932. /**
  131933. * Creates a new DotBlock
  131934. * @param name defines the block name
  131935. */
  131936. constructor(name: string);
  131937. /**
  131938. * Gets the current class name
  131939. * @returns the class name
  131940. */
  131941. getClassName(): string;
  131942. /**
  131943. * Gets the left operand input component
  131944. */
  131945. get left(): NodeMaterialConnectionPoint;
  131946. /**
  131947. * Gets the right operand input component
  131948. */
  131949. get right(): NodeMaterialConnectionPoint;
  131950. /**
  131951. * Gets the output component
  131952. */
  131953. get output(): NodeMaterialConnectionPoint;
  131954. protected _buildBlock(state: NodeMaterialBuildState): this;
  131955. }
  131956. }
  131957. declare module BABYLON {
  131958. /**
  131959. * Block used to remap a float from a range to a new one
  131960. */
  131961. export class RemapBlock extends NodeMaterialBlock {
  131962. /**
  131963. * Gets or sets the source range
  131964. */
  131965. sourceRange: Vector2;
  131966. /**
  131967. * Gets or sets the target range
  131968. */
  131969. targetRange: Vector2;
  131970. /**
  131971. * Creates a new RemapBlock
  131972. * @param name defines the block name
  131973. */
  131974. constructor(name: string);
  131975. /**
  131976. * Gets the current class name
  131977. * @returns the class name
  131978. */
  131979. getClassName(): string;
  131980. /**
  131981. * Gets the input component
  131982. */
  131983. get input(): NodeMaterialConnectionPoint;
  131984. /**
  131985. * Gets the source min input component
  131986. */
  131987. get sourceMin(): NodeMaterialConnectionPoint;
  131988. /**
  131989. * Gets the source max input component
  131990. */
  131991. get sourceMax(): NodeMaterialConnectionPoint;
  131992. /**
  131993. * Gets the target min input component
  131994. */
  131995. get targetMin(): NodeMaterialConnectionPoint;
  131996. /**
  131997. * Gets the target max input component
  131998. */
  131999. get targetMax(): NodeMaterialConnectionPoint;
  132000. /**
  132001. * Gets the output component
  132002. */
  132003. get output(): NodeMaterialConnectionPoint;
  132004. protected _buildBlock(state: NodeMaterialBuildState): this;
  132005. protected _dumpPropertiesCode(): string;
  132006. serialize(): any;
  132007. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132008. }
  132009. }
  132010. declare module BABYLON {
  132011. /**
  132012. * Block used to normalize a vector
  132013. */
  132014. export class NormalizeBlock extends NodeMaterialBlock {
  132015. /**
  132016. * Creates a new NormalizeBlock
  132017. * @param name defines the block name
  132018. */
  132019. constructor(name: string);
  132020. /**
  132021. * Gets the current class name
  132022. * @returns the class name
  132023. */
  132024. getClassName(): string;
  132025. /**
  132026. * Gets the input component
  132027. */
  132028. get input(): NodeMaterialConnectionPoint;
  132029. /**
  132030. * Gets the output component
  132031. */
  132032. get output(): NodeMaterialConnectionPoint;
  132033. protected _buildBlock(state: NodeMaterialBuildState): this;
  132034. }
  132035. }
  132036. declare module BABYLON {
  132037. /**
  132038. * Operations supported by the Trigonometry block
  132039. */
  132040. export enum TrigonometryBlockOperations {
  132041. /** Cos */
  132042. Cos = 0,
  132043. /** Sin */
  132044. Sin = 1,
  132045. /** Abs */
  132046. Abs = 2,
  132047. /** Exp */
  132048. Exp = 3,
  132049. /** Exp2 */
  132050. Exp2 = 4,
  132051. /** Round */
  132052. Round = 5,
  132053. /** Floor */
  132054. Floor = 6,
  132055. /** Ceiling */
  132056. Ceiling = 7,
  132057. /** Square root */
  132058. Sqrt = 8,
  132059. /** Log */
  132060. Log = 9,
  132061. /** Tangent */
  132062. Tan = 10,
  132063. /** Arc tangent */
  132064. ArcTan = 11,
  132065. /** Arc cosinus */
  132066. ArcCos = 12,
  132067. /** Arc sinus */
  132068. ArcSin = 13,
  132069. /** Fraction */
  132070. Fract = 14,
  132071. /** Sign */
  132072. Sign = 15,
  132073. /** To radians (from degrees) */
  132074. Radians = 16,
  132075. /** To degrees (from radians) */
  132076. Degrees = 17
  132077. }
  132078. /**
  132079. * Block used to apply trigonometry operation to floats
  132080. */
  132081. export class TrigonometryBlock extends NodeMaterialBlock {
  132082. /**
  132083. * Gets or sets the operation applied by the block
  132084. */
  132085. operation: TrigonometryBlockOperations;
  132086. /**
  132087. * Creates a new TrigonometryBlock
  132088. * @param name defines the block name
  132089. */
  132090. constructor(name: string);
  132091. /**
  132092. * Gets the current class name
  132093. * @returns the class name
  132094. */
  132095. getClassName(): string;
  132096. /**
  132097. * Gets the input component
  132098. */
  132099. get input(): NodeMaterialConnectionPoint;
  132100. /**
  132101. * Gets the output component
  132102. */
  132103. get output(): NodeMaterialConnectionPoint;
  132104. protected _buildBlock(state: NodeMaterialBuildState): this;
  132105. serialize(): any;
  132106. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132107. protected _dumpPropertiesCode(): string;
  132108. }
  132109. }
  132110. declare module BABYLON {
  132111. /**
  132112. * Block used to create a Color3/4 out of individual inputs (one for each component)
  132113. */
  132114. export class ColorMergerBlock extends NodeMaterialBlock {
  132115. /**
  132116. * Create a new ColorMergerBlock
  132117. * @param name defines the block name
  132118. */
  132119. constructor(name: string);
  132120. /**
  132121. * Gets the current class name
  132122. * @returns the class name
  132123. */
  132124. getClassName(): string;
  132125. /**
  132126. * Gets the rgb component (input)
  132127. */
  132128. get rgbIn(): NodeMaterialConnectionPoint;
  132129. /**
  132130. * Gets the r component (input)
  132131. */
  132132. get r(): NodeMaterialConnectionPoint;
  132133. /**
  132134. * Gets the g component (input)
  132135. */
  132136. get g(): NodeMaterialConnectionPoint;
  132137. /**
  132138. * Gets the b component (input)
  132139. */
  132140. get b(): NodeMaterialConnectionPoint;
  132141. /**
  132142. * Gets the a component (input)
  132143. */
  132144. get a(): NodeMaterialConnectionPoint;
  132145. /**
  132146. * Gets the rgba component (output)
  132147. */
  132148. get rgba(): NodeMaterialConnectionPoint;
  132149. /**
  132150. * Gets the rgb component (output)
  132151. */
  132152. get rgbOut(): NodeMaterialConnectionPoint;
  132153. /**
  132154. * Gets the rgb component (output)
  132155. * @deprecated Please use rgbOut instead.
  132156. */
  132157. get rgb(): NodeMaterialConnectionPoint;
  132158. protected _buildBlock(state: NodeMaterialBuildState): this;
  132159. }
  132160. }
  132161. declare module BABYLON {
  132162. /**
  132163. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  132164. */
  132165. export class VectorMergerBlock extends NodeMaterialBlock {
  132166. /**
  132167. * Create a new VectorMergerBlock
  132168. * @param name defines the block name
  132169. */
  132170. constructor(name: string);
  132171. /**
  132172. * Gets the current class name
  132173. * @returns the class name
  132174. */
  132175. getClassName(): string;
  132176. /**
  132177. * Gets the xyz component (input)
  132178. */
  132179. get xyzIn(): NodeMaterialConnectionPoint;
  132180. /**
  132181. * Gets the xy component (input)
  132182. */
  132183. get xyIn(): NodeMaterialConnectionPoint;
  132184. /**
  132185. * Gets the x component (input)
  132186. */
  132187. get x(): NodeMaterialConnectionPoint;
  132188. /**
  132189. * Gets the y component (input)
  132190. */
  132191. get y(): NodeMaterialConnectionPoint;
  132192. /**
  132193. * Gets the z component (input)
  132194. */
  132195. get z(): NodeMaterialConnectionPoint;
  132196. /**
  132197. * Gets the w component (input)
  132198. */
  132199. get w(): NodeMaterialConnectionPoint;
  132200. /**
  132201. * Gets the xyzw component (output)
  132202. */
  132203. get xyzw(): NodeMaterialConnectionPoint;
  132204. /**
  132205. * Gets the xyz component (output)
  132206. */
  132207. get xyzOut(): NodeMaterialConnectionPoint;
  132208. /**
  132209. * Gets the xy component (output)
  132210. */
  132211. get xyOut(): NodeMaterialConnectionPoint;
  132212. /**
  132213. * Gets the xy component (output)
  132214. * @deprecated Please use xyOut instead.
  132215. */
  132216. get xy(): NodeMaterialConnectionPoint;
  132217. /**
  132218. * Gets the xyz component (output)
  132219. * @deprecated Please use xyzOut instead.
  132220. */
  132221. get xyz(): NodeMaterialConnectionPoint;
  132222. protected _buildBlock(state: NodeMaterialBuildState): this;
  132223. }
  132224. }
  132225. declare module BABYLON {
  132226. /**
  132227. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  132228. */
  132229. export class ColorSplitterBlock extends NodeMaterialBlock {
  132230. /**
  132231. * Create a new ColorSplitterBlock
  132232. * @param name defines the block name
  132233. */
  132234. constructor(name: string);
  132235. /**
  132236. * Gets the current class name
  132237. * @returns the class name
  132238. */
  132239. getClassName(): string;
  132240. /**
  132241. * Gets the rgba component (input)
  132242. */
  132243. get rgba(): NodeMaterialConnectionPoint;
  132244. /**
  132245. * Gets the rgb component (input)
  132246. */
  132247. get rgbIn(): NodeMaterialConnectionPoint;
  132248. /**
  132249. * Gets the rgb component (output)
  132250. */
  132251. get rgbOut(): NodeMaterialConnectionPoint;
  132252. /**
  132253. * Gets the r component (output)
  132254. */
  132255. get r(): NodeMaterialConnectionPoint;
  132256. /**
  132257. * Gets the g component (output)
  132258. */
  132259. get g(): NodeMaterialConnectionPoint;
  132260. /**
  132261. * Gets the b component (output)
  132262. */
  132263. get b(): NodeMaterialConnectionPoint;
  132264. /**
  132265. * Gets the a component (output)
  132266. */
  132267. get a(): NodeMaterialConnectionPoint;
  132268. protected _inputRename(name: string): string;
  132269. protected _outputRename(name: string): string;
  132270. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132271. }
  132272. }
  132273. declare module BABYLON {
  132274. /**
  132275. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  132276. */
  132277. export class VectorSplitterBlock extends NodeMaterialBlock {
  132278. /**
  132279. * Create a new VectorSplitterBlock
  132280. * @param name defines the block name
  132281. */
  132282. constructor(name: string);
  132283. /**
  132284. * Gets the current class name
  132285. * @returns the class name
  132286. */
  132287. getClassName(): string;
  132288. /**
  132289. * Gets the xyzw component (input)
  132290. */
  132291. get xyzw(): NodeMaterialConnectionPoint;
  132292. /**
  132293. * Gets the xyz component (input)
  132294. */
  132295. get xyzIn(): NodeMaterialConnectionPoint;
  132296. /**
  132297. * Gets the xy component (input)
  132298. */
  132299. get xyIn(): NodeMaterialConnectionPoint;
  132300. /**
  132301. * Gets the xyz component (output)
  132302. */
  132303. get xyzOut(): NodeMaterialConnectionPoint;
  132304. /**
  132305. * Gets the xy component (output)
  132306. */
  132307. get xyOut(): NodeMaterialConnectionPoint;
  132308. /**
  132309. * Gets the x component (output)
  132310. */
  132311. get x(): NodeMaterialConnectionPoint;
  132312. /**
  132313. * Gets the y component (output)
  132314. */
  132315. get y(): NodeMaterialConnectionPoint;
  132316. /**
  132317. * Gets the z component (output)
  132318. */
  132319. get z(): NodeMaterialConnectionPoint;
  132320. /**
  132321. * Gets the w component (output)
  132322. */
  132323. get w(): NodeMaterialConnectionPoint;
  132324. protected _inputRename(name: string): string;
  132325. protected _outputRename(name: string): string;
  132326. protected _buildBlock(state: NodeMaterialBuildState): this;
  132327. }
  132328. }
  132329. declare module BABYLON {
  132330. /**
  132331. * Block used to lerp between 2 values
  132332. */
  132333. export class LerpBlock extends NodeMaterialBlock {
  132334. /**
  132335. * Creates a new LerpBlock
  132336. * @param name defines the block name
  132337. */
  132338. constructor(name: string);
  132339. /**
  132340. * Gets the current class name
  132341. * @returns the class name
  132342. */
  132343. getClassName(): string;
  132344. /**
  132345. * Gets the left operand input component
  132346. */
  132347. get left(): NodeMaterialConnectionPoint;
  132348. /**
  132349. * Gets the right operand input component
  132350. */
  132351. get right(): NodeMaterialConnectionPoint;
  132352. /**
  132353. * Gets the gradient operand input component
  132354. */
  132355. get gradient(): NodeMaterialConnectionPoint;
  132356. /**
  132357. * Gets the output component
  132358. */
  132359. get output(): NodeMaterialConnectionPoint;
  132360. protected _buildBlock(state: NodeMaterialBuildState): this;
  132361. }
  132362. }
  132363. declare module BABYLON {
  132364. /**
  132365. * Block used to divide 2 vectors
  132366. */
  132367. export class DivideBlock extends NodeMaterialBlock {
  132368. /**
  132369. * Creates a new DivideBlock
  132370. * @param name defines the block name
  132371. */
  132372. constructor(name: string);
  132373. /**
  132374. * Gets the current class name
  132375. * @returns the class name
  132376. */
  132377. getClassName(): string;
  132378. /**
  132379. * Gets the left operand input component
  132380. */
  132381. get left(): NodeMaterialConnectionPoint;
  132382. /**
  132383. * Gets the right operand input component
  132384. */
  132385. get right(): NodeMaterialConnectionPoint;
  132386. /**
  132387. * Gets the output component
  132388. */
  132389. get output(): NodeMaterialConnectionPoint;
  132390. protected _buildBlock(state: NodeMaterialBuildState): this;
  132391. }
  132392. }
  132393. declare module BABYLON {
  132394. /**
  132395. * Block used to subtract 2 vectors
  132396. */
  132397. export class SubtractBlock extends NodeMaterialBlock {
  132398. /**
  132399. * Creates a new SubtractBlock
  132400. * @param name defines the block name
  132401. */
  132402. constructor(name: string);
  132403. /**
  132404. * Gets the current class name
  132405. * @returns the class name
  132406. */
  132407. getClassName(): string;
  132408. /**
  132409. * Gets the left operand input component
  132410. */
  132411. get left(): NodeMaterialConnectionPoint;
  132412. /**
  132413. * Gets the right operand input component
  132414. */
  132415. get right(): NodeMaterialConnectionPoint;
  132416. /**
  132417. * Gets the output component
  132418. */
  132419. get output(): NodeMaterialConnectionPoint;
  132420. protected _buildBlock(state: NodeMaterialBuildState): this;
  132421. }
  132422. }
  132423. declare module BABYLON {
  132424. /**
  132425. * Block used to step a value
  132426. */
  132427. export class StepBlock extends NodeMaterialBlock {
  132428. /**
  132429. * Creates a new StepBlock
  132430. * @param name defines the block name
  132431. */
  132432. constructor(name: string);
  132433. /**
  132434. * Gets the current class name
  132435. * @returns the class name
  132436. */
  132437. getClassName(): string;
  132438. /**
  132439. * Gets the value operand input component
  132440. */
  132441. get value(): NodeMaterialConnectionPoint;
  132442. /**
  132443. * Gets the edge operand input component
  132444. */
  132445. get edge(): NodeMaterialConnectionPoint;
  132446. /**
  132447. * Gets the output component
  132448. */
  132449. get output(): NodeMaterialConnectionPoint;
  132450. protected _buildBlock(state: NodeMaterialBuildState): this;
  132451. }
  132452. }
  132453. declare module BABYLON {
  132454. /**
  132455. * Block used to get the opposite (1 - x) of a value
  132456. */
  132457. export class OneMinusBlock extends NodeMaterialBlock {
  132458. /**
  132459. * Creates a new OneMinusBlock
  132460. * @param name defines the block name
  132461. */
  132462. constructor(name: string);
  132463. /**
  132464. * Gets the current class name
  132465. * @returns the class name
  132466. */
  132467. getClassName(): string;
  132468. /**
  132469. * Gets the input component
  132470. */
  132471. get input(): NodeMaterialConnectionPoint;
  132472. /**
  132473. * Gets the output component
  132474. */
  132475. get output(): NodeMaterialConnectionPoint;
  132476. protected _buildBlock(state: NodeMaterialBuildState): this;
  132477. }
  132478. }
  132479. declare module BABYLON {
  132480. /**
  132481. * Block used to get the view direction
  132482. */
  132483. export class ViewDirectionBlock extends NodeMaterialBlock {
  132484. /**
  132485. * Creates a new ViewDirectionBlock
  132486. * @param name defines the block name
  132487. */
  132488. constructor(name: string);
  132489. /**
  132490. * Gets the current class name
  132491. * @returns the class name
  132492. */
  132493. getClassName(): string;
  132494. /**
  132495. * Gets the world position component
  132496. */
  132497. get worldPosition(): NodeMaterialConnectionPoint;
  132498. /**
  132499. * Gets the camera position component
  132500. */
  132501. get cameraPosition(): NodeMaterialConnectionPoint;
  132502. /**
  132503. * Gets the output component
  132504. */
  132505. get output(): NodeMaterialConnectionPoint;
  132506. autoConfigure(material: NodeMaterial): void;
  132507. protected _buildBlock(state: NodeMaterialBuildState): this;
  132508. }
  132509. }
  132510. declare module BABYLON {
  132511. /**
  132512. * Block used to compute fresnel value
  132513. */
  132514. export class FresnelBlock extends NodeMaterialBlock {
  132515. /**
  132516. * Create a new FresnelBlock
  132517. * @param name defines the block name
  132518. */
  132519. constructor(name: string);
  132520. /**
  132521. * Gets the current class name
  132522. * @returns the class name
  132523. */
  132524. getClassName(): string;
  132525. /**
  132526. * Gets the world normal input component
  132527. */
  132528. get worldNormal(): NodeMaterialConnectionPoint;
  132529. /**
  132530. * Gets the view direction input component
  132531. */
  132532. get viewDirection(): NodeMaterialConnectionPoint;
  132533. /**
  132534. * Gets the bias input component
  132535. */
  132536. get bias(): NodeMaterialConnectionPoint;
  132537. /**
  132538. * Gets the camera (or eye) position component
  132539. */
  132540. get power(): NodeMaterialConnectionPoint;
  132541. /**
  132542. * Gets the fresnel output component
  132543. */
  132544. get fresnel(): NodeMaterialConnectionPoint;
  132545. autoConfigure(material: NodeMaterial): void;
  132546. protected _buildBlock(state: NodeMaterialBuildState): this;
  132547. }
  132548. }
  132549. declare module BABYLON {
  132550. /**
  132551. * Block used to get the max of 2 values
  132552. */
  132553. export class MaxBlock extends NodeMaterialBlock {
  132554. /**
  132555. * Creates a new MaxBlock
  132556. * @param name defines the block name
  132557. */
  132558. constructor(name: string);
  132559. /**
  132560. * Gets the current class name
  132561. * @returns the class name
  132562. */
  132563. getClassName(): string;
  132564. /**
  132565. * Gets the left operand input component
  132566. */
  132567. get left(): NodeMaterialConnectionPoint;
  132568. /**
  132569. * Gets the right operand input component
  132570. */
  132571. get right(): NodeMaterialConnectionPoint;
  132572. /**
  132573. * Gets the output component
  132574. */
  132575. get output(): NodeMaterialConnectionPoint;
  132576. protected _buildBlock(state: NodeMaterialBuildState): this;
  132577. }
  132578. }
  132579. declare module BABYLON {
  132580. /**
  132581. * Block used to get the min of 2 values
  132582. */
  132583. export class MinBlock extends NodeMaterialBlock {
  132584. /**
  132585. * Creates a new MinBlock
  132586. * @param name defines the block name
  132587. */
  132588. constructor(name: string);
  132589. /**
  132590. * Gets the current class name
  132591. * @returns the class name
  132592. */
  132593. getClassName(): string;
  132594. /**
  132595. * Gets the left operand input component
  132596. */
  132597. get left(): NodeMaterialConnectionPoint;
  132598. /**
  132599. * Gets the right operand input component
  132600. */
  132601. get right(): NodeMaterialConnectionPoint;
  132602. /**
  132603. * Gets the output component
  132604. */
  132605. get output(): NodeMaterialConnectionPoint;
  132606. protected _buildBlock(state: NodeMaterialBuildState): this;
  132607. }
  132608. }
  132609. declare module BABYLON {
  132610. /**
  132611. * Block used to get the distance between 2 values
  132612. */
  132613. export class DistanceBlock extends NodeMaterialBlock {
  132614. /**
  132615. * Creates a new DistanceBlock
  132616. * @param name defines the block name
  132617. */
  132618. constructor(name: string);
  132619. /**
  132620. * Gets the current class name
  132621. * @returns the class name
  132622. */
  132623. getClassName(): string;
  132624. /**
  132625. * Gets the left operand input component
  132626. */
  132627. get left(): NodeMaterialConnectionPoint;
  132628. /**
  132629. * Gets the right operand input component
  132630. */
  132631. get right(): NodeMaterialConnectionPoint;
  132632. /**
  132633. * Gets the output component
  132634. */
  132635. get output(): NodeMaterialConnectionPoint;
  132636. protected _buildBlock(state: NodeMaterialBuildState): this;
  132637. }
  132638. }
  132639. declare module BABYLON {
  132640. /**
  132641. * Block used to get the length of a vector
  132642. */
  132643. export class LengthBlock extends NodeMaterialBlock {
  132644. /**
  132645. * Creates a new LengthBlock
  132646. * @param name defines the block name
  132647. */
  132648. constructor(name: string);
  132649. /**
  132650. * Gets the current class name
  132651. * @returns the class name
  132652. */
  132653. getClassName(): string;
  132654. /**
  132655. * Gets the value input component
  132656. */
  132657. get value(): NodeMaterialConnectionPoint;
  132658. /**
  132659. * Gets the output component
  132660. */
  132661. get output(): NodeMaterialConnectionPoint;
  132662. protected _buildBlock(state: NodeMaterialBuildState): this;
  132663. }
  132664. }
  132665. declare module BABYLON {
  132666. /**
  132667. * Block used to get negative version of a value (i.e. x * -1)
  132668. */
  132669. export class NegateBlock extends NodeMaterialBlock {
  132670. /**
  132671. * Creates a new NegateBlock
  132672. * @param name defines the block name
  132673. */
  132674. constructor(name: string);
  132675. /**
  132676. * Gets the current class name
  132677. * @returns the class name
  132678. */
  132679. getClassName(): string;
  132680. /**
  132681. * Gets the value input component
  132682. */
  132683. get value(): NodeMaterialConnectionPoint;
  132684. /**
  132685. * Gets the output component
  132686. */
  132687. get output(): NodeMaterialConnectionPoint;
  132688. protected _buildBlock(state: NodeMaterialBuildState): this;
  132689. }
  132690. }
  132691. declare module BABYLON {
  132692. /**
  132693. * Block used to get the value of the first parameter raised to the power of the second
  132694. */
  132695. export class PowBlock extends NodeMaterialBlock {
  132696. /**
  132697. * Creates a new PowBlock
  132698. * @param name defines the block name
  132699. */
  132700. constructor(name: string);
  132701. /**
  132702. * Gets the current class name
  132703. * @returns the class name
  132704. */
  132705. getClassName(): string;
  132706. /**
  132707. * Gets the value operand input component
  132708. */
  132709. get value(): NodeMaterialConnectionPoint;
  132710. /**
  132711. * Gets the power operand input component
  132712. */
  132713. get power(): NodeMaterialConnectionPoint;
  132714. /**
  132715. * Gets the output component
  132716. */
  132717. get output(): NodeMaterialConnectionPoint;
  132718. protected _buildBlock(state: NodeMaterialBuildState): this;
  132719. }
  132720. }
  132721. declare module BABYLON {
  132722. /**
  132723. * Block used to get a random number
  132724. */
  132725. export class RandomNumberBlock extends NodeMaterialBlock {
  132726. /**
  132727. * Creates a new RandomNumberBlock
  132728. * @param name defines the block name
  132729. */
  132730. constructor(name: string);
  132731. /**
  132732. * Gets the current class name
  132733. * @returns the class name
  132734. */
  132735. getClassName(): string;
  132736. /**
  132737. * Gets the seed input component
  132738. */
  132739. get seed(): NodeMaterialConnectionPoint;
  132740. /**
  132741. * Gets the output component
  132742. */
  132743. get output(): NodeMaterialConnectionPoint;
  132744. protected _buildBlock(state: NodeMaterialBuildState): this;
  132745. }
  132746. }
  132747. declare module BABYLON {
  132748. /**
  132749. * Block used to compute arc tangent of 2 values
  132750. */
  132751. export class ArcTan2Block extends NodeMaterialBlock {
  132752. /**
  132753. * Creates a new ArcTan2Block
  132754. * @param name defines the block name
  132755. */
  132756. constructor(name: string);
  132757. /**
  132758. * Gets the current class name
  132759. * @returns the class name
  132760. */
  132761. getClassName(): string;
  132762. /**
  132763. * Gets the x operand input component
  132764. */
  132765. get x(): NodeMaterialConnectionPoint;
  132766. /**
  132767. * Gets the y operand input component
  132768. */
  132769. get y(): NodeMaterialConnectionPoint;
  132770. /**
  132771. * Gets the output component
  132772. */
  132773. get output(): NodeMaterialConnectionPoint;
  132774. protected _buildBlock(state: NodeMaterialBuildState): this;
  132775. }
  132776. }
  132777. declare module BABYLON {
  132778. /**
  132779. * Block used to smooth step a value
  132780. */
  132781. export class SmoothStepBlock extends NodeMaterialBlock {
  132782. /**
  132783. * Creates a new SmoothStepBlock
  132784. * @param name defines the block name
  132785. */
  132786. constructor(name: string);
  132787. /**
  132788. * Gets the current class name
  132789. * @returns the class name
  132790. */
  132791. getClassName(): string;
  132792. /**
  132793. * Gets the value operand input component
  132794. */
  132795. get value(): NodeMaterialConnectionPoint;
  132796. /**
  132797. * Gets the first edge operand input component
  132798. */
  132799. get edge0(): NodeMaterialConnectionPoint;
  132800. /**
  132801. * Gets the second edge operand input component
  132802. */
  132803. get edge1(): NodeMaterialConnectionPoint;
  132804. /**
  132805. * Gets the output component
  132806. */
  132807. get output(): NodeMaterialConnectionPoint;
  132808. protected _buildBlock(state: NodeMaterialBuildState): this;
  132809. }
  132810. }
  132811. declare module BABYLON {
  132812. /**
  132813. * Block used to get the reciprocal (1 / x) of a value
  132814. */
  132815. export class ReciprocalBlock extends NodeMaterialBlock {
  132816. /**
  132817. * Creates a new ReciprocalBlock
  132818. * @param name defines the block name
  132819. */
  132820. constructor(name: string);
  132821. /**
  132822. * Gets the current class name
  132823. * @returns the class name
  132824. */
  132825. getClassName(): string;
  132826. /**
  132827. * Gets the input component
  132828. */
  132829. get input(): NodeMaterialConnectionPoint;
  132830. /**
  132831. * Gets the output component
  132832. */
  132833. get output(): NodeMaterialConnectionPoint;
  132834. protected _buildBlock(state: NodeMaterialBuildState): this;
  132835. }
  132836. }
  132837. declare module BABYLON {
  132838. /**
  132839. * Block used to replace a color by another one
  132840. */
  132841. export class ReplaceColorBlock extends NodeMaterialBlock {
  132842. /**
  132843. * Creates a new ReplaceColorBlock
  132844. * @param name defines the block name
  132845. */
  132846. constructor(name: string);
  132847. /**
  132848. * Gets the current class name
  132849. * @returns the class name
  132850. */
  132851. getClassName(): string;
  132852. /**
  132853. * Gets the value input component
  132854. */
  132855. get value(): NodeMaterialConnectionPoint;
  132856. /**
  132857. * Gets the reference input component
  132858. */
  132859. get reference(): NodeMaterialConnectionPoint;
  132860. /**
  132861. * Gets the distance input component
  132862. */
  132863. get distance(): NodeMaterialConnectionPoint;
  132864. /**
  132865. * Gets the replacement input component
  132866. */
  132867. get replacement(): NodeMaterialConnectionPoint;
  132868. /**
  132869. * Gets the output component
  132870. */
  132871. get output(): NodeMaterialConnectionPoint;
  132872. protected _buildBlock(state: NodeMaterialBuildState): this;
  132873. }
  132874. }
  132875. declare module BABYLON {
  132876. /**
  132877. * Block used to posterize a value
  132878. * @see https://en.wikipedia.org/wiki/Posterization
  132879. */
  132880. export class PosterizeBlock extends NodeMaterialBlock {
  132881. /**
  132882. * Creates a new PosterizeBlock
  132883. * @param name defines the block name
  132884. */
  132885. constructor(name: string);
  132886. /**
  132887. * Gets the current class name
  132888. * @returns the class name
  132889. */
  132890. getClassName(): string;
  132891. /**
  132892. * Gets the value input component
  132893. */
  132894. get value(): NodeMaterialConnectionPoint;
  132895. /**
  132896. * Gets the steps input component
  132897. */
  132898. get steps(): NodeMaterialConnectionPoint;
  132899. /**
  132900. * Gets the output component
  132901. */
  132902. get output(): NodeMaterialConnectionPoint;
  132903. protected _buildBlock(state: NodeMaterialBuildState): this;
  132904. }
  132905. }
  132906. declare module BABYLON {
  132907. /**
  132908. * Operations supported by the Wave block
  132909. */
  132910. export enum WaveBlockKind {
  132911. /** SawTooth */
  132912. SawTooth = 0,
  132913. /** Square */
  132914. Square = 1,
  132915. /** Triangle */
  132916. Triangle = 2
  132917. }
  132918. /**
  132919. * Block used to apply wave operation to floats
  132920. */
  132921. export class WaveBlock extends NodeMaterialBlock {
  132922. /**
  132923. * Gets or sets the kibnd of wave to be applied by the block
  132924. */
  132925. kind: WaveBlockKind;
  132926. /**
  132927. * Creates a new WaveBlock
  132928. * @param name defines the block name
  132929. */
  132930. constructor(name: string);
  132931. /**
  132932. * Gets the current class name
  132933. * @returns the class name
  132934. */
  132935. getClassName(): string;
  132936. /**
  132937. * Gets the input component
  132938. */
  132939. get input(): NodeMaterialConnectionPoint;
  132940. /**
  132941. * Gets the output component
  132942. */
  132943. get output(): NodeMaterialConnectionPoint;
  132944. protected _buildBlock(state: NodeMaterialBuildState): this;
  132945. serialize(): any;
  132946. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132947. }
  132948. }
  132949. declare module BABYLON {
  132950. /**
  132951. * Class used to store a color step for the GradientBlock
  132952. */
  132953. export class GradientBlockColorStep {
  132954. /**
  132955. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  132956. */
  132957. step: number;
  132958. /**
  132959. * Gets or sets the color associated with this step
  132960. */
  132961. color: Color3;
  132962. /**
  132963. * Creates a new GradientBlockColorStep
  132964. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  132965. * @param color defines the color associated with this step
  132966. */
  132967. constructor(
  132968. /**
  132969. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  132970. */
  132971. step: number,
  132972. /**
  132973. * Gets or sets the color associated with this step
  132974. */
  132975. color: Color3);
  132976. }
  132977. /**
  132978. * Block used to return a color from a gradient based on an input value between 0 and 1
  132979. */
  132980. export class GradientBlock extends NodeMaterialBlock {
  132981. /**
  132982. * Gets or sets the list of color steps
  132983. */
  132984. colorSteps: GradientBlockColorStep[];
  132985. /**
  132986. * Creates a new GradientBlock
  132987. * @param name defines the block name
  132988. */
  132989. constructor(name: string);
  132990. /**
  132991. * Gets the current class name
  132992. * @returns the class name
  132993. */
  132994. getClassName(): string;
  132995. /**
  132996. * Gets the gradient input component
  132997. */
  132998. get gradient(): NodeMaterialConnectionPoint;
  132999. /**
  133000. * Gets the output component
  133001. */
  133002. get output(): NodeMaterialConnectionPoint;
  133003. private _writeColorConstant;
  133004. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133005. serialize(): any;
  133006. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133007. protected _dumpPropertiesCode(): string;
  133008. }
  133009. }
  133010. declare module BABYLON {
  133011. /**
  133012. * Block used to normalize lerp between 2 values
  133013. */
  133014. export class NLerpBlock extends NodeMaterialBlock {
  133015. /**
  133016. * Creates a new NLerpBlock
  133017. * @param name defines the block name
  133018. */
  133019. constructor(name: string);
  133020. /**
  133021. * Gets the current class name
  133022. * @returns the class name
  133023. */
  133024. getClassName(): string;
  133025. /**
  133026. * Gets the left operand input component
  133027. */
  133028. get left(): NodeMaterialConnectionPoint;
  133029. /**
  133030. * Gets the right operand input component
  133031. */
  133032. get right(): NodeMaterialConnectionPoint;
  133033. /**
  133034. * Gets the gradient operand input component
  133035. */
  133036. get gradient(): NodeMaterialConnectionPoint;
  133037. /**
  133038. * Gets the output component
  133039. */
  133040. get output(): NodeMaterialConnectionPoint;
  133041. protected _buildBlock(state: NodeMaterialBuildState): this;
  133042. }
  133043. }
  133044. declare module BABYLON {
  133045. /**
  133046. * block used to Generate a Worley Noise 3D Noise Pattern
  133047. */
  133048. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  133049. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133050. manhattanDistance: boolean;
  133051. /**
  133052. * Creates a new WorleyNoise3DBlock
  133053. * @param name defines the block name
  133054. */
  133055. constructor(name: string);
  133056. /**
  133057. * Gets the current class name
  133058. * @returns the class name
  133059. */
  133060. getClassName(): string;
  133061. /**
  133062. * Gets the seed input component
  133063. */
  133064. get seed(): NodeMaterialConnectionPoint;
  133065. /**
  133066. * Gets the jitter input component
  133067. */
  133068. get jitter(): NodeMaterialConnectionPoint;
  133069. /**
  133070. * Gets the output component
  133071. */
  133072. get output(): NodeMaterialConnectionPoint;
  133073. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133074. /**
  133075. * Exposes the properties to the UI?
  133076. */
  133077. protected _dumpPropertiesCode(): string;
  133078. /**
  133079. * Exposes the properties to the Seralize?
  133080. */
  133081. serialize(): any;
  133082. /**
  133083. * Exposes the properties to the deseralize?
  133084. */
  133085. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133086. }
  133087. }
  133088. declare module BABYLON {
  133089. /**
  133090. * block used to Generate a Simplex Perlin 3d Noise Pattern
  133091. */
  133092. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  133093. /**
  133094. * Creates a new SimplexPerlin3DBlock
  133095. * @param name defines the block name
  133096. */
  133097. constructor(name: string);
  133098. /**
  133099. * Gets the current class name
  133100. * @returns the class name
  133101. */
  133102. getClassName(): string;
  133103. /**
  133104. * Gets the seed operand input component
  133105. */
  133106. get seed(): NodeMaterialConnectionPoint;
  133107. /**
  133108. * Gets the output component
  133109. */
  133110. get output(): NodeMaterialConnectionPoint;
  133111. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133112. }
  133113. }
  133114. declare module BABYLON {
  133115. /**
  133116. * Block used to blend normals
  133117. */
  133118. export class NormalBlendBlock extends NodeMaterialBlock {
  133119. /**
  133120. * Creates a new NormalBlendBlock
  133121. * @param name defines the block name
  133122. */
  133123. constructor(name: string);
  133124. /**
  133125. * Gets the current class name
  133126. * @returns the class name
  133127. */
  133128. getClassName(): string;
  133129. /**
  133130. * Gets the first input component
  133131. */
  133132. get normalMap0(): NodeMaterialConnectionPoint;
  133133. /**
  133134. * Gets the second input component
  133135. */
  133136. get normalMap1(): NodeMaterialConnectionPoint;
  133137. /**
  133138. * Gets the output component
  133139. */
  133140. get output(): NodeMaterialConnectionPoint;
  133141. protected _buildBlock(state: NodeMaterialBuildState): this;
  133142. }
  133143. }
  133144. declare module BABYLON {
  133145. /**
  133146. * Block used to rotate a 2d vector by a given angle
  133147. */
  133148. export class Rotate2dBlock extends NodeMaterialBlock {
  133149. /**
  133150. * Creates a new Rotate2dBlock
  133151. * @param name defines the block name
  133152. */
  133153. constructor(name: string);
  133154. /**
  133155. * Gets the current class name
  133156. * @returns the class name
  133157. */
  133158. getClassName(): string;
  133159. /**
  133160. * Gets the input vector
  133161. */
  133162. get input(): NodeMaterialConnectionPoint;
  133163. /**
  133164. * Gets the input angle
  133165. */
  133166. get angle(): NodeMaterialConnectionPoint;
  133167. /**
  133168. * Gets the output component
  133169. */
  133170. get output(): NodeMaterialConnectionPoint;
  133171. autoConfigure(material: NodeMaterial): void;
  133172. protected _buildBlock(state: NodeMaterialBuildState): this;
  133173. }
  133174. }
  133175. declare module BABYLON {
  133176. /**
  133177. * Block used to get the reflected vector from a direction and a normal
  133178. */
  133179. export class ReflectBlock extends NodeMaterialBlock {
  133180. /**
  133181. * Creates a new ReflectBlock
  133182. * @param name defines the block name
  133183. */
  133184. constructor(name: string);
  133185. /**
  133186. * Gets the current class name
  133187. * @returns the class name
  133188. */
  133189. getClassName(): string;
  133190. /**
  133191. * Gets the incident component
  133192. */
  133193. get incident(): NodeMaterialConnectionPoint;
  133194. /**
  133195. * Gets the normal component
  133196. */
  133197. get normal(): NodeMaterialConnectionPoint;
  133198. /**
  133199. * Gets the output component
  133200. */
  133201. get output(): NodeMaterialConnectionPoint;
  133202. protected _buildBlock(state: NodeMaterialBuildState): this;
  133203. }
  133204. }
  133205. declare module BABYLON {
  133206. /**
  133207. * Block used to get the refracted vector from a direction and a normal
  133208. */
  133209. export class RefractBlock extends NodeMaterialBlock {
  133210. /**
  133211. * Creates a new RefractBlock
  133212. * @param name defines the block name
  133213. */
  133214. constructor(name: string);
  133215. /**
  133216. * Gets the current class name
  133217. * @returns the class name
  133218. */
  133219. getClassName(): string;
  133220. /**
  133221. * Gets the incident component
  133222. */
  133223. get incident(): NodeMaterialConnectionPoint;
  133224. /**
  133225. * Gets the normal component
  133226. */
  133227. get normal(): NodeMaterialConnectionPoint;
  133228. /**
  133229. * Gets the index of refraction component
  133230. */
  133231. get ior(): NodeMaterialConnectionPoint;
  133232. /**
  133233. * Gets the output component
  133234. */
  133235. get output(): NodeMaterialConnectionPoint;
  133236. protected _buildBlock(state: NodeMaterialBuildState): this;
  133237. }
  133238. }
  133239. declare module BABYLON {
  133240. /**
  133241. * Block used to desaturate a color
  133242. */
  133243. export class DesaturateBlock extends NodeMaterialBlock {
  133244. /**
  133245. * Creates a new DesaturateBlock
  133246. * @param name defines the block name
  133247. */
  133248. constructor(name: string);
  133249. /**
  133250. * Gets the current class name
  133251. * @returns the class name
  133252. */
  133253. getClassName(): string;
  133254. /**
  133255. * Gets the color operand input component
  133256. */
  133257. get color(): NodeMaterialConnectionPoint;
  133258. /**
  133259. * Gets the level operand input component
  133260. */
  133261. get level(): NodeMaterialConnectionPoint;
  133262. /**
  133263. * Gets the output component
  133264. */
  133265. get output(): NodeMaterialConnectionPoint;
  133266. protected _buildBlock(state: NodeMaterialBuildState): this;
  133267. }
  133268. }
  133269. declare module BABYLON {
  133270. /**
  133271. * Effect Render Options
  133272. */
  133273. export interface IEffectRendererOptions {
  133274. /**
  133275. * Defines the vertices positions.
  133276. */
  133277. positions?: number[];
  133278. /**
  133279. * Defines the indices.
  133280. */
  133281. indices?: number[];
  133282. }
  133283. /**
  133284. * Helper class to render one or more effects
  133285. */
  133286. export class EffectRenderer {
  133287. private engine;
  133288. private static _DefaultOptions;
  133289. private _vertexBuffers;
  133290. private _indexBuffer;
  133291. private _ringBufferIndex;
  133292. private _ringScreenBuffer;
  133293. private _fullscreenViewport;
  133294. private _getNextFrameBuffer;
  133295. /**
  133296. * Creates an effect renderer
  133297. * @param engine the engine to use for rendering
  133298. * @param options defines the options of the effect renderer
  133299. */
  133300. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  133301. /**
  133302. * Sets the current viewport in normalized coordinates 0-1
  133303. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  133304. */
  133305. setViewport(viewport?: Viewport): void;
  133306. /**
  133307. * Binds the embedded attributes buffer to the effect.
  133308. * @param effect Defines the effect to bind the attributes for
  133309. */
  133310. bindBuffers(effect: Effect): void;
  133311. /**
  133312. * Sets the current effect wrapper to use during draw.
  133313. * The effect needs to be ready before calling this api.
  133314. * This also sets the default full screen position attribute.
  133315. * @param effectWrapper Defines the effect to draw with
  133316. */
  133317. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  133318. /**
  133319. * Draws a full screen quad.
  133320. */
  133321. draw(): void;
  133322. /**
  133323. * renders one or more effects to a specified texture
  133324. * @param effectWrappers list of effects to renderer
  133325. * @param outputTexture texture to draw to, if null it will render to the screen
  133326. */
  133327. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  133328. /**
  133329. * Disposes of the effect renderer
  133330. */
  133331. dispose(): void;
  133332. }
  133333. /**
  133334. * Options to create an EffectWrapper
  133335. */
  133336. interface EffectWrapperCreationOptions {
  133337. /**
  133338. * Engine to use to create the effect
  133339. */
  133340. engine: ThinEngine;
  133341. /**
  133342. * Fragment shader for the effect
  133343. */
  133344. fragmentShader: string;
  133345. /**
  133346. * Vertex shader for the effect
  133347. */
  133348. vertexShader?: string;
  133349. /**
  133350. * Attributes to use in the shader
  133351. */
  133352. attributeNames?: Array<string>;
  133353. /**
  133354. * Uniforms to use in the shader
  133355. */
  133356. uniformNames?: Array<string>;
  133357. /**
  133358. * Texture sampler names to use in the shader
  133359. */
  133360. samplerNames?: Array<string>;
  133361. /**
  133362. * The friendly name of the effect displayed in Spector.
  133363. */
  133364. name?: string;
  133365. }
  133366. /**
  133367. * Wraps an effect to be used for rendering
  133368. */
  133369. export class EffectWrapper {
  133370. /**
  133371. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  133372. */
  133373. onApplyObservable: Observable<{}>;
  133374. /**
  133375. * The underlying effect
  133376. */
  133377. effect: Effect;
  133378. /**
  133379. * Creates an effect to be renderer
  133380. * @param creationOptions options to create the effect
  133381. */
  133382. constructor(creationOptions: EffectWrapperCreationOptions);
  133383. /**
  133384. * Disposes of the effect wrapper
  133385. */
  133386. dispose(): void;
  133387. }
  133388. }
  133389. declare module BABYLON {
  133390. /**
  133391. * Helper class to push actions to a pool of workers.
  133392. */
  133393. export class WorkerPool implements IDisposable {
  133394. private _workerInfos;
  133395. private _pendingActions;
  133396. /**
  133397. * Constructor
  133398. * @param workers Array of workers to use for actions
  133399. */
  133400. constructor(workers: Array<Worker>);
  133401. /**
  133402. * Terminates all workers and clears any pending actions.
  133403. */
  133404. dispose(): void;
  133405. /**
  133406. * Pushes an action to the worker pool. If all the workers are active, the action will be
  133407. * pended until a worker has completed its action.
  133408. * @param action The action to perform. Call onComplete when the action is complete.
  133409. */
  133410. push(action: (worker: Worker, onComplete: () => void) => void): void;
  133411. private _execute;
  133412. }
  133413. }
  133414. declare module BABYLON {
  133415. /**
  133416. * Configuration for Draco compression
  133417. */
  133418. export interface IDracoCompressionConfiguration {
  133419. /**
  133420. * Configuration for the decoder.
  133421. */
  133422. decoder: {
  133423. /**
  133424. * The url to the WebAssembly module.
  133425. */
  133426. wasmUrl?: string;
  133427. /**
  133428. * The url to the WebAssembly binary.
  133429. */
  133430. wasmBinaryUrl?: string;
  133431. /**
  133432. * The url to the fallback JavaScript module.
  133433. */
  133434. fallbackUrl?: string;
  133435. };
  133436. }
  133437. /**
  133438. * Draco compression (https://google.github.io/draco/)
  133439. *
  133440. * This class wraps the Draco module.
  133441. *
  133442. * **Encoder**
  133443. *
  133444. * The encoder is not currently implemented.
  133445. *
  133446. * **Decoder**
  133447. *
  133448. * 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.
  133449. *
  133450. * To update the configuration, use the following code:
  133451. * ```javascript
  133452. * DracoCompression.Configuration = {
  133453. * decoder: {
  133454. * wasmUrl: "<url to the WebAssembly library>",
  133455. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  133456. * fallbackUrl: "<url to the fallback JavaScript library>",
  133457. * }
  133458. * };
  133459. * ```
  133460. *
  133461. * 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.
  133462. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  133463. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  133464. *
  133465. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  133466. * ```javascript
  133467. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  133468. * ```
  133469. *
  133470. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  133471. */
  133472. export class DracoCompression implements IDisposable {
  133473. private _workerPoolPromise?;
  133474. private _decoderModulePromise?;
  133475. /**
  133476. * The configuration. Defaults to the following urls:
  133477. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  133478. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  133479. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  133480. */
  133481. static Configuration: IDracoCompressionConfiguration;
  133482. /**
  133483. * Returns true if the decoder configuration is available.
  133484. */
  133485. static get DecoderAvailable(): boolean;
  133486. /**
  133487. * Default number of workers to create when creating the draco compression object.
  133488. */
  133489. static DefaultNumWorkers: number;
  133490. private static GetDefaultNumWorkers;
  133491. private static _Default;
  133492. /**
  133493. * Default instance for the draco compression object.
  133494. */
  133495. static get Default(): DracoCompression;
  133496. /**
  133497. * Constructor
  133498. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  133499. */
  133500. constructor(numWorkers?: number);
  133501. /**
  133502. * Stop all async operations and release resources.
  133503. */
  133504. dispose(): void;
  133505. /**
  133506. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  133507. * @returns a promise that resolves when ready
  133508. */
  133509. whenReadyAsync(): Promise<void>;
  133510. /**
  133511. * Decode Draco compressed mesh data to vertex data.
  133512. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  133513. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  133514. * @returns A promise that resolves with the decoded vertex data
  133515. */
  133516. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  133517. [kind: string]: number;
  133518. }): Promise<VertexData>;
  133519. }
  133520. }
  133521. declare module BABYLON {
  133522. /**
  133523. * Class for building Constructive Solid Geometry
  133524. */
  133525. export class CSG {
  133526. private polygons;
  133527. /**
  133528. * The world matrix
  133529. */
  133530. matrix: Matrix;
  133531. /**
  133532. * Stores the position
  133533. */
  133534. position: Vector3;
  133535. /**
  133536. * Stores the rotation
  133537. */
  133538. rotation: Vector3;
  133539. /**
  133540. * Stores the rotation quaternion
  133541. */
  133542. rotationQuaternion: Nullable<Quaternion>;
  133543. /**
  133544. * Stores the scaling vector
  133545. */
  133546. scaling: Vector3;
  133547. /**
  133548. * Convert the Mesh to CSG
  133549. * @param mesh The Mesh to convert to CSG
  133550. * @returns A new CSG from the Mesh
  133551. */
  133552. static FromMesh(mesh: Mesh): CSG;
  133553. /**
  133554. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  133555. * @param polygons Polygons used to construct a CSG solid
  133556. */
  133557. private static FromPolygons;
  133558. /**
  133559. * Clones, or makes a deep copy, of the CSG
  133560. * @returns A new CSG
  133561. */
  133562. clone(): CSG;
  133563. /**
  133564. * Unions this CSG with another CSG
  133565. * @param csg The CSG to union against this CSG
  133566. * @returns The unioned CSG
  133567. */
  133568. union(csg: CSG): CSG;
  133569. /**
  133570. * Unions this CSG with another CSG in place
  133571. * @param csg The CSG to union against this CSG
  133572. */
  133573. unionInPlace(csg: CSG): void;
  133574. /**
  133575. * Subtracts this CSG with another CSG
  133576. * @param csg The CSG to subtract against this CSG
  133577. * @returns A new CSG
  133578. */
  133579. subtract(csg: CSG): CSG;
  133580. /**
  133581. * Subtracts this CSG with another CSG in place
  133582. * @param csg The CSG to subtact against this CSG
  133583. */
  133584. subtractInPlace(csg: CSG): void;
  133585. /**
  133586. * Intersect this CSG with another CSG
  133587. * @param csg The CSG to intersect against this CSG
  133588. * @returns A new CSG
  133589. */
  133590. intersect(csg: CSG): CSG;
  133591. /**
  133592. * Intersects this CSG with another CSG in place
  133593. * @param csg The CSG to intersect against this CSG
  133594. */
  133595. intersectInPlace(csg: CSG): void;
  133596. /**
  133597. * Return a new CSG solid with solid and empty space switched. This solid is
  133598. * not modified.
  133599. * @returns A new CSG solid with solid and empty space switched
  133600. */
  133601. inverse(): CSG;
  133602. /**
  133603. * Inverses the CSG in place
  133604. */
  133605. inverseInPlace(): void;
  133606. /**
  133607. * This is used to keep meshes transformations so they can be restored
  133608. * when we build back a Babylon Mesh
  133609. * NB : All CSG operations are performed in world coordinates
  133610. * @param csg The CSG to copy the transform attributes from
  133611. * @returns This CSG
  133612. */
  133613. copyTransformAttributes(csg: CSG): CSG;
  133614. /**
  133615. * Build Raw mesh from CSG
  133616. * Coordinates here are in world space
  133617. * @param name The name of the mesh geometry
  133618. * @param scene The Scene
  133619. * @param keepSubMeshes Specifies if the submeshes should be kept
  133620. * @returns A new Mesh
  133621. */
  133622. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133623. /**
  133624. * Build Mesh from CSG taking material and transforms into account
  133625. * @param name The name of the Mesh
  133626. * @param material The material of the Mesh
  133627. * @param scene The Scene
  133628. * @param keepSubMeshes Specifies if submeshes should be kept
  133629. * @returns The new Mesh
  133630. */
  133631. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133632. }
  133633. }
  133634. declare module BABYLON {
  133635. /**
  133636. * Class used to create a trail following a mesh
  133637. */
  133638. export class TrailMesh extends Mesh {
  133639. private _generator;
  133640. private _autoStart;
  133641. private _running;
  133642. private _diameter;
  133643. private _length;
  133644. private _sectionPolygonPointsCount;
  133645. private _sectionVectors;
  133646. private _sectionNormalVectors;
  133647. private _beforeRenderObserver;
  133648. /**
  133649. * @constructor
  133650. * @param name The value used by scene.getMeshByName() to do a lookup.
  133651. * @param generator The mesh or transform node to generate a trail.
  133652. * @param scene The scene to add this mesh to.
  133653. * @param diameter Diameter of trailing mesh. Default is 1.
  133654. * @param length Length of trailing mesh. Default is 60.
  133655. * @param autoStart Automatically start trailing mesh. Default true.
  133656. */
  133657. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  133658. /**
  133659. * "TrailMesh"
  133660. * @returns "TrailMesh"
  133661. */
  133662. getClassName(): string;
  133663. private _createMesh;
  133664. /**
  133665. * Start trailing mesh.
  133666. */
  133667. start(): void;
  133668. /**
  133669. * Stop trailing mesh.
  133670. */
  133671. stop(): void;
  133672. /**
  133673. * Update trailing mesh geometry.
  133674. */
  133675. update(): void;
  133676. /**
  133677. * Returns a new TrailMesh object.
  133678. * @param name is a string, the name given to the new mesh
  133679. * @param newGenerator use new generator object for cloned trail mesh
  133680. * @returns a new mesh
  133681. */
  133682. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  133683. /**
  133684. * Serializes this trail mesh
  133685. * @param serializationObject object to write serialization to
  133686. */
  133687. serialize(serializationObject: any): void;
  133688. /**
  133689. * Parses a serialized trail mesh
  133690. * @param parsedMesh the serialized mesh
  133691. * @param scene the scene to create the trail mesh in
  133692. * @returns the created trail mesh
  133693. */
  133694. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  133695. }
  133696. }
  133697. declare module BABYLON {
  133698. /**
  133699. * Class containing static functions to help procedurally build meshes
  133700. */
  133701. export class TiledBoxBuilder {
  133702. /**
  133703. * Creates a box mesh
  133704. * 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)
  133705. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133707. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133709. * @param name defines the name of the mesh
  133710. * @param options defines the options used to create the mesh
  133711. * @param scene defines the hosting scene
  133712. * @returns the box mesh
  133713. */
  133714. static CreateTiledBox(name: string, options: {
  133715. pattern?: number;
  133716. width?: number;
  133717. height?: number;
  133718. depth?: number;
  133719. tileSize?: number;
  133720. tileWidth?: number;
  133721. tileHeight?: number;
  133722. alignHorizontal?: number;
  133723. alignVertical?: number;
  133724. faceUV?: Vector4[];
  133725. faceColors?: Color4[];
  133726. sideOrientation?: number;
  133727. updatable?: boolean;
  133728. }, scene?: Nullable<Scene>): Mesh;
  133729. }
  133730. }
  133731. declare module BABYLON {
  133732. /**
  133733. * Class containing static functions to help procedurally build meshes
  133734. */
  133735. export class TorusKnotBuilder {
  133736. /**
  133737. * Creates a torus knot mesh
  133738. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133739. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133740. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133741. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  133742. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133743. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133744. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133745. * @param name defines the name of the mesh
  133746. * @param options defines the options used to create the mesh
  133747. * @param scene defines the hosting scene
  133748. * @returns the torus knot mesh
  133749. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  133750. */
  133751. static CreateTorusKnot(name: string, options: {
  133752. radius?: number;
  133753. tube?: number;
  133754. radialSegments?: number;
  133755. tubularSegments?: number;
  133756. p?: number;
  133757. q?: number;
  133758. updatable?: boolean;
  133759. sideOrientation?: number;
  133760. frontUVs?: Vector4;
  133761. backUVs?: Vector4;
  133762. }, scene: any): Mesh;
  133763. }
  133764. }
  133765. declare module BABYLON {
  133766. /**
  133767. * Polygon
  133768. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  133769. */
  133770. export class Polygon {
  133771. /**
  133772. * Creates a rectangle
  133773. * @param xmin bottom X coord
  133774. * @param ymin bottom Y coord
  133775. * @param xmax top X coord
  133776. * @param ymax top Y coord
  133777. * @returns points that make the resulting rectation
  133778. */
  133779. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  133780. /**
  133781. * Creates a circle
  133782. * @param radius radius of circle
  133783. * @param cx scale in x
  133784. * @param cy scale in y
  133785. * @param numberOfSides number of sides that make up the circle
  133786. * @returns points that make the resulting circle
  133787. */
  133788. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  133789. /**
  133790. * Creates a polygon from input string
  133791. * @param input Input polygon data
  133792. * @returns the parsed points
  133793. */
  133794. static Parse(input: string): Vector2[];
  133795. /**
  133796. * Starts building a polygon from x and y coordinates
  133797. * @param x x coordinate
  133798. * @param y y coordinate
  133799. * @returns the started path2
  133800. */
  133801. static StartingAt(x: number, y: number): Path2;
  133802. }
  133803. /**
  133804. * Builds a polygon
  133805. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  133806. */
  133807. export class PolygonMeshBuilder {
  133808. private _points;
  133809. private _outlinepoints;
  133810. private _holes;
  133811. private _name;
  133812. private _scene;
  133813. private _epoints;
  133814. private _eholes;
  133815. private _addToepoint;
  133816. /**
  133817. * Babylon reference to the earcut plugin.
  133818. */
  133819. bjsEarcut: any;
  133820. /**
  133821. * Creates a PolygonMeshBuilder
  133822. * @param name name of the builder
  133823. * @param contours Path of the polygon
  133824. * @param scene scene to add to when creating the mesh
  133825. * @param earcutInjection can be used to inject your own earcut reference
  133826. */
  133827. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  133828. /**
  133829. * Adds a whole within the polygon
  133830. * @param hole Array of points defining the hole
  133831. * @returns this
  133832. */
  133833. addHole(hole: Vector2[]): PolygonMeshBuilder;
  133834. /**
  133835. * Creates the polygon
  133836. * @param updatable If the mesh should be updatable
  133837. * @param depth The depth of the mesh created
  133838. * @returns the created mesh
  133839. */
  133840. build(updatable?: boolean, depth?: number): Mesh;
  133841. /**
  133842. * Creates the polygon
  133843. * @param depth The depth of the mesh created
  133844. * @returns the created VertexData
  133845. */
  133846. buildVertexData(depth?: number): VertexData;
  133847. /**
  133848. * Adds a side to the polygon
  133849. * @param positions points that make the polygon
  133850. * @param normals normals of the polygon
  133851. * @param uvs uvs of the polygon
  133852. * @param indices indices of the polygon
  133853. * @param bounds bounds of the polygon
  133854. * @param points points of the polygon
  133855. * @param depth depth of the polygon
  133856. * @param flip flip of the polygon
  133857. */
  133858. private addSide;
  133859. }
  133860. }
  133861. declare module BABYLON {
  133862. /**
  133863. * Class containing static functions to help procedurally build meshes
  133864. */
  133865. export class PolygonBuilder {
  133866. /**
  133867. * Creates a polygon mesh
  133868. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  133869. * * 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
  133870. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133871. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133872. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  133873. * * Remember you can only change the shape positions, not their number when updating a polygon
  133874. * @param name defines the name of the mesh
  133875. * @param options defines the options used to create the mesh
  133876. * @param scene defines the hosting scene
  133877. * @param earcutInjection can be used to inject your own earcut reference
  133878. * @returns the polygon mesh
  133879. */
  133880. static CreatePolygon(name: string, options: {
  133881. shape: Vector3[];
  133882. holes?: Vector3[][];
  133883. depth?: number;
  133884. faceUV?: Vector4[];
  133885. faceColors?: Color4[];
  133886. updatable?: boolean;
  133887. sideOrientation?: number;
  133888. frontUVs?: Vector4;
  133889. backUVs?: Vector4;
  133890. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133891. /**
  133892. * Creates an extruded polygon mesh, with depth in the Y direction.
  133893. * * 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)
  133894. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133895. * @param name defines the name of the mesh
  133896. * @param options defines the options used to create the mesh
  133897. * @param scene defines the hosting scene
  133898. * @param earcutInjection can be used to inject your own earcut reference
  133899. * @returns the polygon mesh
  133900. */
  133901. static ExtrudePolygon(name: string, options: {
  133902. shape: Vector3[];
  133903. holes?: Vector3[][];
  133904. depth?: number;
  133905. faceUV?: Vector4[];
  133906. faceColors?: Color4[];
  133907. updatable?: boolean;
  133908. sideOrientation?: number;
  133909. frontUVs?: Vector4;
  133910. backUVs?: Vector4;
  133911. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  133912. }
  133913. }
  133914. declare module BABYLON {
  133915. /**
  133916. * Class containing static functions to help procedurally build meshes
  133917. */
  133918. export class LatheBuilder {
  133919. /**
  133920. * Creates lathe mesh.
  133921. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  133922. * * 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
  133923. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  133924. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  133925. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  133926. * * 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
  133927. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  133928. * * 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
  133929. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133930. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133931. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  133932. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133933. * @param name defines the name of the mesh
  133934. * @param options defines the options used to create the mesh
  133935. * @param scene defines the hosting scene
  133936. * @returns the lathe mesh
  133937. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  133938. */
  133939. static CreateLathe(name: string, options: {
  133940. shape: Vector3[];
  133941. radius?: number;
  133942. tessellation?: number;
  133943. clip?: number;
  133944. arc?: number;
  133945. closed?: boolean;
  133946. updatable?: boolean;
  133947. sideOrientation?: number;
  133948. frontUVs?: Vector4;
  133949. backUVs?: Vector4;
  133950. cap?: number;
  133951. invertUV?: boolean;
  133952. }, scene?: Nullable<Scene>): Mesh;
  133953. }
  133954. }
  133955. declare module BABYLON {
  133956. /**
  133957. * Class containing static functions to help procedurally build meshes
  133958. */
  133959. export class TiledPlaneBuilder {
  133960. /**
  133961. * Creates a tiled plane mesh
  133962. * * The parameter `pattern` will, depending on value, do nothing or
  133963. * * * flip (reflect about central vertical) alternate tiles across and up
  133964. * * * flip every tile on alternate rows
  133965. * * * rotate (180 degs) alternate tiles across and up
  133966. * * * rotate every tile on alternate rows
  133967. * * * flip and rotate alternate tiles across and up
  133968. * * * flip and rotate every tile on alternate rows
  133969. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  133970. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  133971. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133972. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  133973. * * 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)
  133974. * * 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)
  133975. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  133976. * @param name defines the name of the mesh
  133977. * @param options defines the options used to create the mesh
  133978. * @param scene defines the hosting scene
  133979. * @returns the box mesh
  133980. */
  133981. static CreateTiledPlane(name: string, options: {
  133982. pattern?: number;
  133983. tileSize?: number;
  133984. tileWidth?: number;
  133985. tileHeight?: number;
  133986. size?: number;
  133987. width?: number;
  133988. height?: number;
  133989. alignHorizontal?: number;
  133990. alignVertical?: number;
  133991. sideOrientation?: number;
  133992. frontUVs?: Vector4;
  133993. backUVs?: Vector4;
  133994. updatable?: boolean;
  133995. }, scene?: Nullable<Scene>): Mesh;
  133996. }
  133997. }
  133998. declare module BABYLON {
  133999. /**
  134000. * Class containing static functions to help procedurally build meshes
  134001. */
  134002. export class TubeBuilder {
  134003. /**
  134004. * Creates a tube mesh.
  134005. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134006. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134007. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134008. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134009. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134010. * * 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)
  134011. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134012. * * 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
  134013. * * 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
  134014. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134015. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134016. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134017. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134018. * @param name defines the name of the mesh
  134019. * @param options defines the options used to create the mesh
  134020. * @param scene defines the hosting scene
  134021. * @returns the tube mesh
  134022. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134023. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134024. */
  134025. static CreateTube(name: string, options: {
  134026. path: Vector3[];
  134027. radius?: number;
  134028. tessellation?: number;
  134029. radiusFunction?: {
  134030. (i: number, distance: number): number;
  134031. };
  134032. cap?: number;
  134033. arc?: number;
  134034. updatable?: boolean;
  134035. sideOrientation?: number;
  134036. frontUVs?: Vector4;
  134037. backUVs?: Vector4;
  134038. instance?: Mesh;
  134039. invertUV?: boolean;
  134040. }, scene?: Nullable<Scene>): Mesh;
  134041. }
  134042. }
  134043. declare module BABYLON {
  134044. /**
  134045. * Class containing static functions to help procedurally build meshes
  134046. */
  134047. export class IcoSphereBuilder {
  134048. /**
  134049. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134050. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134051. * * 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`)
  134052. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134053. * * 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
  134054. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134055. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134057. * @param name defines the name of the mesh
  134058. * @param options defines the options used to create the mesh
  134059. * @param scene defines the hosting scene
  134060. * @returns the icosahedron mesh
  134061. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134062. */
  134063. static CreateIcoSphere(name: string, options: {
  134064. radius?: number;
  134065. radiusX?: number;
  134066. radiusY?: number;
  134067. radiusZ?: number;
  134068. flat?: boolean;
  134069. subdivisions?: number;
  134070. sideOrientation?: number;
  134071. frontUVs?: Vector4;
  134072. backUVs?: Vector4;
  134073. updatable?: boolean;
  134074. }, scene?: Nullable<Scene>): Mesh;
  134075. }
  134076. }
  134077. declare module BABYLON {
  134078. /**
  134079. * Class containing static functions to help procedurally build meshes
  134080. */
  134081. export class DecalBuilder {
  134082. /**
  134083. * Creates a decal mesh.
  134084. * 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
  134085. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134086. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134087. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134088. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134089. * @param name defines the name of the mesh
  134090. * @param sourceMesh defines the mesh where the decal must be applied
  134091. * @param options defines the options used to create the mesh
  134092. * @param scene defines the hosting scene
  134093. * @returns the decal mesh
  134094. * @see https://doc.babylonjs.com/how_to/decals
  134095. */
  134096. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134097. position?: Vector3;
  134098. normal?: Vector3;
  134099. size?: Vector3;
  134100. angle?: number;
  134101. }): Mesh;
  134102. }
  134103. }
  134104. declare module BABYLON {
  134105. /**
  134106. * Class containing static functions to help procedurally build meshes
  134107. */
  134108. export class MeshBuilder {
  134109. /**
  134110. * Creates a box mesh
  134111. * * The parameter `size` sets the size (float) of each box side (default 1)
  134112. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134113. * * 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)
  134114. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134115. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134116. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134117. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134118. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134119. * @param name defines the name of the mesh
  134120. * @param options defines the options used to create the mesh
  134121. * @param scene defines the hosting scene
  134122. * @returns the box mesh
  134123. */
  134124. static CreateBox(name: string, options: {
  134125. size?: number;
  134126. width?: number;
  134127. height?: number;
  134128. depth?: number;
  134129. faceUV?: Vector4[];
  134130. faceColors?: Color4[];
  134131. sideOrientation?: number;
  134132. frontUVs?: Vector4;
  134133. backUVs?: Vector4;
  134134. updatable?: boolean;
  134135. }, scene?: Nullable<Scene>): Mesh;
  134136. /**
  134137. * Creates a tiled box mesh
  134138. * * faceTiles sets the pattern, tile size and number of tiles for a face
  134139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134140. * @param name defines the name of the mesh
  134141. * @param options defines the options used to create the mesh
  134142. * @param scene defines the hosting scene
  134143. * @returns the tiled box mesh
  134144. */
  134145. static CreateTiledBox(name: string, options: {
  134146. pattern?: number;
  134147. size?: number;
  134148. width?: number;
  134149. height?: number;
  134150. depth: number;
  134151. tileSize?: number;
  134152. tileWidth?: number;
  134153. tileHeight?: number;
  134154. faceUV?: Vector4[];
  134155. faceColors?: Color4[];
  134156. alignHorizontal?: number;
  134157. alignVertical?: number;
  134158. sideOrientation?: number;
  134159. updatable?: boolean;
  134160. }, scene?: Nullable<Scene>): Mesh;
  134161. /**
  134162. * Creates a sphere mesh
  134163. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  134164. * * 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`)
  134165. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  134166. * * 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
  134167. * * 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)
  134168. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134169. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134170. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134171. * @param name defines the name of the mesh
  134172. * @param options defines the options used to create the mesh
  134173. * @param scene defines the hosting scene
  134174. * @returns the sphere mesh
  134175. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  134176. */
  134177. static CreateSphere(name: string, options: {
  134178. segments?: number;
  134179. diameter?: number;
  134180. diameterX?: number;
  134181. diameterY?: number;
  134182. diameterZ?: number;
  134183. arc?: number;
  134184. slice?: number;
  134185. sideOrientation?: number;
  134186. frontUVs?: Vector4;
  134187. backUVs?: Vector4;
  134188. updatable?: boolean;
  134189. }, scene?: Nullable<Scene>): Mesh;
  134190. /**
  134191. * Creates a plane polygonal mesh. By default, this is a disc
  134192. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  134193. * * 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
  134194. * * 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
  134195. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134196. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134197. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134198. * @param name defines the name of the mesh
  134199. * @param options defines the options used to create the mesh
  134200. * @param scene defines the hosting scene
  134201. * @returns the plane polygonal mesh
  134202. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  134203. */
  134204. static CreateDisc(name: string, options: {
  134205. radius?: number;
  134206. tessellation?: number;
  134207. arc?: number;
  134208. updatable?: boolean;
  134209. sideOrientation?: number;
  134210. frontUVs?: Vector4;
  134211. backUVs?: Vector4;
  134212. }, scene?: Nullable<Scene>): Mesh;
  134213. /**
  134214. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134215. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134216. * * 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`)
  134217. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134218. * * 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
  134219. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134220. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134222. * @param name defines the name of the mesh
  134223. * @param options defines the options used to create the mesh
  134224. * @param scene defines the hosting scene
  134225. * @returns the icosahedron mesh
  134226. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134227. */
  134228. static CreateIcoSphere(name: string, options: {
  134229. radius?: number;
  134230. radiusX?: number;
  134231. radiusY?: number;
  134232. radiusZ?: number;
  134233. flat?: boolean;
  134234. subdivisions?: number;
  134235. sideOrientation?: number;
  134236. frontUVs?: Vector4;
  134237. backUVs?: Vector4;
  134238. updatable?: boolean;
  134239. }, scene?: Nullable<Scene>): Mesh;
  134240. /**
  134241. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134242. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134243. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134244. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134245. * * 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
  134246. * * 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
  134247. * * 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
  134248. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134249. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134250. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134251. * * 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
  134252. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134253. * * 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
  134254. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134256. * @param name defines the name of the mesh
  134257. * @param options defines the options used to create the mesh
  134258. * @param scene defines the hosting scene
  134259. * @returns the ribbon mesh
  134260. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134261. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134262. */
  134263. static CreateRibbon(name: string, options: {
  134264. pathArray: Vector3[][];
  134265. closeArray?: boolean;
  134266. closePath?: boolean;
  134267. offset?: number;
  134268. updatable?: boolean;
  134269. sideOrientation?: number;
  134270. frontUVs?: Vector4;
  134271. backUVs?: Vector4;
  134272. instance?: Mesh;
  134273. invertUV?: boolean;
  134274. uvs?: Vector2[];
  134275. colors?: Color4[];
  134276. }, scene?: Nullable<Scene>): Mesh;
  134277. /**
  134278. * Creates a cylinder or a cone mesh
  134279. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  134280. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  134281. * * 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.
  134282. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  134283. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  134284. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  134285. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  134286. * * 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).
  134287. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  134288. * * 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).
  134289. * * 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
  134290. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  134291. * * 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
  134292. * * 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.
  134293. * * If `enclose` is false, a ring surface is one element.
  134294. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  134295. * * 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
  134296. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134297. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134298. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134299. * @param name defines the name of the mesh
  134300. * @param options defines the options used to create the mesh
  134301. * @param scene defines the hosting scene
  134302. * @returns the cylinder mesh
  134303. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  134304. */
  134305. static CreateCylinder(name: string, options: {
  134306. height?: number;
  134307. diameterTop?: number;
  134308. diameterBottom?: number;
  134309. diameter?: number;
  134310. tessellation?: number;
  134311. subdivisions?: number;
  134312. arc?: number;
  134313. faceColors?: Color4[];
  134314. faceUV?: Vector4[];
  134315. updatable?: boolean;
  134316. hasRings?: boolean;
  134317. enclose?: boolean;
  134318. cap?: number;
  134319. sideOrientation?: number;
  134320. frontUVs?: Vector4;
  134321. backUVs?: Vector4;
  134322. }, scene?: Nullable<Scene>): Mesh;
  134323. /**
  134324. * Creates a torus mesh
  134325. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  134326. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  134327. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  134328. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134329. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134330. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134331. * @param name defines the name of the mesh
  134332. * @param options defines the options used to create the mesh
  134333. * @param scene defines the hosting scene
  134334. * @returns the torus mesh
  134335. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  134336. */
  134337. static CreateTorus(name: string, options: {
  134338. diameter?: number;
  134339. thickness?: number;
  134340. tessellation?: number;
  134341. updatable?: boolean;
  134342. sideOrientation?: number;
  134343. frontUVs?: Vector4;
  134344. backUVs?: Vector4;
  134345. }, scene?: Nullable<Scene>): Mesh;
  134346. /**
  134347. * Creates a torus knot mesh
  134348. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134349. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134350. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134351. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134352. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134353. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134354. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134355. * @param name defines the name of the mesh
  134356. * @param options defines the options used to create the mesh
  134357. * @param scene defines the hosting scene
  134358. * @returns the torus knot mesh
  134359. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134360. */
  134361. static CreateTorusKnot(name: string, options: {
  134362. radius?: number;
  134363. tube?: number;
  134364. radialSegments?: number;
  134365. tubularSegments?: number;
  134366. p?: number;
  134367. q?: number;
  134368. updatable?: boolean;
  134369. sideOrientation?: number;
  134370. frontUVs?: Vector4;
  134371. backUVs?: Vector4;
  134372. }, scene?: Nullable<Scene>): Mesh;
  134373. /**
  134374. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134375. * * 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
  134376. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134377. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134378. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134379. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134380. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134381. * * 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
  134382. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  134383. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134384. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134385. * @param name defines the name of the new line system
  134386. * @param options defines the options used to create the line system
  134387. * @param scene defines the hosting scene
  134388. * @returns a new line system mesh
  134389. */
  134390. static CreateLineSystem(name: string, options: {
  134391. lines: Vector3[][];
  134392. updatable?: boolean;
  134393. instance?: Nullable<LinesMesh>;
  134394. colors?: Nullable<Color4[][]>;
  134395. useVertexAlpha?: boolean;
  134396. }, scene: Nullable<Scene>): LinesMesh;
  134397. /**
  134398. * Creates a line mesh
  134399. * 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
  134400. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134401. * * The parameter `points` is an array successive Vector3
  134402. * * 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
  134403. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134404. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134405. * * When updating an instance, remember that only point positions can change, not the number of points
  134406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134407. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134408. * @param name defines the name of the new line system
  134409. * @param options defines the options used to create the line system
  134410. * @param scene defines the hosting scene
  134411. * @returns a new line mesh
  134412. */
  134413. static CreateLines(name: string, options: {
  134414. points: Vector3[];
  134415. updatable?: boolean;
  134416. instance?: Nullable<LinesMesh>;
  134417. colors?: Color4[];
  134418. useVertexAlpha?: boolean;
  134419. }, scene?: Nullable<Scene>): LinesMesh;
  134420. /**
  134421. * Creates a dashed line mesh
  134422. * * 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
  134423. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134424. * * The parameter `points` is an array successive Vector3
  134425. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134426. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134427. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134428. * * 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
  134429. * * When updating an instance, remember that only point positions can change, not the number of points
  134430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134431. * @param name defines the name of the mesh
  134432. * @param options defines the options used to create the mesh
  134433. * @param scene defines the hosting scene
  134434. * @returns the dashed line mesh
  134435. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134436. */
  134437. static CreateDashedLines(name: string, options: {
  134438. points: Vector3[];
  134439. dashSize?: number;
  134440. gapSize?: number;
  134441. dashNb?: number;
  134442. updatable?: boolean;
  134443. instance?: LinesMesh;
  134444. }, scene?: Nullable<Scene>): LinesMesh;
  134445. /**
  134446. * 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.
  134447. * * 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.
  134448. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134449. * * 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.
  134450. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  134451. * * 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
  134452. * * 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
  134453. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  134454. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134455. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134456. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  134457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134458. * @param name defines the name of the mesh
  134459. * @param options defines the options used to create the mesh
  134460. * @param scene defines the hosting scene
  134461. * @returns the extruded shape mesh
  134462. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134463. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134464. */
  134465. static ExtrudeShape(name: string, options: {
  134466. shape: Vector3[];
  134467. path: Vector3[];
  134468. scale?: number;
  134469. rotation?: number;
  134470. cap?: number;
  134471. updatable?: boolean;
  134472. sideOrientation?: number;
  134473. frontUVs?: Vector4;
  134474. backUVs?: Vector4;
  134475. instance?: Mesh;
  134476. invertUV?: boolean;
  134477. }, scene?: Nullable<Scene>): Mesh;
  134478. /**
  134479. * Creates an custom extruded shape mesh.
  134480. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  134481. * * 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.
  134482. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134483. * * 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
  134484. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  134485. * * 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
  134486. * * It must returns a float value that will be the scale value applied to the shape on each path point
  134487. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  134488. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  134489. * * 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
  134490. * * 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
  134491. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  134492. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134493. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134494. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134495. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134496. * @param name defines the name of the mesh
  134497. * @param options defines the options used to create the mesh
  134498. * @param scene defines the hosting scene
  134499. * @returns the custom extruded shape mesh
  134500. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  134501. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134502. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134503. */
  134504. static ExtrudeShapeCustom(name: string, options: {
  134505. shape: Vector3[];
  134506. path: Vector3[];
  134507. scaleFunction?: any;
  134508. rotationFunction?: any;
  134509. ribbonCloseArray?: boolean;
  134510. ribbonClosePath?: boolean;
  134511. cap?: number;
  134512. updatable?: boolean;
  134513. sideOrientation?: number;
  134514. frontUVs?: Vector4;
  134515. backUVs?: Vector4;
  134516. instance?: Mesh;
  134517. invertUV?: boolean;
  134518. }, scene?: Nullable<Scene>): Mesh;
  134519. /**
  134520. * Creates lathe mesh.
  134521. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134522. * * 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
  134523. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134524. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134525. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134526. * * 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
  134527. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134528. * * 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
  134529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134530. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134531. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134532. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134533. * @param name defines the name of the mesh
  134534. * @param options defines the options used to create the mesh
  134535. * @param scene defines the hosting scene
  134536. * @returns the lathe mesh
  134537. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134538. */
  134539. static CreateLathe(name: string, options: {
  134540. shape: Vector3[];
  134541. radius?: number;
  134542. tessellation?: number;
  134543. clip?: number;
  134544. arc?: number;
  134545. closed?: boolean;
  134546. updatable?: boolean;
  134547. sideOrientation?: number;
  134548. frontUVs?: Vector4;
  134549. backUVs?: Vector4;
  134550. cap?: number;
  134551. invertUV?: boolean;
  134552. }, scene?: Nullable<Scene>): Mesh;
  134553. /**
  134554. * Creates a tiled plane mesh
  134555. * * You can set a limited pattern arrangement with the tiles
  134556. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134557. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134558. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134559. * @param name defines the name of the mesh
  134560. * @param options defines the options used to create the mesh
  134561. * @param scene defines the hosting scene
  134562. * @returns the plane mesh
  134563. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134564. */
  134565. static CreateTiledPlane(name: string, options: {
  134566. pattern?: number;
  134567. tileSize?: number;
  134568. tileWidth?: number;
  134569. tileHeight?: number;
  134570. size?: number;
  134571. width?: number;
  134572. height?: number;
  134573. alignHorizontal?: number;
  134574. alignVertical?: number;
  134575. sideOrientation?: number;
  134576. frontUVs?: Vector4;
  134577. backUVs?: Vector4;
  134578. updatable?: boolean;
  134579. }, scene?: Nullable<Scene>): Mesh;
  134580. /**
  134581. * Creates a plane mesh
  134582. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  134583. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  134584. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  134585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134586. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134588. * @param name defines the name of the mesh
  134589. * @param options defines the options used to create the mesh
  134590. * @param scene defines the hosting scene
  134591. * @returns the plane mesh
  134592. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134593. */
  134594. static CreatePlane(name: string, options: {
  134595. size?: number;
  134596. width?: number;
  134597. height?: number;
  134598. sideOrientation?: number;
  134599. frontUVs?: Vector4;
  134600. backUVs?: Vector4;
  134601. updatable?: boolean;
  134602. sourcePlane?: Plane;
  134603. }, scene?: Nullable<Scene>): Mesh;
  134604. /**
  134605. * Creates a ground mesh
  134606. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  134607. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  134608. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134609. * @param name defines the name of the mesh
  134610. * @param options defines the options used to create the mesh
  134611. * @param scene defines the hosting scene
  134612. * @returns the ground mesh
  134613. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  134614. */
  134615. static CreateGround(name: string, options: {
  134616. width?: number;
  134617. height?: number;
  134618. subdivisions?: number;
  134619. subdivisionsX?: number;
  134620. subdivisionsY?: number;
  134621. updatable?: boolean;
  134622. }, scene?: Nullable<Scene>): Mesh;
  134623. /**
  134624. * Creates a tiled ground mesh
  134625. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  134626. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  134627. * * 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
  134628. * * 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
  134629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134630. * @param name defines the name of the mesh
  134631. * @param options defines the options used to create the mesh
  134632. * @param scene defines the hosting scene
  134633. * @returns the tiled ground mesh
  134634. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  134635. */
  134636. static CreateTiledGround(name: string, options: {
  134637. xmin: number;
  134638. zmin: number;
  134639. xmax: number;
  134640. zmax: number;
  134641. subdivisions?: {
  134642. w: number;
  134643. h: number;
  134644. };
  134645. precision?: {
  134646. w: number;
  134647. h: number;
  134648. };
  134649. updatable?: boolean;
  134650. }, scene?: Nullable<Scene>): Mesh;
  134651. /**
  134652. * Creates a ground mesh from a height map
  134653. * * The parameter `url` sets the URL of the height map image resource.
  134654. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  134655. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  134656. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  134657. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  134658. * * 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.
  134659. * * 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).
  134660. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  134661. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134662. * @param name defines the name of the mesh
  134663. * @param url defines the url to the height map
  134664. * @param options defines the options used to create the mesh
  134665. * @param scene defines the hosting scene
  134666. * @returns the ground mesh
  134667. * @see https://doc.babylonjs.com/babylon101/height_map
  134668. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  134669. */
  134670. static CreateGroundFromHeightMap(name: string, url: string, options: {
  134671. width?: number;
  134672. height?: number;
  134673. subdivisions?: number;
  134674. minHeight?: number;
  134675. maxHeight?: number;
  134676. colorFilter?: Color3;
  134677. alphaFilter?: number;
  134678. updatable?: boolean;
  134679. onReady?: (mesh: GroundMesh) => void;
  134680. }, scene?: Nullable<Scene>): GroundMesh;
  134681. /**
  134682. * Creates a polygon mesh
  134683. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134684. * * 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
  134685. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134687. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134688. * * Remember you can only change the shape positions, not their number when updating a polygon
  134689. * @param name defines the name of the mesh
  134690. * @param options defines the options used to create the mesh
  134691. * @param scene defines the hosting scene
  134692. * @param earcutInjection can be used to inject your own earcut reference
  134693. * @returns the polygon mesh
  134694. */
  134695. static CreatePolygon(name: string, options: {
  134696. shape: Vector3[];
  134697. holes?: Vector3[][];
  134698. depth?: number;
  134699. faceUV?: Vector4[];
  134700. faceColors?: Color4[];
  134701. updatable?: boolean;
  134702. sideOrientation?: number;
  134703. frontUVs?: Vector4;
  134704. backUVs?: Vector4;
  134705. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134706. /**
  134707. * Creates an extruded polygon mesh, with depth in the Y direction.
  134708. * * 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)
  134709. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134710. * @param name defines the name of the mesh
  134711. * @param options defines the options used to create the mesh
  134712. * @param scene defines the hosting scene
  134713. * @param earcutInjection can be used to inject your own earcut reference
  134714. * @returns the polygon mesh
  134715. */
  134716. static ExtrudePolygon(name: string, options: {
  134717. shape: Vector3[];
  134718. holes?: Vector3[][];
  134719. depth?: number;
  134720. faceUV?: Vector4[];
  134721. faceColors?: Color4[];
  134722. updatable?: boolean;
  134723. sideOrientation?: number;
  134724. frontUVs?: Vector4;
  134725. backUVs?: Vector4;
  134726. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134727. /**
  134728. * Creates a tube mesh.
  134729. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134730. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134731. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134732. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134733. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134734. * * 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)
  134735. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134736. * * 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
  134737. * * 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
  134738. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134739. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134740. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134741. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134742. * @param name defines the name of the mesh
  134743. * @param options defines the options used to create the mesh
  134744. * @param scene defines the hosting scene
  134745. * @returns the tube mesh
  134746. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134747. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134748. */
  134749. static CreateTube(name: string, options: {
  134750. path: Vector3[];
  134751. radius?: number;
  134752. tessellation?: number;
  134753. radiusFunction?: {
  134754. (i: number, distance: number): number;
  134755. };
  134756. cap?: number;
  134757. arc?: number;
  134758. updatable?: boolean;
  134759. sideOrientation?: number;
  134760. frontUVs?: Vector4;
  134761. backUVs?: Vector4;
  134762. instance?: Mesh;
  134763. invertUV?: boolean;
  134764. }, scene?: Nullable<Scene>): Mesh;
  134765. /**
  134766. * Creates a polyhedron mesh
  134767. * * 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
  134768. * * The parameter `size` (positive float, default 1) sets the polygon size
  134769. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  134770. * * 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`
  134771. * * 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
  134772. * * 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)`)
  134773. * * 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
  134774. * * 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
  134775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134776. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134778. * @param name defines the name of the mesh
  134779. * @param options defines the options used to create the mesh
  134780. * @param scene defines the hosting scene
  134781. * @returns the polyhedron mesh
  134782. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  134783. */
  134784. static CreatePolyhedron(name: string, options: {
  134785. type?: number;
  134786. size?: number;
  134787. sizeX?: number;
  134788. sizeY?: number;
  134789. sizeZ?: number;
  134790. custom?: any;
  134791. faceUV?: Vector4[];
  134792. faceColors?: Color4[];
  134793. flat?: boolean;
  134794. updatable?: boolean;
  134795. sideOrientation?: number;
  134796. frontUVs?: Vector4;
  134797. backUVs?: Vector4;
  134798. }, scene?: Nullable<Scene>): Mesh;
  134799. /**
  134800. * Creates a decal mesh.
  134801. * 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
  134802. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134803. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134804. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134805. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134806. * @param name defines the name of the mesh
  134807. * @param sourceMesh defines the mesh where the decal must be applied
  134808. * @param options defines the options used to create the mesh
  134809. * @param scene defines the hosting scene
  134810. * @returns the decal mesh
  134811. * @see https://doc.babylonjs.com/how_to/decals
  134812. */
  134813. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134814. position?: Vector3;
  134815. normal?: Vector3;
  134816. size?: Vector3;
  134817. angle?: number;
  134818. }): Mesh;
  134819. }
  134820. }
  134821. declare module BABYLON {
  134822. /**
  134823. * A simplifier interface for future simplification implementations
  134824. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134825. */
  134826. export interface ISimplifier {
  134827. /**
  134828. * Simplification of a given mesh according to the given settings.
  134829. * Since this requires computation, it is assumed that the function runs async.
  134830. * @param settings The settings of the simplification, including quality and distance
  134831. * @param successCallback A callback that will be called after the mesh was simplified.
  134832. * @param errorCallback in case of an error, this callback will be called. optional.
  134833. */
  134834. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  134835. }
  134836. /**
  134837. * Expected simplification settings.
  134838. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  134839. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134840. */
  134841. export interface ISimplificationSettings {
  134842. /**
  134843. * Gets or sets the expected quality
  134844. */
  134845. quality: number;
  134846. /**
  134847. * Gets or sets the distance when this optimized version should be used
  134848. */
  134849. distance: number;
  134850. /**
  134851. * Gets an already optimized mesh
  134852. */
  134853. optimizeMesh?: boolean;
  134854. }
  134855. /**
  134856. * Class used to specify simplification options
  134857. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134858. */
  134859. export class SimplificationSettings implements ISimplificationSettings {
  134860. /** expected quality */
  134861. quality: number;
  134862. /** distance when this optimized version should be used */
  134863. distance: number;
  134864. /** already optimized mesh */
  134865. optimizeMesh?: boolean | undefined;
  134866. /**
  134867. * Creates a SimplificationSettings
  134868. * @param quality expected quality
  134869. * @param distance distance when this optimized version should be used
  134870. * @param optimizeMesh already optimized mesh
  134871. */
  134872. constructor(
  134873. /** expected quality */
  134874. quality: number,
  134875. /** distance when this optimized version should be used */
  134876. distance: number,
  134877. /** already optimized mesh */
  134878. optimizeMesh?: boolean | undefined);
  134879. }
  134880. /**
  134881. * Interface used to define a simplification task
  134882. */
  134883. export interface ISimplificationTask {
  134884. /**
  134885. * Array of settings
  134886. */
  134887. settings: Array<ISimplificationSettings>;
  134888. /**
  134889. * Simplification type
  134890. */
  134891. simplificationType: SimplificationType;
  134892. /**
  134893. * Mesh to simplify
  134894. */
  134895. mesh: Mesh;
  134896. /**
  134897. * Callback called on success
  134898. */
  134899. successCallback?: () => void;
  134900. /**
  134901. * Defines if parallel processing can be used
  134902. */
  134903. parallelProcessing: boolean;
  134904. }
  134905. /**
  134906. * Queue used to order the simplification tasks
  134907. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134908. */
  134909. export class SimplificationQueue {
  134910. private _simplificationArray;
  134911. /**
  134912. * Gets a boolean indicating that the process is still running
  134913. */
  134914. running: boolean;
  134915. /**
  134916. * Creates a new queue
  134917. */
  134918. constructor();
  134919. /**
  134920. * Adds a new simplification task
  134921. * @param task defines a task to add
  134922. */
  134923. addTask(task: ISimplificationTask): void;
  134924. /**
  134925. * Execute next task
  134926. */
  134927. executeNext(): void;
  134928. /**
  134929. * Execute a simplification task
  134930. * @param task defines the task to run
  134931. */
  134932. runSimplification(task: ISimplificationTask): void;
  134933. private getSimplifier;
  134934. }
  134935. /**
  134936. * The implemented types of simplification
  134937. * At the moment only Quadratic Error Decimation is implemented
  134938. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134939. */
  134940. export enum SimplificationType {
  134941. /** Quadratic error decimation */
  134942. QUADRATIC = 0
  134943. }
  134944. }
  134945. declare module BABYLON {
  134946. interface Scene {
  134947. /** @hidden (Backing field) */
  134948. _simplificationQueue: SimplificationQueue;
  134949. /**
  134950. * Gets or sets the simplification queue attached to the scene
  134951. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  134952. */
  134953. simplificationQueue: SimplificationQueue;
  134954. }
  134955. interface Mesh {
  134956. /**
  134957. * Simplify the mesh according to the given array of settings.
  134958. * Function will return immediately and will simplify async
  134959. * @param settings a collection of simplification settings
  134960. * @param parallelProcessing should all levels calculate parallel or one after the other
  134961. * @param simplificationType the type of simplification to run
  134962. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  134963. * @returns the current mesh
  134964. */
  134965. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  134966. }
  134967. /**
  134968. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  134969. * created in a scene
  134970. */
  134971. export class SimplicationQueueSceneComponent implements ISceneComponent {
  134972. /**
  134973. * The component name helpfull to identify the component in the list of scene components.
  134974. */
  134975. readonly name: string;
  134976. /**
  134977. * The scene the component belongs to.
  134978. */
  134979. scene: Scene;
  134980. /**
  134981. * Creates a new instance of the component for the given scene
  134982. * @param scene Defines the scene to register the component in
  134983. */
  134984. constructor(scene: Scene);
  134985. /**
  134986. * Registers the component in a given scene
  134987. */
  134988. register(): void;
  134989. /**
  134990. * Rebuilds the elements related to this component in case of
  134991. * context lost for instance.
  134992. */
  134993. rebuild(): void;
  134994. /**
  134995. * Disposes the component and the associated ressources
  134996. */
  134997. dispose(): void;
  134998. private _beforeCameraUpdate;
  134999. }
  135000. }
  135001. declare module BABYLON {
  135002. /**
  135003. * Navigation plugin interface to add navigation constrained by a navigation mesh
  135004. */
  135005. export interface INavigationEnginePlugin {
  135006. /**
  135007. * plugin name
  135008. */
  135009. name: string;
  135010. /**
  135011. * Creates a navigation mesh
  135012. * @param meshes array of all the geometry used to compute the navigatio mesh
  135013. * @param parameters bunch of parameters used to filter geometry
  135014. */
  135015. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135016. /**
  135017. * Create a navigation mesh debug mesh
  135018. * @param scene is where the mesh will be added
  135019. * @returns debug display mesh
  135020. */
  135021. createDebugNavMesh(scene: Scene): Mesh;
  135022. /**
  135023. * Get a navigation mesh constrained position, closest to the parameter position
  135024. * @param position world position
  135025. * @returns the closest point to position constrained by the navigation mesh
  135026. */
  135027. getClosestPoint(position: Vector3): Vector3;
  135028. /**
  135029. * Get a navigation mesh constrained position, within a particular radius
  135030. * @param position world position
  135031. * @param maxRadius the maximum distance to the constrained world position
  135032. * @returns the closest point to position constrained by the navigation mesh
  135033. */
  135034. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135035. /**
  135036. * Compute the final position from a segment made of destination-position
  135037. * @param position world position
  135038. * @param destination world position
  135039. * @returns the resulting point along the navmesh
  135040. */
  135041. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135042. /**
  135043. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135044. * @param start world position
  135045. * @param end world position
  135046. * @returns array containing world position composing the path
  135047. */
  135048. computePath(start: Vector3, end: Vector3): Vector3[];
  135049. /**
  135050. * If this plugin is supported
  135051. * @returns true if plugin is supported
  135052. */
  135053. isSupported(): boolean;
  135054. /**
  135055. * Create a new Crowd so you can add agents
  135056. * @param maxAgents the maximum agent count in the crowd
  135057. * @param maxAgentRadius the maximum radius an agent can have
  135058. * @param scene to attach the crowd to
  135059. * @returns the crowd you can add agents to
  135060. */
  135061. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135062. /**
  135063. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135064. * The queries will try to find a solution within those bounds
  135065. * default is (1,1,1)
  135066. * @param extent x,y,z value that define the extent around the queries point of reference
  135067. */
  135068. setDefaultQueryExtent(extent: Vector3): void;
  135069. /**
  135070. * Get the Bounding box extent specified by setDefaultQueryExtent
  135071. * @returns the box extent values
  135072. */
  135073. getDefaultQueryExtent(): Vector3;
  135074. /**
  135075. * Release all resources
  135076. */
  135077. dispose(): void;
  135078. }
  135079. /**
  135080. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  135081. */
  135082. export interface ICrowd {
  135083. /**
  135084. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135085. * You can attach anything to that node. The node position is updated in the scene update tick.
  135086. * @param pos world position that will be constrained by the navigation mesh
  135087. * @param parameters agent parameters
  135088. * @param transform hooked to the agent that will be update by the scene
  135089. * @returns agent index
  135090. */
  135091. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135092. /**
  135093. * Returns the agent position in world space
  135094. * @param index agent index returned by addAgent
  135095. * @returns world space position
  135096. */
  135097. getAgentPosition(index: number): Vector3;
  135098. /**
  135099. * Gets the agent velocity in world space
  135100. * @param index agent index returned by addAgent
  135101. * @returns world space velocity
  135102. */
  135103. getAgentVelocity(index: number): Vector3;
  135104. /**
  135105. * remove a particular agent previously created
  135106. * @param index agent index returned by addAgent
  135107. */
  135108. removeAgent(index: number): void;
  135109. /**
  135110. * get the list of all agents attached to this crowd
  135111. * @returns list of agent indices
  135112. */
  135113. getAgents(): number[];
  135114. /**
  135115. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135116. * @param deltaTime in seconds
  135117. */
  135118. update(deltaTime: number): void;
  135119. /**
  135120. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135121. * @param index agent index returned by addAgent
  135122. * @param destination targeted world position
  135123. */
  135124. agentGoto(index: number, destination: Vector3): void;
  135125. /**
  135126. * Teleport the agent to a new position
  135127. * @param index agent index returned by addAgent
  135128. * @param destination targeted world position
  135129. */
  135130. agentTeleport(index: number, destination: Vector3): void;
  135131. /**
  135132. * Update agent parameters
  135133. * @param index agent index returned by addAgent
  135134. * @param parameters agent parameters
  135135. */
  135136. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135137. /**
  135138. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135139. * The queries will try to find a solution within those bounds
  135140. * default is (1,1,1)
  135141. * @param extent x,y,z value that define the extent around the queries point of reference
  135142. */
  135143. setDefaultQueryExtent(extent: Vector3): void;
  135144. /**
  135145. * Get the Bounding box extent specified by setDefaultQueryExtent
  135146. * @returns the box extent values
  135147. */
  135148. getDefaultQueryExtent(): Vector3;
  135149. /**
  135150. * Release all resources
  135151. */
  135152. dispose(): void;
  135153. }
  135154. /**
  135155. * Configures an agent
  135156. */
  135157. export interface IAgentParameters {
  135158. /**
  135159. * Agent radius. [Limit: >= 0]
  135160. */
  135161. radius: number;
  135162. /**
  135163. * Agent height. [Limit: > 0]
  135164. */
  135165. height: number;
  135166. /**
  135167. * Maximum allowed acceleration. [Limit: >= 0]
  135168. */
  135169. maxAcceleration: number;
  135170. /**
  135171. * Maximum allowed speed. [Limit: >= 0]
  135172. */
  135173. maxSpeed: number;
  135174. /**
  135175. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  135176. */
  135177. collisionQueryRange: number;
  135178. /**
  135179. * The path visibility optimization range. [Limit: > 0]
  135180. */
  135181. pathOptimizationRange: number;
  135182. /**
  135183. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  135184. */
  135185. separationWeight: number;
  135186. }
  135187. /**
  135188. * Configures the navigation mesh creation
  135189. */
  135190. export interface INavMeshParameters {
  135191. /**
  135192. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  135193. */
  135194. cs: number;
  135195. /**
  135196. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  135197. */
  135198. ch: number;
  135199. /**
  135200. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  135201. */
  135202. walkableSlopeAngle: number;
  135203. /**
  135204. * Minimum floor to 'ceiling' height that will still allow the floor area to
  135205. * be considered walkable. [Limit: >= 3] [Units: vx]
  135206. */
  135207. walkableHeight: number;
  135208. /**
  135209. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  135210. */
  135211. walkableClimb: number;
  135212. /**
  135213. * The distance to erode/shrink the walkable area of the heightfield away from
  135214. * obstructions. [Limit: >=0] [Units: vx]
  135215. */
  135216. walkableRadius: number;
  135217. /**
  135218. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  135219. */
  135220. maxEdgeLen: number;
  135221. /**
  135222. * The maximum distance a simplfied contour's border edges should deviate
  135223. * the original raw contour. [Limit: >=0] [Units: vx]
  135224. */
  135225. maxSimplificationError: number;
  135226. /**
  135227. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  135228. */
  135229. minRegionArea: number;
  135230. /**
  135231. * Any regions with a span count smaller than this value will, if possible,
  135232. * be merged with larger regions. [Limit: >=0] [Units: vx]
  135233. */
  135234. mergeRegionArea: number;
  135235. /**
  135236. * The maximum number of vertices allowed for polygons generated during the
  135237. * contour to polygon conversion process. [Limit: >= 3]
  135238. */
  135239. maxVertsPerPoly: number;
  135240. /**
  135241. * Sets the sampling distance to use when generating the detail mesh.
  135242. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  135243. */
  135244. detailSampleDist: number;
  135245. /**
  135246. * The maximum distance the detail mesh surface should deviate from heightfield
  135247. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  135248. */
  135249. detailSampleMaxError: number;
  135250. }
  135251. }
  135252. declare module BABYLON {
  135253. /**
  135254. * RecastJS navigation plugin
  135255. */
  135256. export class RecastJSPlugin implements INavigationEnginePlugin {
  135257. /**
  135258. * Reference to the Recast library
  135259. */
  135260. bjsRECAST: any;
  135261. /**
  135262. * plugin name
  135263. */
  135264. name: string;
  135265. /**
  135266. * the first navmesh created. We might extend this to support multiple navmeshes
  135267. */
  135268. navMesh: any;
  135269. /**
  135270. * Initializes the recastJS plugin
  135271. * @param recastInjection can be used to inject your own recast reference
  135272. */
  135273. constructor(recastInjection?: any);
  135274. /**
  135275. * Creates a navigation mesh
  135276. * @param meshes array of all the geometry used to compute the navigatio mesh
  135277. * @param parameters bunch of parameters used to filter geometry
  135278. */
  135279. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135280. /**
  135281. * Create a navigation mesh debug mesh
  135282. * @param scene is where the mesh will be added
  135283. * @returns debug display mesh
  135284. */
  135285. createDebugNavMesh(scene: Scene): Mesh;
  135286. /**
  135287. * Get a navigation mesh constrained position, closest to the parameter position
  135288. * @param position world position
  135289. * @returns the closest point to position constrained by the navigation mesh
  135290. */
  135291. getClosestPoint(position: Vector3): Vector3;
  135292. /**
  135293. * Get a navigation mesh constrained position, within a particular radius
  135294. * @param position world position
  135295. * @param maxRadius the maximum distance to the constrained world position
  135296. * @returns the closest point to position constrained by the navigation mesh
  135297. */
  135298. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135299. /**
  135300. * Compute the final position from a segment made of destination-position
  135301. * @param position world position
  135302. * @param destination world position
  135303. * @returns the resulting point along the navmesh
  135304. */
  135305. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135306. /**
  135307. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135308. * @param start world position
  135309. * @param end world position
  135310. * @returns array containing world position composing the path
  135311. */
  135312. computePath(start: Vector3, end: Vector3): Vector3[];
  135313. /**
  135314. * Create a new Crowd so you can add agents
  135315. * @param maxAgents the maximum agent count in the crowd
  135316. * @param maxAgentRadius the maximum radius an agent can have
  135317. * @param scene to attach the crowd to
  135318. * @returns the crowd you can add agents to
  135319. */
  135320. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135321. /**
  135322. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135323. * The queries will try to find a solution within those bounds
  135324. * default is (1,1,1)
  135325. * @param extent x,y,z value that define the extent around the queries point of reference
  135326. */
  135327. setDefaultQueryExtent(extent: Vector3): void;
  135328. /**
  135329. * Get the Bounding box extent specified by setDefaultQueryExtent
  135330. * @returns the box extent values
  135331. */
  135332. getDefaultQueryExtent(): Vector3;
  135333. /**
  135334. * Disposes
  135335. */
  135336. dispose(): void;
  135337. /**
  135338. * If this plugin is supported
  135339. * @returns true if plugin is supported
  135340. */
  135341. isSupported(): boolean;
  135342. }
  135343. /**
  135344. * Recast detour crowd implementation
  135345. */
  135346. export class RecastJSCrowd implements ICrowd {
  135347. /**
  135348. * Recast/detour plugin
  135349. */
  135350. bjsRECASTPlugin: RecastJSPlugin;
  135351. /**
  135352. * Link to the detour crowd
  135353. */
  135354. recastCrowd: any;
  135355. /**
  135356. * One transform per agent
  135357. */
  135358. transforms: TransformNode[];
  135359. /**
  135360. * All agents created
  135361. */
  135362. agents: number[];
  135363. /**
  135364. * Link to the scene is kept to unregister the crowd from the scene
  135365. */
  135366. private _scene;
  135367. /**
  135368. * Observer for crowd updates
  135369. */
  135370. private _onBeforeAnimationsObserver;
  135371. /**
  135372. * Constructor
  135373. * @param plugin recastJS plugin
  135374. * @param maxAgents the maximum agent count in the crowd
  135375. * @param maxAgentRadius the maximum radius an agent can have
  135376. * @param scene to attach the crowd to
  135377. * @returns the crowd you can add agents to
  135378. */
  135379. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  135380. /**
  135381. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135382. * You can attach anything to that node. The node position is updated in the scene update tick.
  135383. * @param pos world position that will be constrained by the navigation mesh
  135384. * @param parameters agent parameters
  135385. * @param transform hooked to the agent that will be update by the scene
  135386. * @returns agent index
  135387. */
  135388. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135389. /**
  135390. * Returns the agent position in world space
  135391. * @param index agent index returned by addAgent
  135392. * @returns world space position
  135393. */
  135394. getAgentPosition(index: number): Vector3;
  135395. /**
  135396. * Returns the agent velocity in world space
  135397. * @param index agent index returned by addAgent
  135398. * @returns world space velocity
  135399. */
  135400. getAgentVelocity(index: number): Vector3;
  135401. /**
  135402. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135403. * @param index agent index returned by addAgent
  135404. * @param destination targeted world position
  135405. */
  135406. agentGoto(index: number, destination: Vector3): void;
  135407. /**
  135408. * Teleport the agent to a new position
  135409. * @param index agent index returned by addAgent
  135410. * @param destination targeted world position
  135411. */
  135412. agentTeleport(index: number, destination: Vector3): void;
  135413. /**
  135414. * Update agent parameters
  135415. * @param index agent index returned by addAgent
  135416. * @param parameters agent parameters
  135417. */
  135418. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135419. /**
  135420. * remove a particular agent previously created
  135421. * @param index agent index returned by addAgent
  135422. */
  135423. removeAgent(index: number): void;
  135424. /**
  135425. * get the list of all agents attached to this crowd
  135426. * @returns list of agent indices
  135427. */
  135428. getAgents(): number[];
  135429. /**
  135430. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135431. * @param deltaTime in seconds
  135432. */
  135433. update(deltaTime: number): void;
  135434. /**
  135435. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135436. * The queries will try to find a solution within those bounds
  135437. * default is (1,1,1)
  135438. * @param extent x,y,z value that define the extent around the queries point of reference
  135439. */
  135440. setDefaultQueryExtent(extent: Vector3): void;
  135441. /**
  135442. * Get the Bounding box extent specified by setDefaultQueryExtent
  135443. * @returns the box extent values
  135444. */
  135445. getDefaultQueryExtent(): Vector3;
  135446. /**
  135447. * Release all resources
  135448. */
  135449. dispose(): void;
  135450. }
  135451. }
  135452. declare module BABYLON {
  135453. /**
  135454. * Class used to enable access to IndexedDB
  135455. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  135456. */
  135457. export class Database implements IOfflineProvider {
  135458. private _callbackManifestChecked;
  135459. private _currentSceneUrl;
  135460. private _db;
  135461. private _enableSceneOffline;
  135462. private _enableTexturesOffline;
  135463. private _manifestVersionFound;
  135464. private _mustUpdateRessources;
  135465. private _hasReachedQuota;
  135466. private _isSupported;
  135467. private _idbFactory;
  135468. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  135469. private static IsUASupportingBlobStorage;
  135470. /**
  135471. * Gets a boolean indicating if Database storate is enabled (off by default)
  135472. */
  135473. static IDBStorageEnabled: boolean;
  135474. /**
  135475. * Gets a boolean indicating if scene must be saved in the database
  135476. */
  135477. get enableSceneOffline(): boolean;
  135478. /**
  135479. * Gets a boolean indicating if textures must be saved in the database
  135480. */
  135481. get enableTexturesOffline(): boolean;
  135482. /**
  135483. * Creates a new Database
  135484. * @param urlToScene defines the url to load the scene
  135485. * @param callbackManifestChecked defines the callback to use when manifest is checked
  135486. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  135487. */
  135488. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  135489. private static _ParseURL;
  135490. private static _ReturnFullUrlLocation;
  135491. private _checkManifestFile;
  135492. /**
  135493. * Open the database and make it available
  135494. * @param successCallback defines the callback to call on success
  135495. * @param errorCallback defines the callback to call on error
  135496. */
  135497. open(successCallback: () => void, errorCallback: () => void): void;
  135498. /**
  135499. * Loads an image from the database
  135500. * @param url defines the url to load from
  135501. * @param image defines the target DOM image
  135502. */
  135503. loadImage(url: string, image: HTMLImageElement): void;
  135504. private _loadImageFromDBAsync;
  135505. private _saveImageIntoDBAsync;
  135506. private _checkVersionFromDB;
  135507. private _loadVersionFromDBAsync;
  135508. private _saveVersionIntoDBAsync;
  135509. /**
  135510. * Loads a file from database
  135511. * @param url defines the URL to load from
  135512. * @param sceneLoaded defines a callback to call on success
  135513. * @param progressCallBack defines a callback to call when progress changed
  135514. * @param errorCallback defines a callback to call on error
  135515. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  135516. */
  135517. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  135518. private _loadFileAsync;
  135519. private _saveFileAsync;
  135520. /**
  135521. * Validates if xhr data is correct
  135522. * @param xhr defines the request to validate
  135523. * @param dataType defines the expected data type
  135524. * @returns true if data is correct
  135525. */
  135526. private static _ValidateXHRData;
  135527. }
  135528. }
  135529. declare module BABYLON {
  135530. /** @hidden */
  135531. export var gpuUpdateParticlesPixelShader: {
  135532. name: string;
  135533. shader: string;
  135534. };
  135535. }
  135536. declare module BABYLON {
  135537. /** @hidden */
  135538. export var gpuUpdateParticlesVertexShader: {
  135539. name: string;
  135540. shader: string;
  135541. };
  135542. }
  135543. declare module BABYLON {
  135544. /** @hidden */
  135545. export var clipPlaneFragmentDeclaration2: {
  135546. name: string;
  135547. shader: string;
  135548. };
  135549. }
  135550. declare module BABYLON {
  135551. /** @hidden */
  135552. export var gpuRenderParticlesPixelShader: {
  135553. name: string;
  135554. shader: string;
  135555. };
  135556. }
  135557. declare module BABYLON {
  135558. /** @hidden */
  135559. export var clipPlaneVertexDeclaration2: {
  135560. name: string;
  135561. shader: string;
  135562. };
  135563. }
  135564. declare module BABYLON {
  135565. /** @hidden */
  135566. export var gpuRenderParticlesVertexShader: {
  135567. name: string;
  135568. shader: string;
  135569. };
  135570. }
  135571. declare module BABYLON {
  135572. /**
  135573. * This represents a GPU particle system in Babylon
  135574. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  135575. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  135576. */
  135577. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  135578. /**
  135579. * The layer mask we are rendering the particles through.
  135580. */
  135581. layerMask: number;
  135582. private _capacity;
  135583. private _activeCount;
  135584. private _currentActiveCount;
  135585. private _accumulatedCount;
  135586. private _renderEffect;
  135587. private _updateEffect;
  135588. private _buffer0;
  135589. private _buffer1;
  135590. private _spriteBuffer;
  135591. private _updateVAO;
  135592. private _renderVAO;
  135593. private _targetIndex;
  135594. private _sourceBuffer;
  135595. private _targetBuffer;
  135596. private _engine;
  135597. private _currentRenderId;
  135598. private _started;
  135599. private _stopped;
  135600. private _timeDelta;
  135601. private _randomTexture;
  135602. private _randomTexture2;
  135603. private _attributesStrideSize;
  135604. private _updateEffectOptions;
  135605. private _randomTextureSize;
  135606. private _actualFrame;
  135607. private readonly _rawTextureWidth;
  135608. /**
  135609. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  135610. */
  135611. static get IsSupported(): boolean;
  135612. /**
  135613. * An event triggered when the system is disposed.
  135614. */
  135615. onDisposeObservable: Observable<GPUParticleSystem>;
  135616. /**
  135617. * Gets the maximum number of particles active at the same time.
  135618. * @returns The max number of active particles.
  135619. */
  135620. getCapacity(): number;
  135621. /**
  135622. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  135623. * to override the particles.
  135624. */
  135625. forceDepthWrite: boolean;
  135626. /**
  135627. * Gets or set the number of active particles
  135628. */
  135629. get activeParticleCount(): number;
  135630. set activeParticleCount(value: number);
  135631. private _preWarmDone;
  135632. /**
  135633. * Is this system ready to be used/rendered
  135634. * @return true if the system is ready
  135635. */
  135636. isReady(): boolean;
  135637. /**
  135638. * Gets if the system has been started. (Note: this will still be true after stop is called)
  135639. * @returns True if it has been started, otherwise false.
  135640. */
  135641. isStarted(): boolean;
  135642. /**
  135643. * Starts the particle system and begins to emit
  135644. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  135645. */
  135646. start(delay?: number): void;
  135647. /**
  135648. * Stops the particle system.
  135649. */
  135650. stop(): void;
  135651. /**
  135652. * Remove all active particles
  135653. */
  135654. reset(): void;
  135655. /**
  135656. * Returns the string "GPUParticleSystem"
  135657. * @returns a string containing the class name
  135658. */
  135659. getClassName(): string;
  135660. private _colorGradientsTexture;
  135661. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  135662. /**
  135663. * Adds a new color gradient
  135664. * @param gradient defines the gradient to use (between 0 and 1)
  135665. * @param color1 defines the color to affect to the specified gradient
  135666. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  135667. * @returns the current particle system
  135668. */
  135669. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  135670. /**
  135671. * Remove a specific color gradient
  135672. * @param gradient defines the gradient to remove
  135673. * @returns the current particle system
  135674. */
  135675. removeColorGradient(gradient: number): GPUParticleSystem;
  135676. private _angularSpeedGradientsTexture;
  135677. private _sizeGradientsTexture;
  135678. private _velocityGradientsTexture;
  135679. private _limitVelocityGradientsTexture;
  135680. private _dragGradientsTexture;
  135681. private _addFactorGradient;
  135682. /**
  135683. * Adds a new size gradient
  135684. * @param gradient defines the gradient to use (between 0 and 1)
  135685. * @param factor defines the size factor to affect to the specified gradient
  135686. * @returns the current particle system
  135687. */
  135688. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  135689. /**
  135690. * Remove a specific size gradient
  135691. * @param gradient defines the gradient to remove
  135692. * @returns the current particle system
  135693. */
  135694. removeSizeGradient(gradient: number): GPUParticleSystem;
  135695. /**
  135696. * Adds a new angular speed gradient
  135697. * @param gradient defines the gradient to use (between 0 and 1)
  135698. * @param factor defines the angular speed to affect to the specified gradient
  135699. * @returns the current particle system
  135700. */
  135701. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  135702. /**
  135703. * Remove a specific angular speed gradient
  135704. * @param gradient defines the gradient to remove
  135705. * @returns the current particle system
  135706. */
  135707. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  135708. /**
  135709. * Adds a new velocity gradient
  135710. * @param gradient defines the gradient to use (between 0 and 1)
  135711. * @param factor defines the velocity to affect to the specified gradient
  135712. * @returns the current particle system
  135713. */
  135714. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135715. /**
  135716. * Remove a specific velocity gradient
  135717. * @param gradient defines the gradient to remove
  135718. * @returns the current particle system
  135719. */
  135720. removeVelocityGradient(gradient: number): GPUParticleSystem;
  135721. /**
  135722. * Adds a new limit velocity gradient
  135723. * @param gradient defines the gradient to use (between 0 and 1)
  135724. * @param factor defines the limit velocity value to affect to the specified gradient
  135725. * @returns the current particle system
  135726. */
  135727. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135728. /**
  135729. * Remove a specific limit velocity gradient
  135730. * @param gradient defines the gradient to remove
  135731. * @returns the current particle system
  135732. */
  135733. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  135734. /**
  135735. * Adds a new drag gradient
  135736. * @param gradient defines the gradient to use (between 0 and 1)
  135737. * @param factor defines the drag value to affect to the specified gradient
  135738. * @returns the current particle system
  135739. */
  135740. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  135741. /**
  135742. * Remove a specific drag gradient
  135743. * @param gradient defines the gradient to remove
  135744. * @returns the current particle system
  135745. */
  135746. removeDragGradient(gradient: number): GPUParticleSystem;
  135747. /**
  135748. * Not supported by GPUParticleSystem
  135749. * @param gradient defines the gradient to use (between 0 and 1)
  135750. * @param factor defines the emit rate value to affect to the specified gradient
  135751. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135752. * @returns the current particle system
  135753. */
  135754. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135755. /**
  135756. * Not supported by GPUParticleSystem
  135757. * @param gradient defines the gradient to remove
  135758. * @returns the current particle system
  135759. */
  135760. removeEmitRateGradient(gradient: number): IParticleSystem;
  135761. /**
  135762. * Not supported by GPUParticleSystem
  135763. * @param gradient defines the gradient to use (between 0 and 1)
  135764. * @param factor defines the start size value to affect to the specified gradient
  135765. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135766. * @returns the current particle system
  135767. */
  135768. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135769. /**
  135770. * Not supported by GPUParticleSystem
  135771. * @param gradient defines the gradient to remove
  135772. * @returns the current particle system
  135773. */
  135774. removeStartSizeGradient(gradient: number): IParticleSystem;
  135775. /**
  135776. * Not supported by GPUParticleSystem
  135777. * @param gradient defines the gradient to use (between 0 and 1)
  135778. * @param min defines the color remap minimal range
  135779. * @param max defines the color remap maximal range
  135780. * @returns the current particle system
  135781. */
  135782. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135783. /**
  135784. * Not supported by GPUParticleSystem
  135785. * @param gradient defines the gradient to remove
  135786. * @returns the current particle system
  135787. */
  135788. removeColorRemapGradient(): IParticleSystem;
  135789. /**
  135790. * Not supported by GPUParticleSystem
  135791. * @param gradient defines the gradient to use (between 0 and 1)
  135792. * @param min defines the alpha remap minimal range
  135793. * @param max defines the alpha remap maximal range
  135794. * @returns the current particle system
  135795. */
  135796. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135797. /**
  135798. * Not supported by GPUParticleSystem
  135799. * @param gradient defines the gradient to remove
  135800. * @returns the current particle system
  135801. */
  135802. removeAlphaRemapGradient(): IParticleSystem;
  135803. /**
  135804. * Not supported by GPUParticleSystem
  135805. * @param gradient defines the gradient to use (between 0 and 1)
  135806. * @param color defines the color to affect to the specified gradient
  135807. * @returns the current particle system
  135808. */
  135809. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  135810. /**
  135811. * Not supported by GPUParticleSystem
  135812. * @param gradient defines the gradient to remove
  135813. * @returns the current particle system
  135814. */
  135815. removeRampGradient(): IParticleSystem;
  135816. /**
  135817. * Not supported by GPUParticleSystem
  135818. * @returns the list of ramp gradients
  135819. */
  135820. getRampGradients(): Nullable<Array<Color3Gradient>>;
  135821. /**
  135822. * Not supported by GPUParticleSystem
  135823. * Gets or sets a boolean indicating that ramp gradients must be used
  135824. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  135825. */
  135826. get useRampGradients(): boolean;
  135827. set useRampGradients(value: boolean);
  135828. /**
  135829. * Not supported by GPUParticleSystem
  135830. * @param gradient defines the gradient to use (between 0 and 1)
  135831. * @param factor defines the life time factor to affect to the specified gradient
  135832. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135833. * @returns the current particle system
  135834. */
  135835. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135836. /**
  135837. * Not supported by GPUParticleSystem
  135838. * @param gradient defines the gradient to remove
  135839. * @returns the current particle system
  135840. */
  135841. removeLifeTimeGradient(gradient: number): IParticleSystem;
  135842. /**
  135843. * Instantiates a GPU particle system.
  135844. * 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.
  135845. * @param name The name of the particle system
  135846. * @param options The options used to create the system
  135847. * @param scene The scene the particle system belongs to
  135848. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  135849. */
  135850. constructor(name: string, options: Partial<{
  135851. capacity: number;
  135852. randomTextureSize: number;
  135853. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  135854. protected _reset(): void;
  135855. private _createUpdateVAO;
  135856. private _createRenderVAO;
  135857. private _initialize;
  135858. /** @hidden */
  135859. _recreateUpdateEffect(): void;
  135860. /** @hidden */
  135861. _recreateRenderEffect(): void;
  135862. /**
  135863. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  135864. * @param preWarm defines if we are in the pre-warmimg phase
  135865. */
  135866. animate(preWarm?: boolean): void;
  135867. private _createFactorGradientTexture;
  135868. private _createSizeGradientTexture;
  135869. private _createAngularSpeedGradientTexture;
  135870. private _createVelocityGradientTexture;
  135871. private _createLimitVelocityGradientTexture;
  135872. private _createDragGradientTexture;
  135873. private _createColorGradientTexture;
  135874. /**
  135875. * Renders the particle system in its current state
  135876. * @param preWarm defines if the system should only update the particles but not render them
  135877. * @returns the current number of particles
  135878. */
  135879. render(preWarm?: boolean): number;
  135880. /**
  135881. * Rebuilds the particle system
  135882. */
  135883. rebuild(): void;
  135884. private _releaseBuffers;
  135885. private _releaseVAOs;
  135886. /**
  135887. * Disposes the particle system and free the associated resources
  135888. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  135889. */
  135890. dispose(disposeTexture?: boolean): void;
  135891. /**
  135892. * Clones the particle system.
  135893. * @param name The name of the cloned object
  135894. * @param newEmitter The new emitter to use
  135895. * @returns the cloned particle system
  135896. */
  135897. clone(name: string, newEmitter: any): GPUParticleSystem;
  135898. /**
  135899. * Serializes the particle system to a JSON object.
  135900. * @returns the JSON object
  135901. */
  135902. serialize(): any;
  135903. /**
  135904. * Parses a JSON object to create a GPU particle system.
  135905. * @param parsedParticleSystem The JSON object to parse
  135906. * @param scene The scene to create the particle system in
  135907. * @param rootUrl The root url to use to load external dependencies like texture
  135908. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  135909. * @returns the parsed GPU particle system
  135910. */
  135911. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  135912. }
  135913. }
  135914. declare module BABYLON {
  135915. /**
  135916. * Represents a set of particle systems working together to create a specific effect
  135917. */
  135918. export class ParticleSystemSet implements IDisposable {
  135919. /**
  135920. * Gets or sets base Assets URL
  135921. */
  135922. static BaseAssetsUrl: string;
  135923. private _emitterCreationOptions;
  135924. private _emitterNode;
  135925. /**
  135926. * Gets the particle system list
  135927. */
  135928. systems: IParticleSystem[];
  135929. /**
  135930. * Gets the emitter node used with this set
  135931. */
  135932. get emitterNode(): Nullable<TransformNode>;
  135933. /**
  135934. * Creates a new emitter mesh as a sphere
  135935. * @param options defines the options used to create the sphere
  135936. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  135937. * @param scene defines the hosting scene
  135938. */
  135939. setEmitterAsSphere(options: {
  135940. diameter: number;
  135941. segments: number;
  135942. color: Color3;
  135943. }, renderingGroupId: number, scene: Scene): void;
  135944. /**
  135945. * Starts all particle systems of the set
  135946. * @param emitter defines an optional mesh to use as emitter for the particle systems
  135947. */
  135948. start(emitter?: AbstractMesh): void;
  135949. /**
  135950. * Release all associated resources
  135951. */
  135952. dispose(): void;
  135953. /**
  135954. * Serialize the set into a JSON compatible object
  135955. * @returns a JSON compatible representation of the set
  135956. */
  135957. serialize(): any;
  135958. /**
  135959. * Parse a new ParticleSystemSet from a serialized source
  135960. * @param data defines a JSON compatible representation of the set
  135961. * @param scene defines the hosting scene
  135962. * @param gpu defines if we want GPU particles or CPU particles
  135963. * @returns a new ParticleSystemSet
  135964. */
  135965. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  135966. }
  135967. }
  135968. declare module BABYLON {
  135969. /**
  135970. * This class is made for on one-liner static method to help creating particle system set.
  135971. */
  135972. export class ParticleHelper {
  135973. /**
  135974. * Gets or sets base Assets URL
  135975. */
  135976. static BaseAssetsUrl: string;
  135977. /**
  135978. * Create a default particle system that you can tweak
  135979. * @param emitter defines the emitter to use
  135980. * @param capacity defines the system capacity (default is 500 particles)
  135981. * @param scene defines the hosting scene
  135982. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  135983. * @returns the new Particle system
  135984. */
  135985. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  135986. /**
  135987. * This is the main static method (one-liner) of this helper to create different particle systems
  135988. * @param type This string represents the type to the particle system to create
  135989. * @param scene The scene where the particle system should live
  135990. * @param gpu If the system will use gpu
  135991. * @returns the ParticleSystemSet created
  135992. */
  135993. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  135994. /**
  135995. * Static function used to export a particle system to a ParticleSystemSet variable.
  135996. * Please note that the emitter shape is not exported
  135997. * @param systems defines the particle systems to export
  135998. * @returns the created particle system set
  135999. */
  136000. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  136001. }
  136002. }
  136003. declare module BABYLON {
  136004. interface Engine {
  136005. /**
  136006. * Create an effect to use with particle systems.
  136007. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  136008. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  136009. * @param uniformsNames defines a list of attribute names
  136010. * @param samplers defines an array of string used to represent textures
  136011. * @param defines defines the string containing the defines to use to compile the shaders
  136012. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  136013. * @param onCompiled defines a function to call when the effect creation is successful
  136014. * @param onError defines a function to call when the effect creation has failed
  136015. * @returns the new Effect
  136016. */
  136017. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  136018. }
  136019. interface Mesh {
  136020. /**
  136021. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  136022. * @returns an array of IParticleSystem
  136023. */
  136024. getEmittedParticleSystems(): IParticleSystem[];
  136025. /**
  136026. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  136027. * @returns an array of IParticleSystem
  136028. */
  136029. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  136030. }
  136031. /**
  136032. * @hidden
  136033. */
  136034. export var _IDoNeedToBeInTheBuild: number;
  136035. }
  136036. declare module BABYLON {
  136037. /** Defines the 4 color options */
  136038. export enum PointColor {
  136039. /** color value */
  136040. Color = 2,
  136041. /** uv value */
  136042. UV = 1,
  136043. /** random value */
  136044. Random = 0,
  136045. /** stated value */
  136046. Stated = 3
  136047. }
  136048. /**
  136049. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  136050. * 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.
  136051. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  136052. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  136053. *
  136054. * Full documentation here : TO BE ENTERED
  136055. */
  136056. export class PointsCloudSystem implements IDisposable {
  136057. /**
  136058. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  136059. * Example : var p = SPS.particles[i];
  136060. */
  136061. particles: CloudPoint[];
  136062. /**
  136063. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  136064. */
  136065. nbParticles: number;
  136066. /**
  136067. * This a counter for your own usage. It's not set by any SPS functions.
  136068. */
  136069. counter: number;
  136070. /**
  136071. * The PCS name. This name is also given to the underlying mesh.
  136072. */
  136073. name: string;
  136074. /**
  136075. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  136076. */
  136077. mesh: Mesh;
  136078. /**
  136079. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  136080. * Please read :
  136081. */
  136082. vars: any;
  136083. /**
  136084. * @hidden
  136085. */
  136086. _size: number;
  136087. private _scene;
  136088. private _promises;
  136089. private _positions;
  136090. private _indices;
  136091. private _normals;
  136092. private _colors;
  136093. private _uvs;
  136094. private _indices32;
  136095. private _positions32;
  136096. private _colors32;
  136097. private _uvs32;
  136098. private _updatable;
  136099. private _isVisibilityBoxLocked;
  136100. private _alwaysVisible;
  136101. private _groups;
  136102. private _groupCounter;
  136103. private _computeParticleColor;
  136104. private _computeParticleTexture;
  136105. private _computeParticleRotation;
  136106. private _computeBoundingBox;
  136107. private _isReady;
  136108. /**
  136109. * Creates a PCS (Points Cloud System) object
  136110. * @param name (String) is the PCS name, this will be the underlying mesh name
  136111. * @param pointSize (number) is the size for each point
  136112. * @param scene (Scene) is the scene in which the PCS is added
  136113. * @param options defines the options of the PCS e.g.
  136114. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  136115. */
  136116. constructor(name: string, pointSize: number, scene: Scene, options?: {
  136117. updatable?: boolean;
  136118. });
  136119. /**
  136120. * Builds the PCS underlying mesh. Returns a standard Mesh.
  136121. * If no points were added to the PCS, the returned mesh is just a single point.
  136122. * @returns a promise for the created mesh
  136123. */
  136124. buildMeshAsync(): Promise<Mesh>;
  136125. /**
  136126. * @hidden
  136127. */
  136128. private _buildMesh;
  136129. private _addParticle;
  136130. private _randomUnitVector;
  136131. private _getColorIndicesForCoord;
  136132. private _setPointsColorOrUV;
  136133. private _colorFromTexture;
  136134. private _calculateDensity;
  136135. /**
  136136. * Adds points to the PCS in random positions within a unit sphere
  136137. * @param nb (positive integer) the number of particles to be created from this model
  136138. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  136139. * @returns the number of groups in the system
  136140. */
  136141. addPoints(nb: number, pointFunction?: any): number;
  136142. /**
  136143. * Adds points to the PCS from the surface of the model shape
  136144. * @param mesh is any Mesh object that will be used as a surface model for the points
  136145. * @param nb (positive integer) the number of particles to be created from this model
  136146. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136147. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136148. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136149. * @returns the number of groups in the system
  136150. */
  136151. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136152. /**
  136153. * Adds points to the PCS inside the model shape
  136154. * @param mesh is any Mesh object that will be used as a surface model for the points
  136155. * @param nb (positive integer) the number of particles to be created from this model
  136156. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136157. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136158. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136159. * @returns the number of groups in the system
  136160. */
  136161. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136162. /**
  136163. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  136164. * This method calls `updateParticle()` for each particle of the SPS.
  136165. * For an animated SPS, it is usually called within the render loop.
  136166. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  136167. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  136168. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  136169. * @returns the PCS.
  136170. */
  136171. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  136172. /**
  136173. * Disposes the PCS.
  136174. */
  136175. dispose(): void;
  136176. /**
  136177. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  136178. * doc :
  136179. * @returns the PCS.
  136180. */
  136181. refreshVisibleSize(): PointsCloudSystem;
  136182. /**
  136183. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  136184. * @param size the size (float) of the visibility box
  136185. * note : this doesn't lock the PCS mesh bounding box.
  136186. * doc :
  136187. */
  136188. setVisibilityBox(size: number): void;
  136189. /**
  136190. * Gets whether the PCS is always visible or not
  136191. * doc :
  136192. */
  136193. get isAlwaysVisible(): boolean;
  136194. /**
  136195. * Sets the PCS as always visible or not
  136196. * doc :
  136197. */
  136198. set isAlwaysVisible(val: boolean);
  136199. /**
  136200. * Tells to `setParticles()` to compute the particle rotations or not
  136201. * Default value : false. The PCS is faster when it's set to false
  136202. * Note : particle rotations are only applied to parent particles
  136203. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  136204. */
  136205. set computeParticleRotation(val: boolean);
  136206. /**
  136207. * Tells to `setParticles()` to compute the particle colors or not.
  136208. * Default value : true. The PCS is faster when it's set to false.
  136209. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136210. */
  136211. set computeParticleColor(val: boolean);
  136212. set computeParticleTexture(val: boolean);
  136213. /**
  136214. * Gets if `setParticles()` computes the particle colors or not.
  136215. * Default value : false. The PCS is faster when it's set to false.
  136216. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136217. */
  136218. get computeParticleColor(): boolean;
  136219. /**
  136220. * Gets if `setParticles()` computes the particle textures or not.
  136221. * Default value : false. The PCS is faster when it's set to false.
  136222. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  136223. */
  136224. get computeParticleTexture(): boolean;
  136225. /**
  136226. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  136227. */
  136228. set computeBoundingBox(val: boolean);
  136229. /**
  136230. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  136231. */
  136232. get computeBoundingBox(): boolean;
  136233. /**
  136234. * This function does nothing. It may be overwritten to set all the particle first values.
  136235. * The PCS doesn't call this function, you may have to call it by your own.
  136236. * doc :
  136237. */
  136238. initParticles(): void;
  136239. /**
  136240. * This function does nothing. It may be overwritten to recycle a particle
  136241. * The PCS doesn't call this function, you can to call it
  136242. * doc :
  136243. * @param particle The particle to recycle
  136244. * @returns the recycled particle
  136245. */
  136246. recycleParticle(particle: CloudPoint): CloudPoint;
  136247. /**
  136248. * Updates a particle : this function should be overwritten by the user.
  136249. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  136250. * doc :
  136251. * @example : just set a particle position or velocity and recycle conditions
  136252. * @param particle The particle to update
  136253. * @returns the updated particle
  136254. */
  136255. updateParticle(particle: CloudPoint): CloudPoint;
  136256. /**
  136257. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  136258. * This does nothing and may be overwritten by the user.
  136259. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136260. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136261. * @param update the boolean update value actually passed to setParticles()
  136262. */
  136263. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136264. /**
  136265. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  136266. * This will be passed three parameters.
  136267. * This does nothing and may be overwritten by the user.
  136268. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136269. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136270. * @param update the boolean update value actually passed to setParticles()
  136271. */
  136272. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136273. }
  136274. }
  136275. declare module BABYLON {
  136276. /**
  136277. * Represents one particle of a points cloud system.
  136278. */
  136279. export class CloudPoint {
  136280. /**
  136281. * particle global index
  136282. */
  136283. idx: number;
  136284. /**
  136285. * The color of the particle
  136286. */
  136287. color: Nullable<Color4>;
  136288. /**
  136289. * The world space position of the particle.
  136290. */
  136291. position: Vector3;
  136292. /**
  136293. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  136294. */
  136295. rotation: Vector3;
  136296. /**
  136297. * The world space rotation quaternion of the particle.
  136298. */
  136299. rotationQuaternion: Nullable<Quaternion>;
  136300. /**
  136301. * The uv of the particle.
  136302. */
  136303. uv: Nullable<Vector2>;
  136304. /**
  136305. * The current speed of the particle.
  136306. */
  136307. velocity: Vector3;
  136308. /**
  136309. * The pivot point in the particle local space.
  136310. */
  136311. pivot: Vector3;
  136312. /**
  136313. * Must the particle be translated from its pivot point in its local space ?
  136314. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  136315. * Default : false
  136316. */
  136317. translateFromPivot: boolean;
  136318. /**
  136319. * Index of this particle in the global "positions" array (Internal use)
  136320. * @hidden
  136321. */
  136322. _pos: number;
  136323. /**
  136324. * @hidden Index of this particle in the global "indices" array (Internal use)
  136325. */
  136326. _ind: number;
  136327. /**
  136328. * Group this particle belongs to
  136329. */
  136330. _group: PointsGroup;
  136331. /**
  136332. * Group id of this particle
  136333. */
  136334. groupId: number;
  136335. /**
  136336. * Index of the particle in its group id (Internal use)
  136337. */
  136338. idxInGroup: number;
  136339. /**
  136340. * @hidden Particle BoundingInfo object (Internal use)
  136341. */
  136342. _boundingInfo: BoundingInfo;
  136343. /**
  136344. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  136345. */
  136346. _pcs: PointsCloudSystem;
  136347. /**
  136348. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  136349. */
  136350. _stillInvisible: boolean;
  136351. /**
  136352. * @hidden Last computed particle rotation matrix
  136353. */
  136354. _rotationMatrix: number[];
  136355. /**
  136356. * Parent particle Id, if any.
  136357. * Default null.
  136358. */
  136359. parentId: Nullable<number>;
  136360. /**
  136361. * @hidden Internal global position in the PCS.
  136362. */
  136363. _globalPosition: Vector3;
  136364. /**
  136365. * Creates a Point Cloud object.
  136366. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  136367. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  136368. * @param group (PointsGroup) is the group the particle belongs to
  136369. * @param groupId (integer) is the group identifier in the PCS.
  136370. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  136371. * @param pcs defines the PCS it is associated to
  136372. */
  136373. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  136374. /**
  136375. * get point size
  136376. */
  136377. get size(): Vector3;
  136378. /**
  136379. * Set point size
  136380. */
  136381. set size(scale: Vector3);
  136382. /**
  136383. * Legacy support, changed quaternion to rotationQuaternion
  136384. */
  136385. get quaternion(): Nullable<Quaternion>;
  136386. /**
  136387. * Legacy support, changed quaternion to rotationQuaternion
  136388. */
  136389. set quaternion(q: Nullable<Quaternion>);
  136390. /**
  136391. * Returns a boolean. True if the particle intersects a mesh, else false
  136392. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  136393. * @param target is the object (point or mesh) what the intersection is computed against
  136394. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  136395. * @returns true if it intersects
  136396. */
  136397. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  136398. /**
  136399. * get the rotation matrix of the particle
  136400. * @hidden
  136401. */
  136402. getRotationMatrix(m: Matrix): void;
  136403. }
  136404. /**
  136405. * Represents a group of points in a points cloud system
  136406. * * PCS internal tool, don't use it manually.
  136407. */
  136408. export class PointsGroup {
  136409. /**
  136410. * The group id
  136411. * @hidden
  136412. */
  136413. groupID: number;
  136414. /**
  136415. * image data for group (internal use)
  136416. * @hidden
  136417. */
  136418. _groupImageData: Nullable<ArrayBufferView>;
  136419. /**
  136420. * Image Width (internal use)
  136421. * @hidden
  136422. */
  136423. _groupImgWidth: number;
  136424. /**
  136425. * Image Height (internal use)
  136426. * @hidden
  136427. */
  136428. _groupImgHeight: number;
  136429. /**
  136430. * Custom position function (internal use)
  136431. * @hidden
  136432. */
  136433. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  136434. /**
  136435. * density per facet for surface points
  136436. * @hidden
  136437. */
  136438. _groupDensity: number[];
  136439. /**
  136440. * Only when points are colored by texture carries pointer to texture list array
  136441. * @hidden
  136442. */
  136443. _textureNb: number;
  136444. /**
  136445. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  136446. * PCS internal tool, don't use it manually.
  136447. * @hidden
  136448. */
  136449. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  136450. }
  136451. }
  136452. declare module BABYLON {
  136453. interface Scene {
  136454. /** @hidden (Backing field) */
  136455. _physicsEngine: Nullable<IPhysicsEngine>;
  136456. /** @hidden */
  136457. _physicsTimeAccumulator: number;
  136458. /**
  136459. * Gets the current physics engine
  136460. * @returns a IPhysicsEngine or null if none attached
  136461. */
  136462. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  136463. /**
  136464. * Enables physics to the current scene
  136465. * @param gravity defines the scene's gravity for the physics engine
  136466. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  136467. * @return a boolean indicating if the physics engine was initialized
  136468. */
  136469. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  136470. /**
  136471. * Disables and disposes the physics engine associated with the scene
  136472. */
  136473. disablePhysicsEngine(): void;
  136474. /**
  136475. * Gets a boolean indicating if there is an active physics engine
  136476. * @returns a boolean indicating if there is an active physics engine
  136477. */
  136478. isPhysicsEnabled(): boolean;
  136479. /**
  136480. * Deletes a physics compound impostor
  136481. * @param compound defines the compound to delete
  136482. */
  136483. deleteCompoundImpostor(compound: any): void;
  136484. /**
  136485. * An event triggered when physic simulation is about to be run
  136486. */
  136487. onBeforePhysicsObservable: Observable<Scene>;
  136488. /**
  136489. * An event triggered when physic simulation has been done
  136490. */
  136491. onAfterPhysicsObservable: Observable<Scene>;
  136492. }
  136493. interface AbstractMesh {
  136494. /** @hidden */
  136495. _physicsImpostor: Nullable<PhysicsImpostor>;
  136496. /**
  136497. * Gets or sets impostor used for physic simulation
  136498. * @see http://doc.babylonjs.com/features/physics_engine
  136499. */
  136500. physicsImpostor: Nullable<PhysicsImpostor>;
  136501. /**
  136502. * Gets the current physics impostor
  136503. * @see http://doc.babylonjs.com/features/physics_engine
  136504. * @returns a physics impostor or null
  136505. */
  136506. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  136507. /** Apply a physic impulse to the mesh
  136508. * @param force defines the force to apply
  136509. * @param contactPoint defines where to apply the force
  136510. * @returns the current mesh
  136511. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  136512. */
  136513. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  136514. /**
  136515. * Creates a physic joint between two meshes
  136516. * @param otherMesh defines the other mesh to use
  136517. * @param pivot1 defines the pivot to use on this mesh
  136518. * @param pivot2 defines the pivot to use on the other mesh
  136519. * @param options defines additional options (can be plugin dependent)
  136520. * @returns the current mesh
  136521. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  136522. */
  136523. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  136524. /** @hidden */
  136525. _disposePhysicsObserver: Nullable<Observer<Node>>;
  136526. }
  136527. /**
  136528. * Defines the physics engine scene component responsible to manage a physics engine
  136529. */
  136530. export class PhysicsEngineSceneComponent implements ISceneComponent {
  136531. /**
  136532. * The component name helpful to identify the component in the list of scene components.
  136533. */
  136534. readonly name: string;
  136535. /**
  136536. * The scene the component belongs to.
  136537. */
  136538. scene: Scene;
  136539. /**
  136540. * Creates a new instance of the component for the given scene
  136541. * @param scene Defines the scene to register the component in
  136542. */
  136543. constructor(scene: Scene);
  136544. /**
  136545. * Registers the component in a given scene
  136546. */
  136547. register(): void;
  136548. /**
  136549. * Rebuilds the elements related to this component in case of
  136550. * context lost for instance.
  136551. */
  136552. rebuild(): void;
  136553. /**
  136554. * Disposes the component and the associated ressources
  136555. */
  136556. dispose(): void;
  136557. }
  136558. }
  136559. declare module BABYLON {
  136560. /**
  136561. * A helper for physics simulations
  136562. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136563. */
  136564. export class PhysicsHelper {
  136565. private _scene;
  136566. private _physicsEngine;
  136567. /**
  136568. * Initializes the Physics helper
  136569. * @param scene Babylon.js scene
  136570. */
  136571. constructor(scene: Scene);
  136572. /**
  136573. * Applies a radial explosion impulse
  136574. * @param origin the origin of the explosion
  136575. * @param radiusOrEventOptions the radius or the options of radial explosion
  136576. * @param strength the explosion strength
  136577. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136578. * @returns A physics radial explosion event, or null
  136579. */
  136580. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136581. /**
  136582. * Applies a radial explosion force
  136583. * @param origin the origin of the explosion
  136584. * @param radiusOrEventOptions the radius or the options of radial explosion
  136585. * @param strength the explosion strength
  136586. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136587. * @returns A physics radial explosion event, or null
  136588. */
  136589. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136590. /**
  136591. * Creates a gravitational field
  136592. * @param origin the origin of the explosion
  136593. * @param radiusOrEventOptions the radius or the options of radial explosion
  136594. * @param strength the explosion strength
  136595. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136596. * @returns A physics gravitational field event, or null
  136597. */
  136598. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  136599. /**
  136600. * Creates a physics updraft event
  136601. * @param origin the origin of the updraft
  136602. * @param radiusOrEventOptions the radius or the options of the updraft
  136603. * @param strength the strength of the updraft
  136604. * @param height the height of the updraft
  136605. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  136606. * @returns A physics updraft event, or null
  136607. */
  136608. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  136609. /**
  136610. * Creates a physics vortex event
  136611. * @param origin the of the vortex
  136612. * @param radiusOrEventOptions the radius or the options of the vortex
  136613. * @param strength the strength of the vortex
  136614. * @param height the height of the vortex
  136615. * @returns a Physics vortex event, or null
  136616. * A physics vortex event or null
  136617. */
  136618. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  136619. }
  136620. /**
  136621. * Represents a physics radial explosion event
  136622. */
  136623. class PhysicsRadialExplosionEvent {
  136624. private _scene;
  136625. private _options;
  136626. private _sphere;
  136627. private _dataFetched;
  136628. /**
  136629. * Initializes a radial explosioin event
  136630. * @param _scene BabylonJS scene
  136631. * @param _options The options for the vortex event
  136632. */
  136633. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  136634. /**
  136635. * Returns the data related to the radial explosion event (sphere).
  136636. * @returns The radial explosion event data
  136637. */
  136638. getData(): PhysicsRadialExplosionEventData;
  136639. /**
  136640. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  136641. * @param impostor A physics imposter
  136642. * @param origin the origin of the explosion
  136643. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  136644. */
  136645. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  136646. /**
  136647. * Triggers affecterd impostors callbacks
  136648. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  136649. */
  136650. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  136651. /**
  136652. * Disposes the sphere.
  136653. * @param force Specifies if the sphere should be disposed by force
  136654. */
  136655. dispose(force?: boolean): void;
  136656. /*** Helpers ***/
  136657. private _prepareSphere;
  136658. private _intersectsWithSphere;
  136659. }
  136660. /**
  136661. * Represents a gravitational field event
  136662. */
  136663. class PhysicsGravitationalFieldEvent {
  136664. private _physicsHelper;
  136665. private _scene;
  136666. private _origin;
  136667. private _options;
  136668. private _tickCallback;
  136669. private _sphere;
  136670. private _dataFetched;
  136671. /**
  136672. * Initializes the physics gravitational field event
  136673. * @param _physicsHelper A physics helper
  136674. * @param _scene BabylonJS scene
  136675. * @param _origin The origin position of the gravitational field event
  136676. * @param _options The options for the vortex event
  136677. */
  136678. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  136679. /**
  136680. * Returns the data related to the gravitational field event (sphere).
  136681. * @returns A gravitational field event
  136682. */
  136683. getData(): PhysicsGravitationalFieldEventData;
  136684. /**
  136685. * Enables the gravitational field.
  136686. */
  136687. enable(): void;
  136688. /**
  136689. * Disables the gravitational field.
  136690. */
  136691. disable(): void;
  136692. /**
  136693. * Disposes the sphere.
  136694. * @param force The force to dispose from the gravitational field event
  136695. */
  136696. dispose(force?: boolean): void;
  136697. private _tick;
  136698. }
  136699. /**
  136700. * Represents a physics updraft event
  136701. */
  136702. class PhysicsUpdraftEvent {
  136703. private _scene;
  136704. private _origin;
  136705. private _options;
  136706. private _physicsEngine;
  136707. private _originTop;
  136708. private _originDirection;
  136709. private _tickCallback;
  136710. private _cylinder;
  136711. private _cylinderPosition;
  136712. private _dataFetched;
  136713. /**
  136714. * Initializes the physics updraft event
  136715. * @param _scene BabylonJS scene
  136716. * @param _origin The origin position of the updraft
  136717. * @param _options The options for the updraft event
  136718. */
  136719. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  136720. /**
  136721. * Returns the data related to the updraft event (cylinder).
  136722. * @returns A physics updraft event
  136723. */
  136724. getData(): PhysicsUpdraftEventData;
  136725. /**
  136726. * Enables the updraft.
  136727. */
  136728. enable(): void;
  136729. /**
  136730. * Disables the updraft.
  136731. */
  136732. disable(): void;
  136733. /**
  136734. * Disposes the cylinder.
  136735. * @param force Specifies if the updraft should be disposed by force
  136736. */
  136737. dispose(force?: boolean): void;
  136738. private getImpostorHitData;
  136739. private _tick;
  136740. /*** Helpers ***/
  136741. private _prepareCylinder;
  136742. private _intersectsWithCylinder;
  136743. }
  136744. /**
  136745. * Represents a physics vortex event
  136746. */
  136747. class PhysicsVortexEvent {
  136748. private _scene;
  136749. private _origin;
  136750. private _options;
  136751. private _physicsEngine;
  136752. private _originTop;
  136753. private _tickCallback;
  136754. private _cylinder;
  136755. private _cylinderPosition;
  136756. private _dataFetched;
  136757. /**
  136758. * Initializes the physics vortex event
  136759. * @param _scene The BabylonJS scene
  136760. * @param _origin The origin position of the vortex
  136761. * @param _options The options for the vortex event
  136762. */
  136763. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  136764. /**
  136765. * Returns the data related to the vortex event (cylinder).
  136766. * @returns The physics vortex event data
  136767. */
  136768. getData(): PhysicsVortexEventData;
  136769. /**
  136770. * Enables the vortex.
  136771. */
  136772. enable(): void;
  136773. /**
  136774. * Disables the cortex.
  136775. */
  136776. disable(): void;
  136777. /**
  136778. * Disposes the sphere.
  136779. * @param force
  136780. */
  136781. dispose(force?: boolean): void;
  136782. private getImpostorHitData;
  136783. private _tick;
  136784. /*** Helpers ***/
  136785. private _prepareCylinder;
  136786. private _intersectsWithCylinder;
  136787. }
  136788. /**
  136789. * Options fot the radial explosion event
  136790. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136791. */
  136792. export class PhysicsRadialExplosionEventOptions {
  136793. /**
  136794. * The radius of the sphere for the radial explosion.
  136795. */
  136796. radius: number;
  136797. /**
  136798. * The strenth of the explosion.
  136799. */
  136800. strength: number;
  136801. /**
  136802. * The strenght of the force in correspondence to the distance of the affected object
  136803. */
  136804. falloff: PhysicsRadialImpulseFalloff;
  136805. /**
  136806. * Sphere options for the radial explosion.
  136807. */
  136808. sphere: {
  136809. segments: number;
  136810. diameter: number;
  136811. };
  136812. /**
  136813. * Sphere options for the radial explosion.
  136814. */
  136815. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  136816. }
  136817. /**
  136818. * Options fot the updraft event
  136819. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136820. */
  136821. export class PhysicsUpdraftEventOptions {
  136822. /**
  136823. * The radius of the cylinder for the vortex
  136824. */
  136825. radius: number;
  136826. /**
  136827. * The strenth of the updraft.
  136828. */
  136829. strength: number;
  136830. /**
  136831. * The height of the cylinder for the updraft.
  136832. */
  136833. height: number;
  136834. /**
  136835. * The mode for the the updraft.
  136836. */
  136837. updraftMode: PhysicsUpdraftMode;
  136838. }
  136839. /**
  136840. * Options fot the vortex event
  136841. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136842. */
  136843. export class PhysicsVortexEventOptions {
  136844. /**
  136845. * The radius of the cylinder for the vortex
  136846. */
  136847. radius: number;
  136848. /**
  136849. * The strenth of the vortex.
  136850. */
  136851. strength: number;
  136852. /**
  136853. * The height of the cylinder for the vortex.
  136854. */
  136855. height: number;
  136856. /**
  136857. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  136858. */
  136859. centripetalForceThreshold: number;
  136860. /**
  136861. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  136862. */
  136863. centripetalForceMultiplier: number;
  136864. /**
  136865. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  136866. */
  136867. centrifugalForceMultiplier: number;
  136868. /**
  136869. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  136870. */
  136871. updraftForceMultiplier: number;
  136872. }
  136873. /**
  136874. * The strenght of the force in correspondence to the distance of the affected object
  136875. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136876. */
  136877. export enum PhysicsRadialImpulseFalloff {
  136878. /** Defines that impulse is constant in strength across it's whole radius */
  136879. Constant = 0,
  136880. /** Defines that impulse gets weaker if it's further from the origin */
  136881. Linear = 1
  136882. }
  136883. /**
  136884. * The strength of the force in correspondence to the distance of the affected object
  136885. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136886. */
  136887. export enum PhysicsUpdraftMode {
  136888. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  136889. Center = 0,
  136890. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  136891. Perpendicular = 1
  136892. }
  136893. /**
  136894. * Interface for a physics hit data
  136895. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136896. */
  136897. export interface PhysicsHitData {
  136898. /**
  136899. * The force applied at the contact point
  136900. */
  136901. force: Vector3;
  136902. /**
  136903. * The contact point
  136904. */
  136905. contactPoint: Vector3;
  136906. /**
  136907. * The distance from the origin to the contact point
  136908. */
  136909. distanceFromOrigin: number;
  136910. }
  136911. /**
  136912. * Interface for radial explosion event data
  136913. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136914. */
  136915. export interface PhysicsRadialExplosionEventData {
  136916. /**
  136917. * A sphere used for the radial explosion event
  136918. */
  136919. sphere: Mesh;
  136920. }
  136921. /**
  136922. * Interface for gravitational field event data
  136923. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136924. */
  136925. export interface PhysicsGravitationalFieldEventData {
  136926. /**
  136927. * A sphere mesh used for the gravitational field event
  136928. */
  136929. sphere: Mesh;
  136930. }
  136931. /**
  136932. * Interface for updraft event data
  136933. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136934. */
  136935. export interface PhysicsUpdraftEventData {
  136936. /**
  136937. * A cylinder used for the updraft event
  136938. */
  136939. cylinder: Mesh;
  136940. }
  136941. /**
  136942. * Interface for vortex event data
  136943. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136944. */
  136945. export interface PhysicsVortexEventData {
  136946. /**
  136947. * A cylinder used for the vortex event
  136948. */
  136949. cylinder: Mesh;
  136950. }
  136951. /**
  136952. * Interface for an affected physics impostor
  136953. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136954. */
  136955. export interface PhysicsAffectedImpostorWithData {
  136956. /**
  136957. * The impostor affected by the effect
  136958. */
  136959. impostor: PhysicsImpostor;
  136960. /**
  136961. * The data about the hit/horce from the explosion
  136962. */
  136963. hitData: PhysicsHitData;
  136964. }
  136965. }
  136966. declare module BABYLON {
  136967. /** @hidden */
  136968. export var blackAndWhitePixelShader: {
  136969. name: string;
  136970. shader: string;
  136971. };
  136972. }
  136973. declare module BABYLON {
  136974. /**
  136975. * Post process used to render in black and white
  136976. */
  136977. export class BlackAndWhitePostProcess extends PostProcess {
  136978. /**
  136979. * Linear about to convert he result to black and white (default: 1)
  136980. */
  136981. degree: number;
  136982. /**
  136983. * Creates a black and white post process
  136984. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  136985. * @param name The name of the effect.
  136986. * @param options The required width/height ratio to downsize to before computing the render pass.
  136987. * @param camera The camera to apply the render pass to.
  136988. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  136989. * @param engine The engine which the post process will be applied. (default: current engine)
  136990. * @param reusable If the post process can be reused on the same frame. (default: false)
  136991. */
  136992. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  136993. }
  136994. }
  136995. declare module BABYLON {
  136996. /**
  136997. * This represents a set of one or more post processes in Babylon.
  136998. * A post process can be used to apply a shader to a texture after it is rendered.
  136999. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137000. */
  137001. export class PostProcessRenderEffect {
  137002. private _postProcesses;
  137003. private _getPostProcesses;
  137004. private _singleInstance;
  137005. private _cameras;
  137006. private _indicesForCamera;
  137007. /**
  137008. * Name of the effect
  137009. * @hidden
  137010. */
  137011. _name: string;
  137012. /**
  137013. * Instantiates a post process render effect.
  137014. * A post process can be used to apply a shader to a texture after it is rendered.
  137015. * @param engine The engine the effect is tied to
  137016. * @param name The name of the effect
  137017. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  137018. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  137019. */
  137020. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  137021. /**
  137022. * Checks if all the post processes in the effect are supported.
  137023. */
  137024. get isSupported(): boolean;
  137025. /**
  137026. * Updates the current state of the effect
  137027. * @hidden
  137028. */
  137029. _update(): void;
  137030. /**
  137031. * Attaches the effect on cameras
  137032. * @param cameras The camera to attach to.
  137033. * @hidden
  137034. */
  137035. _attachCameras(cameras: Camera): void;
  137036. /**
  137037. * Attaches the effect on cameras
  137038. * @param cameras The camera to attach to.
  137039. * @hidden
  137040. */
  137041. _attachCameras(cameras: Camera[]): void;
  137042. /**
  137043. * Detaches the effect on cameras
  137044. * @param cameras The camera to detatch from.
  137045. * @hidden
  137046. */
  137047. _detachCameras(cameras: Camera): void;
  137048. /**
  137049. * Detatches the effect on cameras
  137050. * @param cameras The camera to detatch from.
  137051. * @hidden
  137052. */
  137053. _detachCameras(cameras: Camera[]): void;
  137054. /**
  137055. * Enables the effect on given cameras
  137056. * @param cameras The camera to enable.
  137057. * @hidden
  137058. */
  137059. _enable(cameras: Camera): void;
  137060. /**
  137061. * Enables the effect on given cameras
  137062. * @param cameras The camera to enable.
  137063. * @hidden
  137064. */
  137065. _enable(cameras: Nullable<Camera[]>): void;
  137066. /**
  137067. * Disables the effect on the given cameras
  137068. * @param cameras The camera to disable.
  137069. * @hidden
  137070. */
  137071. _disable(cameras: Camera): void;
  137072. /**
  137073. * Disables the effect on the given cameras
  137074. * @param cameras The camera to disable.
  137075. * @hidden
  137076. */
  137077. _disable(cameras: Nullable<Camera[]>): void;
  137078. /**
  137079. * Gets a list of the post processes contained in the effect.
  137080. * @param camera The camera to get the post processes on.
  137081. * @returns The list of the post processes in the effect.
  137082. */
  137083. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  137084. }
  137085. }
  137086. declare module BABYLON {
  137087. /** @hidden */
  137088. export var extractHighlightsPixelShader: {
  137089. name: string;
  137090. shader: string;
  137091. };
  137092. }
  137093. declare module BABYLON {
  137094. /**
  137095. * 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.
  137096. */
  137097. export class ExtractHighlightsPostProcess extends PostProcess {
  137098. /**
  137099. * The luminance threshold, pixels below this value will be set to black.
  137100. */
  137101. threshold: number;
  137102. /** @hidden */
  137103. _exposure: number;
  137104. /**
  137105. * Post process which has the input texture to be used when performing highlight extraction
  137106. * @hidden
  137107. */
  137108. _inputPostProcess: Nullable<PostProcess>;
  137109. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137110. }
  137111. }
  137112. declare module BABYLON {
  137113. /** @hidden */
  137114. export var bloomMergePixelShader: {
  137115. name: string;
  137116. shader: string;
  137117. };
  137118. }
  137119. declare module BABYLON {
  137120. /**
  137121. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137122. */
  137123. export class BloomMergePostProcess extends PostProcess {
  137124. /** Weight of the bloom to be added to the original input. */
  137125. weight: number;
  137126. /**
  137127. * Creates a new instance of @see BloomMergePostProcess
  137128. * @param name The name of the effect.
  137129. * @param originalFromInput Post process which's input will be used for the merge.
  137130. * @param blurred Blurred highlights post process which's output will be used.
  137131. * @param weight Weight of the bloom to be added to the original input.
  137132. * @param options The required width/height ratio to downsize to before computing the render pass.
  137133. * @param camera The camera to apply the render pass to.
  137134. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137135. * @param engine The engine which the post process will be applied. (default: current engine)
  137136. * @param reusable If the post process can be reused on the same frame. (default: false)
  137137. * @param textureType Type of textures used when performing the post process. (default: 0)
  137138. * @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)
  137139. */
  137140. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  137141. /** Weight of the bloom to be added to the original input. */
  137142. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137143. }
  137144. }
  137145. declare module BABYLON {
  137146. /**
  137147. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  137148. */
  137149. export class BloomEffect extends PostProcessRenderEffect {
  137150. private bloomScale;
  137151. /**
  137152. * @hidden Internal
  137153. */
  137154. _effects: Array<PostProcess>;
  137155. /**
  137156. * @hidden Internal
  137157. */
  137158. _downscale: ExtractHighlightsPostProcess;
  137159. private _blurX;
  137160. private _blurY;
  137161. private _merge;
  137162. /**
  137163. * The luminance threshold to find bright areas of the image to bloom.
  137164. */
  137165. get threshold(): number;
  137166. set threshold(value: number);
  137167. /**
  137168. * The strength of the bloom.
  137169. */
  137170. get weight(): number;
  137171. set weight(value: number);
  137172. /**
  137173. * Specifies the size of the bloom blur kernel, relative to the final output size
  137174. */
  137175. get kernel(): number;
  137176. set kernel(value: number);
  137177. /**
  137178. * Creates a new instance of @see BloomEffect
  137179. * @param scene The scene the effect belongs to.
  137180. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  137181. * @param bloomKernel The size of the kernel to be used when applying the blur.
  137182. * @param bloomWeight The the strength of bloom.
  137183. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137184. * @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)
  137185. */
  137186. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  137187. /**
  137188. * Disposes each of the internal effects for a given camera.
  137189. * @param camera The camera to dispose the effect on.
  137190. */
  137191. disposeEffects(camera: Camera): void;
  137192. /**
  137193. * @hidden Internal
  137194. */
  137195. _updateEffects(): void;
  137196. /**
  137197. * Internal
  137198. * @returns if all the contained post processes are ready.
  137199. * @hidden
  137200. */
  137201. _isReady(): boolean;
  137202. }
  137203. }
  137204. declare module BABYLON {
  137205. /** @hidden */
  137206. export var chromaticAberrationPixelShader: {
  137207. name: string;
  137208. shader: string;
  137209. };
  137210. }
  137211. declare module BABYLON {
  137212. /**
  137213. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  137214. */
  137215. export class ChromaticAberrationPostProcess extends PostProcess {
  137216. /**
  137217. * The amount of seperation of rgb channels (default: 30)
  137218. */
  137219. aberrationAmount: number;
  137220. /**
  137221. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  137222. */
  137223. radialIntensity: number;
  137224. /**
  137225. * 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))
  137226. */
  137227. direction: Vector2;
  137228. /**
  137229. * 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))
  137230. */
  137231. centerPosition: Vector2;
  137232. /**
  137233. * Creates a new instance ChromaticAberrationPostProcess
  137234. * @param name The name of the effect.
  137235. * @param screenWidth The width of the screen to apply the effect on.
  137236. * @param screenHeight The height of the screen to apply the effect on.
  137237. * @param options The required width/height ratio to downsize to before computing the render pass.
  137238. * @param camera The camera to apply the render pass to.
  137239. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137240. * @param engine The engine which the post process will be applied. (default: current engine)
  137241. * @param reusable If the post process can be reused on the same frame. (default: false)
  137242. * @param textureType Type of textures used when performing the post process. (default: 0)
  137243. * @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)
  137244. */
  137245. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137246. }
  137247. }
  137248. declare module BABYLON {
  137249. /** @hidden */
  137250. export var circleOfConfusionPixelShader: {
  137251. name: string;
  137252. shader: string;
  137253. };
  137254. }
  137255. declare module BABYLON {
  137256. /**
  137257. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  137258. */
  137259. export class CircleOfConfusionPostProcess extends PostProcess {
  137260. /**
  137261. * 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.
  137262. */
  137263. lensSize: number;
  137264. /**
  137265. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137266. */
  137267. fStop: number;
  137268. /**
  137269. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137270. */
  137271. focusDistance: number;
  137272. /**
  137273. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  137274. */
  137275. focalLength: number;
  137276. private _depthTexture;
  137277. /**
  137278. * Creates a new instance CircleOfConfusionPostProcess
  137279. * @param name The name of the effect.
  137280. * @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.
  137281. * @param options The required width/height ratio to downsize to before computing the render pass.
  137282. * @param camera The camera to apply the render pass to.
  137283. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137284. * @param engine The engine which the post process will be applied. (default: current engine)
  137285. * @param reusable If the post process can be reused on the same frame. (default: false)
  137286. * @param textureType Type of textures used when performing the post process. (default: 0)
  137287. * @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)
  137288. */
  137289. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137290. /**
  137291. * 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.
  137292. */
  137293. set depthTexture(value: RenderTargetTexture);
  137294. }
  137295. }
  137296. declare module BABYLON {
  137297. /** @hidden */
  137298. export var colorCorrectionPixelShader: {
  137299. name: string;
  137300. shader: string;
  137301. };
  137302. }
  137303. declare module BABYLON {
  137304. /**
  137305. *
  137306. * This post-process allows the modification of rendered colors by using
  137307. * a 'look-up table' (LUT). This effect is also called Color Grading.
  137308. *
  137309. * The object needs to be provided an url to a texture containing the color
  137310. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  137311. * Use an image editing software to tweak the LUT to match your needs.
  137312. *
  137313. * For an example of a color LUT, see here:
  137314. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  137315. * For explanations on color grading, see here:
  137316. * @see http://udn.epicgames.com/Three/ColorGrading.html
  137317. *
  137318. */
  137319. export class ColorCorrectionPostProcess extends PostProcess {
  137320. private _colorTableTexture;
  137321. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137322. }
  137323. }
  137324. declare module BABYLON {
  137325. /** @hidden */
  137326. export var convolutionPixelShader: {
  137327. name: string;
  137328. shader: string;
  137329. };
  137330. }
  137331. declare module BABYLON {
  137332. /**
  137333. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  137334. * input texture to perform effects such as edge detection or sharpening
  137335. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137336. */
  137337. export class ConvolutionPostProcess extends PostProcess {
  137338. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137339. kernel: number[];
  137340. /**
  137341. * Creates a new instance ConvolutionPostProcess
  137342. * @param name The name of the effect.
  137343. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  137344. * @param options The required width/height ratio to downsize to before computing the render pass.
  137345. * @param camera The camera to apply the render pass to.
  137346. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137347. * @param engine The engine which the post process will be applied. (default: current engine)
  137348. * @param reusable If the post process can be reused on the same frame. (default: false)
  137349. * @param textureType Type of textures used when performing the post process. (default: 0)
  137350. */
  137351. constructor(name: string,
  137352. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137353. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137354. /**
  137355. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137356. */
  137357. static EdgeDetect0Kernel: number[];
  137358. /**
  137359. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137360. */
  137361. static EdgeDetect1Kernel: number[];
  137362. /**
  137363. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137364. */
  137365. static EdgeDetect2Kernel: number[];
  137366. /**
  137367. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137368. */
  137369. static SharpenKernel: number[];
  137370. /**
  137371. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137372. */
  137373. static EmbossKernel: number[];
  137374. /**
  137375. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137376. */
  137377. static GaussianKernel: number[];
  137378. }
  137379. }
  137380. declare module BABYLON {
  137381. /**
  137382. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  137383. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  137384. * based on samples that have a large difference in distance than the center pixel.
  137385. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  137386. */
  137387. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  137388. direction: Vector2;
  137389. /**
  137390. * Creates a new instance CircleOfConfusionPostProcess
  137391. * @param name The name of the effect.
  137392. * @param scene The scene the effect belongs to.
  137393. * @param direction The direction the blur should be applied.
  137394. * @param kernel The size of the kernel used to blur.
  137395. * @param options The required width/height ratio to downsize to before computing the render pass.
  137396. * @param camera The camera to apply the render pass to.
  137397. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  137398. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  137399. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137400. * @param engine The engine which the post process will be applied. (default: current engine)
  137401. * @param reusable If the post process can be reused on the same frame. (default: false)
  137402. * @param textureType Type of textures used when performing the post process. (default: 0)
  137403. * @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)
  137404. */
  137405. 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);
  137406. }
  137407. }
  137408. declare module BABYLON {
  137409. /** @hidden */
  137410. export var depthOfFieldMergePixelShader: {
  137411. name: string;
  137412. shader: string;
  137413. };
  137414. }
  137415. declare module BABYLON {
  137416. /**
  137417. * Options to be set when merging outputs from the default pipeline.
  137418. */
  137419. export class DepthOfFieldMergePostProcessOptions {
  137420. /**
  137421. * The original image to merge on top of
  137422. */
  137423. originalFromInput: PostProcess;
  137424. /**
  137425. * Parameters to perform the merge of the depth of field effect
  137426. */
  137427. depthOfField?: {
  137428. circleOfConfusion: PostProcess;
  137429. blurSteps: Array<PostProcess>;
  137430. };
  137431. /**
  137432. * Parameters to perform the merge of bloom effect
  137433. */
  137434. bloom?: {
  137435. blurred: PostProcess;
  137436. weight: number;
  137437. };
  137438. }
  137439. /**
  137440. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137441. */
  137442. export class DepthOfFieldMergePostProcess extends PostProcess {
  137443. private blurSteps;
  137444. /**
  137445. * Creates a new instance of DepthOfFieldMergePostProcess
  137446. * @param name The name of the effect.
  137447. * @param originalFromInput Post process which's input will be used for the merge.
  137448. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  137449. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  137450. * @param options The required width/height ratio to downsize to before computing the render pass.
  137451. * @param camera The camera to apply the render pass to.
  137452. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137453. * @param engine The engine which the post process will be applied. (default: current engine)
  137454. * @param reusable If the post process can be reused on the same frame. (default: false)
  137455. * @param textureType Type of textures used when performing the post process. (default: 0)
  137456. * @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)
  137457. */
  137458. 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);
  137459. /**
  137460. * Updates the effect with the current post process compile time values and recompiles the shader.
  137461. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  137462. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  137463. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  137464. * @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
  137465. * @param onCompiled Called when the shader has been compiled.
  137466. * @param onError Called if there is an error when compiling a shader.
  137467. */
  137468. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  137469. }
  137470. }
  137471. declare module BABYLON {
  137472. /**
  137473. * Specifies the level of max blur that should be applied when using the depth of field effect
  137474. */
  137475. export enum DepthOfFieldEffectBlurLevel {
  137476. /**
  137477. * Subtle blur
  137478. */
  137479. Low = 0,
  137480. /**
  137481. * Medium blur
  137482. */
  137483. Medium = 1,
  137484. /**
  137485. * Large blur
  137486. */
  137487. High = 2
  137488. }
  137489. /**
  137490. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  137491. */
  137492. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  137493. private _circleOfConfusion;
  137494. /**
  137495. * @hidden Internal, blurs from high to low
  137496. */
  137497. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  137498. private _depthOfFieldBlurY;
  137499. private _dofMerge;
  137500. /**
  137501. * @hidden Internal post processes in depth of field effect
  137502. */
  137503. _effects: Array<PostProcess>;
  137504. /**
  137505. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  137506. */
  137507. set focalLength(value: number);
  137508. get focalLength(): number;
  137509. /**
  137510. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137511. */
  137512. set fStop(value: number);
  137513. get fStop(): number;
  137514. /**
  137515. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137516. */
  137517. set focusDistance(value: number);
  137518. get focusDistance(): number;
  137519. /**
  137520. * 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.
  137521. */
  137522. set lensSize(value: number);
  137523. get lensSize(): number;
  137524. /**
  137525. * Creates a new instance DepthOfFieldEffect
  137526. * @param scene The scene the effect belongs to.
  137527. * @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.
  137528. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137529. * @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)
  137530. */
  137531. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  137532. /**
  137533. * Get the current class name of the current effet
  137534. * @returns "DepthOfFieldEffect"
  137535. */
  137536. getClassName(): string;
  137537. /**
  137538. * 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.
  137539. */
  137540. set depthTexture(value: RenderTargetTexture);
  137541. /**
  137542. * Disposes each of the internal effects for a given camera.
  137543. * @param camera The camera to dispose the effect on.
  137544. */
  137545. disposeEffects(camera: Camera): void;
  137546. /**
  137547. * @hidden Internal
  137548. */
  137549. _updateEffects(): void;
  137550. /**
  137551. * Internal
  137552. * @returns if all the contained post processes are ready.
  137553. * @hidden
  137554. */
  137555. _isReady(): boolean;
  137556. }
  137557. }
  137558. declare module BABYLON {
  137559. /** @hidden */
  137560. export var displayPassPixelShader: {
  137561. name: string;
  137562. shader: string;
  137563. };
  137564. }
  137565. declare module BABYLON {
  137566. /**
  137567. * DisplayPassPostProcess which produces an output the same as it's input
  137568. */
  137569. export class DisplayPassPostProcess extends PostProcess {
  137570. /**
  137571. * Creates the DisplayPassPostProcess
  137572. * @param name The name of the effect.
  137573. * @param options The required width/height ratio to downsize to before computing the render pass.
  137574. * @param camera The camera to apply the render pass to.
  137575. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137576. * @param engine The engine which the post process will be applied. (default: current engine)
  137577. * @param reusable If the post process can be reused on the same frame. (default: false)
  137578. */
  137579. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137580. }
  137581. }
  137582. declare module BABYLON {
  137583. /** @hidden */
  137584. export var filterPixelShader: {
  137585. name: string;
  137586. shader: string;
  137587. };
  137588. }
  137589. declare module BABYLON {
  137590. /**
  137591. * Applies a kernel filter to the image
  137592. */
  137593. export class FilterPostProcess extends PostProcess {
  137594. /** The matrix to be applied to the image */
  137595. kernelMatrix: Matrix;
  137596. /**
  137597. *
  137598. * @param name The name of the effect.
  137599. * @param kernelMatrix The matrix to be applied to the image
  137600. * @param options The required width/height ratio to downsize to before computing the render pass.
  137601. * @param camera The camera to apply the render pass to.
  137602. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137603. * @param engine The engine which the post process will be applied. (default: current engine)
  137604. * @param reusable If the post process can be reused on the same frame. (default: false)
  137605. */
  137606. constructor(name: string,
  137607. /** The matrix to be applied to the image */
  137608. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137609. }
  137610. }
  137611. declare module BABYLON {
  137612. /** @hidden */
  137613. export var fxaaPixelShader: {
  137614. name: string;
  137615. shader: string;
  137616. };
  137617. }
  137618. declare module BABYLON {
  137619. /** @hidden */
  137620. export var fxaaVertexShader: {
  137621. name: string;
  137622. shader: string;
  137623. };
  137624. }
  137625. declare module BABYLON {
  137626. /**
  137627. * Fxaa post process
  137628. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  137629. */
  137630. export class FxaaPostProcess extends PostProcess {
  137631. /** @hidden */
  137632. texelWidth: number;
  137633. /** @hidden */
  137634. texelHeight: number;
  137635. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137636. private _getDefines;
  137637. }
  137638. }
  137639. declare module BABYLON {
  137640. /** @hidden */
  137641. export var grainPixelShader: {
  137642. name: string;
  137643. shader: string;
  137644. };
  137645. }
  137646. declare module BABYLON {
  137647. /**
  137648. * The GrainPostProcess adds noise to the image at mid luminance levels
  137649. */
  137650. export class GrainPostProcess extends PostProcess {
  137651. /**
  137652. * The intensity of the grain added (default: 30)
  137653. */
  137654. intensity: number;
  137655. /**
  137656. * If the grain should be randomized on every frame
  137657. */
  137658. animated: boolean;
  137659. /**
  137660. * Creates a new instance of @see GrainPostProcess
  137661. * @param name The name of the effect.
  137662. * @param options The required width/height ratio to downsize to before computing the render pass.
  137663. * @param camera The camera to apply the render pass to.
  137664. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137665. * @param engine The engine which the post process will be applied. (default: current engine)
  137666. * @param reusable If the post process can be reused on the same frame. (default: false)
  137667. * @param textureType Type of textures used when performing the post process. (default: 0)
  137668. * @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)
  137669. */
  137670. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137671. }
  137672. }
  137673. declare module BABYLON {
  137674. /** @hidden */
  137675. export var highlightsPixelShader: {
  137676. name: string;
  137677. shader: string;
  137678. };
  137679. }
  137680. declare module BABYLON {
  137681. /**
  137682. * Extracts highlights from the image
  137683. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137684. */
  137685. export class HighlightsPostProcess extends PostProcess {
  137686. /**
  137687. * Extracts highlights from the image
  137688. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137689. * @param name The name of the effect.
  137690. * @param options The required width/height ratio to downsize to before computing the render pass.
  137691. * @param camera The camera to apply the render pass to.
  137692. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137693. * @param engine The engine which the post process will be applied. (default: current engine)
  137694. * @param reusable If the post process can be reused on the same frame. (default: false)
  137695. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  137696. */
  137697. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137698. }
  137699. }
  137700. declare module BABYLON {
  137701. /** @hidden */
  137702. export var mrtFragmentDeclaration: {
  137703. name: string;
  137704. shader: string;
  137705. };
  137706. }
  137707. declare module BABYLON {
  137708. /** @hidden */
  137709. export var geometryPixelShader: {
  137710. name: string;
  137711. shader: string;
  137712. };
  137713. }
  137714. declare module BABYLON {
  137715. /** @hidden */
  137716. export var geometryVertexShader: {
  137717. name: string;
  137718. shader: string;
  137719. };
  137720. }
  137721. declare module BABYLON {
  137722. /** @hidden */
  137723. interface ISavedTransformationMatrix {
  137724. world: Matrix;
  137725. viewProjection: Matrix;
  137726. }
  137727. /**
  137728. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  137729. */
  137730. export class GeometryBufferRenderer {
  137731. /**
  137732. * Constant used to retrieve the position texture index in the G-Buffer textures array
  137733. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  137734. */
  137735. static readonly POSITION_TEXTURE_TYPE: number;
  137736. /**
  137737. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  137738. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  137739. */
  137740. static readonly VELOCITY_TEXTURE_TYPE: number;
  137741. /**
  137742. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  137743. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  137744. */
  137745. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  137746. /**
  137747. * Dictionary used to store the previous transformation matrices of each rendered mesh
  137748. * in order to compute objects velocities when enableVelocity is set to "true"
  137749. * @hidden
  137750. */
  137751. _previousTransformationMatrices: {
  137752. [index: number]: ISavedTransformationMatrix;
  137753. };
  137754. /**
  137755. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  137756. * in order to compute objects velocities when enableVelocity is set to "true"
  137757. * @hidden
  137758. */
  137759. _previousBonesTransformationMatrices: {
  137760. [index: number]: Float32Array;
  137761. };
  137762. /**
  137763. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  137764. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  137765. */
  137766. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  137767. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  137768. renderTransparentMeshes: boolean;
  137769. private _scene;
  137770. private _multiRenderTarget;
  137771. private _ratio;
  137772. private _enablePosition;
  137773. private _enableVelocity;
  137774. private _enableReflectivity;
  137775. private _positionIndex;
  137776. private _velocityIndex;
  137777. private _reflectivityIndex;
  137778. protected _effect: Effect;
  137779. protected _cachedDefines: string;
  137780. /**
  137781. * Set the render list (meshes to be rendered) used in the G buffer.
  137782. */
  137783. set renderList(meshes: Mesh[]);
  137784. /**
  137785. * Gets wether or not G buffer are supported by the running hardware.
  137786. * This requires draw buffer supports
  137787. */
  137788. get isSupported(): boolean;
  137789. /**
  137790. * Returns the index of the given texture type in the G-Buffer textures array
  137791. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  137792. * @returns the index of the given texture type in the G-Buffer textures array
  137793. */
  137794. getTextureIndex(textureType: number): number;
  137795. /**
  137796. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  137797. */
  137798. get enablePosition(): boolean;
  137799. /**
  137800. * Sets whether or not objects positions are enabled for the G buffer.
  137801. */
  137802. set enablePosition(enable: boolean);
  137803. /**
  137804. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  137805. */
  137806. get enableVelocity(): boolean;
  137807. /**
  137808. * Sets wether or not objects velocities are enabled for the G buffer.
  137809. */
  137810. set enableVelocity(enable: boolean);
  137811. /**
  137812. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  137813. */
  137814. get enableReflectivity(): boolean;
  137815. /**
  137816. * Sets wether or not objects roughness are enabled for the G buffer.
  137817. */
  137818. set enableReflectivity(enable: boolean);
  137819. /**
  137820. * Gets the scene associated with the buffer.
  137821. */
  137822. get scene(): Scene;
  137823. /**
  137824. * Gets the ratio used by the buffer during its creation.
  137825. * How big is the buffer related to the main canvas.
  137826. */
  137827. get ratio(): number;
  137828. /** @hidden */
  137829. static _SceneComponentInitialization: (scene: Scene) => void;
  137830. /**
  137831. * Creates a new G Buffer for the scene
  137832. * @param scene The scene the buffer belongs to
  137833. * @param ratio How big is the buffer related to the main canvas.
  137834. */
  137835. constructor(scene: Scene, ratio?: number);
  137836. /**
  137837. * Checks wether everything is ready to render a submesh to the G buffer.
  137838. * @param subMesh the submesh to check readiness for
  137839. * @param useInstances is the mesh drawn using instance or not
  137840. * @returns true if ready otherwise false
  137841. */
  137842. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  137843. /**
  137844. * Gets the current underlying G Buffer.
  137845. * @returns the buffer
  137846. */
  137847. getGBuffer(): MultiRenderTarget;
  137848. /**
  137849. * Gets the number of samples used to render the buffer (anti aliasing).
  137850. */
  137851. get samples(): number;
  137852. /**
  137853. * Sets the number of samples used to render the buffer (anti aliasing).
  137854. */
  137855. set samples(value: number);
  137856. /**
  137857. * Disposes the renderer and frees up associated resources.
  137858. */
  137859. dispose(): void;
  137860. protected _createRenderTargets(): void;
  137861. private _copyBonesTransformationMatrices;
  137862. }
  137863. }
  137864. declare module BABYLON {
  137865. interface Scene {
  137866. /** @hidden (Backing field) */
  137867. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137868. /**
  137869. * Gets or Sets the current geometry buffer associated to the scene.
  137870. */
  137871. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  137872. /**
  137873. * Enables a GeometryBufferRender and associates it with the scene
  137874. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  137875. * @returns the GeometryBufferRenderer
  137876. */
  137877. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  137878. /**
  137879. * Disables the GeometryBufferRender associated with the scene
  137880. */
  137881. disableGeometryBufferRenderer(): void;
  137882. }
  137883. /**
  137884. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  137885. * in several rendering techniques.
  137886. */
  137887. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  137888. /**
  137889. * The component name helpful to identify the component in the list of scene components.
  137890. */
  137891. readonly name: string;
  137892. /**
  137893. * The scene the component belongs to.
  137894. */
  137895. scene: Scene;
  137896. /**
  137897. * Creates a new instance of the component for the given scene
  137898. * @param scene Defines the scene to register the component in
  137899. */
  137900. constructor(scene: Scene);
  137901. /**
  137902. * Registers the component in a given scene
  137903. */
  137904. register(): void;
  137905. /**
  137906. * Rebuilds the elements related to this component in case of
  137907. * context lost for instance.
  137908. */
  137909. rebuild(): void;
  137910. /**
  137911. * Disposes the component and the associated ressources
  137912. */
  137913. dispose(): void;
  137914. private _gatherRenderTargets;
  137915. }
  137916. }
  137917. declare module BABYLON {
  137918. /** @hidden */
  137919. export var motionBlurPixelShader: {
  137920. name: string;
  137921. shader: string;
  137922. };
  137923. }
  137924. declare module BABYLON {
  137925. /**
  137926. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  137927. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  137928. * As an example, all you have to do is to create the post-process:
  137929. * var mb = new BABYLON.MotionBlurPostProcess(
  137930. * 'mb', // The name of the effect.
  137931. * scene, // The scene containing the objects to blur according to their velocity.
  137932. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  137933. * camera // The camera to apply the render pass to.
  137934. * );
  137935. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  137936. */
  137937. export class MotionBlurPostProcess extends PostProcess {
  137938. /**
  137939. * Defines how much the image is blurred by the movement. Default value is equal to 1
  137940. */
  137941. motionStrength: number;
  137942. /**
  137943. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  137944. */
  137945. get motionBlurSamples(): number;
  137946. /**
  137947. * Sets the number of iterations to be used for motion blur quality
  137948. */
  137949. set motionBlurSamples(samples: number);
  137950. private _motionBlurSamples;
  137951. private _geometryBufferRenderer;
  137952. /**
  137953. * Creates a new instance MotionBlurPostProcess
  137954. * @param name The name of the effect.
  137955. * @param scene The scene containing the objects to blur according to their velocity.
  137956. * @param options The required width/height ratio to downsize to before computing the render pass.
  137957. * @param camera The camera to apply the render pass to.
  137958. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137959. * @param engine The engine which the post process will be applied. (default: current engine)
  137960. * @param reusable If the post process can be reused on the same frame. (default: false)
  137961. * @param textureType Type of textures used when performing the post process. (default: 0)
  137962. * @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)
  137963. */
  137964. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137965. /**
  137966. * Excludes the given skinned mesh from computing bones velocities.
  137967. * 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.
  137968. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  137969. */
  137970. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  137971. /**
  137972. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  137973. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  137974. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  137975. */
  137976. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  137977. /**
  137978. * Disposes the post process.
  137979. * @param camera The camera to dispose the post process on.
  137980. */
  137981. dispose(camera?: Camera): void;
  137982. }
  137983. }
  137984. declare module BABYLON {
  137985. /** @hidden */
  137986. export var refractionPixelShader: {
  137987. name: string;
  137988. shader: string;
  137989. };
  137990. }
  137991. declare module BABYLON {
  137992. /**
  137993. * Post process which applies a refractin texture
  137994. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  137995. */
  137996. export class RefractionPostProcess extends PostProcess {
  137997. /** the base color of the refraction (used to taint the rendering) */
  137998. color: Color3;
  137999. /** simulated refraction depth */
  138000. depth: number;
  138001. /** the coefficient of the base color (0 to remove base color tainting) */
  138002. colorLevel: number;
  138003. private _refTexture;
  138004. private _ownRefractionTexture;
  138005. /**
  138006. * Gets or sets the refraction texture
  138007. * Please note that you are responsible for disposing the texture if you set it manually
  138008. */
  138009. get refractionTexture(): Texture;
  138010. set refractionTexture(value: Texture);
  138011. /**
  138012. * Initializes the RefractionPostProcess
  138013. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138014. * @param name The name of the effect.
  138015. * @param refractionTextureUrl Url of the refraction texture to use
  138016. * @param color the base color of the refraction (used to taint the rendering)
  138017. * @param depth simulated refraction depth
  138018. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  138019. * @param camera The camera to apply the render pass to.
  138020. * @param options The required width/height ratio to downsize to before computing the render pass.
  138021. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138022. * @param engine The engine which the post process will be applied. (default: current engine)
  138023. * @param reusable If the post process can be reused on the same frame. (default: false)
  138024. */
  138025. constructor(name: string, refractionTextureUrl: string,
  138026. /** the base color of the refraction (used to taint the rendering) */
  138027. color: Color3,
  138028. /** simulated refraction depth */
  138029. depth: number,
  138030. /** the coefficient of the base color (0 to remove base color tainting) */
  138031. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138032. /**
  138033. * Disposes of the post process
  138034. * @param camera Camera to dispose post process on
  138035. */
  138036. dispose(camera: Camera): void;
  138037. }
  138038. }
  138039. declare module BABYLON {
  138040. /** @hidden */
  138041. export var sharpenPixelShader: {
  138042. name: string;
  138043. shader: string;
  138044. };
  138045. }
  138046. declare module BABYLON {
  138047. /**
  138048. * The SharpenPostProcess applies a sharpen kernel to every pixel
  138049. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  138050. */
  138051. export class SharpenPostProcess extends PostProcess {
  138052. /**
  138053. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  138054. */
  138055. colorAmount: number;
  138056. /**
  138057. * How much sharpness should be applied (default: 0.3)
  138058. */
  138059. edgeAmount: number;
  138060. /**
  138061. * Creates a new instance ConvolutionPostProcess
  138062. * @param name The name of the effect.
  138063. * @param options The required width/height ratio to downsize to before computing the render pass.
  138064. * @param camera The camera to apply the render pass to.
  138065. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138066. * @param engine The engine which the post process will be applied. (default: current engine)
  138067. * @param reusable If the post process can be reused on the same frame. (default: false)
  138068. * @param textureType Type of textures used when performing the post process. (default: 0)
  138069. * @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)
  138070. */
  138071. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138072. }
  138073. }
  138074. declare module BABYLON {
  138075. /**
  138076. * PostProcessRenderPipeline
  138077. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138078. */
  138079. export class PostProcessRenderPipeline {
  138080. private engine;
  138081. private _renderEffects;
  138082. private _renderEffectsForIsolatedPass;
  138083. /**
  138084. * List of inspectable custom properties (used by the Inspector)
  138085. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  138086. */
  138087. inspectableCustomProperties: IInspectable[];
  138088. /**
  138089. * @hidden
  138090. */
  138091. protected _cameras: Camera[];
  138092. /** @hidden */
  138093. _name: string;
  138094. /**
  138095. * Gets pipeline name
  138096. */
  138097. get name(): string;
  138098. /** Gets the list of attached cameras */
  138099. get cameras(): Camera[];
  138100. /**
  138101. * Initializes a PostProcessRenderPipeline
  138102. * @param engine engine to add the pipeline to
  138103. * @param name name of the pipeline
  138104. */
  138105. constructor(engine: Engine, name: string);
  138106. /**
  138107. * Gets the class name
  138108. * @returns "PostProcessRenderPipeline"
  138109. */
  138110. getClassName(): string;
  138111. /**
  138112. * If all the render effects in the pipeline are supported
  138113. */
  138114. get isSupported(): boolean;
  138115. /**
  138116. * Adds an effect to the pipeline
  138117. * @param renderEffect the effect to add
  138118. */
  138119. addEffect(renderEffect: PostProcessRenderEffect): void;
  138120. /** @hidden */
  138121. _rebuild(): void;
  138122. /** @hidden */
  138123. _enableEffect(renderEffectName: string, cameras: Camera): void;
  138124. /** @hidden */
  138125. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  138126. /** @hidden */
  138127. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138128. /** @hidden */
  138129. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138130. /** @hidden */
  138131. _attachCameras(cameras: Camera, unique: boolean): void;
  138132. /** @hidden */
  138133. _attachCameras(cameras: Camera[], unique: boolean): void;
  138134. /** @hidden */
  138135. _detachCameras(cameras: Camera): void;
  138136. /** @hidden */
  138137. _detachCameras(cameras: Nullable<Camera[]>): void;
  138138. /** @hidden */
  138139. _update(): void;
  138140. /** @hidden */
  138141. _reset(): void;
  138142. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  138143. /**
  138144. * Disposes of the pipeline
  138145. */
  138146. dispose(): void;
  138147. }
  138148. }
  138149. declare module BABYLON {
  138150. /**
  138151. * PostProcessRenderPipelineManager class
  138152. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138153. */
  138154. export class PostProcessRenderPipelineManager {
  138155. private _renderPipelines;
  138156. /**
  138157. * Initializes a PostProcessRenderPipelineManager
  138158. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138159. */
  138160. constructor();
  138161. /**
  138162. * Gets the list of supported render pipelines
  138163. */
  138164. get supportedPipelines(): PostProcessRenderPipeline[];
  138165. /**
  138166. * Adds a pipeline to the manager
  138167. * @param renderPipeline The pipeline to add
  138168. */
  138169. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  138170. /**
  138171. * Attaches a camera to the pipeline
  138172. * @param renderPipelineName The name of the pipeline to attach to
  138173. * @param cameras the camera to attach
  138174. * @param unique if the camera can be attached multiple times to the pipeline
  138175. */
  138176. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  138177. /**
  138178. * Detaches a camera from the pipeline
  138179. * @param renderPipelineName The name of the pipeline to detach from
  138180. * @param cameras the camera to detach
  138181. */
  138182. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  138183. /**
  138184. * Enables an effect by name on a pipeline
  138185. * @param renderPipelineName the name of the pipeline to enable the effect in
  138186. * @param renderEffectName the name of the effect to enable
  138187. * @param cameras the cameras that the effect should be enabled on
  138188. */
  138189. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138190. /**
  138191. * Disables an effect by name on a pipeline
  138192. * @param renderPipelineName the name of the pipeline to disable the effect in
  138193. * @param renderEffectName the name of the effect to disable
  138194. * @param cameras the cameras that the effect should be disabled on
  138195. */
  138196. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138197. /**
  138198. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  138199. */
  138200. update(): void;
  138201. /** @hidden */
  138202. _rebuild(): void;
  138203. /**
  138204. * Disposes of the manager and pipelines
  138205. */
  138206. dispose(): void;
  138207. }
  138208. }
  138209. declare module BABYLON {
  138210. interface Scene {
  138211. /** @hidden (Backing field) */
  138212. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138213. /**
  138214. * Gets the postprocess render pipeline manager
  138215. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138216. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138217. */
  138218. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138219. }
  138220. /**
  138221. * Defines the Render Pipeline scene component responsible to rendering pipelines
  138222. */
  138223. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  138224. /**
  138225. * The component name helpfull to identify the component in the list of scene components.
  138226. */
  138227. readonly name: string;
  138228. /**
  138229. * The scene the component belongs to.
  138230. */
  138231. scene: Scene;
  138232. /**
  138233. * Creates a new instance of the component for the given scene
  138234. * @param scene Defines the scene to register the component in
  138235. */
  138236. constructor(scene: Scene);
  138237. /**
  138238. * Registers the component in a given scene
  138239. */
  138240. register(): void;
  138241. /**
  138242. * Rebuilds the elements related to this component in case of
  138243. * context lost for instance.
  138244. */
  138245. rebuild(): void;
  138246. /**
  138247. * Disposes the component and the associated ressources
  138248. */
  138249. dispose(): void;
  138250. private _gatherRenderTargets;
  138251. }
  138252. }
  138253. declare module BABYLON {
  138254. /**
  138255. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  138256. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138257. */
  138258. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138259. private _scene;
  138260. private _camerasToBeAttached;
  138261. /**
  138262. * ID of the sharpen post process,
  138263. */
  138264. private readonly SharpenPostProcessId;
  138265. /**
  138266. * @ignore
  138267. * ID of the image processing post process;
  138268. */
  138269. readonly ImageProcessingPostProcessId: string;
  138270. /**
  138271. * @ignore
  138272. * ID of the Fast Approximate Anti-Aliasing post process;
  138273. */
  138274. readonly FxaaPostProcessId: string;
  138275. /**
  138276. * ID of the chromatic aberration post process,
  138277. */
  138278. private readonly ChromaticAberrationPostProcessId;
  138279. /**
  138280. * ID of the grain post process
  138281. */
  138282. private readonly GrainPostProcessId;
  138283. /**
  138284. * Sharpen post process which will apply a sharpen convolution to enhance edges
  138285. */
  138286. sharpen: SharpenPostProcess;
  138287. private _sharpenEffect;
  138288. private bloom;
  138289. /**
  138290. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  138291. */
  138292. depthOfField: DepthOfFieldEffect;
  138293. /**
  138294. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138295. */
  138296. fxaa: FxaaPostProcess;
  138297. /**
  138298. * Image post processing pass used to perform operations such as tone mapping or color grading.
  138299. */
  138300. imageProcessing: ImageProcessingPostProcess;
  138301. /**
  138302. * Chromatic aberration post process which will shift rgb colors in the image
  138303. */
  138304. chromaticAberration: ChromaticAberrationPostProcess;
  138305. private _chromaticAberrationEffect;
  138306. /**
  138307. * Grain post process which add noise to the image
  138308. */
  138309. grain: GrainPostProcess;
  138310. private _grainEffect;
  138311. /**
  138312. * Glow post process which adds a glow to emissive areas of the image
  138313. */
  138314. private _glowLayer;
  138315. /**
  138316. * Animations which can be used to tweak settings over a period of time
  138317. */
  138318. animations: Animation[];
  138319. private _imageProcessingConfigurationObserver;
  138320. private _sharpenEnabled;
  138321. private _bloomEnabled;
  138322. private _depthOfFieldEnabled;
  138323. private _depthOfFieldBlurLevel;
  138324. private _fxaaEnabled;
  138325. private _imageProcessingEnabled;
  138326. private _defaultPipelineTextureType;
  138327. private _bloomScale;
  138328. private _chromaticAberrationEnabled;
  138329. private _grainEnabled;
  138330. private _buildAllowed;
  138331. /**
  138332. * Gets active scene
  138333. */
  138334. get scene(): Scene;
  138335. /**
  138336. * Enable or disable the sharpen process from the pipeline
  138337. */
  138338. set sharpenEnabled(enabled: boolean);
  138339. get sharpenEnabled(): boolean;
  138340. private _resizeObserver;
  138341. private _hardwareScaleLevel;
  138342. private _bloomKernel;
  138343. /**
  138344. * Specifies the size of the bloom blur kernel, relative to the final output size
  138345. */
  138346. get bloomKernel(): number;
  138347. set bloomKernel(value: number);
  138348. /**
  138349. * Specifies the weight of the bloom in the final rendering
  138350. */
  138351. private _bloomWeight;
  138352. /**
  138353. * Specifies the luma threshold for the area that will be blurred by the bloom
  138354. */
  138355. private _bloomThreshold;
  138356. private _hdr;
  138357. /**
  138358. * The strength of the bloom.
  138359. */
  138360. set bloomWeight(value: number);
  138361. get bloomWeight(): number;
  138362. /**
  138363. * The strength of the bloom.
  138364. */
  138365. set bloomThreshold(value: number);
  138366. get bloomThreshold(): number;
  138367. /**
  138368. * The scale of the bloom, lower value will provide better performance.
  138369. */
  138370. set bloomScale(value: number);
  138371. get bloomScale(): number;
  138372. /**
  138373. * Enable or disable the bloom from the pipeline
  138374. */
  138375. set bloomEnabled(enabled: boolean);
  138376. get bloomEnabled(): boolean;
  138377. private _rebuildBloom;
  138378. /**
  138379. * If the depth of field is enabled.
  138380. */
  138381. get depthOfFieldEnabled(): boolean;
  138382. set depthOfFieldEnabled(enabled: boolean);
  138383. /**
  138384. * Blur level of the depth of field effect. (Higher blur will effect performance)
  138385. */
  138386. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  138387. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  138388. /**
  138389. * If the anti aliasing is enabled.
  138390. */
  138391. set fxaaEnabled(enabled: boolean);
  138392. get fxaaEnabled(): boolean;
  138393. private _samples;
  138394. /**
  138395. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  138396. */
  138397. set samples(sampleCount: number);
  138398. get samples(): number;
  138399. /**
  138400. * If image processing is enabled.
  138401. */
  138402. set imageProcessingEnabled(enabled: boolean);
  138403. get imageProcessingEnabled(): boolean;
  138404. /**
  138405. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  138406. */
  138407. set glowLayerEnabled(enabled: boolean);
  138408. get glowLayerEnabled(): boolean;
  138409. /**
  138410. * Gets the glow layer (or null if not defined)
  138411. */
  138412. get glowLayer(): Nullable<GlowLayer>;
  138413. /**
  138414. * Enable or disable the chromaticAberration process from the pipeline
  138415. */
  138416. set chromaticAberrationEnabled(enabled: boolean);
  138417. get chromaticAberrationEnabled(): boolean;
  138418. /**
  138419. * Enable or disable the grain process from the pipeline
  138420. */
  138421. set grainEnabled(enabled: boolean);
  138422. get grainEnabled(): boolean;
  138423. /**
  138424. * @constructor
  138425. * @param name - The rendering pipeline name (default: "")
  138426. * @param hdr - If high dynamic range textures should be used (default: true)
  138427. * @param scene - The scene linked to this pipeline (default: the last created scene)
  138428. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  138429. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  138430. */
  138431. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  138432. /**
  138433. * Get the class name
  138434. * @returns "DefaultRenderingPipeline"
  138435. */
  138436. getClassName(): string;
  138437. /**
  138438. * Force the compilation of the entire pipeline.
  138439. */
  138440. prepare(): void;
  138441. private _hasCleared;
  138442. private _prevPostProcess;
  138443. private _prevPrevPostProcess;
  138444. private _setAutoClearAndTextureSharing;
  138445. private _depthOfFieldSceneObserver;
  138446. private _buildPipeline;
  138447. private _disposePostProcesses;
  138448. /**
  138449. * Adds a camera to the pipeline
  138450. * @param camera the camera to be added
  138451. */
  138452. addCamera(camera: Camera): void;
  138453. /**
  138454. * Removes a camera from the pipeline
  138455. * @param camera the camera to remove
  138456. */
  138457. removeCamera(camera: Camera): void;
  138458. /**
  138459. * Dispose of the pipeline and stop all post processes
  138460. */
  138461. dispose(): void;
  138462. /**
  138463. * Serialize the rendering pipeline (Used when exporting)
  138464. * @returns the serialized object
  138465. */
  138466. serialize(): any;
  138467. /**
  138468. * Parse the serialized pipeline
  138469. * @param source Source pipeline.
  138470. * @param scene The scene to load the pipeline to.
  138471. * @param rootUrl The URL of the serialized pipeline.
  138472. * @returns An instantiated pipeline from the serialized object.
  138473. */
  138474. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  138475. }
  138476. }
  138477. declare module BABYLON {
  138478. /** @hidden */
  138479. export var lensHighlightsPixelShader: {
  138480. name: string;
  138481. shader: string;
  138482. };
  138483. }
  138484. declare module BABYLON {
  138485. /** @hidden */
  138486. export var depthOfFieldPixelShader: {
  138487. name: string;
  138488. shader: string;
  138489. };
  138490. }
  138491. declare module BABYLON {
  138492. /**
  138493. * BABYLON.JS Chromatic Aberration GLSL Shader
  138494. * Author: Olivier Guyot
  138495. * Separates very slightly R, G and B colors on the edges of the screen
  138496. * Inspired by Francois Tarlier & Martins Upitis
  138497. */
  138498. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  138499. /**
  138500. * @ignore
  138501. * The chromatic aberration PostProcess id in the pipeline
  138502. */
  138503. LensChromaticAberrationEffect: string;
  138504. /**
  138505. * @ignore
  138506. * The highlights enhancing PostProcess id in the pipeline
  138507. */
  138508. HighlightsEnhancingEffect: string;
  138509. /**
  138510. * @ignore
  138511. * The depth-of-field PostProcess id in the pipeline
  138512. */
  138513. LensDepthOfFieldEffect: string;
  138514. private _scene;
  138515. private _depthTexture;
  138516. private _grainTexture;
  138517. private _chromaticAberrationPostProcess;
  138518. private _highlightsPostProcess;
  138519. private _depthOfFieldPostProcess;
  138520. private _edgeBlur;
  138521. private _grainAmount;
  138522. private _chromaticAberration;
  138523. private _distortion;
  138524. private _highlightsGain;
  138525. private _highlightsThreshold;
  138526. private _dofDistance;
  138527. private _dofAperture;
  138528. private _dofDarken;
  138529. private _dofPentagon;
  138530. private _blurNoise;
  138531. /**
  138532. * @constructor
  138533. *
  138534. * Effect parameters are as follow:
  138535. * {
  138536. * chromatic_aberration: number; // from 0 to x (1 for realism)
  138537. * edge_blur: number; // from 0 to x (1 for realism)
  138538. * distortion: number; // from 0 to x (1 for realism)
  138539. * grain_amount: number; // from 0 to 1
  138540. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  138541. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  138542. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  138543. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  138544. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  138545. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  138546. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  138547. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  138548. * }
  138549. * Note: if an effect parameter is unset, effect is disabled
  138550. *
  138551. * @param name The rendering pipeline name
  138552. * @param parameters - An object containing all parameters (see above)
  138553. * @param scene The scene linked to this pipeline
  138554. * @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)
  138555. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138556. */
  138557. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  138558. /**
  138559. * Get the class name
  138560. * @returns "LensRenderingPipeline"
  138561. */
  138562. getClassName(): string;
  138563. /**
  138564. * Gets associated scene
  138565. */
  138566. get scene(): Scene;
  138567. /**
  138568. * Gets or sets the edge blur
  138569. */
  138570. get edgeBlur(): number;
  138571. set edgeBlur(value: number);
  138572. /**
  138573. * Gets or sets the grain amount
  138574. */
  138575. get grainAmount(): number;
  138576. set grainAmount(value: number);
  138577. /**
  138578. * Gets or sets the chromatic aberration amount
  138579. */
  138580. get chromaticAberration(): number;
  138581. set chromaticAberration(value: number);
  138582. /**
  138583. * Gets or sets the depth of field aperture
  138584. */
  138585. get dofAperture(): number;
  138586. set dofAperture(value: number);
  138587. /**
  138588. * Gets or sets the edge distortion
  138589. */
  138590. get edgeDistortion(): number;
  138591. set edgeDistortion(value: number);
  138592. /**
  138593. * Gets or sets the depth of field distortion
  138594. */
  138595. get dofDistortion(): number;
  138596. set dofDistortion(value: number);
  138597. /**
  138598. * Gets or sets the darken out of focus amount
  138599. */
  138600. get darkenOutOfFocus(): number;
  138601. set darkenOutOfFocus(value: number);
  138602. /**
  138603. * Gets or sets a boolean indicating if blur noise is enabled
  138604. */
  138605. get blurNoise(): boolean;
  138606. set blurNoise(value: boolean);
  138607. /**
  138608. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  138609. */
  138610. get pentagonBokeh(): boolean;
  138611. set pentagonBokeh(value: boolean);
  138612. /**
  138613. * Gets or sets the highlight grain amount
  138614. */
  138615. get highlightsGain(): number;
  138616. set highlightsGain(value: number);
  138617. /**
  138618. * Gets or sets the highlight threshold
  138619. */
  138620. get highlightsThreshold(): number;
  138621. set highlightsThreshold(value: number);
  138622. /**
  138623. * Sets the amount of blur at the edges
  138624. * @param amount blur amount
  138625. */
  138626. setEdgeBlur(amount: number): void;
  138627. /**
  138628. * Sets edge blur to 0
  138629. */
  138630. disableEdgeBlur(): void;
  138631. /**
  138632. * Sets the amout of grain
  138633. * @param amount Amount of grain
  138634. */
  138635. setGrainAmount(amount: number): void;
  138636. /**
  138637. * Set grain amount to 0
  138638. */
  138639. disableGrain(): void;
  138640. /**
  138641. * Sets the chromatic aberration amount
  138642. * @param amount amount of chromatic aberration
  138643. */
  138644. setChromaticAberration(amount: number): void;
  138645. /**
  138646. * Sets chromatic aberration amount to 0
  138647. */
  138648. disableChromaticAberration(): void;
  138649. /**
  138650. * Sets the EdgeDistortion amount
  138651. * @param amount amount of EdgeDistortion
  138652. */
  138653. setEdgeDistortion(amount: number): void;
  138654. /**
  138655. * Sets edge distortion to 0
  138656. */
  138657. disableEdgeDistortion(): void;
  138658. /**
  138659. * Sets the FocusDistance amount
  138660. * @param amount amount of FocusDistance
  138661. */
  138662. setFocusDistance(amount: number): void;
  138663. /**
  138664. * Disables depth of field
  138665. */
  138666. disableDepthOfField(): void;
  138667. /**
  138668. * Sets the Aperture amount
  138669. * @param amount amount of Aperture
  138670. */
  138671. setAperture(amount: number): void;
  138672. /**
  138673. * Sets the DarkenOutOfFocus amount
  138674. * @param amount amount of DarkenOutOfFocus
  138675. */
  138676. setDarkenOutOfFocus(amount: number): void;
  138677. private _pentagonBokehIsEnabled;
  138678. /**
  138679. * Creates a pentagon bokeh effect
  138680. */
  138681. enablePentagonBokeh(): void;
  138682. /**
  138683. * Disables the pentagon bokeh effect
  138684. */
  138685. disablePentagonBokeh(): void;
  138686. /**
  138687. * Enables noise blur
  138688. */
  138689. enableNoiseBlur(): void;
  138690. /**
  138691. * Disables noise blur
  138692. */
  138693. disableNoiseBlur(): void;
  138694. /**
  138695. * Sets the HighlightsGain amount
  138696. * @param amount amount of HighlightsGain
  138697. */
  138698. setHighlightsGain(amount: number): void;
  138699. /**
  138700. * Sets the HighlightsThreshold amount
  138701. * @param amount amount of HighlightsThreshold
  138702. */
  138703. setHighlightsThreshold(amount: number): void;
  138704. /**
  138705. * Disables highlights
  138706. */
  138707. disableHighlights(): void;
  138708. /**
  138709. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  138710. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  138711. */
  138712. dispose(disableDepthRender?: boolean): void;
  138713. private _createChromaticAberrationPostProcess;
  138714. private _createHighlightsPostProcess;
  138715. private _createDepthOfFieldPostProcess;
  138716. private _createGrainTexture;
  138717. }
  138718. }
  138719. declare module BABYLON {
  138720. /** @hidden */
  138721. export var ssao2PixelShader: {
  138722. name: string;
  138723. shader: string;
  138724. };
  138725. }
  138726. declare module BABYLON {
  138727. /** @hidden */
  138728. export var ssaoCombinePixelShader: {
  138729. name: string;
  138730. shader: string;
  138731. };
  138732. }
  138733. declare module BABYLON {
  138734. /**
  138735. * Render pipeline to produce ssao effect
  138736. */
  138737. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  138738. /**
  138739. * @ignore
  138740. * The PassPostProcess id in the pipeline that contains the original scene color
  138741. */
  138742. SSAOOriginalSceneColorEffect: string;
  138743. /**
  138744. * @ignore
  138745. * The SSAO PostProcess id in the pipeline
  138746. */
  138747. SSAORenderEffect: string;
  138748. /**
  138749. * @ignore
  138750. * The horizontal blur PostProcess id in the pipeline
  138751. */
  138752. SSAOBlurHRenderEffect: string;
  138753. /**
  138754. * @ignore
  138755. * The vertical blur PostProcess id in the pipeline
  138756. */
  138757. SSAOBlurVRenderEffect: string;
  138758. /**
  138759. * @ignore
  138760. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138761. */
  138762. SSAOCombineRenderEffect: string;
  138763. /**
  138764. * The output strength of the SSAO post-process. Default value is 1.0.
  138765. */
  138766. totalStrength: number;
  138767. /**
  138768. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  138769. */
  138770. maxZ: number;
  138771. /**
  138772. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  138773. */
  138774. minZAspect: number;
  138775. private _samples;
  138776. /**
  138777. * Number of samples used for the SSAO calculations. Default value is 8
  138778. */
  138779. set samples(n: number);
  138780. get samples(): number;
  138781. private _textureSamples;
  138782. /**
  138783. * Number of samples to use for antialiasing
  138784. */
  138785. set textureSamples(n: number);
  138786. get textureSamples(): number;
  138787. /**
  138788. * Ratio object used for SSAO ratio and blur ratio
  138789. */
  138790. private _ratio;
  138791. /**
  138792. * Dynamically generated sphere sampler.
  138793. */
  138794. private _sampleSphere;
  138795. /**
  138796. * Blur filter offsets
  138797. */
  138798. private _samplerOffsets;
  138799. private _expensiveBlur;
  138800. /**
  138801. * If bilateral blur should be used
  138802. */
  138803. set expensiveBlur(b: boolean);
  138804. get expensiveBlur(): boolean;
  138805. /**
  138806. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  138807. */
  138808. radius: number;
  138809. /**
  138810. * The base color of the SSAO post-process
  138811. * The final result is "base + ssao" between [0, 1]
  138812. */
  138813. base: number;
  138814. /**
  138815. * Support test.
  138816. */
  138817. static get IsSupported(): boolean;
  138818. private _scene;
  138819. private _depthTexture;
  138820. private _normalTexture;
  138821. private _randomTexture;
  138822. private _originalColorPostProcess;
  138823. private _ssaoPostProcess;
  138824. private _blurHPostProcess;
  138825. private _blurVPostProcess;
  138826. private _ssaoCombinePostProcess;
  138827. /**
  138828. * Gets active scene
  138829. */
  138830. get scene(): Scene;
  138831. /**
  138832. * @constructor
  138833. * @param name The rendering pipeline name
  138834. * @param scene The scene linked to this pipeline
  138835. * @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 }
  138836. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138837. */
  138838. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138839. /**
  138840. * Get the class name
  138841. * @returns "SSAO2RenderingPipeline"
  138842. */
  138843. getClassName(): string;
  138844. /**
  138845. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138846. */
  138847. dispose(disableGeometryBufferRenderer?: boolean): void;
  138848. private _createBlurPostProcess;
  138849. /** @hidden */
  138850. _rebuild(): void;
  138851. private _bits;
  138852. private _radicalInverse_VdC;
  138853. private _hammersley;
  138854. private _hemisphereSample_uniform;
  138855. private _generateHemisphere;
  138856. private _createSSAOPostProcess;
  138857. private _createSSAOCombinePostProcess;
  138858. private _createRandomTexture;
  138859. /**
  138860. * Serialize the rendering pipeline (Used when exporting)
  138861. * @returns the serialized object
  138862. */
  138863. serialize(): any;
  138864. /**
  138865. * Parse the serialized pipeline
  138866. * @param source Source pipeline.
  138867. * @param scene The scene to load the pipeline to.
  138868. * @param rootUrl The URL of the serialized pipeline.
  138869. * @returns An instantiated pipeline from the serialized object.
  138870. */
  138871. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  138872. }
  138873. }
  138874. declare module BABYLON {
  138875. /** @hidden */
  138876. export var ssaoPixelShader: {
  138877. name: string;
  138878. shader: string;
  138879. };
  138880. }
  138881. declare module BABYLON {
  138882. /**
  138883. * Render pipeline to produce ssao effect
  138884. */
  138885. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  138886. /**
  138887. * @ignore
  138888. * The PassPostProcess id in the pipeline that contains the original scene color
  138889. */
  138890. SSAOOriginalSceneColorEffect: string;
  138891. /**
  138892. * @ignore
  138893. * The SSAO PostProcess id in the pipeline
  138894. */
  138895. SSAORenderEffect: string;
  138896. /**
  138897. * @ignore
  138898. * The horizontal blur PostProcess id in the pipeline
  138899. */
  138900. SSAOBlurHRenderEffect: string;
  138901. /**
  138902. * @ignore
  138903. * The vertical blur PostProcess id in the pipeline
  138904. */
  138905. SSAOBlurVRenderEffect: string;
  138906. /**
  138907. * @ignore
  138908. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138909. */
  138910. SSAOCombineRenderEffect: string;
  138911. /**
  138912. * The output strength of the SSAO post-process. Default value is 1.0.
  138913. */
  138914. totalStrength: number;
  138915. /**
  138916. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  138917. */
  138918. radius: number;
  138919. /**
  138920. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  138921. * Must not be equal to fallOff and superior to fallOff.
  138922. * Default value is 0.0075
  138923. */
  138924. area: number;
  138925. /**
  138926. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  138927. * Must not be equal to area and inferior to area.
  138928. * Default value is 0.000001
  138929. */
  138930. fallOff: number;
  138931. /**
  138932. * The base color of the SSAO post-process
  138933. * The final result is "base + ssao" between [0, 1]
  138934. */
  138935. base: number;
  138936. private _scene;
  138937. private _depthTexture;
  138938. private _randomTexture;
  138939. private _originalColorPostProcess;
  138940. private _ssaoPostProcess;
  138941. private _blurHPostProcess;
  138942. private _blurVPostProcess;
  138943. private _ssaoCombinePostProcess;
  138944. private _firstUpdate;
  138945. /**
  138946. * Gets active scene
  138947. */
  138948. get scene(): Scene;
  138949. /**
  138950. * @constructor
  138951. * @param name - The rendering pipeline name
  138952. * @param scene - The scene linked to this pipeline
  138953. * @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 }
  138954. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  138955. */
  138956. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  138957. /**
  138958. * Get the class name
  138959. * @returns "SSAORenderingPipeline"
  138960. */
  138961. getClassName(): string;
  138962. /**
  138963. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  138964. */
  138965. dispose(disableDepthRender?: boolean): void;
  138966. private _createBlurPostProcess;
  138967. /** @hidden */
  138968. _rebuild(): void;
  138969. private _createSSAOPostProcess;
  138970. private _createSSAOCombinePostProcess;
  138971. private _createRandomTexture;
  138972. }
  138973. }
  138974. declare module BABYLON {
  138975. /** @hidden */
  138976. export var screenSpaceReflectionPixelShader: {
  138977. name: string;
  138978. shader: string;
  138979. };
  138980. }
  138981. declare module BABYLON {
  138982. /**
  138983. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  138984. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  138985. */
  138986. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  138987. /**
  138988. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  138989. */
  138990. threshold: number;
  138991. /**
  138992. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  138993. */
  138994. strength: number;
  138995. /**
  138996. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  138997. */
  138998. reflectionSpecularFalloffExponent: number;
  138999. /**
  139000. * Gets or sets the step size used to iterate until the effect finds the color of the reflection's pixel. Typically in interval [0.1, 1.0]
  139001. */
  139002. step: number;
  139003. /**
  139004. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  139005. */
  139006. roughnessFactor: number;
  139007. private _geometryBufferRenderer;
  139008. private _enableSmoothReflections;
  139009. private _reflectionSamples;
  139010. private _smoothSteps;
  139011. /**
  139012. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  139013. * @param name The name of the effect.
  139014. * @param scene The scene containing the objects to calculate reflections.
  139015. * @param options The required width/height ratio to downsize to before computing the render pass.
  139016. * @param camera The camera to apply the render pass to.
  139017. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139018. * @param engine The engine which the post process will be applied. (default: current engine)
  139019. * @param reusable If the post process can be reused on the same frame. (default: false)
  139020. * @param textureType Type of textures used when performing the post process. (default: 0)
  139021. * @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)
  139022. */
  139023. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139024. /**
  139025. * Gets wether or not smoothing reflections is enabled.
  139026. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139027. */
  139028. get enableSmoothReflections(): boolean;
  139029. /**
  139030. * Sets wether or not smoothing reflections is enabled.
  139031. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139032. */
  139033. set enableSmoothReflections(enabled: boolean);
  139034. /**
  139035. * Gets the number of samples taken while computing reflections. More samples count is high,
  139036. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139037. */
  139038. get reflectionSamples(): number;
  139039. /**
  139040. * Sets the number of samples taken while computing reflections. More samples count is high,
  139041. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139042. */
  139043. set reflectionSamples(samples: number);
  139044. /**
  139045. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  139046. * more the post-process will require GPU power and can generate a drop in FPS.
  139047. * Default value (5.0) work pretty well in all cases but can be adjusted.
  139048. */
  139049. get smoothSteps(): number;
  139050. set smoothSteps(steps: number);
  139051. private _updateEffectDefines;
  139052. }
  139053. }
  139054. declare module BABYLON {
  139055. /** @hidden */
  139056. export var standardPixelShader: {
  139057. name: string;
  139058. shader: string;
  139059. };
  139060. }
  139061. declare module BABYLON {
  139062. /**
  139063. * Standard rendering pipeline
  139064. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139065. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  139066. */
  139067. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  139068. /**
  139069. * Public members
  139070. */
  139071. /**
  139072. * Post-process which contains the original scene color before the pipeline applies all the effects
  139073. */
  139074. originalPostProcess: Nullable<PostProcess>;
  139075. /**
  139076. * Post-process used to down scale an image x4
  139077. */
  139078. downSampleX4PostProcess: Nullable<PostProcess>;
  139079. /**
  139080. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  139081. */
  139082. brightPassPostProcess: Nullable<PostProcess>;
  139083. /**
  139084. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  139085. */
  139086. blurHPostProcesses: PostProcess[];
  139087. /**
  139088. * Post-process array storing all the vertical blur post-processes used by the pipeline
  139089. */
  139090. blurVPostProcesses: PostProcess[];
  139091. /**
  139092. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  139093. */
  139094. textureAdderPostProcess: Nullable<PostProcess>;
  139095. /**
  139096. * Post-process used to create volumetric lighting effect
  139097. */
  139098. volumetricLightPostProcess: Nullable<PostProcess>;
  139099. /**
  139100. * Post-process used to smooth the previous volumetric light post-process on the X axis
  139101. */
  139102. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  139103. /**
  139104. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  139105. */
  139106. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  139107. /**
  139108. * Post-process used to merge the volumetric light effect and the real scene color
  139109. */
  139110. volumetricLightMergePostProces: Nullable<PostProcess>;
  139111. /**
  139112. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  139113. */
  139114. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  139115. /**
  139116. * Base post-process used to calculate the average luminance of the final image for HDR
  139117. */
  139118. luminancePostProcess: Nullable<PostProcess>;
  139119. /**
  139120. * Post-processes used to create down sample post-processes in order to get
  139121. * the average luminance of the final image for HDR
  139122. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  139123. */
  139124. luminanceDownSamplePostProcesses: PostProcess[];
  139125. /**
  139126. * Post-process used to create a HDR effect (light adaptation)
  139127. */
  139128. hdrPostProcess: Nullable<PostProcess>;
  139129. /**
  139130. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  139131. */
  139132. textureAdderFinalPostProcess: Nullable<PostProcess>;
  139133. /**
  139134. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  139135. */
  139136. lensFlareFinalPostProcess: Nullable<PostProcess>;
  139137. /**
  139138. * Post-process used to merge the final HDR post-process and the real scene color
  139139. */
  139140. hdrFinalPostProcess: Nullable<PostProcess>;
  139141. /**
  139142. * Post-process used to create a lens flare effect
  139143. */
  139144. lensFlarePostProcess: Nullable<PostProcess>;
  139145. /**
  139146. * Post-process that merges the result of the lens flare post-process and the real scene color
  139147. */
  139148. lensFlareComposePostProcess: Nullable<PostProcess>;
  139149. /**
  139150. * Post-process used to create a motion blur effect
  139151. */
  139152. motionBlurPostProcess: Nullable<PostProcess>;
  139153. /**
  139154. * Post-process used to create a depth of field effect
  139155. */
  139156. depthOfFieldPostProcess: Nullable<PostProcess>;
  139157. /**
  139158. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  139159. */
  139160. fxaaPostProcess: Nullable<FxaaPostProcess>;
  139161. /**
  139162. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  139163. */
  139164. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  139165. /**
  139166. * Represents the brightness threshold in order to configure the illuminated surfaces
  139167. */
  139168. brightThreshold: number;
  139169. /**
  139170. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  139171. */
  139172. blurWidth: number;
  139173. /**
  139174. * Sets if the blur for highlighted surfaces must be only horizontal
  139175. */
  139176. horizontalBlur: boolean;
  139177. /**
  139178. * Gets the overall exposure used by the pipeline
  139179. */
  139180. get exposure(): number;
  139181. /**
  139182. * Sets the overall exposure used by the pipeline
  139183. */
  139184. set exposure(value: number);
  139185. /**
  139186. * Texture used typically to simulate "dirty" on camera lens
  139187. */
  139188. lensTexture: Nullable<Texture>;
  139189. /**
  139190. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  139191. */
  139192. volumetricLightCoefficient: number;
  139193. /**
  139194. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  139195. */
  139196. volumetricLightPower: number;
  139197. /**
  139198. * Used the set the blur intensity to smooth the volumetric lights
  139199. */
  139200. volumetricLightBlurScale: number;
  139201. /**
  139202. * Light (spot or directional) used to generate the volumetric lights rays
  139203. * The source light must have a shadow generate so the pipeline can get its
  139204. * depth map
  139205. */
  139206. sourceLight: Nullable<SpotLight | DirectionalLight>;
  139207. /**
  139208. * For eye adaptation, represents the minimum luminance the eye can see
  139209. */
  139210. hdrMinimumLuminance: number;
  139211. /**
  139212. * For eye adaptation, represents the decrease luminance speed
  139213. */
  139214. hdrDecreaseRate: number;
  139215. /**
  139216. * For eye adaptation, represents the increase luminance speed
  139217. */
  139218. hdrIncreaseRate: number;
  139219. /**
  139220. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139221. */
  139222. get hdrAutoExposure(): boolean;
  139223. /**
  139224. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139225. */
  139226. set hdrAutoExposure(value: boolean);
  139227. /**
  139228. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  139229. */
  139230. lensColorTexture: Nullable<Texture>;
  139231. /**
  139232. * The overall strengh for the lens flare effect
  139233. */
  139234. lensFlareStrength: number;
  139235. /**
  139236. * Dispersion coefficient for lens flare ghosts
  139237. */
  139238. lensFlareGhostDispersal: number;
  139239. /**
  139240. * Main lens flare halo width
  139241. */
  139242. lensFlareHaloWidth: number;
  139243. /**
  139244. * Based on the lens distortion effect, defines how much the lens flare result
  139245. * is distorted
  139246. */
  139247. lensFlareDistortionStrength: number;
  139248. /**
  139249. * Configures the blur intensity used for for lens flare (halo)
  139250. */
  139251. lensFlareBlurWidth: number;
  139252. /**
  139253. * Lens star texture must be used to simulate rays on the flares and is available
  139254. * in the documentation
  139255. */
  139256. lensStarTexture: Nullable<Texture>;
  139257. /**
  139258. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  139259. * flare effect by taking account of the dirt texture
  139260. */
  139261. lensFlareDirtTexture: Nullable<Texture>;
  139262. /**
  139263. * Represents the focal length for the depth of field effect
  139264. */
  139265. depthOfFieldDistance: number;
  139266. /**
  139267. * Represents the blur intensity for the blurred part of the depth of field effect
  139268. */
  139269. depthOfFieldBlurWidth: number;
  139270. /**
  139271. * Gets how much the image is blurred by the movement while using the motion blur post-process
  139272. */
  139273. get motionStrength(): number;
  139274. /**
  139275. * Sets how much the image is blurred by the movement while using the motion blur post-process
  139276. */
  139277. set motionStrength(strength: number);
  139278. /**
  139279. * Gets wether or not the motion blur post-process is object based or screen based.
  139280. */
  139281. get objectBasedMotionBlur(): boolean;
  139282. /**
  139283. * Sets wether or not the motion blur post-process should be object based or screen based
  139284. */
  139285. set objectBasedMotionBlur(value: boolean);
  139286. /**
  139287. * List of animations for the pipeline (IAnimatable implementation)
  139288. */
  139289. animations: Animation[];
  139290. /**
  139291. * Private members
  139292. */
  139293. private _scene;
  139294. private _currentDepthOfFieldSource;
  139295. private _basePostProcess;
  139296. private _fixedExposure;
  139297. private _currentExposure;
  139298. private _hdrAutoExposure;
  139299. private _hdrCurrentLuminance;
  139300. private _motionStrength;
  139301. private _isObjectBasedMotionBlur;
  139302. private _floatTextureType;
  139303. private _camerasToBeAttached;
  139304. private _ratio;
  139305. private _bloomEnabled;
  139306. private _depthOfFieldEnabled;
  139307. private _vlsEnabled;
  139308. private _lensFlareEnabled;
  139309. private _hdrEnabled;
  139310. private _motionBlurEnabled;
  139311. private _fxaaEnabled;
  139312. private _screenSpaceReflectionsEnabled;
  139313. private _motionBlurSamples;
  139314. private _volumetricLightStepsCount;
  139315. private _samples;
  139316. /**
  139317. * @ignore
  139318. * Specifies if the bloom pipeline is enabled
  139319. */
  139320. get BloomEnabled(): boolean;
  139321. set BloomEnabled(enabled: boolean);
  139322. /**
  139323. * @ignore
  139324. * Specifies if the depth of field pipeline is enabed
  139325. */
  139326. get DepthOfFieldEnabled(): boolean;
  139327. set DepthOfFieldEnabled(enabled: boolean);
  139328. /**
  139329. * @ignore
  139330. * Specifies if the lens flare pipeline is enabed
  139331. */
  139332. get LensFlareEnabled(): boolean;
  139333. set LensFlareEnabled(enabled: boolean);
  139334. /**
  139335. * @ignore
  139336. * Specifies if the HDR pipeline is enabled
  139337. */
  139338. get HDREnabled(): boolean;
  139339. set HDREnabled(enabled: boolean);
  139340. /**
  139341. * @ignore
  139342. * Specifies if the volumetric lights scattering effect is enabled
  139343. */
  139344. get VLSEnabled(): boolean;
  139345. set VLSEnabled(enabled: boolean);
  139346. /**
  139347. * @ignore
  139348. * Specifies if the motion blur effect is enabled
  139349. */
  139350. get MotionBlurEnabled(): boolean;
  139351. set MotionBlurEnabled(enabled: boolean);
  139352. /**
  139353. * Specifies if anti-aliasing is enabled
  139354. */
  139355. get fxaaEnabled(): boolean;
  139356. set fxaaEnabled(enabled: boolean);
  139357. /**
  139358. * Specifies if screen space reflections are enabled.
  139359. */
  139360. get screenSpaceReflectionsEnabled(): boolean;
  139361. set screenSpaceReflectionsEnabled(enabled: boolean);
  139362. /**
  139363. * Specifies the number of steps used to calculate the volumetric lights
  139364. * Typically in interval [50, 200]
  139365. */
  139366. get volumetricLightStepsCount(): number;
  139367. set volumetricLightStepsCount(count: number);
  139368. /**
  139369. * Specifies the number of samples used for the motion blur effect
  139370. * Typically in interval [16, 64]
  139371. */
  139372. get motionBlurSamples(): number;
  139373. set motionBlurSamples(samples: number);
  139374. /**
  139375. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  139376. */
  139377. get samples(): number;
  139378. set samples(sampleCount: number);
  139379. /**
  139380. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139381. * @constructor
  139382. * @param name The rendering pipeline name
  139383. * @param scene The scene linked to this pipeline
  139384. * @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)
  139385. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  139386. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139387. */
  139388. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  139389. private _buildPipeline;
  139390. private _createDownSampleX4PostProcess;
  139391. private _createBrightPassPostProcess;
  139392. private _createBlurPostProcesses;
  139393. private _createTextureAdderPostProcess;
  139394. private _createVolumetricLightPostProcess;
  139395. private _createLuminancePostProcesses;
  139396. private _createHdrPostProcess;
  139397. private _createLensFlarePostProcess;
  139398. private _createDepthOfFieldPostProcess;
  139399. private _createMotionBlurPostProcess;
  139400. private _getDepthTexture;
  139401. private _disposePostProcesses;
  139402. /**
  139403. * Dispose of the pipeline and stop all post processes
  139404. */
  139405. dispose(): void;
  139406. /**
  139407. * Serialize the rendering pipeline (Used when exporting)
  139408. * @returns the serialized object
  139409. */
  139410. serialize(): any;
  139411. /**
  139412. * Parse the serialized pipeline
  139413. * @param source Source pipeline.
  139414. * @param scene The scene to load the pipeline to.
  139415. * @param rootUrl The URL of the serialized pipeline.
  139416. * @returns An instantiated pipeline from the serialized object.
  139417. */
  139418. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  139419. /**
  139420. * Luminance steps
  139421. */
  139422. static LuminanceSteps: number;
  139423. }
  139424. }
  139425. declare module BABYLON {
  139426. /** @hidden */
  139427. export var tonemapPixelShader: {
  139428. name: string;
  139429. shader: string;
  139430. };
  139431. }
  139432. declare module BABYLON {
  139433. /** Defines operator used for tonemapping */
  139434. export enum TonemappingOperator {
  139435. /** Hable */
  139436. Hable = 0,
  139437. /** Reinhard */
  139438. Reinhard = 1,
  139439. /** HejiDawson */
  139440. HejiDawson = 2,
  139441. /** Photographic */
  139442. Photographic = 3
  139443. }
  139444. /**
  139445. * Defines a post process to apply tone mapping
  139446. */
  139447. export class TonemapPostProcess extends PostProcess {
  139448. private _operator;
  139449. /** Defines the required exposure adjustement */
  139450. exposureAdjustment: number;
  139451. /**
  139452. * Creates a new TonemapPostProcess
  139453. * @param name defines the name of the postprocess
  139454. * @param _operator defines the operator to use
  139455. * @param exposureAdjustment defines the required exposure adjustement
  139456. * @param camera defines the camera to use (can be null)
  139457. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  139458. * @param engine defines the hosting engine (can be ignore if camera is set)
  139459. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139460. */
  139461. constructor(name: string, _operator: TonemappingOperator,
  139462. /** Defines the required exposure adjustement */
  139463. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  139464. }
  139465. }
  139466. declare module BABYLON {
  139467. /** @hidden */
  139468. export var volumetricLightScatteringPixelShader: {
  139469. name: string;
  139470. shader: string;
  139471. };
  139472. }
  139473. declare module BABYLON {
  139474. /** @hidden */
  139475. export var volumetricLightScatteringPassVertexShader: {
  139476. name: string;
  139477. shader: string;
  139478. };
  139479. }
  139480. declare module BABYLON {
  139481. /** @hidden */
  139482. export var volumetricLightScatteringPassPixelShader: {
  139483. name: string;
  139484. shader: string;
  139485. };
  139486. }
  139487. declare module BABYLON {
  139488. /**
  139489. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  139490. */
  139491. export class VolumetricLightScatteringPostProcess extends PostProcess {
  139492. private _volumetricLightScatteringPass;
  139493. private _volumetricLightScatteringRTT;
  139494. private _viewPort;
  139495. private _screenCoordinates;
  139496. private _cachedDefines;
  139497. /**
  139498. * If not undefined, the mesh position is computed from the attached node position
  139499. */
  139500. attachedNode: {
  139501. position: Vector3;
  139502. };
  139503. /**
  139504. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  139505. */
  139506. customMeshPosition: Vector3;
  139507. /**
  139508. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  139509. */
  139510. useCustomMeshPosition: boolean;
  139511. /**
  139512. * If the post-process should inverse the light scattering direction
  139513. */
  139514. invert: boolean;
  139515. /**
  139516. * The internal mesh used by the post-process
  139517. */
  139518. mesh: Mesh;
  139519. /**
  139520. * @hidden
  139521. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  139522. */
  139523. get useDiffuseColor(): boolean;
  139524. set useDiffuseColor(useDiffuseColor: boolean);
  139525. /**
  139526. * Array containing the excluded meshes not rendered in the internal pass
  139527. */
  139528. excludedMeshes: AbstractMesh[];
  139529. /**
  139530. * Controls the overall intensity of the post-process
  139531. */
  139532. exposure: number;
  139533. /**
  139534. * Dissipates each sample's contribution in range [0, 1]
  139535. */
  139536. decay: number;
  139537. /**
  139538. * Controls the overall intensity of each sample
  139539. */
  139540. weight: number;
  139541. /**
  139542. * Controls the density of each sample
  139543. */
  139544. density: number;
  139545. /**
  139546. * @constructor
  139547. * @param name The post-process name
  139548. * @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)
  139549. * @param camera The camera that the post-process will be attached to
  139550. * @param mesh The mesh used to create the light scattering
  139551. * @param samples The post-process quality, default 100
  139552. * @param samplingModeThe post-process filtering mode
  139553. * @param engine The babylon engine
  139554. * @param reusable If the post-process is reusable
  139555. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  139556. */
  139557. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  139558. /**
  139559. * Returns the string "VolumetricLightScatteringPostProcess"
  139560. * @returns "VolumetricLightScatteringPostProcess"
  139561. */
  139562. getClassName(): string;
  139563. private _isReady;
  139564. /**
  139565. * Sets the new light position for light scattering effect
  139566. * @param position The new custom light position
  139567. */
  139568. setCustomMeshPosition(position: Vector3): void;
  139569. /**
  139570. * Returns the light position for light scattering effect
  139571. * @return Vector3 The custom light position
  139572. */
  139573. getCustomMeshPosition(): Vector3;
  139574. /**
  139575. * Disposes the internal assets and detaches the post-process from the camera
  139576. */
  139577. dispose(camera: Camera): void;
  139578. /**
  139579. * Returns the render target texture used by the post-process
  139580. * @return the render target texture used by the post-process
  139581. */
  139582. getPass(): RenderTargetTexture;
  139583. private _meshExcluded;
  139584. private _createPass;
  139585. private _updateMeshScreenCoordinates;
  139586. /**
  139587. * Creates a default mesh for the Volumeric Light Scattering post-process
  139588. * @param name The mesh name
  139589. * @param scene The scene where to create the mesh
  139590. * @return the default mesh
  139591. */
  139592. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  139593. }
  139594. }
  139595. declare module BABYLON {
  139596. interface Scene {
  139597. /** @hidden (Backing field) */
  139598. _boundingBoxRenderer: BoundingBoxRenderer;
  139599. /** @hidden (Backing field) */
  139600. _forceShowBoundingBoxes: boolean;
  139601. /**
  139602. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  139603. */
  139604. forceShowBoundingBoxes: boolean;
  139605. /**
  139606. * Gets the bounding box renderer associated with the scene
  139607. * @returns a BoundingBoxRenderer
  139608. */
  139609. getBoundingBoxRenderer(): BoundingBoxRenderer;
  139610. }
  139611. interface AbstractMesh {
  139612. /** @hidden (Backing field) */
  139613. _showBoundingBox: boolean;
  139614. /**
  139615. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  139616. */
  139617. showBoundingBox: boolean;
  139618. }
  139619. /**
  139620. * Component responsible of rendering the bounding box of the meshes in a scene.
  139621. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  139622. */
  139623. export class BoundingBoxRenderer implements ISceneComponent {
  139624. /**
  139625. * The component name helpfull to identify the component in the list of scene components.
  139626. */
  139627. readonly name: string;
  139628. /**
  139629. * The scene the component belongs to.
  139630. */
  139631. scene: Scene;
  139632. /**
  139633. * Color of the bounding box lines placed in front of an object
  139634. */
  139635. frontColor: Color3;
  139636. /**
  139637. * Color of the bounding box lines placed behind an object
  139638. */
  139639. backColor: Color3;
  139640. /**
  139641. * Defines if the renderer should show the back lines or not
  139642. */
  139643. showBackLines: boolean;
  139644. /**
  139645. * @hidden
  139646. */
  139647. renderList: SmartArray<BoundingBox>;
  139648. private _colorShader;
  139649. private _vertexBuffers;
  139650. private _indexBuffer;
  139651. private _fillIndexBuffer;
  139652. private _fillIndexData;
  139653. /**
  139654. * Instantiates a new bounding box renderer in a scene.
  139655. * @param scene the scene the renderer renders in
  139656. */
  139657. constructor(scene: Scene);
  139658. /**
  139659. * Registers the component in a given scene
  139660. */
  139661. register(): void;
  139662. private _evaluateSubMesh;
  139663. private _activeMesh;
  139664. private _prepareRessources;
  139665. private _createIndexBuffer;
  139666. /**
  139667. * Rebuilds the elements related to this component in case of
  139668. * context lost for instance.
  139669. */
  139670. rebuild(): void;
  139671. /**
  139672. * @hidden
  139673. */
  139674. reset(): void;
  139675. /**
  139676. * Render the bounding boxes of a specific rendering group
  139677. * @param renderingGroupId defines the rendering group to render
  139678. */
  139679. render(renderingGroupId: number): void;
  139680. /**
  139681. * In case of occlusion queries, we can render the occlusion bounding box through this method
  139682. * @param mesh Define the mesh to render the occlusion bounding box for
  139683. */
  139684. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  139685. /**
  139686. * Dispose and release the resources attached to this renderer.
  139687. */
  139688. dispose(): void;
  139689. }
  139690. }
  139691. declare module BABYLON {
  139692. interface Scene {
  139693. /** @hidden (Backing field) */
  139694. _depthRenderer: {
  139695. [id: string]: DepthRenderer;
  139696. };
  139697. /**
  139698. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  139699. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  139700. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139701. * @returns the created depth renderer
  139702. */
  139703. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  139704. /**
  139705. * Disables a depth renderer for a given camera
  139706. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  139707. */
  139708. disableDepthRenderer(camera?: Nullable<Camera>): void;
  139709. }
  139710. /**
  139711. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  139712. * in several rendering techniques.
  139713. */
  139714. export class DepthRendererSceneComponent implements ISceneComponent {
  139715. /**
  139716. * The component name helpfull to identify the component in the list of scene components.
  139717. */
  139718. readonly name: string;
  139719. /**
  139720. * The scene the component belongs to.
  139721. */
  139722. scene: Scene;
  139723. /**
  139724. * Creates a new instance of the component for the given scene
  139725. * @param scene Defines the scene to register the component in
  139726. */
  139727. constructor(scene: Scene);
  139728. /**
  139729. * Registers the component in a given scene
  139730. */
  139731. register(): void;
  139732. /**
  139733. * Rebuilds the elements related to this component in case of
  139734. * context lost for instance.
  139735. */
  139736. rebuild(): void;
  139737. /**
  139738. * Disposes the component and the associated ressources
  139739. */
  139740. dispose(): void;
  139741. private _gatherRenderTargets;
  139742. private _gatherActiveCameraRenderTargets;
  139743. }
  139744. }
  139745. declare module BABYLON {
  139746. /** @hidden */
  139747. export var outlinePixelShader: {
  139748. name: string;
  139749. shader: string;
  139750. };
  139751. }
  139752. declare module BABYLON {
  139753. /** @hidden */
  139754. export var outlineVertexShader: {
  139755. name: string;
  139756. shader: string;
  139757. };
  139758. }
  139759. declare module BABYLON {
  139760. interface Scene {
  139761. /** @hidden */
  139762. _outlineRenderer: OutlineRenderer;
  139763. /**
  139764. * Gets the outline renderer associated with the scene
  139765. * @returns a OutlineRenderer
  139766. */
  139767. getOutlineRenderer(): OutlineRenderer;
  139768. }
  139769. interface AbstractMesh {
  139770. /** @hidden (Backing field) */
  139771. _renderOutline: boolean;
  139772. /**
  139773. * Gets or sets a boolean indicating if the outline must be rendered as well
  139774. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  139775. */
  139776. renderOutline: boolean;
  139777. /** @hidden (Backing field) */
  139778. _renderOverlay: boolean;
  139779. /**
  139780. * Gets or sets a boolean indicating if the overlay must be rendered as well
  139781. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  139782. */
  139783. renderOverlay: boolean;
  139784. }
  139785. /**
  139786. * This class is responsible to draw bothe outline/overlay of meshes.
  139787. * It should not be used directly but through the available method on mesh.
  139788. */
  139789. export class OutlineRenderer implements ISceneComponent {
  139790. /**
  139791. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  139792. */
  139793. private static _StencilReference;
  139794. /**
  139795. * The name of the component. Each component must have a unique name.
  139796. */
  139797. name: string;
  139798. /**
  139799. * The scene the component belongs to.
  139800. */
  139801. scene: Scene;
  139802. /**
  139803. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  139804. */
  139805. zOffset: number;
  139806. private _engine;
  139807. private _effect;
  139808. private _cachedDefines;
  139809. private _savedDepthWrite;
  139810. /**
  139811. * Instantiates a new outline renderer. (There could be only one per scene).
  139812. * @param scene Defines the scene it belongs to
  139813. */
  139814. constructor(scene: Scene);
  139815. /**
  139816. * Register the component to one instance of a scene.
  139817. */
  139818. register(): void;
  139819. /**
  139820. * Rebuilds the elements related to this component in case of
  139821. * context lost for instance.
  139822. */
  139823. rebuild(): void;
  139824. /**
  139825. * Disposes the component and the associated ressources.
  139826. */
  139827. dispose(): void;
  139828. /**
  139829. * Renders the outline in the canvas.
  139830. * @param subMesh Defines the sumesh to render
  139831. * @param batch Defines the batch of meshes in case of instances
  139832. * @param useOverlay Defines if the rendering is for the overlay or the outline
  139833. */
  139834. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  139835. /**
  139836. * Returns whether or not the outline renderer is ready for a given submesh.
  139837. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  139838. * @param subMesh Defines the submesh to check readyness for
  139839. * @param useInstances Defines wheter wee are trying to render instances or not
  139840. * @returns true if ready otherwise false
  139841. */
  139842. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139843. private _beforeRenderingMesh;
  139844. private _afterRenderingMesh;
  139845. }
  139846. }
  139847. declare module BABYLON {
  139848. /**
  139849. * Defines the basic options interface of a Sprite Frame Source Size.
  139850. */
  139851. export interface ISpriteJSONSpriteSourceSize {
  139852. /**
  139853. * number of the original width of the Frame
  139854. */
  139855. w: number;
  139856. /**
  139857. * number of the original height of the Frame
  139858. */
  139859. h: number;
  139860. }
  139861. /**
  139862. * Defines the basic options interface of a Sprite Frame Data.
  139863. */
  139864. export interface ISpriteJSONSpriteFrameData {
  139865. /**
  139866. * number of the x offset of the Frame
  139867. */
  139868. x: number;
  139869. /**
  139870. * number of the y offset of the Frame
  139871. */
  139872. y: number;
  139873. /**
  139874. * number of the width of the Frame
  139875. */
  139876. w: number;
  139877. /**
  139878. * number of the height of the Frame
  139879. */
  139880. h: number;
  139881. }
  139882. /**
  139883. * Defines the basic options interface of a JSON Sprite.
  139884. */
  139885. export interface ISpriteJSONSprite {
  139886. /**
  139887. * string name of the Frame
  139888. */
  139889. filename: string;
  139890. /**
  139891. * ISpriteJSONSpriteFrame basic object of the frame data
  139892. */
  139893. frame: ISpriteJSONSpriteFrameData;
  139894. /**
  139895. * boolean to flag is the frame was rotated.
  139896. */
  139897. rotated: boolean;
  139898. /**
  139899. * boolean to flag is the frame was trimmed.
  139900. */
  139901. trimmed: boolean;
  139902. /**
  139903. * ISpriteJSONSpriteFrame basic object of the source data
  139904. */
  139905. spriteSourceSize: ISpriteJSONSpriteFrameData;
  139906. /**
  139907. * ISpriteJSONSpriteFrame basic object of the source data
  139908. */
  139909. sourceSize: ISpriteJSONSpriteSourceSize;
  139910. }
  139911. /**
  139912. * Defines the basic options interface of a JSON atlas.
  139913. */
  139914. export interface ISpriteJSONAtlas {
  139915. /**
  139916. * Array of objects that contain the frame data.
  139917. */
  139918. frames: Array<ISpriteJSONSprite>;
  139919. /**
  139920. * object basic object containing the sprite meta data.
  139921. */
  139922. meta?: object;
  139923. }
  139924. }
  139925. declare module BABYLON {
  139926. /** @hidden */
  139927. export var spriteMapPixelShader: {
  139928. name: string;
  139929. shader: string;
  139930. };
  139931. }
  139932. declare module BABYLON {
  139933. /** @hidden */
  139934. export var spriteMapVertexShader: {
  139935. name: string;
  139936. shader: string;
  139937. };
  139938. }
  139939. declare module BABYLON {
  139940. /**
  139941. * Defines the basic options interface of a SpriteMap
  139942. */
  139943. export interface ISpriteMapOptions {
  139944. /**
  139945. * Vector2 of the number of cells in the grid.
  139946. */
  139947. stageSize?: Vector2;
  139948. /**
  139949. * Vector2 of the size of the output plane in World Units.
  139950. */
  139951. outputSize?: Vector2;
  139952. /**
  139953. * Vector3 of the position of the output plane in World Units.
  139954. */
  139955. outputPosition?: Vector3;
  139956. /**
  139957. * Vector3 of the rotation of the output plane.
  139958. */
  139959. outputRotation?: Vector3;
  139960. /**
  139961. * number of layers that the system will reserve in resources.
  139962. */
  139963. layerCount?: number;
  139964. /**
  139965. * number of max animation frames a single cell will reserve in resources.
  139966. */
  139967. maxAnimationFrames?: number;
  139968. /**
  139969. * number cell index of the base tile when the system compiles.
  139970. */
  139971. baseTile?: number;
  139972. /**
  139973. * boolean flip the sprite after its been repositioned by the framing data.
  139974. */
  139975. flipU?: boolean;
  139976. /**
  139977. * Vector3 scalar of the global RGB values of the SpriteMap.
  139978. */
  139979. colorMultiply?: Vector3;
  139980. }
  139981. /**
  139982. * Defines the IDisposable interface in order to be cleanable from resources.
  139983. */
  139984. export interface ISpriteMap extends IDisposable {
  139985. /**
  139986. * String name of the SpriteMap.
  139987. */
  139988. name: string;
  139989. /**
  139990. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  139991. */
  139992. atlasJSON: ISpriteJSONAtlas;
  139993. /**
  139994. * Texture of the SpriteMap.
  139995. */
  139996. spriteSheet: Texture;
  139997. /**
  139998. * The parameters to initialize the SpriteMap with.
  139999. */
  140000. options: ISpriteMapOptions;
  140001. }
  140002. /**
  140003. * Class used to manage a grid restricted sprite deployment on an Output plane.
  140004. */
  140005. export class SpriteMap implements ISpriteMap {
  140006. /** The Name of the spriteMap */
  140007. name: string;
  140008. /** The JSON file with the frame and meta data */
  140009. atlasJSON: ISpriteJSONAtlas;
  140010. /** The systems Sprite Sheet Texture */
  140011. spriteSheet: Texture;
  140012. /** Arguments passed with the Constructor */
  140013. options: ISpriteMapOptions;
  140014. /** Public Sprite Storage array, parsed from atlasJSON */
  140015. sprites: Array<ISpriteJSONSprite>;
  140016. /** Returns the Number of Sprites in the System */
  140017. get spriteCount(): number;
  140018. /** Returns the Position of Output Plane*/
  140019. get position(): Vector3;
  140020. /** Returns the Position of Output Plane*/
  140021. set position(v: Vector3);
  140022. /** Returns the Rotation of Output Plane*/
  140023. get rotation(): Vector3;
  140024. /** Returns the Rotation of Output Plane*/
  140025. set rotation(v: Vector3);
  140026. /** Sets the AnimationMap*/
  140027. get animationMap(): RawTexture;
  140028. /** Sets the AnimationMap*/
  140029. set animationMap(v: RawTexture);
  140030. /** Scene that the SpriteMap was created in */
  140031. private _scene;
  140032. /** Texture Buffer of Float32 that holds tile frame data*/
  140033. private _frameMap;
  140034. /** Texture Buffers of Float32 that holds tileMap data*/
  140035. private _tileMaps;
  140036. /** Texture Buffer of Float32 that holds Animation Data*/
  140037. private _animationMap;
  140038. /** Custom ShaderMaterial Central to the System*/
  140039. private _material;
  140040. /** Custom ShaderMaterial Central to the System*/
  140041. private _output;
  140042. /** Systems Time Ticker*/
  140043. private _time;
  140044. /**
  140045. * Creates a new SpriteMap
  140046. * @param name defines the SpriteMaps Name
  140047. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  140048. * @param spriteSheet is the Texture that the Sprites are on.
  140049. * @param options a basic deployment configuration
  140050. * @param scene The Scene that the map is deployed on
  140051. */
  140052. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  140053. /**
  140054. * Returns tileID location
  140055. * @returns Vector2 the cell position ID
  140056. */
  140057. getTileID(): Vector2;
  140058. /**
  140059. * Gets the UV location of the mouse over the SpriteMap.
  140060. * @returns Vector2 the UV position of the mouse interaction
  140061. */
  140062. getMousePosition(): Vector2;
  140063. /**
  140064. * Creates the "frame" texture Buffer
  140065. * -------------------------------------
  140066. * Structure of frames
  140067. * "filename": "Falling-Water-2.png",
  140068. * "frame": {"x":69,"y":103,"w":24,"h":32},
  140069. * "rotated": true,
  140070. * "trimmed": true,
  140071. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  140072. * "sourceSize": {"w":32,"h":32}
  140073. * @returns RawTexture of the frameMap
  140074. */
  140075. private _createFrameBuffer;
  140076. /**
  140077. * Creates the tileMap texture Buffer
  140078. * @param buffer normally and array of numbers, or a false to generate from scratch
  140079. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  140080. * @returns RawTexture of the tileMap
  140081. */
  140082. private _createTileBuffer;
  140083. /**
  140084. * Modifies the data of the tileMaps
  140085. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  140086. * @param pos is the iVector2 Coordinates of the Tile
  140087. * @param tile The SpriteIndex of the new Tile
  140088. */
  140089. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  140090. /**
  140091. * Creates the animationMap texture Buffer
  140092. * @param buffer normally and array of numbers, or a false to generate from scratch
  140093. * @returns RawTexture of the animationMap
  140094. */
  140095. private _createTileAnimationBuffer;
  140096. /**
  140097. * Modifies the data of the animationMap
  140098. * @param cellID is the Index of the Sprite
  140099. * @param _frame is the target Animation frame
  140100. * @param toCell is the Target Index of the next frame of the animation
  140101. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  140102. * @param speed is a global scalar of the time variable on the map.
  140103. */
  140104. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  140105. /**
  140106. * Exports the .tilemaps file
  140107. */
  140108. saveTileMaps(): void;
  140109. /**
  140110. * Imports the .tilemaps file
  140111. * @param url of the .tilemaps file
  140112. */
  140113. loadTileMaps(url: string): void;
  140114. /**
  140115. * Release associated resources
  140116. */
  140117. dispose(): void;
  140118. }
  140119. }
  140120. declare module BABYLON {
  140121. /**
  140122. * Class used to manage multiple sprites of different sizes on the same spritesheet
  140123. * @see http://doc.babylonjs.com/babylon101/sprites
  140124. */
  140125. export class SpritePackedManager extends SpriteManager {
  140126. /** defines the packed manager's name */
  140127. name: string;
  140128. /**
  140129. * Creates a new sprite manager from a packed sprite sheet
  140130. * @param name defines the manager's name
  140131. * @param imgUrl defines the sprite sheet url
  140132. * @param capacity defines the maximum allowed number of sprites
  140133. * @param scene defines the hosting scene
  140134. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  140135. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  140136. * @param samplingMode defines the smapling mode to use with spritesheet
  140137. * @param fromPacked set to true; do not alter
  140138. */
  140139. constructor(
  140140. /** defines the packed manager's name */
  140141. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  140142. }
  140143. }
  140144. declare module BABYLON {
  140145. /**
  140146. * Defines the list of states available for a task inside a AssetsManager
  140147. */
  140148. export enum AssetTaskState {
  140149. /**
  140150. * Initialization
  140151. */
  140152. INIT = 0,
  140153. /**
  140154. * Running
  140155. */
  140156. RUNNING = 1,
  140157. /**
  140158. * Done
  140159. */
  140160. DONE = 2,
  140161. /**
  140162. * Error
  140163. */
  140164. ERROR = 3
  140165. }
  140166. /**
  140167. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  140168. */
  140169. export abstract class AbstractAssetTask {
  140170. /**
  140171. * Task name
  140172. */ name: string;
  140173. /**
  140174. * Callback called when the task is successful
  140175. */
  140176. onSuccess: (task: any) => void;
  140177. /**
  140178. * Callback called when the task is not successful
  140179. */
  140180. onError: (task: any, message?: string, exception?: any) => void;
  140181. /**
  140182. * Creates a new AssetsManager
  140183. * @param name defines the name of the task
  140184. */
  140185. constructor(
  140186. /**
  140187. * Task name
  140188. */ name: string);
  140189. private _isCompleted;
  140190. private _taskState;
  140191. private _errorObject;
  140192. /**
  140193. * Get if the task is completed
  140194. */
  140195. get isCompleted(): boolean;
  140196. /**
  140197. * Gets the current state of the task
  140198. */
  140199. get taskState(): AssetTaskState;
  140200. /**
  140201. * Gets the current error object (if task is in error)
  140202. */
  140203. get errorObject(): {
  140204. message?: string;
  140205. exception?: any;
  140206. };
  140207. /**
  140208. * Internal only
  140209. * @hidden
  140210. */
  140211. _setErrorObject(message?: string, exception?: any): void;
  140212. /**
  140213. * Execute the current task
  140214. * @param scene defines the scene where you want your assets to be loaded
  140215. * @param onSuccess is a callback called when the task is successfully executed
  140216. * @param onError is a callback called if an error occurs
  140217. */
  140218. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140219. /**
  140220. * Execute the current task
  140221. * @param scene defines the scene where you want your assets to be loaded
  140222. * @param onSuccess is a callback called when the task is successfully executed
  140223. * @param onError is a callback called if an error occurs
  140224. */
  140225. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140226. /**
  140227. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  140228. * This can be used with failed tasks that have the reason for failure fixed.
  140229. */
  140230. reset(): void;
  140231. private onErrorCallback;
  140232. private onDoneCallback;
  140233. }
  140234. /**
  140235. * Define the interface used by progress events raised during assets loading
  140236. */
  140237. export interface IAssetsProgressEvent {
  140238. /**
  140239. * Defines the number of remaining tasks to process
  140240. */
  140241. remainingCount: number;
  140242. /**
  140243. * Defines the total number of tasks
  140244. */
  140245. totalCount: number;
  140246. /**
  140247. * Defines the task that was just processed
  140248. */
  140249. task: AbstractAssetTask;
  140250. }
  140251. /**
  140252. * Class used to share progress information about assets loading
  140253. */
  140254. export class AssetsProgressEvent implements IAssetsProgressEvent {
  140255. /**
  140256. * Defines the number of remaining tasks to process
  140257. */
  140258. remainingCount: number;
  140259. /**
  140260. * Defines the total number of tasks
  140261. */
  140262. totalCount: number;
  140263. /**
  140264. * Defines the task that was just processed
  140265. */
  140266. task: AbstractAssetTask;
  140267. /**
  140268. * Creates a AssetsProgressEvent
  140269. * @param remainingCount defines the number of remaining tasks to process
  140270. * @param totalCount defines the total number of tasks
  140271. * @param task defines the task that was just processed
  140272. */
  140273. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  140274. }
  140275. /**
  140276. * Define a task used by AssetsManager to load meshes
  140277. */
  140278. export class MeshAssetTask extends AbstractAssetTask {
  140279. /**
  140280. * Defines the name of the task
  140281. */
  140282. name: string;
  140283. /**
  140284. * Defines the list of mesh's names you want to load
  140285. */
  140286. meshesNames: any;
  140287. /**
  140288. * Defines the root url to use as a base to load your meshes and associated resources
  140289. */
  140290. rootUrl: string;
  140291. /**
  140292. * Defines the filename of the scene to load from
  140293. */
  140294. sceneFilename: string;
  140295. /**
  140296. * Gets the list of loaded meshes
  140297. */
  140298. loadedMeshes: Array<AbstractMesh>;
  140299. /**
  140300. * Gets the list of loaded particle systems
  140301. */
  140302. loadedParticleSystems: Array<IParticleSystem>;
  140303. /**
  140304. * Gets the list of loaded skeletons
  140305. */
  140306. loadedSkeletons: Array<Skeleton>;
  140307. /**
  140308. * Gets the list of loaded animation groups
  140309. */
  140310. loadedAnimationGroups: Array<AnimationGroup>;
  140311. /**
  140312. * Callback called when the task is successful
  140313. */
  140314. onSuccess: (task: MeshAssetTask) => void;
  140315. /**
  140316. * Callback called when the task is successful
  140317. */
  140318. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  140319. /**
  140320. * Creates a new MeshAssetTask
  140321. * @param name defines the name of the task
  140322. * @param meshesNames defines the list of mesh's names you want to load
  140323. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  140324. * @param sceneFilename defines the filename of the scene to load from
  140325. */
  140326. constructor(
  140327. /**
  140328. * Defines the name of the task
  140329. */
  140330. name: string,
  140331. /**
  140332. * Defines the list of mesh's names you want to load
  140333. */
  140334. meshesNames: any,
  140335. /**
  140336. * Defines the root url to use as a base to load your meshes and associated resources
  140337. */
  140338. rootUrl: string,
  140339. /**
  140340. * Defines the filename of the scene to load from
  140341. */
  140342. sceneFilename: string);
  140343. /**
  140344. * Execute the current task
  140345. * @param scene defines the scene where you want your assets to be loaded
  140346. * @param onSuccess is a callback called when the task is successfully executed
  140347. * @param onError is a callback called if an error occurs
  140348. */
  140349. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140350. }
  140351. /**
  140352. * Define a task used by AssetsManager to load text content
  140353. */
  140354. export class TextFileAssetTask extends AbstractAssetTask {
  140355. /**
  140356. * Defines the name of the task
  140357. */
  140358. name: string;
  140359. /**
  140360. * Defines the location of the file to load
  140361. */
  140362. url: string;
  140363. /**
  140364. * Gets the loaded text string
  140365. */
  140366. text: string;
  140367. /**
  140368. * Callback called when the task is successful
  140369. */
  140370. onSuccess: (task: TextFileAssetTask) => void;
  140371. /**
  140372. * Callback called when the task is successful
  140373. */
  140374. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  140375. /**
  140376. * Creates a new TextFileAssetTask object
  140377. * @param name defines the name of the task
  140378. * @param url defines the location of the file to load
  140379. */
  140380. constructor(
  140381. /**
  140382. * Defines the name of the task
  140383. */
  140384. name: string,
  140385. /**
  140386. * Defines the location of the file to load
  140387. */
  140388. url: string);
  140389. /**
  140390. * Execute the current task
  140391. * @param scene defines the scene where you want your assets to be loaded
  140392. * @param onSuccess is a callback called when the task is successfully executed
  140393. * @param onError is a callback called if an error occurs
  140394. */
  140395. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140396. }
  140397. /**
  140398. * Define a task used by AssetsManager to load binary data
  140399. */
  140400. export class BinaryFileAssetTask extends AbstractAssetTask {
  140401. /**
  140402. * Defines the name of the task
  140403. */
  140404. name: string;
  140405. /**
  140406. * Defines the location of the file to load
  140407. */
  140408. url: string;
  140409. /**
  140410. * Gets the lodaded data (as an array buffer)
  140411. */
  140412. data: ArrayBuffer;
  140413. /**
  140414. * Callback called when the task is successful
  140415. */
  140416. onSuccess: (task: BinaryFileAssetTask) => void;
  140417. /**
  140418. * Callback called when the task is successful
  140419. */
  140420. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  140421. /**
  140422. * Creates a new BinaryFileAssetTask object
  140423. * @param name defines the name of the new task
  140424. * @param url defines the location of the file to load
  140425. */
  140426. constructor(
  140427. /**
  140428. * Defines the name of the task
  140429. */
  140430. name: string,
  140431. /**
  140432. * Defines the location of the file to load
  140433. */
  140434. url: string);
  140435. /**
  140436. * Execute the current task
  140437. * @param scene defines the scene where you want your assets to be loaded
  140438. * @param onSuccess is a callback called when the task is successfully executed
  140439. * @param onError is a callback called if an error occurs
  140440. */
  140441. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140442. }
  140443. /**
  140444. * Define a task used by AssetsManager to load images
  140445. */
  140446. export class ImageAssetTask extends AbstractAssetTask {
  140447. /**
  140448. * Defines the name of the task
  140449. */
  140450. name: string;
  140451. /**
  140452. * Defines the location of the image to load
  140453. */
  140454. url: string;
  140455. /**
  140456. * Gets the loaded images
  140457. */
  140458. image: HTMLImageElement;
  140459. /**
  140460. * Callback called when the task is successful
  140461. */
  140462. onSuccess: (task: ImageAssetTask) => void;
  140463. /**
  140464. * Callback called when the task is successful
  140465. */
  140466. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  140467. /**
  140468. * Creates a new ImageAssetTask
  140469. * @param name defines the name of the task
  140470. * @param url defines the location of the image to load
  140471. */
  140472. constructor(
  140473. /**
  140474. * Defines the name of the task
  140475. */
  140476. name: string,
  140477. /**
  140478. * Defines the location of the image to load
  140479. */
  140480. url: string);
  140481. /**
  140482. * Execute the current task
  140483. * @param scene defines the scene where you want your assets to be loaded
  140484. * @param onSuccess is a callback called when the task is successfully executed
  140485. * @param onError is a callback called if an error occurs
  140486. */
  140487. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140488. }
  140489. /**
  140490. * Defines the interface used by texture loading tasks
  140491. */
  140492. export interface ITextureAssetTask<TEX extends BaseTexture> {
  140493. /**
  140494. * Gets the loaded texture
  140495. */
  140496. texture: TEX;
  140497. }
  140498. /**
  140499. * Define a task used by AssetsManager to load 2D textures
  140500. */
  140501. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  140502. /**
  140503. * Defines the name of the task
  140504. */
  140505. name: string;
  140506. /**
  140507. * Defines the location of the file to load
  140508. */
  140509. url: string;
  140510. /**
  140511. * Defines if mipmap should not be generated (default is false)
  140512. */
  140513. noMipmap?: boolean | undefined;
  140514. /**
  140515. * Defines if texture must be inverted on Y axis (default is false)
  140516. */
  140517. invertY?: boolean | undefined;
  140518. /**
  140519. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140520. */
  140521. samplingMode: number;
  140522. /**
  140523. * Gets the loaded texture
  140524. */
  140525. texture: Texture;
  140526. /**
  140527. * Callback called when the task is successful
  140528. */
  140529. onSuccess: (task: TextureAssetTask) => void;
  140530. /**
  140531. * Callback called when the task is successful
  140532. */
  140533. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  140534. /**
  140535. * Creates a new TextureAssetTask object
  140536. * @param name defines the name of the task
  140537. * @param url defines the location of the file to load
  140538. * @param noMipmap defines if mipmap should not be generated (default is false)
  140539. * @param invertY defines if texture must be inverted on Y axis (default is false)
  140540. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140541. */
  140542. constructor(
  140543. /**
  140544. * Defines the name of the task
  140545. */
  140546. name: string,
  140547. /**
  140548. * Defines the location of the file to load
  140549. */
  140550. url: string,
  140551. /**
  140552. * Defines if mipmap should not be generated (default is false)
  140553. */
  140554. noMipmap?: boolean | undefined,
  140555. /**
  140556. * Defines if texture must be inverted on Y axis (default is false)
  140557. */
  140558. invertY?: boolean | undefined,
  140559. /**
  140560. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140561. */
  140562. samplingMode?: number);
  140563. /**
  140564. * Execute the current task
  140565. * @param scene defines the scene where you want your assets to be loaded
  140566. * @param onSuccess is a callback called when the task is successfully executed
  140567. * @param onError is a callback called if an error occurs
  140568. */
  140569. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140570. }
  140571. /**
  140572. * Define a task used by AssetsManager to load cube textures
  140573. */
  140574. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  140575. /**
  140576. * Defines the name of the task
  140577. */
  140578. name: string;
  140579. /**
  140580. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140581. */
  140582. url: string;
  140583. /**
  140584. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140585. */
  140586. extensions?: string[] | undefined;
  140587. /**
  140588. * Defines if mipmaps should not be generated (default is false)
  140589. */
  140590. noMipmap?: boolean | undefined;
  140591. /**
  140592. * Defines the explicit list of files (undefined by default)
  140593. */
  140594. files?: string[] | undefined;
  140595. /**
  140596. * Gets the loaded texture
  140597. */
  140598. texture: CubeTexture;
  140599. /**
  140600. * Callback called when the task is successful
  140601. */
  140602. onSuccess: (task: CubeTextureAssetTask) => void;
  140603. /**
  140604. * Callback called when the task is successful
  140605. */
  140606. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  140607. /**
  140608. * Creates a new CubeTextureAssetTask
  140609. * @param name defines the name of the task
  140610. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140611. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140612. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140613. * @param files defines the explicit list of files (undefined by default)
  140614. */
  140615. constructor(
  140616. /**
  140617. * Defines the name of the task
  140618. */
  140619. name: string,
  140620. /**
  140621. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140622. */
  140623. url: string,
  140624. /**
  140625. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140626. */
  140627. extensions?: string[] | undefined,
  140628. /**
  140629. * Defines if mipmaps should not be generated (default is false)
  140630. */
  140631. noMipmap?: boolean | undefined,
  140632. /**
  140633. * Defines the explicit list of files (undefined by default)
  140634. */
  140635. files?: string[] | undefined);
  140636. /**
  140637. * Execute the current task
  140638. * @param scene defines the scene where you want your assets to be loaded
  140639. * @param onSuccess is a callback called when the task is successfully executed
  140640. * @param onError is a callback called if an error occurs
  140641. */
  140642. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140643. }
  140644. /**
  140645. * Define a task used by AssetsManager to load HDR cube textures
  140646. */
  140647. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  140648. /**
  140649. * Defines the name of the task
  140650. */
  140651. name: string;
  140652. /**
  140653. * Defines the location of the file to load
  140654. */
  140655. url: string;
  140656. /**
  140657. * Defines the desired size (the more it increases the longer the generation will be)
  140658. */
  140659. size: number;
  140660. /**
  140661. * Defines if mipmaps should not be generated (default is false)
  140662. */
  140663. noMipmap: boolean;
  140664. /**
  140665. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140666. */
  140667. generateHarmonics: boolean;
  140668. /**
  140669. * 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)
  140670. */
  140671. gammaSpace: boolean;
  140672. /**
  140673. * Internal Use Only
  140674. */
  140675. reserved: boolean;
  140676. /**
  140677. * Gets the loaded texture
  140678. */
  140679. texture: HDRCubeTexture;
  140680. /**
  140681. * Callback called when the task is successful
  140682. */
  140683. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  140684. /**
  140685. * Callback called when the task is successful
  140686. */
  140687. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  140688. /**
  140689. * Creates a new HDRCubeTextureAssetTask object
  140690. * @param name defines the name of the task
  140691. * @param url defines the location of the file to load
  140692. * @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.
  140693. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140694. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140695. * @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)
  140696. * @param reserved Internal use only
  140697. */
  140698. constructor(
  140699. /**
  140700. * Defines the name of the task
  140701. */
  140702. name: string,
  140703. /**
  140704. * Defines the location of the file to load
  140705. */
  140706. url: string,
  140707. /**
  140708. * Defines the desired size (the more it increases the longer the generation will be)
  140709. */
  140710. size: number,
  140711. /**
  140712. * Defines if mipmaps should not be generated (default is false)
  140713. */
  140714. noMipmap?: boolean,
  140715. /**
  140716. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140717. */
  140718. generateHarmonics?: boolean,
  140719. /**
  140720. * 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)
  140721. */
  140722. gammaSpace?: boolean,
  140723. /**
  140724. * Internal Use Only
  140725. */
  140726. reserved?: boolean);
  140727. /**
  140728. * Execute the current task
  140729. * @param scene defines the scene where you want your assets to be loaded
  140730. * @param onSuccess is a callback called when the task is successfully executed
  140731. * @param onError is a callback called if an error occurs
  140732. */
  140733. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140734. }
  140735. /**
  140736. * Define a task used by AssetsManager to load Equirectangular cube textures
  140737. */
  140738. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  140739. /**
  140740. * Defines the name of the task
  140741. */
  140742. name: string;
  140743. /**
  140744. * Defines the location of the file to load
  140745. */
  140746. url: string;
  140747. /**
  140748. * Defines the desired size (the more it increases the longer the generation will be)
  140749. */
  140750. size: number;
  140751. /**
  140752. * Defines if mipmaps should not be generated (default is false)
  140753. */
  140754. noMipmap: boolean;
  140755. /**
  140756. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140757. * but the standard material would require them in Gamma space) (default is true)
  140758. */
  140759. gammaSpace: boolean;
  140760. /**
  140761. * Gets the loaded texture
  140762. */
  140763. texture: EquiRectangularCubeTexture;
  140764. /**
  140765. * Callback called when the task is successful
  140766. */
  140767. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  140768. /**
  140769. * Callback called when the task is successful
  140770. */
  140771. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  140772. /**
  140773. * Creates a new EquiRectangularCubeTextureAssetTask object
  140774. * @param name defines the name of the task
  140775. * @param url defines the location of the file to load
  140776. * @param size defines the desired size (the more it increases the longer the generation will be)
  140777. * If the size is omitted this implies you are using a preprocessed cubemap.
  140778. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140779. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  140780. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  140781. * (default is true)
  140782. */
  140783. constructor(
  140784. /**
  140785. * Defines the name of the task
  140786. */
  140787. name: string,
  140788. /**
  140789. * Defines the location of the file to load
  140790. */
  140791. url: string,
  140792. /**
  140793. * Defines the desired size (the more it increases the longer the generation will be)
  140794. */
  140795. size: number,
  140796. /**
  140797. * Defines if mipmaps should not be generated (default is false)
  140798. */
  140799. noMipmap?: boolean,
  140800. /**
  140801. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140802. * but the standard material would require them in Gamma space) (default is true)
  140803. */
  140804. gammaSpace?: boolean);
  140805. /**
  140806. * Execute the current task
  140807. * @param scene defines the scene where you want your assets to be loaded
  140808. * @param onSuccess is a callback called when the task is successfully executed
  140809. * @param onError is a callback called if an error occurs
  140810. */
  140811. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140812. }
  140813. /**
  140814. * This class can be used to easily import assets into a scene
  140815. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  140816. */
  140817. export class AssetsManager {
  140818. private _scene;
  140819. private _isLoading;
  140820. protected _tasks: AbstractAssetTask[];
  140821. protected _waitingTasksCount: number;
  140822. protected _totalTasksCount: number;
  140823. /**
  140824. * Callback called when all tasks are processed
  140825. */
  140826. onFinish: (tasks: AbstractAssetTask[]) => void;
  140827. /**
  140828. * Callback called when a task is successful
  140829. */
  140830. onTaskSuccess: (task: AbstractAssetTask) => void;
  140831. /**
  140832. * Callback called when a task had an error
  140833. */
  140834. onTaskError: (task: AbstractAssetTask) => void;
  140835. /**
  140836. * Callback called when a task is done (whatever the result is)
  140837. */
  140838. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  140839. /**
  140840. * Observable called when all tasks are processed
  140841. */
  140842. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  140843. /**
  140844. * Observable called when a task had an error
  140845. */
  140846. onTaskErrorObservable: Observable<AbstractAssetTask>;
  140847. /**
  140848. * Observable called when all tasks were executed
  140849. */
  140850. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  140851. /**
  140852. * Observable called when a task is done (whatever the result is)
  140853. */
  140854. onProgressObservable: Observable<IAssetsProgressEvent>;
  140855. /**
  140856. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  140857. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  140858. */
  140859. useDefaultLoadingScreen: boolean;
  140860. /**
  140861. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  140862. * when all assets have been downloaded.
  140863. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  140864. */
  140865. autoHideLoadingUI: boolean;
  140866. /**
  140867. * Creates a new AssetsManager
  140868. * @param scene defines the scene to work on
  140869. */
  140870. constructor(scene: Scene);
  140871. /**
  140872. * Add a MeshAssetTask to the list of active tasks
  140873. * @param taskName defines the name of the new task
  140874. * @param meshesNames defines the name of meshes to load
  140875. * @param rootUrl defines the root url to use to locate files
  140876. * @param sceneFilename defines the filename of the scene file
  140877. * @returns a new MeshAssetTask object
  140878. */
  140879. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  140880. /**
  140881. * Add a TextFileAssetTask to the list of active tasks
  140882. * @param taskName defines the name of the new task
  140883. * @param url defines the url of the file to load
  140884. * @returns a new TextFileAssetTask object
  140885. */
  140886. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  140887. /**
  140888. * Add a BinaryFileAssetTask to the list of active tasks
  140889. * @param taskName defines the name of the new task
  140890. * @param url defines the url of the file to load
  140891. * @returns a new BinaryFileAssetTask object
  140892. */
  140893. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  140894. /**
  140895. * Add a ImageAssetTask to the list of active tasks
  140896. * @param taskName defines the name of the new task
  140897. * @param url defines the url of the file to load
  140898. * @returns a new ImageAssetTask object
  140899. */
  140900. addImageTask(taskName: string, url: string): ImageAssetTask;
  140901. /**
  140902. * Add a TextureAssetTask to the list of active tasks
  140903. * @param taskName defines the name of the new task
  140904. * @param url defines the url of the file to load
  140905. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140906. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  140907. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  140908. * @returns a new TextureAssetTask object
  140909. */
  140910. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  140911. /**
  140912. * Add a CubeTextureAssetTask to the list of active tasks
  140913. * @param taskName defines the name of the new task
  140914. * @param url defines the url of the file to load
  140915. * @param extensions defines the extension to use to load the cube map (can be null)
  140916. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140917. * @param files defines the list of files to load (can be null)
  140918. * @returns a new CubeTextureAssetTask object
  140919. */
  140920. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  140921. /**
  140922. *
  140923. * Add a HDRCubeTextureAssetTask to the list of active tasks
  140924. * @param taskName defines the name of the new task
  140925. * @param url defines the url of the file to load
  140926. * @param size defines the size you want for the cubemap (can be null)
  140927. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140928. * @param generateHarmonics defines if you want to automatically generate (true by default)
  140929. * @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)
  140930. * @param reserved Internal use only
  140931. * @returns a new HDRCubeTextureAssetTask object
  140932. */
  140933. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  140934. /**
  140935. *
  140936. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  140937. * @param taskName defines the name of the new task
  140938. * @param url defines the url of the file to load
  140939. * @param size defines the size you want for the cubemap (can be null)
  140940. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  140941. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  140942. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  140943. * @returns a new EquiRectangularCubeTextureAssetTask object
  140944. */
  140945. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  140946. /**
  140947. * Remove a task from the assets manager.
  140948. * @param task the task to remove
  140949. */
  140950. removeTask(task: AbstractAssetTask): void;
  140951. private _decreaseWaitingTasksCount;
  140952. private _runTask;
  140953. /**
  140954. * Reset the AssetsManager and remove all tasks
  140955. * @return the current instance of the AssetsManager
  140956. */
  140957. reset(): AssetsManager;
  140958. /**
  140959. * Start the loading process
  140960. * @return the current instance of the AssetsManager
  140961. */
  140962. load(): AssetsManager;
  140963. /**
  140964. * Start the loading process as an async operation
  140965. * @return a promise returning the list of failed tasks
  140966. */
  140967. loadAsync(): Promise<void>;
  140968. }
  140969. }
  140970. declare module BABYLON {
  140971. /**
  140972. * Wrapper class for promise with external resolve and reject.
  140973. */
  140974. export class Deferred<T> {
  140975. /**
  140976. * The promise associated with this deferred object.
  140977. */
  140978. readonly promise: Promise<T>;
  140979. private _resolve;
  140980. private _reject;
  140981. /**
  140982. * The resolve method of the promise associated with this deferred object.
  140983. */
  140984. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  140985. /**
  140986. * The reject method of the promise associated with this deferred object.
  140987. */
  140988. get reject(): (reason?: any) => void;
  140989. /**
  140990. * Constructor for this deferred object.
  140991. */
  140992. constructor();
  140993. }
  140994. }
  140995. declare module BABYLON {
  140996. /**
  140997. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  140998. */
  140999. export class MeshExploder {
  141000. private _centerMesh;
  141001. private _meshes;
  141002. private _meshesOrigins;
  141003. private _toCenterVectors;
  141004. private _scaledDirection;
  141005. private _newPosition;
  141006. private _centerPosition;
  141007. /**
  141008. * Explodes meshes from a center mesh.
  141009. * @param meshes The meshes to explode.
  141010. * @param centerMesh The mesh to be center of explosion.
  141011. */
  141012. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  141013. private _setCenterMesh;
  141014. /**
  141015. * Get class name
  141016. * @returns "MeshExploder"
  141017. */
  141018. getClassName(): string;
  141019. /**
  141020. * "Exploded meshes"
  141021. * @returns Array of meshes with the centerMesh at index 0.
  141022. */
  141023. getMeshes(): Array<Mesh>;
  141024. /**
  141025. * Explodes meshes giving a specific direction
  141026. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  141027. */
  141028. explode(direction?: number): void;
  141029. }
  141030. }
  141031. declare module BABYLON {
  141032. /**
  141033. * Class used to help managing file picking and drag'n'drop
  141034. */
  141035. export class FilesInput {
  141036. /**
  141037. * List of files ready to be loaded
  141038. */
  141039. static get FilesToLoad(): {
  141040. [key: string]: File;
  141041. };
  141042. /**
  141043. * Callback called when a file is processed
  141044. */
  141045. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  141046. private _engine;
  141047. private _currentScene;
  141048. private _sceneLoadedCallback;
  141049. private _progressCallback;
  141050. private _additionalRenderLoopLogicCallback;
  141051. private _textureLoadingCallback;
  141052. private _startingProcessingFilesCallback;
  141053. private _onReloadCallback;
  141054. private _errorCallback;
  141055. private _elementToMonitor;
  141056. private _sceneFileToLoad;
  141057. private _filesToLoad;
  141058. /**
  141059. * Creates a new FilesInput
  141060. * @param engine defines the rendering engine
  141061. * @param scene defines the hosting scene
  141062. * @param sceneLoadedCallback callback called when scene is loaded
  141063. * @param progressCallback callback called to track progress
  141064. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  141065. * @param textureLoadingCallback callback called when a texture is loading
  141066. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  141067. * @param onReloadCallback callback called when a reload is requested
  141068. * @param errorCallback callback call if an error occurs
  141069. */
  141070. 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);
  141071. private _dragEnterHandler;
  141072. private _dragOverHandler;
  141073. private _dropHandler;
  141074. /**
  141075. * Calls this function to listen to drag'n'drop events on a specific DOM element
  141076. * @param elementToMonitor defines the DOM element to track
  141077. */
  141078. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  141079. /**
  141080. * Release all associated resources
  141081. */
  141082. dispose(): void;
  141083. private renderFunction;
  141084. private drag;
  141085. private drop;
  141086. private _traverseFolder;
  141087. private _processFiles;
  141088. /**
  141089. * Load files from a drop event
  141090. * @param event defines the drop event to use as source
  141091. */
  141092. loadFiles(event: any): void;
  141093. private _processReload;
  141094. /**
  141095. * Reload the current scene from the loaded files
  141096. */
  141097. reload(): void;
  141098. }
  141099. }
  141100. declare module BABYLON {
  141101. /**
  141102. * Defines the root class used to create scene optimization to use with SceneOptimizer
  141103. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141104. */
  141105. export class SceneOptimization {
  141106. /**
  141107. * Defines the priority of this optimization (0 by default which means first in the list)
  141108. */
  141109. priority: number;
  141110. /**
  141111. * Gets a string describing the action executed by the current optimization
  141112. * @returns description string
  141113. */
  141114. getDescription(): string;
  141115. /**
  141116. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141117. * @param scene defines the current scene where to apply this optimization
  141118. * @param optimizer defines the current optimizer
  141119. * @returns true if everything that can be done was applied
  141120. */
  141121. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141122. /**
  141123. * Creates the SceneOptimization object
  141124. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141125. * @param desc defines the description associated with the optimization
  141126. */
  141127. constructor(
  141128. /**
  141129. * Defines the priority of this optimization (0 by default which means first in the list)
  141130. */
  141131. priority?: number);
  141132. }
  141133. /**
  141134. * Defines an optimization used to reduce the size of render target textures
  141135. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141136. */
  141137. export class TextureOptimization extends SceneOptimization {
  141138. /**
  141139. * Defines the priority of this optimization (0 by default which means first in the list)
  141140. */
  141141. priority: number;
  141142. /**
  141143. * 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
  141144. */
  141145. maximumSize: number;
  141146. /**
  141147. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141148. */
  141149. step: number;
  141150. /**
  141151. * Gets a string describing the action executed by the current optimization
  141152. * @returns description string
  141153. */
  141154. getDescription(): string;
  141155. /**
  141156. * Creates the TextureOptimization object
  141157. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141158. * @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
  141159. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141160. */
  141161. constructor(
  141162. /**
  141163. * Defines the priority of this optimization (0 by default which means first in the list)
  141164. */
  141165. priority?: number,
  141166. /**
  141167. * 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
  141168. */
  141169. maximumSize?: number,
  141170. /**
  141171. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141172. */
  141173. step?: number);
  141174. /**
  141175. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141176. * @param scene defines the current scene where to apply this optimization
  141177. * @param optimizer defines the current optimizer
  141178. * @returns true if everything that can be done was applied
  141179. */
  141180. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141181. }
  141182. /**
  141183. * Defines an optimization used to increase or decrease the rendering resolution
  141184. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141185. */
  141186. export class HardwareScalingOptimization extends SceneOptimization {
  141187. /**
  141188. * Defines the priority of this optimization (0 by default which means first in the list)
  141189. */
  141190. priority: number;
  141191. /**
  141192. * Defines the maximum scale to use (2 by default)
  141193. */
  141194. maximumScale: number;
  141195. /**
  141196. * Defines the step to use between two passes (0.5 by default)
  141197. */
  141198. step: number;
  141199. private _currentScale;
  141200. private _directionOffset;
  141201. /**
  141202. * Gets a string describing the action executed by the current optimization
  141203. * @return description string
  141204. */
  141205. getDescription(): string;
  141206. /**
  141207. * Creates the HardwareScalingOptimization object
  141208. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141209. * @param maximumScale defines the maximum scale to use (2 by default)
  141210. * @param step defines the step to use between two passes (0.5 by default)
  141211. */
  141212. constructor(
  141213. /**
  141214. * Defines the priority of this optimization (0 by default which means first in the list)
  141215. */
  141216. priority?: number,
  141217. /**
  141218. * Defines the maximum scale to use (2 by default)
  141219. */
  141220. maximumScale?: number,
  141221. /**
  141222. * Defines the step to use between two passes (0.5 by default)
  141223. */
  141224. step?: number);
  141225. /**
  141226. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141227. * @param scene defines the current scene where to apply this optimization
  141228. * @param optimizer defines the current optimizer
  141229. * @returns true if everything that can be done was applied
  141230. */
  141231. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141232. }
  141233. /**
  141234. * Defines an optimization used to remove shadows
  141235. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141236. */
  141237. export class ShadowsOptimization extends SceneOptimization {
  141238. /**
  141239. * Gets a string describing the action executed by the current optimization
  141240. * @return description string
  141241. */
  141242. getDescription(): string;
  141243. /**
  141244. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141245. * @param scene defines the current scene where to apply this optimization
  141246. * @param optimizer defines the current optimizer
  141247. * @returns true if everything that can be done was applied
  141248. */
  141249. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141250. }
  141251. /**
  141252. * Defines an optimization used to turn post-processes off
  141253. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141254. */
  141255. export class PostProcessesOptimization extends SceneOptimization {
  141256. /**
  141257. * Gets a string describing the action executed by the current optimization
  141258. * @return description string
  141259. */
  141260. getDescription(): string;
  141261. /**
  141262. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141263. * @param scene defines the current scene where to apply this optimization
  141264. * @param optimizer defines the current optimizer
  141265. * @returns true if everything that can be done was applied
  141266. */
  141267. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141268. }
  141269. /**
  141270. * Defines an optimization used to turn lens flares off
  141271. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141272. */
  141273. export class LensFlaresOptimization extends SceneOptimization {
  141274. /**
  141275. * Gets a string describing the action executed by the current optimization
  141276. * @return description string
  141277. */
  141278. getDescription(): string;
  141279. /**
  141280. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141281. * @param scene defines the current scene where to apply this optimization
  141282. * @param optimizer defines the current optimizer
  141283. * @returns true if everything that can be done was applied
  141284. */
  141285. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141286. }
  141287. /**
  141288. * Defines an optimization based on user defined callback.
  141289. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141290. */
  141291. export class CustomOptimization extends SceneOptimization {
  141292. /**
  141293. * Callback called to apply the custom optimization.
  141294. */
  141295. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  141296. /**
  141297. * Callback called to get custom description
  141298. */
  141299. onGetDescription: () => string;
  141300. /**
  141301. * Gets a string describing the action executed by the current optimization
  141302. * @returns description string
  141303. */
  141304. getDescription(): string;
  141305. /**
  141306. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141307. * @param scene defines the current scene where to apply this optimization
  141308. * @param optimizer defines the current optimizer
  141309. * @returns true if everything that can be done was applied
  141310. */
  141311. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141312. }
  141313. /**
  141314. * Defines an optimization used to turn particles off
  141315. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141316. */
  141317. export class ParticlesOptimization extends SceneOptimization {
  141318. /**
  141319. * Gets a string describing the action executed by the current optimization
  141320. * @return description string
  141321. */
  141322. getDescription(): string;
  141323. /**
  141324. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141325. * @param scene defines the current scene where to apply this optimization
  141326. * @param optimizer defines the current optimizer
  141327. * @returns true if everything that can be done was applied
  141328. */
  141329. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141330. }
  141331. /**
  141332. * Defines an optimization used to turn render targets off
  141333. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141334. */
  141335. export class RenderTargetsOptimization extends SceneOptimization {
  141336. /**
  141337. * Gets a string describing the action executed by the current optimization
  141338. * @return description string
  141339. */
  141340. getDescription(): string;
  141341. /**
  141342. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141343. * @param scene defines the current scene where to apply this optimization
  141344. * @param optimizer defines the current optimizer
  141345. * @returns true if everything that can be done was applied
  141346. */
  141347. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141348. }
  141349. /**
  141350. * Defines an optimization used to merge meshes with compatible materials
  141351. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141352. */
  141353. export class MergeMeshesOptimization extends SceneOptimization {
  141354. private static _UpdateSelectionTree;
  141355. /**
  141356. * Gets or sets a boolean which defines if optimization octree has to be updated
  141357. */
  141358. static get UpdateSelectionTree(): boolean;
  141359. /**
  141360. * Gets or sets a boolean which defines if optimization octree has to be updated
  141361. */
  141362. static set UpdateSelectionTree(value: boolean);
  141363. /**
  141364. * Gets a string describing the action executed by the current optimization
  141365. * @return description string
  141366. */
  141367. getDescription(): string;
  141368. private _canBeMerged;
  141369. /**
  141370. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141371. * @param scene defines the current scene where to apply this optimization
  141372. * @param optimizer defines the current optimizer
  141373. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  141374. * @returns true if everything that can be done was applied
  141375. */
  141376. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  141377. }
  141378. /**
  141379. * Defines a list of options used by SceneOptimizer
  141380. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141381. */
  141382. export class SceneOptimizerOptions {
  141383. /**
  141384. * Defines the target frame rate to reach (60 by default)
  141385. */
  141386. targetFrameRate: number;
  141387. /**
  141388. * Defines the interval between two checkes (2000ms by default)
  141389. */
  141390. trackerDuration: number;
  141391. /**
  141392. * Gets the list of optimizations to apply
  141393. */
  141394. optimizations: SceneOptimization[];
  141395. /**
  141396. * Creates a new list of options used by SceneOptimizer
  141397. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  141398. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  141399. */
  141400. constructor(
  141401. /**
  141402. * Defines the target frame rate to reach (60 by default)
  141403. */
  141404. targetFrameRate?: number,
  141405. /**
  141406. * Defines the interval between two checkes (2000ms by default)
  141407. */
  141408. trackerDuration?: number);
  141409. /**
  141410. * Add a new optimization
  141411. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  141412. * @returns the current SceneOptimizerOptions
  141413. */
  141414. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  141415. /**
  141416. * Add a new custom optimization
  141417. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  141418. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  141419. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141420. * @returns the current SceneOptimizerOptions
  141421. */
  141422. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  141423. /**
  141424. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  141425. * @param targetFrameRate defines the target frame rate (60 by default)
  141426. * @returns a SceneOptimizerOptions object
  141427. */
  141428. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141429. /**
  141430. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  141431. * @param targetFrameRate defines the target frame rate (60 by default)
  141432. * @returns a SceneOptimizerOptions object
  141433. */
  141434. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141435. /**
  141436. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  141437. * @param targetFrameRate defines the target frame rate (60 by default)
  141438. * @returns a SceneOptimizerOptions object
  141439. */
  141440. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141441. }
  141442. /**
  141443. * Class used to run optimizations in order to reach a target frame rate
  141444. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141445. */
  141446. export class SceneOptimizer implements IDisposable {
  141447. private _isRunning;
  141448. private _options;
  141449. private _scene;
  141450. private _currentPriorityLevel;
  141451. private _targetFrameRate;
  141452. private _trackerDuration;
  141453. private _currentFrameRate;
  141454. private _sceneDisposeObserver;
  141455. private _improvementMode;
  141456. /**
  141457. * Defines an observable called when the optimizer reaches the target frame rate
  141458. */
  141459. onSuccessObservable: Observable<SceneOptimizer>;
  141460. /**
  141461. * Defines an observable called when the optimizer enables an optimization
  141462. */
  141463. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  141464. /**
  141465. * Defines an observable called when the optimizer is not able to reach the target frame rate
  141466. */
  141467. onFailureObservable: Observable<SceneOptimizer>;
  141468. /**
  141469. * Gets a boolean indicating if the optimizer is in improvement mode
  141470. */
  141471. get isInImprovementMode(): boolean;
  141472. /**
  141473. * Gets the current priority level (0 at start)
  141474. */
  141475. get currentPriorityLevel(): number;
  141476. /**
  141477. * Gets the current frame rate checked by the SceneOptimizer
  141478. */
  141479. get currentFrameRate(): number;
  141480. /**
  141481. * Gets or sets the current target frame rate (60 by default)
  141482. */
  141483. get targetFrameRate(): number;
  141484. /**
  141485. * Gets or sets the current target frame rate (60 by default)
  141486. */
  141487. set targetFrameRate(value: number);
  141488. /**
  141489. * Gets or sets the current interval between two checks (every 2000ms by default)
  141490. */
  141491. get trackerDuration(): number;
  141492. /**
  141493. * Gets or sets the current interval between two checks (every 2000ms by default)
  141494. */
  141495. set trackerDuration(value: number);
  141496. /**
  141497. * Gets the list of active optimizations
  141498. */
  141499. get optimizations(): SceneOptimization[];
  141500. /**
  141501. * Creates a new SceneOptimizer
  141502. * @param scene defines the scene to work on
  141503. * @param options defines the options to use with the SceneOptimizer
  141504. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  141505. * @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)
  141506. */
  141507. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  141508. /**
  141509. * Stops the current optimizer
  141510. */
  141511. stop(): void;
  141512. /**
  141513. * Reset the optimizer to initial step (current priority level = 0)
  141514. */
  141515. reset(): void;
  141516. /**
  141517. * Start the optimizer. By default it will try to reach a specific framerate
  141518. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  141519. */
  141520. start(): void;
  141521. private _checkCurrentState;
  141522. /**
  141523. * Release all resources
  141524. */
  141525. dispose(): void;
  141526. /**
  141527. * Helper function to create a SceneOptimizer with one single line of code
  141528. * @param scene defines the scene to work on
  141529. * @param options defines the options to use with the SceneOptimizer
  141530. * @param onSuccess defines a callback to call on success
  141531. * @param onFailure defines a callback to call on failure
  141532. * @returns the new SceneOptimizer object
  141533. */
  141534. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  141535. }
  141536. }
  141537. declare module BABYLON {
  141538. /**
  141539. * Class used to serialize a scene into a string
  141540. */
  141541. export class SceneSerializer {
  141542. /**
  141543. * Clear cache used by a previous serialization
  141544. */
  141545. static ClearCache(): void;
  141546. /**
  141547. * Serialize a scene into a JSON compatible object
  141548. * @param scene defines the scene to serialize
  141549. * @returns a JSON compatible object
  141550. */
  141551. static Serialize(scene: Scene): any;
  141552. /**
  141553. * Serialize a mesh into a JSON compatible object
  141554. * @param toSerialize defines the mesh to serialize
  141555. * @param withParents defines if parents must be serialized as well
  141556. * @param withChildren defines if children must be serialized as well
  141557. * @returns a JSON compatible object
  141558. */
  141559. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  141560. }
  141561. }
  141562. declare module BABYLON {
  141563. /**
  141564. * Class used to host texture specific utilities
  141565. */
  141566. export class TextureTools {
  141567. /**
  141568. * Uses the GPU to create a copy texture rescaled at a given size
  141569. * @param texture Texture to copy from
  141570. * @param width defines the desired width
  141571. * @param height defines the desired height
  141572. * @param useBilinearMode defines if bilinear mode has to be used
  141573. * @return the generated texture
  141574. */
  141575. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  141576. }
  141577. }
  141578. declare module BABYLON {
  141579. /**
  141580. * This represents the different options available for the video capture.
  141581. */
  141582. export interface VideoRecorderOptions {
  141583. /** Defines the mime type of the video. */
  141584. mimeType: string;
  141585. /** Defines the FPS the video should be recorded at. */
  141586. fps: number;
  141587. /** Defines the chunk size for the recording data. */
  141588. recordChunckSize: number;
  141589. /** The audio tracks to attach to the recording. */
  141590. audioTracks?: MediaStreamTrack[];
  141591. }
  141592. /**
  141593. * This can help with recording videos from BabylonJS.
  141594. * This is based on the available WebRTC functionalities of the browser.
  141595. *
  141596. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  141597. */
  141598. export class VideoRecorder {
  141599. private static readonly _defaultOptions;
  141600. /**
  141601. * Returns whether or not the VideoRecorder is available in your browser.
  141602. * @param engine Defines the Babylon Engine.
  141603. * @returns true if supported otherwise false.
  141604. */
  141605. static IsSupported(engine: Engine): boolean;
  141606. private readonly _options;
  141607. private _canvas;
  141608. private _mediaRecorder;
  141609. private _recordedChunks;
  141610. private _fileName;
  141611. private _resolve;
  141612. private _reject;
  141613. /**
  141614. * True when a recording is already in progress.
  141615. */
  141616. get isRecording(): boolean;
  141617. /**
  141618. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  141619. * @param engine Defines the BabylonJS Engine you wish to record.
  141620. * @param options Defines options that can be used to customize the capture.
  141621. */
  141622. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  141623. /**
  141624. * Stops the current recording before the default capture timeout passed in the startRecording function.
  141625. */
  141626. stopRecording(): void;
  141627. /**
  141628. * Starts recording the canvas for a max duration specified in parameters.
  141629. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  141630. * If null no automatic download will start and you can rely on the promise to get the data back.
  141631. * @param maxDuration Defines the maximum recording time in seconds.
  141632. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  141633. * @return A promise callback at the end of the recording with the video data in Blob.
  141634. */
  141635. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  141636. /**
  141637. * Releases internal resources used during the recording.
  141638. */
  141639. dispose(): void;
  141640. private _handleDataAvailable;
  141641. private _handleError;
  141642. private _handleStop;
  141643. }
  141644. }
  141645. declare module BABYLON {
  141646. /**
  141647. * Class containing a set of static utilities functions for screenshots
  141648. */
  141649. export class ScreenshotTools {
  141650. /**
  141651. * Captures a screenshot of the current rendering
  141652. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141653. * @param engine defines the rendering engine
  141654. * @param camera defines the source camera
  141655. * @param size This parameter can be set to a single number or to an object with the
  141656. * following (optional) properties: precision, width, height. If a single number is passed,
  141657. * it will be used for both width and height. If an object is passed, the screenshot size
  141658. * will be derived from the parameters. The precision property is a multiplier allowing
  141659. * rendering at a higher or lower resolution
  141660. * @param successCallback defines the callback receives a single parameter which contains the
  141661. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141662. * src parameter of an <img> to display it
  141663. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141664. * Check your browser for supported MIME types
  141665. */
  141666. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  141667. /**
  141668. * Captures a screenshot of the current rendering
  141669. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141670. * @param engine defines the rendering engine
  141671. * @param camera defines the source camera
  141672. * @param size This parameter can be set to a single number or to an object with the
  141673. * following (optional) properties: precision, width, height. If a single number is passed,
  141674. * it will be used for both width and height. If an object is passed, the screenshot size
  141675. * will be derived from the parameters. The precision property is a multiplier allowing
  141676. * rendering at a higher or lower resolution
  141677. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141678. * Check your browser for supported MIME types
  141679. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141680. * to the src parameter of an <img> to display it
  141681. */
  141682. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  141683. /**
  141684. * Generates an image screenshot from the specified camera.
  141685. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141686. * @param engine The engine to use for rendering
  141687. * @param camera The camera to use for rendering
  141688. * @param size This parameter can be set to a single number or to an object with the
  141689. * following (optional) properties: precision, width, height. If a single number is passed,
  141690. * it will be used for both width and height. If an object is passed, the screenshot size
  141691. * will be derived from the parameters. The precision property is a multiplier allowing
  141692. * rendering at a higher or lower resolution
  141693. * @param successCallback The callback receives a single parameter which contains the
  141694. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141695. * src parameter of an <img> to display it
  141696. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141697. * Check your browser for supported MIME types
  141698. * @param samples Texture samples (default: 1)
  141699. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141700. * @param fileName A name for for the downloaded file.
  141701. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  141702. */
  141703. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  141704. /**
  141705. * Generates an image screenshot from the specified camera.
  141706. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141707. * @param engine The engine to use for rendering
  141708. * @param camera The camera to use for rendering
  141709. * @param size This parameter can be set to a single number or to an object with the
  141710. * following (optional) properties: precision, width, height. If a single number is passed,
  141711. * it will be used for both width and height. If an object is passed, the screenshot size
  141712. * will be derived from the parameters. The precision property is a multiplier allowing
  141713. * rendering at a higher or lower resolution
  141714. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141715. * Check your browser for supported MIME types
  141716. * @param samples Texture samples (default: 1)
  141717. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141718. * @param fileName A name for for the downloaded file.
  141719. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  141720. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141721. * to the src parameter of an <img> to display it
  141722. */
  141723. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  141724. /**
  141725. * Gets height and width for screenshot size
  141726. * @private
  141727. */
  141728. private static _getScreenshotSize;
  141729. }
  141730. }
  141731. declare module BABYLON {
  141732. /**
  141733. * Interface for a data buffer
  141734. */
  141735. export interface IDataBuffer {
  141736. /**
  141737. * Reads bytes from the data buffer.
  141738. * @param byteOffset The byte offset to read
  141739. * @param byteLength The byte length to read
  141740. * @returns A promise that resolves when the bytes are read
  141741. */
  141742. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  141743. /**
  141744. * The byte length of the buffer.
  141745. */
  141746. readonly byteLength: number;
  141747. }
  141748. /**
  141749. * Utility class for reading from a data buffer
  141750. */
  141751. export class DataReader {
  141752. /**
  141753. * The data buffer associated with this data reader.
  141754. */
  141755. readonly buffer: IDataBuffer;
  141756. /**
  141757. * The current byte offset from the beginning of the data buffer.
  141758. */
  141759. byteOffset: number;
  141760. private _dataView;
  141761. private _dataByteOffset;
  141762. /**
  141763. * Constructor
  141764. * @param buffer The buffer to read
  141765. */
  141766. constructor(buffer: IDataBuffer);
  141767. /**
  141768. * Loads the given byte length.
  141769. * @param byteLength The byte length to load
  141770. * @returns A promise that resolves when the load is complete
  141771. */
  141772. loadAsync(byteLength: number): Promise<void>;
  141773. /**
  141774. * Read a unsigned 32-bit integer from the currently loaded data range.
  141775. * @returns The 32-bit integer read
  141776. */
  141777. readUint32(): number;
  141778. /**
  141779. * Read a byte array from the currently loaded data range.
  141780. * @param byteLength The byte length to read
  141781. * @returns The byte array read
  141782. */
  141783. readUint8Array(byteLength: number): Uint8Array;
  141784. /**
  141785. * Read a string from the currently loaded data range.
  141786. * @param byteLength The byte length to read
  141787. * @returns The string read
  141788. */
  141789. readString(byteLength: number): string;
  141790. /**
  141791. * Skips the given byte length the currently loaded data range.
  141792. * @param byteLength The byte length to skip
  141793. */
  141794. skipBytes(byteLength: number): void;
  141795. }
  141796. }
  141797. declare module BABYLON {
  141798. /**
  141799. * Options used for hit testing
  141800. */
  141801. export interface IWebXRHitTestOptions {
  141802. /**
  141803. * Only test when user interacted with the scene. Default - hit test every frame
  141804. */
  141805. testOnPointerDownOnly?: boolean;
  141806. /**
  141807. * The node to use to transform the local results to world coordinates
  141808. */
  141809. worldParentNode?: TransformNode;
  141810. }
  141811. /**
  141812. * Interface defining the babylon result of raycasting/hit-test
  141813. */
  141814. export interface IWebXRHitResult {
  141815. /**
  141816. * Transformation matrix that can be applied to a node that will put it in the hit point location
  141817. */
  141818. transformationMatrix: Matrix;
  141819. /**
  141820. * The native hit test result
  141821. */
  141822. xrHitResult: XRHitResult;
  141823. }
  141824. /**
  141825. * The currently-working hit-test module.
  141826. * Hit test (or Ray-casting) is used to interact with the real world.
  141827. * For further information read here - https://github.com/immersive-web/hit-test
  141828. */
  141829. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  141830. /**
  141831. * options to use when constructing this feature
  141832. */
  141833. readonly options: IWebXRHitTestOptions;
  141834. private _direction;
  141835. private _mat;
  141836. private _onSelectEnabled;
  141837. private _origin;
  141838. /**
  141839. * The module's name
  141840. */
  141841. static readonly Name: string;
  141842. /**
  141843. * The (Babylon) version of this module.
  141844. * This is an integer representing the implementation version.
  141845. * This number does not correspond to the WebXR specs version
  141846. */
  141847. static readonly Version: number;
  141848. /**
  141849. * Populated with the last native XR Hit Results
  141850. */
  141851. lastNativeXRHitResults: XRHitResult[];
  141852. /**
  141853. * Triggered when new babylon (transformed) hit test results are available
  141854. */
  141855. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  141856. /**
  141857. * Creates a new instance of the (legacy version) hit test feature
  141858. * @param _xrSessionManager an instance of WebXRSessionManager
  141859. * @param options options to use when constructing this feature
  141860. */
  141861. constructor(_xrSessionManager: WebXRSessionManager,
  141862. /**
  141863. * options to use when constructing this feature
  141864. */
  141865. options?: IWebXRHitTestOptions);
  141866. /**
  141867. * execute a hit test with an XR Ray
  141868. *
  141869. * @param xrSession a native xrSession that will execute this hit test
  141870. * @param xrRay the ray (position and direction) to use for ray-casting
  141871. * @param referenceSpace native XR reference space to use for the hit-test
  141872. * @param filter filter function that will filter the results
  141873. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141874. */
  141875. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  141876. /**
  141877. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  141878. * @param event the (select) event to use to select with
  141879. * @param referenceSpace the reference space to use for this hit test
  141880. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  141881. */
  141882. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  141883. /**
  141884. * attach this feature
  141885. * Will usually be called by the features manager
  141886. *
  141887. * @returns true if successful.
  141888. */
  141889. attach(): boolean;
  141890. /**
  141891. * detach this feature.
  141892. * Will usually be called by the features manager
  141893. *
  141894. * @returns true if successful.
  141895. */
  141896. detach(): boolean;
  141897. /**
  141898. * Dispose this feature and all of the resources attached
  141899. */
  141900. dispose(): void;
  141901. protected _onXRFrame(frame: XRFrame): void;
  141902. private _onHitTestResults;
  141903. private _onSelect;
  141904. }
  141905. }
  141906. declare module BABYLON {
  141907. /**
  141908. * Options used in the plane detector module
  141909. */
  141910. export interface IWebXRPlaneDetectorOptions {
  141911. /**
  141912. * The node to use to transform the local results to world coordinates
  141913. */
  141914. worldParentNode?: TransformNode;
  141915. }
  141916. /**
  141917. * A babylon interface for a WebXR plane.
  141918. * A Plane is actually a polygon, built from N points in space
  141919. *
  141920. * Supported in chrome 79, not supported in canary 81 ATM
  141921. */
  141922. export interface IWebXRPlane {
  141923. /**
  141924. * a babylon-assigned ID for this polygon
  141925. */
  141926. id: number;
  141927. /**
  141928. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  141929. */
  141930. polygonDefinition: Array<Vector3>;
  141931. /**
  141932. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  141933. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  141934. */
  141935. transformationMatrix: Matrix;
  141936. /**
  141937. * the native xr-plane object
  141938. */
  141939. xrPlane: XRPlane;
  141940. }
  141941. /**
  141942. * The plane detector is used to detect planes in the real world when in AR
  141943. * For more information see https://github.com/immersive-web/real-world-geometry/
  141944. */
  141945. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  141946. private _options;
  141947. private _detectedPlanes;
  141948. private _enabled;
  141949. private _lastFrameDetected;
  141950. /**
  141951. * The module's name
  141952. */
  141953. static readonly Name: string;
  141954. /**
  141955. * The (Babylon) version of this module.
  141956. * This is an integer representing the implementation version.
  141957. * This number does not correspond to the WebXR specs version
  141958. */
  141959. static readonly Version: number;
  141960. /**
  141961. * Observers registered here will be executed when a new plane was added to the session
  141962. */
  141963. onPlaneAddedObservable: Observable<IWebXRPlane>;
  141964. /**
  141965. * Observers registered here will be executed when a plane is no longer detected in the session
  141966. */
  141967. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  141968. /**
  141969. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  141970. * This can execute N times every frame
  141971. */
  141972. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  141973. /**
  141974. * construct a new Plane Detector
  141975. * @param _xrSessionManager an instance of xr Session manager
  141976. * @param _options configuration to use when constructing this feature
  141977. */
  141978. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  141979. /**
  141980. * Dispose this feature and all of the resources attached
  141981. */
  141982. dispose(): void;
  141983. protected _onXRFrame(frame: XRFrame): void;
  141984. private _init;
  141985. private _updatePlaneWithXRPlane;
  141986. /**
  141987. * avoiding using Array.find for global support.
  141988. * @param xrPlane the plane to find in the array
  141989. */
  141990. private findIndexInPlaneArray;
  141991. }
  141992. }
  141993. declare module BABYLON {
  141994. /**
  141995. * Configuration options of the anchor system
  141996. */
  141997. export interface IWebXRAnchorSystemOptions {
  141998. /**
  141999. * Should a new anchor be added every time a select event is triggered
  142000. */
  142001. addAnchorOnSelect?: boolean;
  142002. /**
  142003. * should the anchor system use plane detection.
  142004. * If set to true, the plane-detection feature should be set using setPlaneDetector
  142005. */
  142006. usePlaneDetection?: boolean;
  142007. /**
  142008. * a node that will be used to convert local to world coordinates
  142009. */
  142010. worldParentNode?: TransformNode;
  142011. }
  142012. /**
  142013. * A babylon container for an XR Anchor
  142014. */
  142015. export interface IWebXRAnchor {
  142016. /**
  142017. * A babylon-assigned ID for this anchor
  142018. */
  142019. id: number;
  142020. /**
  142021. * Transformation matrix to apply to an object attached to this anchor
  142022. */
  142023. transformationMatrix: Matrix;
  142024. /**
  142025. * The native anchor object
  142026. */
  142027. xrAnchor: XRAnchor;
  142028. }
  142029. /**
  142030. * An implementation of the anchor system of WebXR.
  142031. * Note that the current documented implementation is not available in any browser. Future implementations
  142032. * will use the frame to create an anchor and not the session or a detected plane
  142033. * For further information see https://github.com/immersive-web/anchors/
  142034. */
  142035. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  142036. private _options;
  142037. private _enabled;
  142038. private _hitTestModule;
  142039. private _lastFrameDetected;
  142040. private _onSelect;
  142041. private _planeDetector;
  142042. private _trackedAnchors;
  142043. /**
  142044. * The module's name
  142045. */
  142046. static readonly Name: string;
  142047. /**
  142048. * The (Babylon) version of this module.
  142049. * This is an integer representing the implementation version.
  142050. * This number does not correspond to the WebXR specs version
  142051. */
  142052. static readonly Version: number;
  142053. /**
  142054. * Observers registered here will be executed when a new anchor was added to the session
  142055. */
  142056. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  142057. /**
  142058. * Observers registered here will be executed when an anchor was removed from the session
  142059. */
  142060. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  142061. /**
  142062. * Observers registered here will be executed when an existing anchor updates
  142063. * This can execute N times every frame
  142064. */
  142065. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  142066. /**
  142067. * constructs a new anchor system
  142068. * @param _xrSessionManager an instance of WebXRSessionManager
  142069. * @param _options configuration object for this feature
  142070. */
  142071. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  142072. /**
  142073. * Add anchor at a specific XR point.
  142074. *
  142075. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  142076. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  142077. * @returns a promise the fulfills when the anchor was created
  142078. */
  142079. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  142080. /**
  142081. * attach this feature
  142082. * Will usually be called by the features manager
  142083. *
  142084. * @returns true if successful.
  142085. */
  142086. attach(): boolean;
  142087. /**
  142088. * detach this feature.
  142089. * Will usually be called by the features manager
  142090. *
  142091. * @returns true if successful.
  142092. */
  142093. detach(): boolean;
  142094. /**
  142095. * Dispose this feature and all of the resources attached
  142096. */
  142097. dispose(): void;
  142098. /**
  142099. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  142100. * @param hitTestModule the hit-test module to use.
  142101. */
  142102. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  142103. /**
  142104. * set the plane detector to use in order to create anchors from frames
  142105. * @param planeDetector the plane-detector module to use
  142106. * @param enable enable plane-anchors. default is true
  142107. */
  142108. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  142109. protected _onXRFrame(frame: XRFrame): void;
  142110. /**
  142111. * avoiding using Array.find for global support.
  142112. * @param xrAnchor the plane to find in the array
  142113. */
  142114. private _findIndexInAnchorArray;
  142115. private _updateAnchorWithXRFrame;
  142116. }
  142117. }
  142118. declare module BABYLON {
  142119. /**
  142120. * Options interface for the background remover plugin
  142121. */
  142122. export interface IWebXRBackgroundRemoverOptions {
  142123. /**
  142124. * Further background meshes to disable when entering AR
  142125. */
  142126. backgroundMeshes?: AbstractMesh[];
  142127. /**
  142128. * flags to configure the removal of the environment helper.
  142129. * If not set, the entire background will be removed. If set, flags should be set as well.
  142130. */
  142131. environmentHelperRemovalFlags?: {
  142132. /**
  142133. * Should the skybox be removed (default false)
  142134. */
  142135. skyBox?: boolean;
  142136. /**
  142137. * Should the ground be removed (default false)
  142138. */
  142139. ground?: boolean;
  142140. };
  142141. /**
  142142. * don't disable the environment helper
  142143. */
  142144. ignoreEnvironmentHelper?: boolean;
  142145. }
  142146. /**
  142147. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  142148. */
  142149. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  142150. /**
  142151. * read-only options to be used in this module
  142152. */
  142153. readonly options: IWebXRBackgroundRemoverOptions;
  142154. /**
  142155. * The module's name
  142156. */
  142157. static readonly Name: string;
  142158. /**
  142159. * The (Babylon) version of this module.
  142160. * This is an integer representing the implementation version.
  142161. * This number does not correspond to the WebXR specs version
  142162. */
  142163. static readonly Version: number;
  142164. /**
  142165. * registered observers will be triggered when the background state changes
  142166. */
  142167. onBackgroundStateChangedObservable: Observable<boolean>;
  142168. /**
  142169. * constructs a new background remover module
  142170. * @param _xrSessionManager the session manager for this module
  142171. * @param options read-only options to be used in this module
  142172. */
  142173. constructor(_xrSessionManager: WebXRSessionManager,
  142174. /**
  142175. * read-only options to be used in this module
  142176. */
  142177. options?: IWebXRBackgroundRemoverOptions);
  142178. /**
  142179. * attach this feature
  142180. * Will usually be called by the features manager
  142181. *
  142182. * @returns true if successful.
  142183. */
  142184. attach(): boolean;
  142185. /**
  142186. * detach this feature.
  142187. * Will usually be called by the features manager
  142188. *
  142189. * @returns true if successful.
  142190. */
  142191. detach(): boolean;
  142192. /**
  142193. * Dispose this feature and all of the resources attached
  142194. */
  142195. dispose(): void;
  142196. protected _onXRFrame(_xrFrame: XRFrame): void;
  142197. private _setBackgroundState;
  142198. }
  142199. }
  142200. declare module BABYLON {
  142201. /**
  142202. * Options for the controller physics feature
  142203. */
  142204. export class IWebXRControllerPhysicsOptions {
  142205. /**
  142206. * Should the headset get its own impostor
  142207. */
  142208. enableHeadsetImpostor?: boolean;
  142209. /**
  142210. * Optional parameters for the headset impostor
  142211. */
  142212. headsetImpostorParams?: {
  142213. /**
  142214. * The type of impostor to create. Default is sphere
  142215. */
  142216. impostorType: number;
  142217. /**
  142218. * the size of the impostor. Defaults to 10cm
  142219. */
  142220. impostorSize?: number | {
  142221. width: number;
  142222. height: number;
  142223. depth: number;
  142224. };
  142225. /**
  142226. * Friction definitions
  142227. */
  142228. friction?: number;
  142229. /**
  142230. * Restitution
  142231. */
  142232. restitution?: number;
  142233. };
  142234. /**
  142235. * The physics properties of the future impostors
  142236. */
  142237. physicsProperties?: {
  142238. /**
  142239. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  142240. * Note that this requires a physics engine that supports mesh impostors!
  142241. */
  142242. useControllerMesh?: boolean;
  142243. /**
  142244. * The type of impostor to create. Default is sphere
  142245. */
  142246. impostorType?: number;
  142247. /**
  142248. * the size of the impostor. Defaults to 10cm
  142249. */
  142250. impostorSize?: number | {
  142251. width: number;
  142252. height: number;
  142253. depth: number;
  142254. };
  142255. /**
  142256. * Friction definitions
  142257. */
  142258. friction?: number;
  142259. /**
  142260. * Restitution
  142261. */
  142262. restitution?: number;
  142263. };
  142264. /**
  142265. * the xr input to use with this pointer selection
  142266. */
  142267. xrInput: WebXRInput;
  142268. }
  142269. /**
  142270. * Add physics impostor to your webxr controllers,
  142271. * including naive calculation of their linear and angular velocity
  142272. */
  142273. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  142274. private readonly _options;
  142275. private _attachController;
  142276. private _controllers;
  142277. private _debugMode;
  142278. private _delta;
  142279. private _headsetImpostor?;
  142280. private _headsetMesh?;
  142281. private _lastTimestamp;
  142282. private _tmpQuaternion;
  142283. private _tmpVector;
  142284. /**
  142285. * The module's name
  142286. */
  142287. static readonly Name: string;
  142288. /**
  142289. * The (Babylon) version of this module.
  142290. * This is an integer representing the implementation version.
  142291. * This number does not correspond to the webxr specs version
  142292. */
  142293. static readonly Version: number;
  142294. /**
  142295. * Construct a new Controller Physics Feature
  142296. * @param _xrSessionManager the corresponding xr session manager
  142297. * @param _options options to create this feature with
  142298. */
  142299. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  142300. /**
  142301. * @hidden
  142302. * enable debugging - will show console outputs and the impostor mesh
  142303. */
  142304. _enablePhysicsDebug(): void;
  142305. /**
  142306. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  142307. * @param xrController the controller to add
  142308. */
  142309. addController(xrController: WebXRInputSource): void;
  142310. /**
  142311. * attach this feature
  142312. * Will usually be called by the features manager
  142313. *
  142314. * @returns true if successful.
  142315. */
  142316. attach(): boolean;
  142317. /**
  142318. * detach this feature.
  142319. * Will usually be called by the features manager
  142320. *
  142321. * @returns true if successful.
  142322. */
  142323. detach(): boolean;
  142324. /**
  142325. * Get the headset impostor, if enabled
  142326. * @returns the impostor
  142327. */
  142328. getHeadsetImpostor(): PhysicsImpostor | undefined;
  142329. /**
  142330. * Get the physics impostor of a specific controller.
  142331. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  142332. * @param controller the controller or the controller id of which to get the impostor
  142333. * @returns the impostor or null
  142334. */
  142335. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  142336. /**
  142337. * Update the physics properties provided in the constructor
  142338. * @param newProperties the new properties object
  142339. */
  142340. setPhysicsProperties(newProperties: {
  142341. impostorType?: number;
  142342. impostorSize?: number | {
  142343. width: number;
  142344. height: number;
  142345. depth: number;
  142346. };
  142347. friction?: number;
  142348. restitution?: number;
  142349. }): void;
  142350. protected _onXRFrame(_xrFrame: any): void;
  142351. private _detachController;
  142352. }
  142353. }
  142354. declare module BABYLON {
  142355. /**
  142356. * The motion controller class for all microsoft mixed reality controllers
  142357. */
  142358. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  142359. protected readonly _mapping: {
  142360. defaultButton: {
  142361. "valueNodeName": string;
  142362. "unpressedNodeName": string;
  142363. "pressedNodeName": string;
  142364. };
  142365. defaultAxis: {
  142366. "valueNodeName": string;
  142367. "minNodeName": string;
  142368. "maxNodeName": string;
  142369. };
  142370. buttons: {
  142371. "xr-standard-trigger": {
  142372. "rootNodeName": string;
  142373. "componentProperty": string;
  142374. "states": string[];
  142375. };
  142376. "xr-standard-squeeze": {
  142377. "rootNodeName": string;
  142378. "componentProperty": string;
  142379. "states": string[];
  142380. };
  142381. "xr-standard-touchpad": {
  142382. "rootNodeName": string;
  142383. "labelAnchorNodeName": string;
  142384. "touchPointNodeName": string;
  142385. };
  142386. "xr-standard-thumbstick": {
  142387. "rootNodeName": string;
  142388. "componentProperty": string;
  142389. "states": string[];
  142390. };
  142391. };
  142392. axes: {
  142393. "xr-standard-touchpad": {
  142394. "x-axis": {
  142395. "rootNodeName": string;
  142396. };
  142397. "y-axis": {
  142398. "rootNodeName": string;
  142399. };
  142400. };
  142401. "xr-standard-thumbstick": {
  142402. "x-axis": {
  142403. "rootNodeName": string;
  142404. };
  142405. "y-axis": {
  142406. "rootNodeName": string;
  142407. };
  142408. };
  142409. };
  142410. };
  142411. /**
  142412. * The base url used to load the left and right controller models
  142413. */
  142414. static MODEL_BASE_URL: string;
  142415. /**
  142416. * The name of the left controller model file
  142417. */
  142418. static MODEL_LEFT_FILENAME: string;
  142419. /**
  142420. * The name of the right controller model file
  142421. */
  142422. static MODEL_RIGHT_FILENAME: string;
  142423. profileId: string;
  142424. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142425. protected _getFilenameAndPath(): {
  142426. filename: string;
  142427. path: string;
  142428. };
  142429. protected _getModelLoadingConstraints(): boolean;
  142430. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142431. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142432. protected _updateModel(): void;
  142433. }
  142434. }
  142435. declare module BABYLON {
  142436. /**
  142437. * The motion controller class for oculus touch (quest, rift).
  142438. * This class supports legacy mapping as well the standard xr mapping
  142439. */
  142440. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  142441. private _forceLegacyControllers;
  142442. private _modelRootNode;
  142443. /**
  142444. * The base url used to load the left and right controller models
  142445. */
  142446. static MODEL_BASE_URL: string;
  142447. /**
  142448. * The name of the left controller model file
  142449. */
  142450. static MODEL_LEFT_FILENAME: string;
  142451. /**
  142452. * The name of the right controller model file
  142453. */
  142454. static MODEL_RIGHT_FILENAME: string;
  142455. /**
  142456. * Base Url for the Quest controller model.
  142457. */
  142458. static QUEST_MODEL_BASE_URL: string;
  142459. profileId: string;
  142460. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  142461. protected _getFilenameAndPath(): {
  142462. filename: string;
  142463. path: string;
  142464. };
  142465. protected _getModelLoadingConstraints(): boolean;
  142466. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142467. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142468. protected _updateModel(): void;
  142469. /**
  142470. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  142471. * between the touch and touch 2.
  142472. */
  142473. private _isQuest;
  142474. }
  142475. }
  142476. declare module BABYLON {
  142477. /**
  142478. * The motion controller class for the standard HTC-Vive controllers
  142479. */
  142480. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  142481. private _modelRootNode;
  142482. /**
  142483. * The base url used to load the left and right controller models
  142484. */
  142485. static MODEL_BASE_URL: string;
  142486. /**
  142487. * File name for the controller model.
  142488. */
  142489. static MODEL_FILENAME: string;
  142490. profileId: string;
  142491. /**
  142492. * Create a new Vive motion controller object
  142493. * @param scene the scene to use to create this controller
  142494. * @param gamepadObject the corresponding gamepad object
  142495. * @param handness the handness of the controller
  142496. */
  142497. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142498. protected _getFilenameAndPath(): {
  142499. filename: string;
  142500. path: string;
  142501. };
  142502. protected _getModelLoadingConstraints(): boolean;
  142503. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142504. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142505. protected _updateModel(): void;
  142506. }
  142507. }
  142508. declare module BABYLON {
  142509. /**
  142510. * A cursor which tracks a point on a path
  142511. */
  142512. export class PathCursor {
  142513. private path;
  142514. /**
  142515. * Stores path cursor callbacks for when an onchange event is triggered
  142516. */
  142517. private _onchange;
  142518. /**
  142519. * The value of the path cursor
  142520. */
  142521. value: number;
  142522. /**
  142523. * The animation array of the path cursor
  142524. */
  142525. animations: Animation[];
  142526. /**
  142527. * Initializes the path cursor
  142528. * @param path The path to track
  142529. */
  142530. constructor(path: Path2);
  142531. /**
  142532. * Gets the cursor point on the path
  142533. * @returns A point on the path cursor at the cursor location
  142534. */
  142535. getPoint(): Vector3;
  142536. /**
  142537. * Moves the cursor ahead by the step amount
  142538. * @param step The amount to move the cursor forward
  142539. * @returns This path cursor
  142540. */
  142541. moveAhead(step?: number): PathCursor;
  142542. /**
  142543. * Moves the cursor behind by the step amount
  142544. * @param step The amount to move the cursor back
  142545. * @returns This path cursor
  142546. */
  142547. moveBack(step?: number): PathCursor;
  142548. /**
  142549. * Moves the cursor by the step amount
  142550. * If the step amount is greater than one, an exception is thrown
  142551. * @param step The amount to move the cursor
  142552. * @returns This path cursor
  142553. */
  142554. move(step: number): PathCursor;
  142555. /**
  142556. * Ensures that the value is limited between zero and one
  142557. * @returns This path cursor
  142558. */
  142559. private ensureLimits;
  142560. /**
  142561. * Runs onchange callbacks on change (used by the animation engine)
  142562. * @returns This path cursor
  142563. */
  142564. private raiseOnChange;
  142565. /**
  142566. * Executes a function on change
  142567. * @param f A path cursor onchange callback
  142568. * @returns This path cursor
  142569. */
  142570. onchange(f: (cursor: PathCursor) => void): PathCursor;
  142571. }
  142572. }
  142573. declare module BABYLON {
  142574. /** @hidden */
  142575. export var blurPixelShader: {
  142576. name: string;
  142577. shader: string;
  142578. };
  142579. }
  142580. declare module BABYLON {
  142581. /** @hidden */
  142582. export var pointCloudVertexDeclaration: {
  142583. name: string;
  142584. shader: string;
  142585. };
  142586. }
  142587. // Mixins
  142588. interface Window {
  142589. mozIndexedDB: IDBFactory;
  142590. webkitIndexedDB: IDBFactory;
  142591. msIndexedDB: IDBFactory;
  142592. webkitURL: typeof URL;
  142593. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  142594. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  142595. WebGLRenderingContext: WebGLRenderingContext;
  142596. MSGesture: MSGesture;
  142597. CANNON: any;
  142598. AudioContext: AudioContext;
  142599. webkitAudioContext: AudioContext;
  142600. PointerEvent: any;
  142601. Math: Math;
  142602. Uint8Array: Uint8ArrayConstructor;
  142603. Float32Array: Float32ArrayConstructor;
  142604. mozURL: typeof URL;
  142605. msURL: typeof URL;
  142606. VRFrameData: any; // WebVR, from specs 1.1
  142607. DracoDecoderModule: any;
  142608. setImmediate(handler: (...args: any[]) => void): number;
  142609. }
  142610. interface HTMLCanvasElement {
  142611. requestPointerLock(): void;
  142612. msRequestPointerLock?(): void;
  142613. mozRequestPointerLock?(): void;
  142614. webkitRequestPointerLock?(): void;
  142615. /** Track wether a record is in progress */
  142616. isRecording: boolean;
  142617. /** Capture Stream method defined by some browsers */
  142618. captureStream(fps?: number): MediaStream;
  142619. }
  142620. interface CanvasRenderingContext2D {
  142621. msImageSmoothingEnabled: boolean;
  142622. }
  142623. interface MouseEvent {
  142624. mozMovementX: number;
  142625. mozMovementY: number;
  142626. webkitMovementX: number;
  142627. webkitMovementY: number;
  142628. msMovementX: number;
  142629. msMovementY: number;
  142630. }
  142631. interface Navigator {
  142632. mozGetVRDevices: (any: any) => any;
  142633. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142634. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142635. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142636. webkitGetGamepads(): Gamepad[];
  142637. msGetGamepads(): Gamepad[];
  142638. webkitGamepads(): Gamepad[];
  142639. }
  142640. interface HTMLVideoElement {
  142641. mozSrcObject: any;
  142642. }
  142643. interface Math {
  142644. fround(x: number): number;
  142645. imul(a: number, b: number): number;
  142646. }
  142647. interface WebGLRenderingContext {
  142648. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  142649. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  142650. vertexAttribDivisor(index: number, divisor: number): void;
  142651. createVertexArray(): any;
  142652. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  142653. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  142654. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  142655. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  142656. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  142657. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  142658. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  142659. // Queries
  142660. createQuery(): WebGLQuery;
  142661. deleteQuery(query: WebGLQuery): void;
  142662. beginQuery(target: number, query: WebGLQuery): void;
  142663. endQuery(target: number): void;
  142664. getQueryParameter(query: WebGLQuery, pname: number): any;
  142665. getQuery(target: number, pname: number): any;
  142666. MAX_SAMPLES: number;
  142667. RGBA8: number;
  142668. READ_FRAMEBUFFER: number;
  142669. DRAW_FRAMEBUFFER: number;
  142670. UNIFORM_BUFFER: number;
  142671. HALF_FLOAT_OES: number;
  142672. RGBA16F: number;
  142673. RGBA32F: number;
  142674. R32F: number;
  142675. RG32F: number;
  142676. RGB32F: number;
  142677. R16F: number;
  142678. RG16F: number;
  142679. RGB16F: number;
  142680. RED: number;
  142681. RG: number;
  142682. R8: number;
  142683. RG8: number;
  142684. UNSIGNED_INT_24_8: number;
  142685. DEPTH24_STENCIL8: number;
  142686. MIN: number;
  142687. MAX: number;
  142688. /* Multiple Render Targets */
  142689. drawBuffers(buffers: number[]): void;
  142690. readBuffer(src: number): void;
  142691. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  142692. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  142693. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  142694. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  142695. // Occlusion Query
  142696. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  142697. ANY_SAMPLES_PASSED: number;
  142698. QUERY_RESULT_AVAILABLE: number;
  142699. QUERY_RESULT: number;
  142700. }
  142701. interface WebGLProgram {
  142702. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  142703. }
  142704. interface EXT_disjoint_timer_query {
  142705. QUERY_COUNTER_BITS_EXT: number;
  142706. TIME_ELAPSED_EXT: number;
  142707. TIMESTAMP_EXT: number;
  142708. GPU_DISJOINT_EXT: number;
  142709. QUERY_RESULT_EXT: number;
  142710. QUERY_RESULT_AVAILABLE_EXT: number;
  142711. queryCounterEXT(query: WebGLQuery, target: number): void;
  142712. createQueryEXT(): WebGLQuery;
  142713. beginQueryEXT(target: number, query: WebGLQuery): void;
  142714. endQueryEXT(target: number): void;
  142715. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  142716. deleteQueryEXT(query: WebGLQuery): void;
  142717. }
  142718. interface WebGLUniformLocation {
  142719. _currentState: any;
  142720. }
  142721. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  142722. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  142723. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  142724. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142725. interface WebGLRenderingContext {
  142726. readonly RASTERIZER_DISCARD: number;
  142727. readonly DEPTH_COMPONENT24: number;
  142728. readonly TEXTURE_3D: number;
  142729. readonly TEXTURE_2D_ARRAY: number;
  142730. readonly TEXTURE_COMPARE_FUNC: number;
  142731. readonly TEXTURE_COMPARE_MODE: number;
  142732. readonly COMPARE_REF_TO_TEXTURE: number;
  142733. readonly TEXTURE_WRAP_R: number;
  142734. readonly HALF_FLOAT: number;
  142735. readonly RGB8: number;
  142736. readonly RED_INTEGER: number;
  142737. readonly RG_INTEGER: number;
  142738. readonly RGB_INTEGER: number;
  142739. readonly RGBA_INTEGER: number;
  142740. readonly R8_SNORM: number;
  142741. readonly RG8_SNORM: number;
  142742. readonly RGB8_SNORM: number;
  142743. readonly RGBA8_SNORM: number;
  142744. readonly R8I: number;
  142745. readonly RG8I: number;
  142746. readonly RGB8I: number;
  142747. readonly RGBA8I: number;
  142748. readonly R8UI: number;
  142749. readonly RG8UI: number;
  142750. readonly RGB8UI: number;
  142751. readonly RGBA8UI: number;
  142752. readonly R16I: number;
  142753. readonly RG16I: number;
  142754. readonly RGB16I: number;
  142755. readonly RGBA16I: number;
  142756. readonly R16UI: number;
  142757. readonly RG16UI: number;
  142758. readonly RGB16UI: number;
  142759. readonly RGBA16UI: number;
  142760. readonly R32I: number;
  142761. readonly RG32I: number;
  142762. readonly RGB32I: number;
  142763. readonly RGBA32I: number;
  142764. readonly R32UI: number;
  142765. readonly RG32UI: number;
  142766. readonly RGB32UI: number;
  142767. readonly RGBA32UI: number;
  142768. readonly RGB10_A2UI: number;
  142769. readonly R11F_G11F_B10F: number;
  142770. readonly RGB9_E5: number;
  142771. readonly RGB10_A2: number;
  142772. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  142773. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  142774. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  142775. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  142776. readonly DEPTH_COMPONENT32F: number;
  142777. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  142778. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  142779. 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;
  142780. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  142781. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  142782. readonly TRANSFORM_FEEDBACK: number;
  142783. readonly INTERLEAVED_ATTRIBS: number;
  142784. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  142785. createTransformFeedback(): WebGLTransformFeedback;
  142786. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  142787. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  142788. beginTransformFeedback(primitiveMode: number): void;
  142789. endTransformFeedback(): void;
  142790. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  142791. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142792. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142793. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142794. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  142795. }
  142796. interface ImageBitmap {
  142797. readonly width: number;
  142798. readonly height: number;
  142799. close(): void;
  142800. }
  142801. interface WebGLQuery extends WebGLObject {
  142802. }
  142803. declare var WebGLQuery: {
  142804. prototype: WebGLQuery;
  142805. new(): WebGLQuery;
  142806. };
  142807. interface WebGLSampler extends WebGLObject {
  142808. }
  142809. declare var WebGLSampler: {
  142810. prototype: WebGLSampler;
  142811. new(): WebGLSampler;
  142812. };
  142813. interface WebGLSync extends WebGLObject {
  142814. }
  142815. declare var WebGLSync: {
  142816. prototype: WebGLSync;
  142817. new(): WebGLSync;
  142818. };
  142819. interface WebGLTransformFeedback extends WebGLObject {
  142820. }
  142821. declare var WebGLTransformFeedback: {
  142822. prototype: WebGLTransformFeedback;
  142823. new(): WebGLTransformFeedback;
  142824. };
  142825. interface WebGLVertexArrayObject extends WebGLObject {
  142826. }
  142827. declare var WebGLVertexArrayObject: {
  142828. prototype: WebGLVertexArrayObject;
  142829. new(): WebGLVertexArrayObject;
  142830. };
  142831. // Type definitions for WebVR API
  142832. // Project: https://w3c.github.io/webvr/
  142833. // Definitions by: six a <https://github.com/lostfictions>
  142834. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142835. interface VRDisplay extends EventTarget {
  142836. /**
  142837. * Dictionary of capabilities describing the VRDisplay.
  142838. */
  142839. readonly capabilities: VRDisplayCapabilities;
  142840. /**
  142841. * z-depth defining the far plane of the eye view frustum
  142842. * enables mapping of values in the render target depth
  142843. * attachment to scene coordinates. Initially set to 10000.0.
  142844. */
  142845. depthFar: number;
  142846. /**
  142847. * z-depth defining the near plane of the eye view frustum
  142848. * enables mapping of values in the render target depth
  142849. * attachment to scene coordinates. Initially set to 0.01.
  142850. */
  142851. depthNear: number;
  142852. /**
  142853. * An identifier for this distinct VRDisplay. Used as an
  142854. * association point in the Gamepad API.
  142855. */
  142856. readonly displayId: number;
  142857. /**
  142858. * A display name, a user-readable name identifying it.
  142859. */
  142860. readonly displayName: string;
  142861. readonly isConnected: boolean;
  142862. readonly isPresenting: boolean;
  142863. /**
  142864. * If this VRDisplay supports room-scale experiences, the optional
  142865. * stage attribute contains details on the room-scale parameters.
  142866. */
  142867. readonly stageParameters: VRStageParameters | null;
  142868. /**
  142869. * Passing the value returned by `requestAnimationFrame` to
  142870. * `cancelAnimationFrame` will unregister the callback.
  142871. * @param handle Define the hanle of the request to cancel
  142872. */
  142873. cancelAnimationFrame(handle: number): void;
  142874. /**
  142875. * Stops presenting to the VRDisplay.
  142876. * @returns a promise to know when it stopped
  142877. */
  142878. exitPresent(): Promise<void>;
  142879. /**
  142880. * Return the current VREyeParameters for the given eye.
  142881. * @param whichEye Define the eye we want the parameter for
  142882. * @returns the eye parameters
  142883. */
  142884. getEyeParameters(whichEye: string): VREyeParameters;
  142885. /**
  142886. * Populates the passed VRFrameData with the information required to render
  142887. * the current frame.
  142888. * @param frameData Define the data structure to populate
  142889. * @returns true if ok otherwise false
  142890. */
  142891. getFrameData(frameData: VRFrameData): boolean;
  142892. /**
  142893. * Get the layers currently being presented.
  142894. * @returns the list of VR layers
  142895. */
  142896. getLayers(): VRLayer[];
  142897. /**
  142898. * Return a VRPose containing the future predicted pose of the VRDisplay
  142899. * when the current frame will be presented. The value returned will not
  142900. * change until JavaScript has returned control to the browser.
  142901. *
  142902. * The VRPose will contain the position, orientation, velocity,
  142903. * and acceleration of each of these properties.
  142904. * @returns the pose object
  142905. */
  142906. getPose(): VRPose;
  142907. /**
  142908. * Return the current instantaneous pose of the VRDisplay, with no
  142909. * prediction applied.
  142910. * @returns the current instantaneous pose
  142911. */
  142912. getImmediatePose(): VRPose;
  142913. /**
  142914. * The callback passed to `requestAnimationFrame` will be called
  142915. * any time a new frame should be rendered. When the VRDisplay is
  142916. * presenting the callback will be called at the native refresh
  142917. * rate of the HMD. When not presenting this function acts
  142918. * identically to how window.requestAnimationFrame acts. Content should
  142919. * make no assumptions of frame rate or vsync behavior as the HMD runs
  142920. * asynchronously from other displays and at differing refresh rates.
  142921. * @param callback Define the eaction to run next frame
  142922. * @returns the request handle it
  142923. */
  142924. requestAnimationFrame(callback: FrameRequestCallback): number;
  142925. /**
  142926. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  142927. * Repeat calls while already presenting will update the VRLayers being displayed.
  142928. * @param layers Define the list of layer to present
  142929. * @returns a promise to know when the request has been fulfilled
  142930. */
  142931. requestPresent(layers: VRLayer[]): Promise<void>;
  142932. /**
  142933. * Reset the pose for this display, treating its current position and
  142934. * orientation as the "origin/zero" values. VRPose.position,
  142935. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  142936. * updated when calling resetPose(). This should be called in only
  142937. * sitting-space experiences.
  142938. */
  142939. resetPose(): void;
  142940. /**
  142941. * The VRLayer provided to the VRDisplay will be captured and presented
  142942. * in the HMD. Calling this function has the same effect on the source
  142943. * canvas as any other operation that uses its source image, and canvases
  142944. * created without preserveDrawingBuffer set to true will be cleared.
  142945. * @param pose Define the pose to submit
  142946. */
  142947. submitFrame(pose?: VRPose): void;
  142948. }
  142949. declare var VRDisplay: {
  142950. prototype: VRDisplay;
  142951. new(): VRDisplay;
  142952. };
  142953. interface VRLayer {
  142954. leftBounds?: number[] | Float32Array | null;
  142955. rightBounds?: number[] | Float32Array | null;
  142956. source?: HTMLCanvasElement | null;
  142957. }
  142958. interface VRDisplayCapabilities {
  142959. readonly canPresent: boolean;
  142960. readonly hasExternalDisplay: boolean;
  142961. readonly hasOrientation: boolean;
  142962. readonly hasPosition: boolean;
  142963. readonly maxLayers: number;
  142964. }
  142965. interface VREyeParameters {
  142966. /** @deprecated */
  142967. readonly fieldOfView: VRFieldOfView;
  142968. readonly offset: Float32Array;
  142969. readonly renderHeight: number;
  142970. readonly renderWidth: number;
  142971. }
  142972. interface VRFieldOfView {
  142973. readonly downDegrees: number;
  142974. readonly leftDegrees: number;
  142975. readonly rightDegrees: number;
  142976. readonly upDegrees: number;
  142977. }
  142978. interface VRFrameData {
  142979. readonly leftProjectionMatrix: Float32Array;
  142980. readonly leftViewMatrix: Float32Array;
  142981. readonly pose: VRPose;
  142982. readonly rightProjectionMatrix: Float32Array;
  142983. readonly rightViewMatrix: Float32Array;
  142984. readonly timestamp: number;
  142985. }
  142986. interface VRPose {
  142987. readonly angularAcceleration: Float32Array | null;
  142988. readonly angularVelocity: Float32Array | null;
  142989. readonly linearAcceleration: Float32Array | null;
  142990. readonly linearVelocity: Float32Array | null;
  142991. readonly orientation: Float32Array | null;
  142992. readonly position: Float32Array | null;
  142993. readonly timestamp: number;
  142994. }
  142995. interface VRStageParameters {
  142996. sittingToStandingTransform?: Float32Array;
  142997. sizeX?: number;
  142998. sizeY?: number;
  142999. }
  143000. interface Navigator {
  143001. getVRDisplays(): Promise<VRDisplay[]>;
  143002. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  143003. }
  143004. interface Window {
  143005. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  143006. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  143007. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  143008. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143009. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143010. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  143011. }
  143012. interface Gamepad {
  143013. readonly displayId: number;
  143014. }
  143015. type XRSessionMode =
  143016. | "inline"
  143017. | "immersive-vr"
  143018. | "immersive-ar";
  143019. type XRReferenceSpaceType =
  143020. | "viewer"
  143021. | "local"
  143022. | "local-floor"
  143023. | "bounded-floor"
  143024. | "unbounded";
  143025. type XREnvironmentBlendMode =
  143026. | "opaque"
  143027. | "additive"
  143028. | "alpha-blend";
  143029. type XRVisibilityState =
  143030. | "visible"
  143031. | "visible-blurred"
  143032. | "hidden";
  143033. type XRHandedness =
  143034. | "none"
  143035. | "left"
  143036. | "right";
  143037. type XRTargetRayMode =
  143038. | "gaze"
  143039. | "tracked-pointer"
  143040. | "screen";
  143041. type XREye =
  143042. | "none"
  143043. | "left"
  143044. | "right";
  143045. interface XRSpace extends EventTarget {
  143046. }
  143047. interface XRRenderState {
  143048. depthNear?: number;
  143049. depthFar?: number;
  143050. inlineVerticalFieldOfView?: number;
  143051. baseLayer?: XRWebGLLayer;
  143052. }
  143053. interface XRInputSource {
  143054. handedness: XRHandedness;
  143055. targetRayMode: XRTargetRayMode;
  143056. targetRaySpace: XRSpace;
  143057. gripSpace: XRSpace | undefined;
  143058. gamepad: Gamepad | undefined;
  143059. profiles: Array<string>;
  143060. }
  143061. interface XRSessionInit {
  143062. optionalFeatures?: XRReferenceSpaceType[];
  143063. requiredFeatures?: XRReferenceSpaceType[];
  143064. }
  143065. interface XRSession extends XRAnchorCreator {
  143066. addEventListener: Function;
  143067. removeEventListener: Function;
  143068. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  143069. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  143070. requestAnimationFrame: Function;
  143071. end(): Promise<void>;
  143072. renderState: XRRenderState;
  143073. inputSources: Array<XRInputSource>;
  143074. // AR hit test
  143075. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143076. updateWorldTrackingState(options: {
  143077. planeDetectionState?: { enabled: boolean; }
  143078. }): void;
  143079. }
  143080. interface XRReferenceSpace extends XRSpace {
  143081. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  143082. onreset: any;
  143083. }
  143084. type XRPlaneSet = Set<XRPlane>;
  143085. type XRAnchorSet = Set<XRAnchor>;
  143086. interface XRFrame {
  143087. session: XRSession;
  143088. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  143089. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  143090. // Anchors
  143091. trackedAnchors?: XRAnchorSet;
  143092. // Planes
  143093. worldInformation: {
  143094. detectedPlanes?: XRPlaneSet;
  143095. };
  143096. }
  143097. interface XRViewerPose extends XRPose {
  143098. views: Array<XRView>;
  143099. }
  143100. interface XRPose {
  143101. transform: XRRigidTransform;
  143102. emulatedPosition: boolean;
  143103. }
  143104. interface XRWebGLLayerOptions {
  143105. antialias?: boolean;
  143106. depth?: boolean;
  143107. stencil?: boolean;
  143108. alpha?: boolean;
  143109. multiview?: boolean;
  143110. framebufferScaleFactor?: number;
  143111. }
  143112. declare var XRWebGLLayer: {
  143113. prototype: XRWebGLLayer;
  143114. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  143115. };
  143116. interface XRWebGLLayer {
  143117. framebuffer: WebGLFramebuffer;
  143118. framebufferWidth: number;
  143119. framebufferHeight: number;
  143120. getViewport: Function;
  143121. }
  143122. declare class XRRigidTransform {
  143123. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  143124. position: DOMPointReadOnly;
  143125. orientation: DOMPointReadOnly;
  143126. matrix: Float32Array;
  143127. inverse: XRRigidTransform;
  143128. }
  143129. interface XRView {
  143130. eye: XREye;
  143131. projectionMatrix: Float32Array;
  143132. transform: XRRigidTransform;
  143133. }
  143134. interface XRInputSourceChangeEvent {
  143135. session: XRSession;
  143136. removed: Array<XRInputSource>;
  143137. added: Array<XRInputSource>;
  143138. }
  143139. interface XRInputSourceEvent extends Event {
  143140. readonly frame: XRFrame;
  143141. readonly inputSource: XRInputSource;
  143142. }
  143143. // Experimental(er) features
  143144. declare class XRRay {
  143145. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  143146. origin: DOMPointReadOnly;
  143147. direction: DOMPointReadOnly;
  143148. matrix: Float32Array;
  143149. }
  143150. interface XRHitResult {
  143151. hitMatrix: Float32Array;
  143152. }
  143153. interface XRAnchor {
  143154. // remove?
  143155. id?: string;
  143156. anchorSpace: XRSpace;
  143157. lastChangedTime: number;
  143158. detach(): void;
  143159. }
  143160. interface XRPlane extends XRAnchorCreator {
  143161. orientation: "Horizontal" | "Vertical";
  143162. planeSpace: XRSpace;
  143163. polygon: Array<DOMPointReadOnly>;
  143164. lastChangedTime: number;
  143165. }
  143166. interface XRAnchorCreator {
  143167. // AR Anchors
  143168. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  143169. }